MFF

    Minecraft Forge France
    • Récent
    • Mots-clés
    • Populaire
    • Utilisateurs
    • Groupes
    • Forge Events
      • Automatique
      • Foncé
      • Clair
    • S'inscrire
    • Se connecter

    Une plante plantable sur un bloc moddé

    Planifier Épinglé Verrouillé Déplacé Résolu 1.7.x
    1.7.10
    5 Messages 4 Publieurs 1.1k Vues 1 Watching
    Charger plus de messages
    • Du plus ancien au plus récent
    • Du plus récent au plus ancien
    • Les plus votés
    Répondre
    • Répondre à l'aide d'un nouveau sujet
    Se connecter pour répondre
    Ce sujet a été supprimé. Seuls les utilisateurs avec les droits d'administration peuvent le voir.
    • MinantcraftM Hors-ligne
      Minantcraft
      dernière édition par

      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 🙂

      Minantcraft ;)

      >! Binary Dimension
      [url=https://minecraft.cu…

      1 réponse Dernière réponse Répondre Citer 0
      • LeBossMax2L Hors-ligne
        LeBossMax2
        dernière édition par

        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 réponse Dernière réponse Répondre Citer 0
        • SCAREXS Hors-ligne
          SCAREX
          dernière édition par

          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

          Site web contenant mes scripts : http://SCAREXgaming.github.io

          Pas de demandes de support par MP ni par skype SVP.
          Je n'accepte sur skype que l…

          1 réponse Dernière réponse Répondre Citer 0
          • MinantcraftM Hors-ligne
            Minantcraft
            dernière édition par

            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

            Minantcraft ;)

            >! Binary Dimension
            [url=https://minecraft.cu…

            1 réponse Dernière réponse Répondre Citer 0
            • moscaphone421M Hors-ligne
              moscaphone421
              dernière édition par

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

              1 réponse Dernière réponse Répondre Citer 0
              • 1 / 1
              • Premier message
                Dernier message
              Design by Woryk
              ContactMentions Légales

              MINECRAFT FORGE FRANCE © 2024

              Powered by NodeBB