MFF

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

    Comment créer une plante cultivable de 2 blocs de haut ?

    Planifier Épinglé Verrouillé Déplacé Non résolu Sans suite
    1.7.10
    32 Messages 6 Publieurs 3.7k Vues 3 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.
    • robin4002R Hors-ligne
      robin4002 Moddeurs confirmés Rédacteurs Administrateurs
      dernière édition par robin4002

      Salut,
      Pour faire un bloc dans Minecraft qui prend la place de plusieurs blocs, il faut en placer plusieurs. Il faut donc une classe d’item bloc custom et override la fonction qui gère le clic droit pour faire deux placement de bloc au lieu d’un seul.
      Il faudrait assez pouvoir différencier si le bloc est celui du bas ou celui du haut, en général la solution la plus pour cela est d’utiliser des metadatas différents.

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

        euh… j’ai du mal à suivre… 😅

        1 réponse Dernière réponse Répondre Citer 0
        • robin4002R Hors-ligne
          robin4002 Moddeurs confirmés Rédacteurs Administrateurs
          dernière édition par

          Quel point faut-il détailler ?

          S’il te faut du code, tu peux jeter un œil à la porte qui utilise ce principe.

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

            ok je vais essayer

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

              je comprends rien du tout… 😓

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

                j’ai modifié l’item de ma graine en ajoutant les codes présents dans ItemDoor et en essayant de les modifiers et quand je vais en jeu, ça me fait apparaître la plante à n’importe quel stade de croissance et la partie du haut apparaît mais disparait aussitôt… 😞

                1 réponse Dernière réponse Répondre Citer 0
                • robin4002R Hors-ligne
                  robin4002 Moddeurs confirmés Rédacteurs Administrateurs
                  dernière édition par

                  Tu peux envoyer le code de ton item ?

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

                    Voila !!

                    La classe de mon Item :

                    package mod.plantsandfoodpack.common;
                    
                    import net.minecraft.block.Block;
                    import net.minecraft.entity.player.EntityPlayer;
                    import net.minecraft.init.Blocks;
                    import net.minecraft.item.ItemSeeds;
                    import net.minecraft.item.ItemStack;
                    import net.minecraft.util.MathHelper;
                    import net.minecraft.world.World;
                    
                    public class ItemGrapesSeeds extends ItemSeeds {
                    
                    	public ItemGrapesSeeds(Block block, Block blockground)
                    	{
                    		super(block, blockground);
                    	}
                    	
                    	public boolean onItemUse(ItemStack p_77648_1_, EntityPlayer p_77648_2_, World p_77648_3_, int p_77648_4_, int p_77648_5_, int p_77648_6_, int p_77648_7_, float p_77648_8_, float p_77648_9_, float p_77648_10_)
                    	{
                    		if(p_77648_7_ !=1)
                    		{
                    			return false;
                    		}
                    		else
                    		{
                    			++p_77648_5_;
                    			Block block = ModPlantsandFoodPack.blockGrapesCrop;
                    			
                    			if(p_77648_2_.canPlayerEdit(p_77648_4_, p_77648_5_, p_77648_6_, p_77648_7_, p_77648_1_) && p_77648_2_.canPlayerEdit(p_77648_4_, p_77648_5_ + 1, p_77648_6_, p_77648_7_, p_77648_1_))
                    			{
                    				if(!block.canPlaceBlockAt(p_77648_3_, p_77648_4_, p_77648_5_, p_77648_6_))
                    				{
                    					return false;
                    				}
                    				else
                    				{
                    					int i1 = MathHelper.floor_double((double)((p_77648_2_.rotationYaw + 180.0F) * 4.0F / 360.0F) - 0.5D) & 3;
                    					placeDoorBlock(p_77648_3_, p_77648_4_, p_77648_5_, p_77648_6_, i1, block);
                    					--p_77648_1_.stackSize;
                    					return true;
                    				}
                    			}
                    			else
                    			{
                    				return false;
                    			}
                    		}
                    	}
                    	
                    	public static void placeDoorBlock(World p_150924_0_, int p_150924_1_, int p_150924_2_, int p_150924_3_, int p_150924_4_, Block p_150924_5_)
                        {
                            byte b0 = 0;
                            byte b1 = 0;
                    
                            if (p_150924_4_ == 0)
                            {
                                b1 = 1;
                            }
                    
                            if (p_150924_4_ == 1)
                            {
                                b0 = -1;
                            }
                    
                            if (p_150924_4_ == 2)
                            {
                                b1 = -1;
                            }
                    
                            if (p_150924_4_ == 3)
                            {
                                b0 = 1;
                            }
                    
                            int i1 = (p_150924_0_.getBlock(p_150924_1_ - b0, p_150924_2_, p_150924_3_ - b1).isNormalCube() ? 1 : 0) + (p_150924_0_.getBlock(p_150924_1_ - b0, p_150924_2_ + 1, p_150924_3_ - b1).isNormalCube() ? 1 : 0);
                            int j1 = (p_150924_0_.getBlock(p_150924_1_ + b0, p_150924_2_, p_150924_3_ + b1).isNormalCube() ? 1 : 0) + (p_150924_0_.getBlock(p_150924_1_ + b0, p_150924_2_ + 1, p_150924_3_ + b1).isNormalCube() ? 1 : 0);
                            boolean flag = p_150924_0_.getBlock(p_150924_1_ - b0, p_150924_2_, p_150924_3_ - b1) == p_150924_5_ || p_150924_0_.getBlock(p_150924_1_ - b0, p_150924_2_ + 1, p_150924_3_ - b1) == p_150924_5_;
                            boolean flag1 = p_150924_0_.getBlock(p_150924_1_ + b0, p_150924_2_, p_150924_3_ + b1) == p_150924_5_ || p_150924_0_.getBlock(p_150924_1_ + b0, p_150924_2_ + 1, p_150924_3_ + b1) == p_150924_5_;
                            boolean flag2 = false;
                    
                            if (flag && !flag1)
                            {
                                flag2 = true;
                            }
                            else if (j1 > i1)
                            {
                                flag2 = true;
                            }
                    
                            p_150924_0_.setBlock(p_150924_1_, p_150924_2_, p_150924_3_, p_150924_5_, p_150924_4_, 2);
                            p_150924_0_.setBlock(p_150924_1_, p_150924_2_ + 1, p_150924_3_, p_150924_5_, 8 | (flag2 ? 1 : 0), 2);
                        }
                    
                    }
                    
                    

                    Et la classe de ma culture (au cas où) :

                    package mod.plantsandfoodpack.common;
                    
                    import java.util.ArrayList;
                    import java.util.List;
                    import java.util.Random;
                    
                    import cpw.mods.fml.relauncher.Side;
                    import cpw.mods.fml.relauncher.SideOnly;
                    import net.minecraft.block.Block;
                    import net.minecraft.block.BlockCrops;
                    import net.minecraft.block.BlockDoublePlant;
                    import net.minecraft.block.IGrowable;
                    import net.minecraft.block.material.Material;
                    import net.minecraft.client.renderer.texture.IIconRegister;
                    import net.minecraft.creativetab.CreativeTabs;
                    import net.minecraft.entity.EntityLivingBase;
                    import net.minecraft.entity.player.EntityPlayer;
                    import net.minecraft.init.Blocks;
                    import net.minecraft.init.Items;
                    import net.minecraft.item.Item;
                    import net.minecraft.item.ItemStack;
                    import net.minecraft.stats.StatList;
                    import net.minecraft.util.AxisAlignedBB;
                    import net.minecraft.util.IIcon;
                    import net.minecraft.util.MathHelper;
                    import net.minecraft.world.IBlockAccess;
                    import net.minecraft.world.World;
                    
                    public class BlockGrapesCrop extends BlockCrops implements IGrowable
                    {
                    	protected int maxGrowthStage = 5;
                    	
                    	@SideOnly(Side.CLIENT)
                        private IIcon[] doublePlantBottomIcons;
                        @SideOnly(Side.CLIENT)
                        private IIcon[] doublePlantTopIcons;
                        
                        public BlockGrapesCrop()
                        {
                        	setTickRandomly(true);
                            float f = 0.5F;
                            this.setHardness(0.0F);
                            this.setStepSound(soundTypeGrass);
                            this.setBlockName("grapesCrop");
                            disableStats();
                        }
                    
                        public int getRenderType()
                        {
                            return 1;
                        }
                        
                        public void setBlockBoundsBasedOnState(IBlockAccess p_149719_1_, int p_149719_2_, int p_149719_3_, int p_149719_4_)
                        {
                            this.setBlockBounds(0F, 0F, 0F, 1F, 2F, 1F);
                        }
                        
                        public int func_149885_e(IBlockAccess p_149885_1_, int p_149885_2_, int p_149885_3_, int p_149885_4_)
                        {
                            int l = p_149885_1_.getBlockMetadata(p_149885_2_, p_149885_3_, p_149885_4_);
                            return !func_149887_c(l) ? l & 7 : p_149885_1_.getBlockMetadata(p_149885_2_, p_149885_3_ - 1, p_149885_4_) & 7;
                        }
                    
                    	@Override
                    	protected boolean canPlaceBlockOn(Block block)
                    	{
                    		return block == Blocks.farmland;
                    	}
                        
                    	public void incrementGrowStage(World parWorld, Random parRand, int parX, int parY, int parZ)
                        {
                            int growStage = parWorld.getBlockMetadata(parX, parY, parZ) + 
                                  MathHelper.getRandomIntegerInRange(parRand, 2, 5);
                    
                            if (growStage > maxGrowthStage)
                            {
                             growStage = maxGrowthStage;
                            }
                    
                            parWorld.setBlockMetadataWithNotify(parX, parY, parZ, growStage, 2);
                        }
                    	
                        public boolean canPlaceBlockAt(World p_149742_1_, int p_149742_2_, int p_149742_3_, int p_149742_4_)
                        {
                            return super.canPlaceBlockAt(p_149742_1_, p_149742_2_, p_149742_3_, p_149742_4_) && p_149742_1_.isAirBlock(p_149742_2_, p_149742_3_ + 1, p_149742_4_);
                        }
                    
                        protected void checkAndDropBlock(World p_149855_1_, int p_149855_2_, int p_149855_3_, int p_149855_4_)
                        {
                            if (!this.canBlockStay(p_149855_1_, p_149855_2_, p_149855_3_, p_149855_4_))
                            {
                                int l = p_149855_1_.getBlockMetadata(p_149855_2_, p_149855_3_, p_149855_4_);
                    
                                if (!func_149887_c(l))
                                {
                                    this.dropBlockAsItem(p_149855_1_, p_149855_2_, p_149855_3_, p_149855_4_, l, 0);
                    
                                    if (p_149855_1_.getBlock(p_149855_2_, p_149855_3_ + 1, p_149855_4_) == this)
                                    {
                                        p_149855_1_.setBlock(p_149855_2_, p_149855_3_ + 1, p_149855_4_, Blocks.air, 0, 2);
                                    }
                                }
                    
                                p_149855_1_.setBlock(p_149855_2_, p_149855_3_, p_149855_4_, Blocks.air, 0, 2);
                            }
                        }
                        
                    
                        public static boolean func_149887_c(int p_149887_0_)
                        {
                            return (p_149887_0_ & 8) != 0;
                        }
                    
                        public static int func_149890_d(int p_149890_0_)
                        {
                            return p_149890_0_ & 7;
                        }
                    	
                    	@Override
                    	@SideOnly(Side.CLIENT)
                        public IIcon getIcon(int p_149691_1_, int metadata)
                        {
                    		if (metadata < 0 || metadata > 5)
                            {
                    			metadata = 5;
                    			
                            }
                    
                    		return func_149887_c(metadata) ? this.doublePlantBottomIcons[metadata] : this.doublePlantBottomIcons[metadata];
                        }
                    	
                    	
                    	@SideOnly(Side.CLIENT)
                        public IIcon func_149888_a(boolean p_149888_1_, int metadata)
                        {
                            return p_149888_1_ ? this.doublePlantTopIcons[metadata] : this.doublePlantBottomIcons[metadata];
                        }
                        
                    	public void func_149889_c(World p_149889_1_, int p_149889_2_, int p_149889_3_, int p_149889_4_, int p_149889_5_, int p_149889_6_)
                        {
                            p_149889_1_.setBlock(p_149889_2_, p_149889_3_, p_149889_4_, this, p_149889_5_, p_149889_6_);
                            p_149889_1_.setBlock(p_149889_2_, p_149889_3_ + 1, p_149889_4_, this, 8, p_149889_6_);
                        }
                    	
                    	public void onBlockPlacedBy(World p_149689_1_, int p_149689_2_, int p_149689_3_, int p_149689_4_, EntityLivingBase p_149689_5_, ItemStack p_149689_6_)
                        {
                            int l = ((MathHelper.floor_double((double)(p_149689_5_.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3) + 2) % 4;
                            p_149689_1_.setBlock(p_149689_2_, p_149689_3_ + 1, p_149689_4_, this, 8 | l, 2);
                        }
                    	
                    	public void onBlockHarvested(World p_149681_1_, int p_149681_2_, int p_149681_3_, int p_149681_4_, int p_149681_5_, EntityPlayer p_149681_6_)
                        {
                            if (func_149887_c(p_149681_5_))
                            {
                                if (p_149681_1_.getBlock(p_149681_2_, p_149681_3_ - 1, p_149681_4_) == this)
                                {
                                    if (!p_149681_6_.capabilities.isCreativeMode)
                                    {
                                        int i1 = p_149681_1_.getBlockMetadata(p_149681_2_, p_149681_3_ - 1, p_149681_4_);
                                        int j1 = func_149890_d(i1);
                    
                                        if (j1 != 3 && j1 != 2)
                                        {
                                            p_149681_1_.func_147480_a(p_149681_2_, p_149681_3_ - 1, p_149681_4_, true);
                                        }
                                        else
                                        {
                    
                                            p_149681_1_.setBlockToAir(p_149681_2_, p_149681_3_ - 1, p_149681_4_);
                                        }
                                    }
                                    else
                                    {
                                        p_149681_1_.setBlockToAir(p_149681_2_, p_149681_3_ - 1, p_149681_4_);
                                    }
                                }
                            }
                            else if (p_149681_6_.capabilities.isCreativeMode && p_149681_1_.getBlock(p_149681_2_, p_149681_3_ + 1, p_149681_4_) == this)
                            {
                                p_149681_1_.setBlock(p_149681_2_, p_149681_3_ + 1, p_149681_4_, Blocks.air, 0, 2);
                            }
                    
                            super.onBlockHarvested(p_149681_1_, p_149681_2_, p_149681_3_, p_149681_4_, p_149681_5_, p_149681_6_);
                        }
                    
                        private boolean func_149886_b(World p_149886_1_, int p_149886_2_, int p_149886_3_, int p_149886_4_, int p_149886_5_, EntityPlayer p_149886_6_)
                        {
                            int i1 = func_149890_d(p_149886_5_);
                    
                            if (i1 != 3 && i1 != 2)
                            {
                                return false;
                            }
                            else
                            {
                                p_149886_6_.addStat(StatList.mineBlockStatArray[Block.getIdFromBlock(this)], 1);
                                byte b0 = 1;
                    
                                if (i1 == 3)
                                {
                                    b0 = 2;
                                }
                                return true;
                            }
                        }
                    	
                    	protected Item func_149866_i()
                        {
                            return ModPlantsandFoodPack.itemGrapesSeeds;
                        }
                    
                        protected Item func_149865_P()
                        {
                            return ModPlantsandFoodPack.itemGrapes;
                        }
                        
                        @Override
                        public Item getItemDropped(int p_149650_1_, Random p_149650_2_, int p_149650_3_)
                        {
                            return p_149650_1_ == 5 ? this.func_149865_P() : this.func_149866_i();
                        }
                    
                    	@Override
                    	public int quantityDropped(int meta, int fortune, Random random)
                    	{
                    		return meta == 5 ? 4 : 1;
                    	}
                    	
                    	public int getDamageValue(World p_149643_1_, int p_149643_2_, int p_149643_3_, int p_149643_4_)
                        {
                            int l = p_149643_1_.getBlockMetadata(p_149643_2_, p_149643_3_, p_149643_4_);
                            return func_149887_c(l) ? func_149890_d(p_149643_1_.getBlockMetadata(p_149643_2_, p_149643_3_ - 1, p_149643_4_)) : func_149890_d(l);
                        }
                        
                    	@Override
                    	public boolean func_149851_a(World parWorld, int parX, int parY, int parZ, 
                    	          boolean p_149851_5_)
                    	    {
                    		int l = this.func_149885_e(parWorld, parX, parY, parZ);
                            return parWorld.getBlockMetadata(parX, parY, parZ) != 5;
                    	    }
                    	
                    	@Override
                        public boolean func_149852_a(World p_149852_1_, Random parRand, int p_149852_3_, 
                              int p_149852_4_, int p_149852_5_)
                        {
                            return true;
                        }
                    	
                    	@SideOnly(Side.CLIENT)
                        public Item getItem(World p_149694_1_, int p_149694_2_, int p_149694_3_, int p_149694_4_)
                        {
                            return this.func_149866_i();
                        }
                    	
                    	@Override
                        @SideOnly(Side.CLIENT)
                        public void registerBlockIcons(IIconRegister parIIconRegister)
                        {
                    		doublePlantBottomIcons = new IIcon[maxGrowthStage+1];
                    		doublePlantTopIcons = new IIcon[maxGrowthStage+2];
                    		
                    		doublePlantBottomIcons[0] = parIIconRegister.registerIcon(ModPlantsandFoodPack.MODID + ":grapes_bottom_stage_0");
                    		doublePlantBottomIcons[1] = parIIconRegister.registerIcon(ModPlantsandFoodPack.MODID + ":grapes_bottom_stage_1");
                    		doublePlantBottomIcons[2] = parIIconRegister.registerIcon(ModPlantsandFoodPack.MODID + ":grapes_bottom_stage_2");
                    		doublePlantBottomIcons[3] = parIIconRegister.registerIcon(ModPlantsandFoodPack.MODID + ":grapes_bottom_stage_3");
                    		doublePlantBottomIcons[4] = parIIconRegister.registerIcon(ModPlantsandFoodPack.MODID + ":grapes_bottom_stage_4");
                    		doublePlantBottomIcons[5] = parIIconRegister.registerIcon(ModPlantsandFoodPack.MODID + ":grapes_bottom_stage_5");
                    		
                    		doublePlantTopIcons[0] = parIIconRegister.registerIcon(ModPlantsandFoodPack.MODID + ":grapes_top_stage_0");
                    		doublePlantTopIcons[1] = parIIconRegister.registerIcon(ModPlantsandFoodPack.MODID + ":grapes_top_stage_1");
                    		doublePlantTopIcons[2] = parIIconRegister.registerIcon(ModPlantsandFoodPack.MODID + ":grapes_top_stage_2");
                    		doublePlantTopIcons[3] = parIIconRegister.registerIcon(ModPlantsandFoodPack.MODID + ":grapes_top_stage_3");
                    		doublePlantTopIcons[4] = parIIconRegister.registerIcon(ModPlantsandFoodPack.MODID + ":grapes_top_stage_4");
                    		doublePlantTopIcons[5] = parIIconRegister.registerIcon(ModPlantsandFoodPack.MODID + ":grapes_top_stage_5");
                        }
                    	
                    	@SideOnly(Side.CLIENT)
                        public void getSubBlocks(Item p_149666_1_, CreativeTabs p_149666_2_, List p_149666_3_)
                        {
                            for (int i = 0; i < this.doublePlantBottomIcons.length; ++i)
                            {
                                p_149666_3_.add(new ItemStack(p_149666_1_, 1, i));
                            }
                        }
                    	
                    	
                    	@Override
                        public void func_149853_b(World parWorld, Random parRand, int parX, int parY, 
                              int parZ)
                        {
                    		int l = this.func_149885_e(parWorld, parX, parY, parZ);
                            incrementGrowStage(parWorld, parRand, parX, parY, parZ);
                        }
                    	
                    	
                    }
                    
                    
                    1 réponse Dernière réponse Répondre Citer 0
                    • robin4002R Hors-ligne
                      robin4002 Moddeurs confirmés Rédacteurs Administrateurs
                      dernière édition par

                      L’essentiel c’était d’avoir les deux setBlock.
                      Comme ceci c’est probablement mieux :

                      package mod.plantsandfoodpack.common;
                      
                      import net.minecraft.block.Block;
                      import net.minecraft.entity.player.EntityPlayer;
                      import net.minecraft.init.Blocks;
                      import net.minecraft.item.ItemSeeds;
                      import net.minecraft.item.ItemStack;
                      import net.minecraft.util.MathHelper;
                      import net.minecraft.world.World;
                      
                      public class ItemGrapesSeeds extends ItemSeeds {
                      
                      	public ItemGrapesSeeds(Block block, Block blockground)
                      	{
                      		super(block, blockground);
                      	}
                      	
                      	public boolean onItemUse(ItemStack p_77648_1_, EntityPlayer p_77648_2_, World p_77648_3_, int p_77648_4_, int p_77648_5_, int p_77648_6_, int p_77648_7_, float p_77648_8_, float p_77648_9_, float p_77648_10_)
                      	{
                      		if(p_77648_7_ !=1)
                      		{
                      			return false;
                      		}
                      		else
                      		{
                      			++p_77648_5_;
                      			Block block = ModPlantsandFoodPack.blockGrapesCrop;
                      			
                      			if(p_77648_2_.canPlayerEdit(p_77648_4_, p_77648_5_, p_77648_6_, p_77648_7_, p_77648_1_) && p_77648_2_.canPlayerEdit(p_77648_4_, p_77648_5_ + 1, p_77648_6_, p_77648_7_, p_77648_1_))
                      			{
                      				if(!block.canPlaceBlockAt(p_77648_3_, p_77648_4_, p_77648_5_, p_77648_6_))
                      				{
                      					return false;
                      				}
                      				else
                      				{
                      					p_77648_3_.setBlock(p_77648_4_, p_77648_5_, p_77648_6_, block, 0, 2);
                      					p_77648_3_.setBlock(p_77648_4_, p_77648_5_ + 1, p_77648_6_, block, 8, 2);
                      					--p_77648_1_.stackSize;
                      					return true;
                      				}
                      			}
                      			else
                      			{
                      				return false;
                      			}
                      		}
                      	}
                      }
                      

                      Ce qui serait encore mieux, c’est de renommer les p_xxxxx en quelque chose de compréhensible.

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

                        J’ai essayé,

                        Maintenant ça me met la partie du bas en haut à la place de la partie du haut mais à son dernier stade de croissance…

                        La classe de mon Item en un peu plus compréhensible :

                        package mod.plantsandfoodpack.common;
                        
                        import net.minecraft.block.Block;
                        import net.minecraft.entity.player.EntityPlayer;
                        import net.minecraft.init.Blocks;
                        import net.minecraft.item.ItemSeeds;
                        import net.minecraft.item.ItemStack;
                        import net.minecraft.util.MathHelper;
                        import net.minecraft.world.World;
                        
                        public class ItemGrapesSeeds extends ItemSeeds {
                        
                        	public ItemGrapesSeeds(Block block, Block blockground)
                        	{
                        		super(block, blockground);
                        	}
                        	
                        	public boolean onItemUse(ItemStack itemStack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ)
                        	{
                        		if(side !=1)
                        		{
                        			return false;
                        		}
                        		else
                        		{
                        			++y;
                        			Block block = ModPlantsandFoodPack.blockGrapesCrop;
                        			
                        			if(player.canPlayerEdit(x, y, z, side, itemStack) && player.canPlayerEdit(x, y + 1, z, side, itemStack))
                        			{
                        				if(!block.canPlaceBlockAt(world, x, y, z))
                        				{
                        					return false;
                        				}
                        				else
                        				{
                        					world.setBlock(x, y, z, block, 0, 2);
                        					world.setBlock(x, y + 1, z, block, 8, 2);
                        					--itemStack.stackSize;
                        					return true;
                        				}
                        			}
                        			else
                        			{
                        				return false;
                        			}
                        		}
                        	}
                        	
                        }
                        
                        

                        ce que ça donne en jeu :

                        text alternatif

                        J’espère que vous pourrez m’aider 😥

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

                          personne ne peut m’aider… ? 😥 😧

                          1 réponse Dernière réponse Répondre Citer 0
                          • robin4002R Hors-ligne
                            robin4002 Moddeurs confirmés Rédacteurs Administrateurs
                            dernière édition par

                            Il faut que tu adaptes le metadata posé et la texture du bloc en fonction de metadata.

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

                              j’ai essayer mais ça me met toujours la texture du bas en haut !

                              1 réponse Dernière réponse Répondre Citer 0
                              • robin4002R Hors-ligne
                                robin4002 Moddeurs confirmés Rédacteurs Administrateurs
                                dernière édition par

                                Tu peux envoyer le code actuel de ton bloc ?

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

                                  Mon bloc :

                                  package mod.plantsandfoodpack.common;
                                  
                                  import java.util.ArrayList;
                                  import java.util.List;
                                  import java.util.Random;
                                  
                                  import cpw.mods.fml.relauncher.Side;
                                  import cpw.mods.fml.relauncher.SideOnly;
                                  import net.minecraft.block.Block;
                                  import net.minecraft.block.BlockCrops;
                                  import net.minecraft.block.BlockDoublePlant;
                                  import net.minecraft.block.IGrowable;
                                  import net.minecraft.block.material.Material;
                                  import net.minecraft.client.renderer.texture.IIconRegister;
                                  import net.minecraft.creativetab.CreativeTabs;
                                  import net.minecraft.entity.EntityLivingBase;
                                  import net.minecraft.entity.player.EntityPlayer;
                                  import net.minecraft.init.Blocks;
                                  import net.minecraft.init.Items;
                                  import net.minecraft.item.Item;
                                  import net.minecraft.item.ItemStack;
                                  import net.minecraft.stats.StatList;
                                  import net.minecraft.util.AxisAlignedBB;
                                  import net.minecraft.util.IIcon;
                                  import net.minecraft.util.MathHelper;
                                  import net.minecraft.world.IBlockAccess;
                                  import net.minecraft.world.World;
                                  
                                  public class BlockGrapesCrop extends BlockCrops implements IGrowable
                                  {
                                  	protected int maxGrowthStage = 5;
                                  	
                                  	@SideOnly(Side.CLIENT)
                                      private IIcon[] doublePlantBottomIcons;
                                      @SideOnly(Side.CLIENT)
                                      private IIcon[] doublePlantTopIcons;
                                      
                                      public BlockGrapesCrop()
                                      {
                                      	setTickRandomly(true);
                                          float f = 0.5F;
                                          this.setHardness(0.0F);
                                          this.setStepSound(soundTypeGrass);
                                          this.setBlockName("grapesCrop");
                                          disableStats();
                                      }
                                  
                                      public int getRenderType()
                                      {
                                          return 1;
                                      }
                                      
                                      public void setBlockBoundsBasedOnState(IBlockAccess p_149719_1_, int p_149719_2_, int p_149719_3_, int p_149719_4_)
                                      {
                                          this.setBlockBounds(0F, 0F, 0F, 1F, 2F, 1F);
                                      }
                                      
                                      public int func_149885_e(IBlockAccess p_149885_1_, int p_149885_2_, int p_149885_3_, int p_149885_4_)
                                      {
                                          int l = p_149885_1_.getBlockMetadata(p_149885_2_, p_149885_3_, p_149885_4_);
                                          return !func_149887_c(l) ? l & 7 : p_149885_1_.getBlockMetadata(p_149885_2_, p_149885_3_ - 1, p_149885_4_) & 7;
                                      }
                                  
                                  	@Override
                                  	protected boolean canPlaceBlockOn(Block block)
                                  	{
                                  		return block == Blocks.farmland;
                                  	}
                                      
                                  	public void incrementGrowStage(World parWorld, Random parRand, int parX, int parY, int parZ)
                                      {
                                          int growStage = parWorld.getBlockMetadata(parX, parY, parZ) + 
                                                MathHelper.getRandomIntegerInRange(parRand, 2, 5);
                                  
                                          if (growStage > maxGrowthStage)
                                          {
                                           growStage = maxGrowthStage;
                                          }
                                  
                                          parWorld.setBlockMetadataWithNotify(parX, parY, parZ, growStage, 2);
                                      }
                                  	
                                      public boolean canPlaceBlockAt(World p_149742_1_, int p_149742_2_, int p_149742_3_, int p_149742_4_)
                                      {
                                          return super.canPlaceBlockAt(p_149742_1_, p_149742_2_, p_149742_3_, p_149742_4_) && p_149742_1_.isAirBlock(p_149742_2_, p_149742_3_ + 1, p_149742_4_);
                                      }
                                  
                                      protected void checkAndDropBlock(World p_149855_1_, int p_149855_2_, int p_149855_3_, int p_149855_4_)
                                      {
                                          if (!this.canBlockStay(p_149855_1_, p_149855_2_, p_149855_3_, p_149855_4_))
                                          {
                                              int l = p_149855_1_.getBlockMetadata(p_149855_2_, p_149855_3_, p_149855_4_);
                                  
                                              if (!func_149887_c(l))
                                              {
                                                  this.dropBlockAsItem(p_149855_1_, p_149855_2_, p_149855_3_, p_149855_4_, l, 0);
                                  
                                                  if (p_149855_1_.getBlock(p_149855_2_, p_149855_3_ + 1, p_149855_4_) == this)
                                                  {
                                                      p_149855_1_.setBlock(p_149855_2_, p_149855_3_ + 1, p_149855_4_, Blocks.air, 0, 2);
                                                  }
                                              }
                                  
                                              p_149855_1_.setBlock(p_149855_2_, p_149855_3_, p_149855_4_, Blocks.air, 0, 2);
                                          }
                                      }
                                      
                                  
                                      public static boolean func_149887_c(int p_149887_0_)
                                      {
                                          return (p_149887_0_ & 8) != 0;
                                      }
                                  
                                      public static int func_149890_d(int p_149890_0_)
                                      {
                                          return p_149890_0_ & 7;
                                      }
                                  	
                                  	@Override
                                  	@SideOnly(Side.CLIENT)
                                      public IIcon getIcon(int p_149691_1_, int metadata)
                                      {
                                  		if (metadata < 0 || metadata > 5)
                                          {
                                  			metadata = 5;
                                  			
                                          }
                                  
                                  		return func_149887_c(metadata) ? this.doublePlantBottomIcons[metadata] : this.doublePlantBottomIcons[metadata];
                                      }
                                  	
                                  	
                                  	@SideOnly(Side.CLIENT)
                                      public IIcon func_149888_a(boolean p_149888_1_, int metadata)
                                      {
                                          return p_149888_1_ ? this.doublePlantTopIcons[metadata] : this.doublePlantBottomIcons[metadata];
                                      }
                                      
                                  	public void func_149889_c(World p_149889_1_, int p_149889_2_, int p_149889_3_, int p_149889_4_, int p_149889_5_, int p_149889_6_)
                                      {
                                          p_149889_1_.setBlock(p_149889_2_, p_149889_3_, p_149889_4_, this, p_149889_5_, p_149889_6_);
                                          p_149889_1_.setBlock(p_149889_2_, p_149889_3_ + 1, p_149889_4_, this, 8, p_149889_6_);
                                      }
                                  	
                                  	public void onBlockPlacedBy(World p_149689_1_, int p_149689_2_, int p_149689_3_, int p_149689_4_, EntityLivingBase p_149689_5_, ItemStack p_149689_6_)
                                      {
                                          int l = ((MathHelper.floor_double((double)(p_149689_5_.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3) + 2) % 4;
                                          p_149689_1_.setBlock(p_149689_2_, p_149689_3_ + 1, p_149689_4_, this, 8 | l, 2);
                                      }
                                  	
                                  	public void onBlockHarvested(World p_149681_1_, int p_149681_2_, int p_149681_3_, int p_149681_4_, int p_149681_5_, EntityPlayer p_149681_6_)
                                      {
                                          if (func_149887_c(p_149681_5_))
                                          {
                                              if (p_149681_1_.getBlock(p_149681_2_, p_149681_3_ - 1, p_149681_4_) == this)
                                              {
                                                  if (!p_149681_6_.capabilities.isCreativeMode)
                                                  {
                                                      int i1 = p_149681_1_.getBlockMetadata(p_149681_2_, p_149681_3_ - 1, p_149681_4_);
                                                      int j1 = func_149890_d(i1);
                                  
                                                      if (j1 != 3 && j1 != 2)
                                                      {
                                                          p_149681_1_.func_147480_a(p_149681_2_, p_149681_3_ - 1, p_149681_4_, true);
                                                      }
                                                      else
                                                      {
                                  
                                                          p_149681_1_.setBlockToAir(p_149681_2_, p_149681_3_ - 1, p_149681_4_);
                                                      }
                                                  }
                                                  else
                                                  {
                                                      p_149681_1_.setBlockToAir(p_149681_2_, p_149681_3_ - 1, p_149681_4_);
                                                  }
                                              }
                                          }
                                          else if (p_149681_6_.capabilities.isCreativeMode && p_149681_1_.getBlock(p_149681_2_, p_149681_3_ + 1, p_149681_4_) == this)
                                          {
                                              p_149681_1_.setBlock(p_149681_2_, p_149681_3_ + 1, p_149681_4_, Blocks.air, 0, 2);
                                          }
                                  
                                          super.onBlockHarvested(p_149681_1_, p_149681_2_, p_149681_3_, p_149681_4_, p_149681_5_, p_149681_6_);
                                      }
                                  
                                      private boolean func_149886_b(World p_149886_1_, int p_149886_2_, int p_149886_3_, int p_149886_4_, int p_149886_5_, EntityPlayer p_149886_6_)
                                      {
                                          int i1 = func_149890_d(p_149886_5_);
                                  
                                          if (i1 != 3 && i1 != 2)
                                          {
                                              return false;
                                          }
                                          else
                                          {
                                              p_149886_6_.addStat(StatList.mineBlockStatArray[Block.getIdFromBlock(this)], 1);
                                              byte b0 = 1;
                                  
                                              if (i1 == 3)
                                              {
                                                  b0 = 2;
                                              }
                                              return true;
                                          }
                                      }
                                  	
                                  	protected Item func_149866_i()
                                      {
                                          return ModPlantsandFoodPack.itemGrapesSeeds;
                                      }
                                  
                                      protected Item func_149865_P()
                                      {
                                          return ModPlantsandFoodPack.itemGrapes;
                                      }
                                      
                                      @Override
                                      public Item getItemDropped(int p_149650_1_, Random p_149650_2_, int p_149650_3_)
                                      {
                                          return p_149650_1_ == 5 ? this.func_149865_P() : this.func_149866_i();
                                      }
                                  
                                  	@Override
                                  	public int quantityDropped(int meta, int fortune, Random random)
                                  	{
                                  		return meta == 5 ? 4 : 1;
                                  	}
                                  	
                                  	public int getDamageValue(World p_149643_1_, int p_149643_2_, int p_149643_3_, int p_149643_4_)
                                      {
                                          int l = p_149643_1_.getBlockMetadata(p_149643_2_, p_149643_3_, p_149643_4_);
                                          return func_149887_c(l) ? func_149890_d(p_149643_1_.getBlockMetadata(p_149643_2_, p_149643_3_ - 1, p_149643_4_)) : func_149890_d(l);
                                      }
                                      
                                  	@Override
                                  	public boolean func_149851_a(World parWorld, int parX, int parY, int parZ, 
                                  	          boolean p_149851_5_)
                                  	    {
                                  		int l = this.func_149885_e(parWorld, parX, parY, parZ);
                                          return parWorld.getBlockMetadata(parX, parY, parZ) != 5;
                                  	    }
                                  	
                                  	@Override
                                      public boolean func_149852_a(World p_149852_1_, Random parRand, int p_149852_3_, 
                                            int p_149852_4_, int p_149852_5_)
                                      {
                                          return true;
                                      }
                                  	
                                  	@SideOnly(Side.CLIENT)
                                      public Item getItem(World p_149694_1_, int p_149694_2_, int p_149694_3_, int p_149694_4_)
                                      {
                                          return this.func_149866_i();
                                      }
                                  	
                                  	@Override
                                      @SideOnly(Side.CLIENT)
                                      public void registerBlockIcons(IIconRegister parIIconRegister)
                                      {
                                  		doublePlantBottomIcons = new IIcon[maxGrowthStage+1];
                                  		doublePlantTopIcons = new IIcon[maxGrowthStage+2];
                                  		
                                  		doublePlantBottomIcons[0] = parIIconRegister.registerIcon(ModPlantsandFoodPack.MODID + ":grapes_bottom_stage_0");
                                  		doublePlantBottomIcons[1] = parIIconRegister.registerIcon(ModPlantsandFoodPack.MODID + ":grapes_bottom_stage_1");
                                  		doublePlantBottomIcons[2] = parIIconRegister.registerIcon(ModPlantsandFoodPack.MODID + ":grapes_bottom_stage_2");
                                  		doublePlantBottomIcons[3] = parIIconRegister.registerIcon(ModPlantsandFoodPack.MODID + ":grapes_bottom_stage_3");
                                  		doublePlantBottomIcons[4] = parIIconRegister.registerIcon(ModPlantsandFoodPack.MODID + ":grapes_bottom_stage_4");
                                  		doublePlantBottomIcons[5] = parIIconRegister.registerIcon(ModPlantsandFoodPack.MODID + ":grapes_bottom_stage_5");
                                  		
                                  		doublePlantTopIcons[0] = parIIconRegister.registerIcon(ModPlantsandFoodPack.MODID + ":grapes_top_stage_0");
                                  		doublePlantTopIcons[1] = parIIconRegister.registerIcon(ModPlantsandFoodPack.MODID + ":grapes_top_stage_1");
                                  		doublePlantTopIcons[2] = parIIconRegister.registerIcon(ModPlantsandFoodPack.MODID + ":grapes_top_stage_2");
                                  		doublePlantTopIcons[3] = parIIconRegister.registerIcon(ModPlantsandFoodPack.MODID + ":grapes_top_stage_3");
                                  		doublePlantTopIcons[4] = parIIconRegister.registerIcon(ModPlantsandFoodPack.MODID + ":grapes_top_stage_4");
                                  		doublePlantTopIcons[5] = parIIconRegister.registerIcon(ModPlantsandFoodPack.MODID + ":grapes_top_stage_5");
                                      }
                                  	
                                  	@SideOnly(Side.CLIENT)
                                      public void getSubBlocks(Item p_149666_1_, CreativeTabs p_149666_2_, List p_149666_3_)
                                      {
                                          for (int i = 0; i < this.doublePlantBottomIcons.length; ++i)
                                          {
                                              p_149666_3_.add(new ItemStack(p_149666_1_, 1, i));
                                          }
                                      }
                                  	
                                  	
                                  	@Override
                                      public void func_149853_b(World parWorld, Random parRand, int parX, int parY, 
                                            int parZ)
                                      {
                                  		int l = this.func_149885_e(parWorld, parX, parY, parZ);
                                          incrementGrowStage(parWorld, parRand, parX, parY, parZ);
                                      }
                                  	
                                  	
                                  }
                                  
                                  
                                  1 réponse Dernière réponse Répondre Citer 0
                                  • AymericRedA Hors-ligne
                                    AymericRed
                                    dernière édition par

                                    Le problème est simple :

                                    	@Override
                                    	@SideOnly(Side.CLIENT)
                                        public IIcon getIcon(int p_149691_1_, int metadata)
                                        {
                                    		if (metadata < 0 || metadata > 5)
                                            {
                                    			metadata = 5;
                                    			
                                            }
                                    
                                    		return func_149887_c(metadata) ? this.doublePlantBottomIcons[metadata] : this.doublePlantBottomIcons[metadata];
                                        }
                                    

                                    Tu retournes toujours ‘doublePlantBottomIcons’ (la texture du bas).

                                    Si je vous ai aidé, n'oubliez pas d’être heureux, j'aiderai encore +

                                    AymericRed, moddeur expérimenté qui aide sur ce forum et qui peut accepter de faire un mod Forge rémunéré de temps en temps.

                                    Mes tutos : Table de craft, plugin NEI, plugin JEI, modifier l'overlay
                                    Je suis un membre apprécié et joueur, j'ai déjà obtenu 6 points de réputation.

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

                                      j’ai essayer d’en remplacer un par la texture du haut mais quand je modifie le premier, ça change rien et si je modifie le 2eme, les deux parties prennent la texture du haut…

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

                                        …

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

                                          personne ne sait comment m’aider ?.. 😥 😢

                                          1 réponse Dernière réponse Répondre Citer 0
                                          • robin4002R Hors-ligne
                                            robin4002 Moddeurs confirmés Rédacteurs Administrateurs
                                            dernière édition par

                                            Il faudrait que je prenne le code de mon côté pour faire des tests moi-même, mais je n’ai plus de workspace 1.7.10 et je n’ai pas du tout envie de refaire un setup (ni de dev d’ailleurs) dans cette version obsolète.
                                            Désolé.

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

                                            MINECRAFT FORGE FRANCE © 2024

                                            Powered by NodeBB