Problème block orientable



  • Salut salut c'est encore moi ^^

    Voilà mon problème j'ai suivit un tutoriel pour faire un block orientable multitexture en 1.7.10
    Les textures s'affochent bien mais l'orientation ne marche pas /:
    Voici la classe de mon block

    package fr.romain120105.energyzedhand.Blocks;
    import java.util.Random;
    import fr.romain120105.energyzedhand.Main;
    import fr.romain120105.energyzedhand.gui.tileentity.TileTest;
    import fr.romain120105.energyzedhand.init.EnergyzedBlocks;
    import fr.romain120105.energyzedhand.init.EnergyzedItems;
    import mekanism.common.MekanismItems;
    import net.minecraft.block.Block;
    import net.minecraft.block.material.Material;
    import net.minecraft.client.renderer.texture.IIconRegister;
    import net.minecraft.entity.item.EntityItem;
    import net.minecraft.entity.player.EntityPlayer;
    import net.minecraft.init.Blocks;
    import net.minecraft.inventory.IInventory;
    import net.minecraft.item.Item;
    import net.minecraft.item.ItemStack;
    import net.minecraft.nbt.NBTTagCompound;
    import net.minecraft.tileentity.TileEntity;
    import net.minecraft.util.ChatComponentTranslation;
    import net.minecraft.util.IIcon;
    import net.minecraft.world.World;
    public class GuiTest extends Block
    {
    
     private final Random field_149933_a = new Random();
     private final boolean field_149932_b;
     private static boolean field_149934_M;
     private IIcon field_149935_N;
     private IIcon field_149936_O;
     private static final String __OBFID = "CL_00000248";
    
     public GuiTest(boolean p_i45407_1_, Material rock)
        {
            super(Material.rock);
            this.setHardness(10F);
            this.field_149932_b = p_i45407_1_;
        }
    
     public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ){
      if(player.getHeldItem() != null && player.getHeldItem().getItem() == MekanismItems.Configurator) {
       Block b = world.getBlock(x, y, z);
       world.getBlock(x, y, z).dropBlockAsItem(world, x, y, z, world.getBlockMetadata(x, y, z), 0);
       world.setBlockToAir(x, y, z);
    
       player.addChatMessage(new ChatComponentTranslation("Bien joué"));
      }
    
      if(player.getHeldItem() != null && player.getHeldItem().getItem() == EnergyzedItems.wrench) {
        Block b = world.getBlock(x, y, z);
        world.getBlock(x, y, z).dropBlockAsItem(world, x, y, z, world.getBlockMetadata(x, y, z), 0);
        world.setBlockToAir(x, y, z);
    
        player.addChatMessage(new ChatComponentTranslation("Bien joué"));
      }else{
    
        if(world.isRemote) {
         return true;
        }
        else {
         player.openGui(Main.instance, 0, world, x, y, z);
         return true;
        }
    
       }
    
       return false;
    
     }
    
     public void breakBlock(World world, int x, int y, int z, Block block, int metadata)
      {
       TileEntity tileentity = world.getTileEntity(x, y, z);
       if(tileentity instanceof IInventory)
       {
        IInventory inv = (IInventory)tileentity;
        for(int i1 = 0; i1 < inv.getSizeInventory(); ++i1)
        {
         ItemStack itemstack = inv.getStackInSlot(i1);
         if(itemstack != null)
         {
          float f = world.rand.nextFloat() * 0.8F + 0.1F;
          float f1 = world.rand.nextFloat() * 0.8F + 0.1F;
          EntityItem entityitem;
          for(float f2 = world.rand.nextFloat() * 0.8F + 0.1F; itemstack.stackSize > 0; world.spawnEntityInWorld(entityitem))
          {
           int j1 = world.rand.nextInt(21) + 10;
           if(j1 > itemstack.stackSize)
           {
            j1 = itemstack.stackSize;
           }
           itemstack.stackSize -= j1;
           entityitem = new EntityItem(world, (double)((float)x + f), (double)((float)y + f1), (double)((float)z + f2), new ItemStack(itemstack.getItem(), j1, itemstack.getItemDamage()));
           float f3 = 0.05F;
           entityitem.motionX = (double)((float)world.rand.nextGaussian() * f3);
           entityitem.motionY = (double)((float)world.rand.nextGaussian() * f3 + 0.2F);
           entityitem.motionZ = (double)((float)world.rand.nextGaussian() * f3);
           if(itemstack.hasTagCompound())
           {
            entityitem.getEntityItem().setTagCompound((NBTTagCompound)itemstack.getTagCompound().copy());
           }
          }
         }
        }
        world.func_147453_f(x, y, z, block);
      }
      super.breakBlock(world, x, y, z, block, metadata);;
      }
    
     @Override
     public boolean hasTileEntity(int metadata) {
      return true;
     }
    
     @Override
     public TileEntity createTileEntity(World world, int metadata)
     {
      return new TileTest();
    
     }
     public Item getItemDropped(int p_149650_1_, Random p_149650_2_, int p_149650_3_)
        {
            return Item.getItemFromBlock(EnergyzedBlocks.guiTest);
        }
        public void onBlockAdded(World p_149726_1_, int p_149726_2_, int p_149726_3_, int p_149726_4_)
        {
            super.onBlockAdded(p_149726_1_, p_149726_2_, p_149726_3_, p_149726_4_);
            this.func_149930_e(p_149726_1_, p_149726_2_, p_149726_3_, p_149726_4_);
        }
        private void func_149930_e(World p_149930_1_, int p_149930_2_, int p_149930_3_, int p_149930_4_)
        {
            if (!p_149930_1_.isRemote)
            {
                Block var5 = p_149930_1_.getBlock(p_149930_2_, p_149930_3_, p_149930_4_ - 1);
                Block var6 = p_149930_1_.getBlock(p_149930_2_, p_149930_3_, p_149930_4_ + 1);
                Block var7 = p_149930_1_.getBlock(p_149930_2_ - 1, p_149930_3_, p_149930_4_);
                Block var8 = p_149930_1_.getBlock(p_149930_2_ + 1, p_149930_3_, p_149930_4_);
                byte var9 = 3;
                if (var5.func_149730_j() && !var6.func_149730_j())
                {
                    var9 = 3;
                }
                if (var6.func_149730_j() && !var5.func_149730_j())
                {
                    var9 = 2;
                }
                if (var7.func_149730_j() && !var8.func_149730_j())
                {
                    var9 = 5;
                }
                if (var8.func_149730_j() && !var7.func_149730_j())
                {
                    var9 = 4;
                }
                p_149930_1_.setBlockMetadataWithNotify(p_149930_2_, p_149930_3_, p_149930_4_, var9, 2);
            }
        }
    
        public IIcon getIcon(int p_149691_1_, int p_149691_2_)
        {
            return p_149691_1_ == 1 ? this.field_149935_N : (p_149691_1_ == 0 ? this.field_149935_N : (p_149691_1_ != p_149691_2_ ? this.blockIcon : this.field_149936_O));
        }
        public void registerBlockIcons(IIconRegister p_149651_1_)
        {
            this.blockIcon = p_149651_1_.registerIcon(Main.MODID + ":guiTest_side");
            this.field_149936_O = p_149651_1_.registerIcon(Main.MODID + ":guiTest_front_off");
            this.field_149935_N = p_149651_1_.registerIcon(Main.MODID + ":guiTest_top");
        }
    
    }
    

    Merci d'avance 🙂


  • Administrateurs

    Salut,
    Il te manque la fonction onBlockPlacedBy
    https://www.minecraftforgefrance.fr/showthread.php?tid=1304#partie2-1



  • @'robin4002':

    Salut,
    Il te manque la fonction onBlockPlacedBy
    https://www.minecraftforgefrance.fr/showthread.php?tid=1304#partie2-1

    Merci mais toujours pas /: maintenant je n'ai plus qu'un seul texture 😕



  • @'robin4002':

    Salut,
    Il te manque la fonction onBlockPlacedBy
    https://www.minecraftforgefrance.fr/showthread.php?tid=1304#partie2-1

    Pas d'idée ?


  • Administrateurs

    Donnes des noms claires à tes variables, retires les fonctions onBlockAdded et func_149930_e et adaptes la fonction getIcon en suivant le tutoriel.



  • @'robin4002':

    Donnes des noms claires à tes variables, retires les fonctions onBlockAdded et func_149930_e et adaptes la fonction getIcon en suivant le tutoriel.

    Ok merci je vais essayer 🙂


    Merci milles fois robin ça fonctionne !! 😄