Navigation

    • Register
    • Login
    • Search
    • Recent
    • Tags
    • Popular
    • Users
    • Groups

    SOLVED Une plante plantable sur un bloc moddé

    1.7.x
    1.7.10
    4
    5
    832
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • Minantcraft
      Minantcraft last edited by

      Bonjour, désolé de faire encore un nouveau topic, mais voilà: J’ai fais une plante mais qui peut se planter sur un des blocs de mon mod mais quand j’en mets une autre à coté, ça update le bloc et la plante est cassée 😞

      Le code:

      public class ItemSeedsMod extends ItemSeeds
      {
      private Block bplant, bfarm;
      
      public ItemSeedsMod(Block plant, Block farm)
      {
      super(plant, farm);
      bplant = plant;
      bfarm = farm;
      }
      
      public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int p_77648_7_, float p_77648_8_, float p_77648_9_, float p_77648_10_)
      {
      if (p_77648_7_ != 1)
      {
      return false;
      }
      
      if (player.canPlayerEdit(x, y, z, z, stack) && player.canPlayerEdit(x, y + 1, z, p_77648_7_, stack))
      {
      if (world.getBlock(x, y, z) == bfarm && world.isAirBlock(x, y + 1, z))
      {
      world.setBlock(x, y + 1, z, bplant);
      –stack.stackSize;
      return true;
      }
      }
      return false;
      }
      }
      

      Voilà, j’espère grandement que vous m’aiderez 🙂

      1 Reply Last reply Reply Quote 0
      • LeBossMax2
        LeBossMax2 last edited by

        Le problème ne viens pas de l’item qui plante la plante mais de la plante en elle même, montre nous plutôt le class du block de la plante.

        1 Reply Last reply Reply Quote 0
        • SCAREX
          SCAREX last edited by

          Il faut modifier la méthode canSustainPlant, et d’ailleurs tu devrais retirer le == bfarm et utiliser cette fonction plutôt : cela permettrait aux autre de créer un block sur lequel faire pousser ta plante

          1 Reply Last reply Reply Quote 0
          • Minantcraft
            Minantcraft last edited by

            J’ai modifié, ça marche nickel
            le code:

            package com.mod.test.blocks;
            
            import com.mod.test.init.BlockMod;
            
            import net.minecraft.block.Block;
            import net.minecraft.block.BlockCrops;
            import net.minecraft.init.Blocks;
            import net.minecraft.world.World;
            import net.minecraftforge.common.util.ForgeDirection;
            
            public class BlockCropsMod extends BlockCrops
            {
            protected boolean canPlaceBlockOn(Block block)
            {
            return block == BlockMod.binary_block;
            }
            
            private float func_149864_n(World world, int x, int y, int z)
            {
            float f = 1.0F;
            Block block = world.getBlock(x, x, z - 1);
            Block block1 = world.getBlock(x, x, z + 1);
            Block block2 = world.getBlock(x - 1, x, z);
            Block block3 = world.getBlock(x + 1, x, z);
            Block block4 = world.getBlock(x - 1, x, z - 1);
            Block block5 = world.getBlock(x + 1, x, z - 1);
            Block block6 = world.getBlock(x + 1, x, z + 1);
            Block block7 = world.getBlock(x - 1, x, z + 1);
            boolean flag = block2 == this || block3 == this;
            boolean flag1 = block == this || block1 == this;
            boolean flag2 = block4 == this || block5 == this || block6 == this || block7 == this;
            
            for (int l = x - 1; l <= x + 1; ++l)
            {
            for (int i1 = z - 1; i1 <= z + 1; ++i1)
            {
            float f1 = 0.0F;
            
            if (world.getBlock(l, x - 1, i1) == BlockMod.binary_block)
            {
            f1 = 1.0F;
            
            if (isFertile(world.getBlock(l, x - 1, i1), world, l, x - 1, i1))
            {
            f1 = 3.0F;
            }
            }
            
            if (l != x || i1 != z)
            {
            f1 /= 4.0F;
            }
            
            f += f1;
            }
            }
            
            if (flag2 || flag && flag1)
            {
            f /= 2.0F;
            }
            
            return f;
            }
            
            public boolean isFertile(Block block, World world, int x, int y, int z)
            {
            if (block == BlockMod.binary_block)
            {
            return true;
            }
            return false;
            }
            }
            
            

            @‘SCAREX’:

            Il faut modifier la méthode canSustainPlant, et d’ailleurs tu devrais retirer le == bfarm et utiliser cette fonction plutôt : cela permettrait aux autre de créer un block sur lequel faire pousser ta plante

            J’ai pas compris

            1 Reply Last reply Reply Quote 0
            • moscaphone421
              moscaphone421 last edited by

              euh Une plante plantable ? mince j’avais une idée pour une non plantable

              1 Reply Last reply Reply Quote 0
              • 1 / 1
              • First post
                Last post
              Design by Woryk
              Contact / Mentions Légales / Faire un don

              MINECRAFT FORGE FRANCE © 2018

              Powered by NodeBB