MFF

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

    Bloc Orientable (TileEntity)

    Planifier Épinglé Verrouillé Déplacé Résolu 1.8.x
    1.8
    71 Messages 6 Publieurs 15.6k 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.
    • EryahE Hors-ligne
      Eryah
      dernière édition par

      Elle existait déjà dans mon code
      Enfin, la méthode était déjà présente quand j’ai copié collé ce que tu m’a donné

      Malheureusement, je ne peut pas tester maintenant le code, j’ai un erreur, qui je pense fera crash mon jeu

      Membre fantôme
      Je développe maintenant un jeu sur UnrealEngine4


      Contact :…

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

        Bon… Au risque d’attiser votre rage… Cela ne marche pas. Mon bloc ne tourne toujours pas

        Je vous donne a peut-près toutes mes classes qui gèrent le bloc
        (Je confirme d’avoir check la totalité du code, et je ne voit aucune erreur )

        Classe Principale

        package eryah.usefulthings;
        
        import net.minecraft.block.Block;
        import net.minecraft.init.Blocks;
        import net.minecraft.init.Bootstrap;
        import net.minecraft.init.Items;
        import net.minecraft.item.Item.ToolMaterial;
        import net.minecraft.item.ItemStack;
        import net.minecraft.util.ResourceLocation;
        import net.minecraftforge.common.util.EnumHelper;
        import net.minecraftforge.fml.common.Mod;
        import net.minecraftforge.fml.common.Mod.EventHandler;
        import net.minecraftforge.fml.common.SidedProxy;
        import net.minecraftforge.fml.common.event.FMLInitializationEvent;
        import net.minecraftforge.fml.common.event.FMLPostInitializationEvent;
        import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
        import net.minecraftforge.fml.common.registry.GameRegistry;
        import eryah.usefulthings.blocks.MarkedRoadBlock;
        import eryah.usefulthings.blocks.PlateCrafter;
        import eryah.usefulthings.blocks.ResinLeaves;
        import eryah.usefulthings.blocks.RoadBlock;
        import eryah.usefulthings.blocks.Scaffolding;
        import eryah.usefulthings.init.BottleHerm;
        import eryah.usefulthings.init.BucketHerm;
        import eryah.usefulthings.init.Chainsaw;
        import eryah.usefulthings.init.CoalPowder;
        import eryah.usefulthings.init.EnderGem;
        import eryah.usefulthings.init.EnderSoul;
        import eryah.usefulthings.init.Engine;
        import eryah.usefulthings.init.GoldenEgg;
        import eryah.usefulthings.init.LapisAxe;
        import eryah.usefulthings.init.LapisPickaxe;
        import eryah.usefulthings.init.LapisShovel;
        import eryah.usefulthings.init.LapisSword;
        import eryah.usefulthings.init.PolishedLapis;
        import eryah.usefulthings.init.ResinTree;
        import eryah.usefulthings.init.SteelAxe;
        import eryah.usefulthings.init.SteelIngot;
        import eryah.usefulthings.init.SteelPickaxe;
        import eryah.usefulthings.init.SteelShovel;
        import eryah.usefulthings.init.SteelSword;
        import eryah.usefulthings.init.SuperBadassAdminTool;
        import eryah.usefulthings.init.UTResin;
        import eryah.usefulthings.init.VegeStick;
        import eryah.usefulthings.proxy.CommonProxy;
        import eryah.usefulthings.tileentity.TileEntityPlateCrafter;
        
        @Mod(modid = Reference.MOD_ID, name = Reference.MOD_NAME, version = Reference.VERSION)
        public class UsefulthingsMod {
        
        @SidedProxy(clientSide = Reference.CLIENT_PROXY_CLASS, serverSide = Reference.SERVER_PROXY_CLASS)
        public static CommonProxy proxy;
        
        public static final CreativeTab UTTab = new CreativeTab("UTTab");
        public static ToolMaterial chainsawMat = EnumHelper.addToolMaterial("chainsawMat", 1, 1000, 15.0F, 3.0F, 14);
        public static ToolMaterial steelMat = EnumHelper.addToolMaterial("steelMat", 2, 1200, 7.0F, 3.0F, 16);
        public static ToolMaterial lapisMat = EnumHelper.addToolMaterial("lapisMat", 2, 600, 7.0F, 3.0F, 20);
        public static ToolMaterial adminMat = EnumHelper.addToolMaterial("adminMat", 999999999, 999999999, 99999999999999999999.0F, 123456789.0F, 999999999);
        public static ToolMaterial dragonMat = EnumHelper.addToolMaterial("dragonMat", 3, 2300, 12.0F, 5.0F, 20);
        
        @EventHandler
        public void preInit(FMLPreInitializationEvent event)
        {
        ResinTree.init();
        ResinTree.register();
        UTResin.init();
        UTResin.register();
        Engine.init();
        Engine.register();
        ResinLeaves.init();
        ResinLeaves.register();
        Chainsaw.init();
        Chainsaw.register();
        BucketHerm.init();
        BucketHerm.register();
        CoalPowder.init();
        CoalPowder.register();
        SteelIngot.init();
        SteelIngot.register();
        SteelSword.init();
        SteelSword.register();
        SteelAxe.init();
        SteelAxe.register();
        SteelPickaxe.init();
        SteelPickaxe.register();
        SteelShovel.init();
        SteelShovel.register();
        PlateCrafter.init();
        PlateCrafter.register();
        VegeStick.init();
        VegeStick.register();
        Scaffolding.init();
        Scaffolding.register();
        BottleHerm.init();
        BottleHerm.register();
        RoadBlock.init();
        RoadBlock.register();
        MarkedRoadBlock.init();
        MarkedRoadBlock.register();
        GoldenEgg.init();
        GoldenEgg.register();
        PolishedLapis.init();
        PolishedLapis.register();
        LapisSword.init();
        LapisSword.register();
        LapisAxe.init();
        LapisAxe.register();
        LapisPickaxe.init();
        LapisPickaxe.register();
        LapisShovel.init();
        LapisShovel.register();
        SuperBadassAdminTool.init();
        SuperBadassAdminTool.register();
        EnderSoul.init();
        EnderSoul.register();
        EnderGem.init();
        EnderGem.register();
        GameRegistry.registerTileEntity(TileEntityPlateCrafter.class, "TileEntityPlateCrafter");
        
        }
        
        @EventHandler
        public void init(FMLInitializationEvent event)
        {
        proxy.registerRenders();
        GameRegistry.addRecipe(new ItemStack(Engine.engine), new Object[]{" R ", "PRP","RRR", 'R',Items.redstone, 'P',Blocks.piston});
        GameRegistry.addShapelessRecipe(new ItemStack(BucketHerm.bucketherm), UTResin.resin, Items.bucket, Blocks.sand);
        GameRegistry.addRecipe(new ItemStack(Chainsaw.chainsaw), new Object[]{"I  ", " IC"," CM", 'I',Items.iron_ingot, 'M',Engine.engine, 'C', new ItemStack(Items.dye, 1, 14)});
        GameRegistry.addShapelessRecipe(new ItemStack(CoalPowder.coalpowder), Items.coal);
        GameRegistry.addShapelessRecipe(new ItemStack(CoalPowder.coalpowder), new ItemStack(Items.coal, 1, 1));
        GameRegistry.addShapelessRecipe(new ItemStack(SteelIngot.steelingot), CoalPowder.coalpowder ,Items.iron_ingot);
        GameRegistry.addRecipe(new ItemStack(SteelSword.SteelSword), new Object[]{" A ", " A ", " S ", 'A',SteelIngot.steelingot, 'S',Items.stick});
        GameRegistry.addRecipe(new ItemStack(SteelAxe.SteelAxe), new Object[]{"AA ", "AS  ", " S ", 'A',SteelIngot.steelingot, 'S',Items.stick});
        GameRegistry.addRecipe(new ItemStack(SteelPickaxe.SteelPickaxe), new Object[]{"AAA", " S ", " S ", 'A',SteelIngot.steelingot, 'S',Items.stick});
        GameRegistry.addRecipe(new ItemStack(SteelShovel.SteelShovel), new Object[]{" A ", " S ", " S ", 'A',SteelIngot.steelingot, 'S',Items.stick});
        GameRegistry.addRecipe(new ItemStack(PlateCrafter.platecrafter), new Object[]{" I ", "CSC", "CTC", 'I',Blocks.iron_block, 'S',Items.stick, 'C',Blocks.cobblestone, 'T',Blocks.crafting_table});
        GameRegistry.addShapelessRecipe(new ItemStack(VegeStick.vegetal_stick), Items.stick , Blocks.vine);
        GameRegistry.addShapelessRecipe(new ItemStack(VegeStick.vegetal_stick), Items.stick , new ItemStack(Blocks.tallgrass, 3, 0));
        GameRegistry.addRecipe(new ItemStack(Scaffolding.scaffolding, 8), new Object[]{" S ", "SPS"," S ", 'S',Items.stick, 'P',Blocks.planks});
        GameRegistry.addShapelessRecipe(new ItemStack(BottleHerm.bottleherm), Items.glass_bottle, BucketHerm.bucketherm);
        GameRegistry.addShapelessRecipe(new ItemStack(Items.gold_nugget, 4), GoldenEgg.golden_egg);
        GameRegistry.addRecipe(new ItemStack(PolishedLapis.polished_lapislazuli), new Object[]{"LL", "LL", 'L', new ItemStack(Items.dye, 1, 4)});
        GameRegistry.addRecipe(new ItemStack(LapisSword.LapisSword), new Object[]{" L ", " L ", " S ", 'L',PolishedLapis.polished_lapislazuli, 'S',Items.stick});
        GameRegistry.addRecipe(new ItemStack(LapisAxe.LapisAxe), new Object[]{"LL ", "LS  ", " S ", 'L',PolishedLapis.polished_lapislazuli, 'S',Items.stick});
        GameRegistry.addRecipe(new ItemStack(LapisPickaxe.LapisPickaxe), new Object[]{"LLL", " S ", " S ", 'L',PolishedLapis.polished_lapislazuli, 'S',Items.stick});
        GameRegistry.addRecipe(new ItemStack(LapisShovel.LapisShovel), new Object[]{" L ", " S ", " S ", 'L',PolishedLapis.polished_lapislazuli, 'S',Items.stick});
        GameRegistry.addShapelessRecipe(new ItemStack(EnderSoul.ender_soul, 3), Items.ender_eye, new ItemStack(Items.ender_pearl, 2));
        GameRegistry.addShapelessRecipe(new ItemStack(EnderGem.ender_gem), EnderSoul.ender_soul, Items.emerald);
        
        }
        
        @EventHandler
        public void PostInit(FMLPostInitializationEvent event)
        {
        
        }
        
        private static Block getRegisteredBlock(String p_180383_0_)
           {
               return (Block)Block.blockRegistry.getObject(new ResourceLocation(p_180383_0_));
           }
        
        static
           {
               if (!Bootstrap.isRegistered())
               {
                   throw new RuntimeException("Accessed Blocks before Bootstrap!");
               }
               else
               {
                   PlateCrafter.platecrafter = getRegisteredBlock("platecrafter");
        
               }
           }
        
        }
        
        

        ClientProxy

        package eryah.usefulthings.proxy;
        
        import net.minecraftforge.fml.client.registry.ClientRegistry;
        import eryah.usefulthings.blocks.MarkedRoadBlock;
        import eryah.usefulthings.blocks.PlateCrafter;
        import eryah.usefulthings.blocks.ResinLeaves;
        import eryah.usefulthings.blocks.RoadBlock;
        import eryah.usefulthings.blocks.Scaffolding;
        import eryah.usefulthings.client.TileEntityPlateCrafterSpecialRenderer;
        import eryah.usefulthings.init.BottleHerm;
        import eryah.usefulthings.init.BucketHerm;
        import eryah.usefulthings.init.Chainsaw;
        import eryah.usefulthings.init.CoalPowder;
        import eryah.usefulthings.init.EnderGem;
        import eryah.usefulthings.init.EnderSoul;
        import eryah.usefulthings.init.Engine;
        import eryah.usefulthings.init.GoldenEgg;
        import eryah.usefulthings.init.LapisAxe;
        import eryah.usefulthings.init.LapisPickaxe;
        import eryah.usefulthings.init.LapisShovel;
        import eryah.usefulthings.init.LapisSword;
        import eryah.usefulthings.init.PolishedLapis;
        import eryah.usefulthings.init.ResinTree;
        import eryah.usefulthings.init.SteelAxe;
        import eryah.usefulthings.init.SteelIngot;
        import eryah.usefulthings.init.SteelPickaxe;
        import eryah.usefulthings.init.SteelShovel;
        import eryah.usefulthings.init.SteelSword;
        import eryah.usefulthings.init.SuperBadassAdminTool;
        import eryah.usefulthings.init.UTResin;
        import eryah.usefulthings.init.VegeStick;
        import eryah.usefulthings.tileentity.TileEntityPlateCrafter;
        
        public class ClientProxy extends CommonProxy {
        @Override
        public void registerRenders() {
        ResinTree.registerRenders();
        UTResin.registerRenders();
        Engine.registerRenders();
        ResinLeaves.registerRenders();
        Chainsaw.registerRenders();
        BucketHerm.registerRenders();
        CoalPowder.registerRenders();
        SteelIngot.registerRenders();
        SteelAxe.registerRenders();
        SteelSword.registerRenders();
        SteelPickaxe.registerRenders();
        SteelShovel.registerRenders();
        PlateCrafter.registerRenders();
        VegeStick.registerRenders();
        Scaffolding.registerRenders();
        BottleHerm.registerRenders();
        RoadBlock.registerRenders();
        MarkedRoadBlock.registerRenders();
        GoldenEgg.registerRenders();
        PolishedLapis.registerRenders();
        LapisAxe.registerRenders();
        LapisSword.registerRenders();
        LapisPickaxe.registerRenders();
        LapisShovel.registerRenders();
        SuperBadassAdminTool.registerRenders();
        EnderSoul.registerRenders();
        EnderGem.registerRenders();
        ClientRegistry.bindTileEntitySpecialRenderer(TileEntityPlateCrafter.class, new TileEntityPlateCrafterSpecialRenderer());
        
        }
        }
        
        

        Bloc

        package eryah.usefulthings.blocks;
        
        import java.util.Iterator;
        
        import net.minecraft.block.Block;
        import net.minecraft.block.BlockContainer;
        import net.minecraft.block.material.Material;
        import net.minecraft.block.properties.IProperty;
        import net.minecraft.block.properties.PropertyDirection;
        import net.minecraft.block.state.BlockState;
        import net.minecraft.block.state.IBlockState;
        import net.minecraft.client.Minecraft;
        import net.minecraft.client.resources.model.ModelResourceLocation;
        import net.minecraft.entity.EntityLivingBase;
        import net.minecraft.entity.player.EntityPlayer;
        import net.minecraft.item.Item;
        import net.minecraft.tileentity.TileEntity;
        import net.minecraft.util.BlockPos;
        import net.minecraft.util.EnumFacing;
        import net.minecraft.world.World;
        import net.minecraftforge.fml.common.registry.GameRegistry;
        import eryah.usefulthings.Reference;
        import eryah.usefulthings.UsefulthingsMod;
        import eryah.usefulthings.tileentity.TileEntityPlateCrafter;
        
        public class PlateCrafter extends BlockContainer
        {
        
        public static final PropertyDirection FACING = PropertyDirection.create("facing", EnumFacing.Plane.HORIZONTAL);
        public static Block platecrafter;  
        
          public PlateCrafter(Material material)
           {
                super(material);
                this.setDefaultState(this.blockState.getBaseState().withProperty(FACING, EnumFacing.NORTH));
        
           }      
        
          @Override
           public TileEntity createNewTileEntity(World world, int metadata) //Instancie le TileEntity
           {
               return new TileEntityPlateCrafter();
           }
        
           public boolean hasTileEntity(int metadata) //Permet de savoir si le bloc a un TileEntity
           {
               return true;
           }
        
        public static void init()
        {
        platecrafter = new PlateCrafter(Material.rock).setUnlocalizedName("platecrafter").setCreativeTab(UsefulthingsMod.UTTab);
        }
        
        public static void register()
        {
        GameRegistry.registerBlock(platecrafter, platecrafter.getUnlocalizedName().substring(5));
        }
        
        public static void registerRenders()
        {
        registerRender(platecrafter);
        }
        
        public static void registerRender(Block block)
        {
        Item item = Item.getItemFromBlock(block);
        Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(item, 0, new ModelResourceLocation(Reference.MOD_ID + ":" + item.getUnlocalizedName().substring(5), "inventory"));
        }
        
        public boolean isOpaqueCube()
           {
               return false;
           }
        
           public boolean renderAsNormalBlock()
           {
               return false;
           }
        
           public int getRenderType()
           {
               return -1;
           }
        
           public IBlockState onBlockPlaced(World worldIn, BlockPos pos, EnumFacing facing, float hitX, float hitY, float hitZ, int meta, EntityLivingBase placer)
           {
               return this.getDefaultState().withProperty(FACING, placer.getHorizontalFacing().getOpposite());
           }
        
           public IBlockState getStateFromMeta(int meta)
           {
               return this.getDefaultState().withProperty(FACING, EnumFacing.getHorizontal(meta));
           }
        
           public int getMetaFromState(IBlockState state)
           {
               return ((EnumFacing)state.getValue(FACING)).getHorizontalIndex();
           }
        
           protected BlockState createBlockState()
           {
               return new BlockState(this, new IProperty[] {FACING});
           }
           public IBlockState correctFacing(World worldIn, BlockPos pos, IBlockState state)
           {
               EnumFacing enumfacing = null;
               Iterator iterator = EnumFacing.Plane.HORIZONTAL.iterator();
        
               while (iterator.hasNext())
               {
                   EnumFacing enumfacing1 = (EnumFacing)iterator.next();
                   IBlockState iblockstate1 = worldIn.getBlockState(pos.offset(enumfacing1));
        
                   if (iblockstate1.getBlock() == this)
                   {
                       return state;
                   }
        
                   if (iblockstate1.getBlock().isFullBlock())
                   {
                       if (enumfacing != null)
                       {
                           enumfacing = null;
                           break;
                       }
        
                       enumfacing = enumfacing1;
                   }
               }
        
               if (enumfacing != null)
               {
                   return state.withProperty(FACING, enumfacing.getOpposite());
               }
               else
               {
                   EnumFacing enumfacing2 = (EnumFacing)state.getValue(FACING);
        
                   if (worldIn.getBlockState(pos.offset(enumfacing2)).getBlock().isFullBlock())
                   {
                       enumfacing2 = enumfacing2.getOpposite();
                   }
        
                   if (worldIn.getBlockState(pos.offset(enumfacing2)).getBlock().isFullBlock())
                   {
                       enumfacing2 = enumfacing2.rotateY();
                   }
        
                   if (worldIn.getBlockState(pos.offset(enumfacing2)).getBlock().isFullBlock())
                   {
                       enumfacing2 = enumfacing2.getOpposite();
                   }
        
                   return state.withProperty(FACING, enumfacing2);
               }
           }
        
           public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float hitx, float hity, float hitz)
           {
               if (world.isRemote)
               {
                   return true;
               }
               else
               {
                player.openGui(UsefulthingsMod.instance, 0, world, x, y, z);
                   return true;
               }
           }
        
        }
        
        

        TileEntity

        package eryah.usefulthings.tileentity;
        
        import eryah.usefulthings.recipes.PlateCrafterRecipes;
        import net.minecraft.entity.player.EntityPlayer;
        import net.minecraft.inventory.IInventory;
        import net.minecraft.item.ItemStack;
        import net.minecraft.nbt.NBTTagCompound;
        import net.minecraft.nbt.NBTTagList;
        import net.minecraft.tileentity.TileEntity;
        import net.minecraft.util.IChatComponent;
        
        public class TileEntityPlateCrafter extends TileEntity implements IInventory {
        
        private ItemStack[] contents = new ItemStack[4]; //0, 1 et 2 sont les inputs et 3 est l'output
        
        private int workingTime = 0; //Temps de cuisson actuel
        private int workingTimeNeeded = 10; //Temps de cuisson nécessaire
        
        @Override
           public void writeToNBT(NBTTagCompound compound)
           {
               super.writeToNBT(compound);
               NBTTagList nbttaglist = new NBTTagList();
        
               for (int i = 0; i < this.contents.length; ++i) //pour les slots
               {
                   if (this.contents* != null)
                   {
                       NBTTagCompound nbttagcompound1 = new NBTTagCompound();
                       nbttagcompound1.setByte("Slot", (byte)i);
                       this.contents*.writeToNBT(nbttagcompound1);
                       nbttaglist.appendTag(nbttagcompound1);
                   }
               }
        
               compound.setTag("Items", nbttaglist);
               compound.setShort("workingTime",(short)this.workingTime); //On les enregistrent en short
               compound.setShort("workingTimeNeeded", (short)this.workingTimeNeeded);
           }
        
        @Override
           public void readFromNBT(NBTTagCompound compound)
           {
               super.readFromNBT(compound);
        
               NBTTagList nbttaglist = compound.getTagList("Items", 10);
               this.contents = new ItemStack[this.getSizeInventory()];
        
               for (int i = 0; i < nbttaglist.tagCount(); ++i) //Encore une fois pour les slots
               {
                   NBTTagCompound nbttagcompound1 = nbttaglist.getCompoundTagAt(i);
                   int j = nbttagcompound1.getByte("Slot") & 255;
        
                   if (j >= 0 && j < this.contents.length)
                   {
                       this.contents[j] = ItemStack.loadItemStackFromNBT(nbttagcompound1);
                   }
               }
        
               this.workingTime = compound.getShort("workingTime"); //On lit nos valeurs
               this.workingTimeNeeded = compound.getShort("workingTimeNeeded");
           }
        
        public int getSizeInventory() { //Tout est dans le nom, retourne la taille de l'inventaire, pour notre bloc c'est quatre
        return this.contents.length;
        }
        
        public ItemStack getStackInSlot(int slotIndex) { //Renvoie L'itemStack se trouvant dans le slot passé en argument
        return this.contents[slotIndex];
        }
        
        public ItemStack decrStackSize(int slotIndex, int amount) {
        if (this.contents[slotIndex] != null)
               {
                   ItemStack itemstack;
        
                   if (this.contents[slotIndex].stackSize <= amount)
                   {
                       itemstack = this.contents[slotIndex];
                       this.contents[slotIndex] = null;
                       this.markDirty();
                       return itemstack;
                   }
                   else
                   {
                       itemstack = this.contents[slotIndex].splitStack(amount);
        
                       if (this.contents[slotIndex].stackSize == 0)
                       {
                           this.contents[slotIndex] = null;
                       }
        
                       this.markDirty();
                       return itemstack;
                   }
               }
               else
               {
                   return null;
               }
        }
        
        public ItemStack getStackInSlotOnClosing(int slotIndex) {
        if (this.contents[slotIndex] != null)
               {
                   ItemStack itemstack = this.contents[slotIndex];
                   this.contents[slotIndex] = null;
                   return itemstack;
               }
               else
               {
                   return null;
               }
        }
        
        public void setInventorySlotContents(int slotIndex, ItemStack stack) {
        this.contents[slotIndex] = stack;
        
               if (stack != null && stack.stackSize > this.getInventoryStackLimit())
               {
                   stack.stackSize = this.getInventoryStackLimit();
               }
        
               this.markDirty();
        }
        
        public String getInventoryName() { //J'ai décider qu'on ne pouvait pas mettre de nom custom
        return "tile.PlateCrafter";
        }
        
        public boolean hasCustomInventoryName() {
        return false;
        }
        
        public int getInventoryStackLimit() {
        return 64;
        }
        
        public void openInventory() {
        
        }
        
        public void closeInventory() {
        
        }
        
        public boolean isItemValidForSlot(int slot, ItemStack stack) {
        return slot == 3 ? false : true;
        }
        
        public boolean isBurning()
           {
               return this.workingTime > 0;
           }
        
        private boolean canSmelt()
           {
               if (this.contents[0] == null ) //Si les trois premiers slots sont vides
               {
                   return false; //On ne peut pas lancer le processus
               }
               else
               {
                   ItemStack itemstack = PlateCrafterRecipes.smelting().getSmeltingResult(new ItemStack[]{this.contents[0]}); //Il y a une erreur ici, c'est normal, on y vient après (c'est pour les recettes)
                   if (itemstack == null) return false; //rapport avec les recettes
                   if (this.contents[3] == null) return true; //vérifications du slot d'output
                   if (!this.contents[3].isItemEqual(itemstack)) return false; //ici aussi
                   int result = contents[3].stackSize + itemstack.stackSize;
                   return result <= getInventoryStackLimit() && result <= this.contents[3].getMaxStackSize(); //Et là aussi décidément
               }
           }
        
        public void updateEntity() //Méthode exécutée à chaque tick
           {
            if(this.isBurning() && this.canSmelt()) //Si on "cuit" et que notre recette et toujours bonne, on continue
            {
            ++this.workingTime; //incrémentation
            }
            if(this.canSmelt() && !this.isBurning()) //Si la recette est bonne mais qu'elle n'est toujours pas lancée, on la lance
            {
            this.workingTime = 1; //La méthode isBurning() renverra true maintenant (1>0)
            }
            if(this.canSmelt() && this.workingTime == this.workingTimeNeeded) //Si on est arrivé au bout du temps de cuisson et que la recette est toujours bonne
            {
            this.smeltItem(); //on "cuit" les items
            this.workingTime = 0; //et on réinitialise le temps de cuisson
            }
               if(!this.canSmelt()) //Si la recette la recette n'est plus bonne
               {
                      this.workingTime= 0; //le temps de cuisson est de 0
               }
           }
        
        public void smeltItem()
           {
               if (this.canSmelt())
               {
                   ItemStack itemstack = PlateCrafterRecipes.smelting().getSmeltingResult(new ItemStack[]{this.contents[0]}); //On récupère l'output de la recette
                    if (this.contents[1] == null) //Si il y a rien dans le slot d'output
                    {
                         this.contents[1] = itemstack.copy(); //On met directement l'ItemStack
                    }
                    else if (this.contents[1].getItem() == itemstack.getItem()) //Et si l'item que l'on veut est le même que celui qu'il y a déjà
                    {
                         this.contents[1].stackSize += itemstack.stackSize; // Alors ont incrémente l'ItemStack
                    }
        
                    –this.contents[0].stackSize; //On décrémente les slots d'input
        
                    if (this.contents[0].stackSize <= 0) //Si les slots sont vides, on remet à null le slot
                    {
                        this.contents[0] = null;
                    }
        
                    }
               }
        
        public float getDirection() {
        // TODO Auto-generated method stub
        return 0;
        }
        
        @Override
        public String getName() {
        // TODO Auto-generated method stub
        return null;
        }
        
        @Override
        public boolean hasCustomName() {
        // TODO Auto-generated method stub
        return false;
        }
        
        @Override
        public IChatComponent getDisplayName() {
        // TODO Auto-generated method stub
        return null;
        }
        
        @Override
        public boolean isUseableByPlayer(EntityPlayer player) {
        // TODO Auto-generated method stub
        return false;
        }
        
        @Override
        public void openInventory(EntityPlayer player) {
        // TODO Auto-generated method stub
        
        }
        
        @Override
        public void closeInventory(EntityPlayer player) {
        // TODO Auto-generated method stub
        
        }
        
        @Override
        public int getField(int id) {
        // TODO Auto-generated method stub
        return 0;
        }
        
        @Override
        public void setField(int id, int value) {
        // TODO Auto-generated method stub
        
        }
        
        @Override
        public int getFieldCount() {
        // TODO Auto-generated method stub
        return 0;
        }
        
        @Override
        public void clear() {
        // TODO Auto-generated method stub
        
        }
        
        }
        
        

        TileEntitySpecialRender

        package eryah.usefulthings.client;
        
        import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
        import net.minecraft.tileentity.TileEntity;
        import net.minecraft.util.ResourceLocation;
        
        import org.lwjgl.opengl.GL11;
        
        import eryah.usefulthings.Reference;
        import eryah.usefulthings.tileentity.TileEntityPlateCrafter;
        
        public class TileEntityPlateCrafterSpecialRenderer extends TileEntitySpecialRenderer {
            public static Modelplatecrafter model = new Modelplatecrafter();
               public static ResourceLocation texture = new ResourceLocation(Reference.MOD_ID, "textures/models/blocks/platecrafter.png");
        
                   private void renderTileEntityPlateCrafterAt(TileEntityPlateCrafter tile, double x, double y, double z, float partialRenderTick) // ma propre fonction
                   {
                       GL11.glPushMatrix(); // ouvre une matrix
                       GL11.glTranslated(x + 0.5D, y + 1.5D, z + 0.5D); // déplace le bloc sur les coordonnés et le centre
                       GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); // met droit le bloc (par défaut il est à l'envers)
                       GL11.glRotatef(90F * tile.getDirection(), 0.0F, 1.0F, 0.0F);
                       this.bindTexture(texture); // affiche la texture
                       model.renderAll(); // rend le modèle
                       GL11.glPopMatrix(); // ferme la matrix
                   }
        
           @Override
           public void renderTileEntityAt(TileEntity tile, double x,
                   double y, double z, float partialRenderTick, int i) {
               this.renderTileEntityPlateCrafterAt((TileEntityPlateCrafter)tile, x, y, z, partialRenderTick); // j'appelle ma fonction renderTileEntityTutorielAt en castant TileEntityTutoriel à l'argument tile
           }
        }
        

        Membre fantôme
        Je développe maintenant un jeu sur UnrealEngine4


        Contact :…

        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

          Sachant que dans le code du rendu tu fais tourner en fonction de tile.getDirection()

          Et que dans ton tile entity tu as :

          ​    public float getDirection() {
                  // TODO Auto-generated method stub
                  return 0;
              }
          

          Pas étonnant que ça ne tourne pas …

          Un conseil en général, pour tout le monde et non toi en particulier. Si vous copier/coller du code sans lire le reste du tutoriel, sans chercher à comprendre ce que fait le code, vous n’allez jamais progresser.

          Franchement le principe de la rotation est vraiment simple. En fonction de l’angle du joueur lorsqu’il pose le bloc, on met une valeur différente dans le tile entity (0, 1, 2 ou 3). Ensuite en fonction de cette valeur on fait un rotate 90. Il n’y a pas plus simple …
          Il suffit de lire en entier le tutoriel ainsi que les prérequis, chercher les équivalents des fonctions qui ont changés en 1.8 et on peut se débrouiller.

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

            Excusez-moi pour ma nullité naturelle, mais, par quoi faut-il remplacer le 0 ?
            J’ai essayer plusiseurs choses, soit crash, soit ça ne trounait pas

            Membre fantôme
            Je développe maintenant un jeu sur UnrealEngine4


            Contact :…

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

              Bon… J’ai toujours besoin d’aide.
              Je sais que je fais chier les gens ( Ma réputation, mais de toute façon je m’en fout c’est qu’un chiffre ), mais j’aimerai bien qu’on m’aide tout de même 😞
              J’ai tenté quelques choses, par exemple

              public byte getDirection() {
              return direction;
              }
              

              Comme dans le tuto mais toujours rien

              Membre fantôme
              Je développe maintenant un jeu sur UnrealEngine4


              Contact :…

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

                Je n’ai jamais fait de direction de ma vie, et ma réponse servira peux-être à rien ou à quelque chose x) mais bon ^^.

                Essaye de faire comme robin à dit.

                tu fait un if( =1)
                return degre;

                ( if ( =0 ) {
                   return 0;
                } else if( =1 ){
                  return 90;
                }

                Comme j’ai dit plus haut, je dit surrement des bêtises x). Voir des très grosses. Ou peux-être pas.

                Aucune signature n'est disponible pour une barre chocolatée.

                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

                  @‘robin4002’:

                  Franchement le principe de la rotation est vraiment simple. En fonction de l’angle du joueur lorsqu’il pose le bloc, on met une valeur différente dans le tile entity (0, 1, 2 ou 3). Ensuite en fonction de cette valeur on fait un rotate 90. Il n’y a pas plus simple …

                  Je suis sensé dire quoi de plus ? J’ai dit tout le principe, il suffit juste de l’appliquer …
                  Bon, aller quelques indices en me basant sur le dernier code que tu as donné :

                  • dans ton tile entity, il manque la variable pour stocker la direction (et ce qui va avec dans readFromNBT et writeToNBT)
                  • dans ton bloc, il manque la fonction
                        public void onBlockPlacedBy(World worldIn, BlockPos pos, IBlockState state, EntityLivingBase placer, ItemStack stack) {}
                    dans laquelle tu dois mettre la valeur de la direction en fonction de la direction de placer. (le code est disponible dans le tuto 1.7 et normalement fonctionnel, il y a juste le nom de cette méthode qui a changé)
                  1 réponse Dernière réponse Répondre Citer 0
                  • EryahE Hors-ligne
                    Eryah
                    dernière édition par

                    Bon, je reprend ce topic.

                    J’ai refait le tuto etc (http://www.minecraftforgefrance.fr/showthread.php?tid=1304 - http://www.minecraftforgefrance.fr/showthread.php?tid=1509#bonus )

                    Et là, erreurs partouts partouts !! Sûrment ma faute mais bon.
                    Il ya des  problèmes de casts, des fichiers non existants, etc…

                    Je vais avoir du mal a tout lister
                    Heureusement, ce sont toujours les mêmes problèmes

                    Bloc

                    ​package eryah.usefulthings.blocks;
                    
                    import java.util.Random;
                    
                    import javax.swing.Icon;
                    
                    import net.minecraft.block.Block;
                    import net.minecraft.block.BlockContainer;
                    import net.minecraft.block.material.Material;
                    import net.minecraft.block.properties.IProperty;
                    import net.minecraft.block.properties.PropertyDirection;
                    import net.minecraft.block.state.BlockState;
                    import net.minecraft.block.state.IBlockState;
                    import net.minecraft.client.Minecraft;
                    import net.minecraft.client.resources.model.ModelResourceLocation;
                    import net.minecraft.entity.EntityLivingBase;
                    import net.minecraft.entity.player.EntityPlayer;
                    import net.minecraft.inventory.Container;
                    import net.minecraft.inventory.InventoryHelper;
                    import net.minecraft.item.Item;
                    import net.minecraft.item.ItemStack;
                    import net.minecraft.tileentity.TileEntity;
                    import net.minecraft.util.BlockPos;
                    import net.minecraft.util.EnumFacing;
                    import net.minecraft.util.EnumParticleTypes;
                    import net.minecraft.util.MathHelper;
                    import net.minecraft.world.IBlockAccess;
                    import net.minecraft.world.World;
                    import net.minecraftforge.fml.common.registry.GameRegistry;
                    import net.minecraftforge.fml.relauncher.Side;
                    import net.minecraftforge.fml.relauncher.SideOnly;
                    import eryah.usefulthings.Reference;
                    import eryah.usefulthings.UsefulthingsMod;
                    import eryah.usefulthings.tileentity.TileEntityPlateCrafter;
                    
                    public class PlateCrafter extends BlockContainer
                    {
                        public static final PropertyDirection FACING = PropertyDirection.create("facing", EnumFacing.Plane.HORIZONTAL);
                        private static boolean isBurning;
                        private static boolean keepInventory;
                        private static final String __OBFID = "CL_00000248";
                        public static Block platecrafter;
                    
                        protected PlateCrafter(Material mat, boolean isBurning)
                        {
                            super(Material.rock);
                            this.setDefaultState(this.blockState.getBaseState().withProperty(FACING, EnumFacing.NORTH));
                            this.isBurning = isBurning;
                        }
                    
                    public static void init()
                    {
                    platecrafter = new PlateCrafter(Material.rock, isBurning).setUnlocalizedName("platecrafter").setCreativeTab(UsefulthingsMod.UTTab);
                    }
                    
                    public static void register()
                    {
                    GameRegistry.registerBlock(platecrafter, platecrafter.getUnlocalizedName().substring(5));
                    }
                    
                    public static void registerRenders()
                    {
                    registerRender(platecrafter);
                    }
                    
                    public static void registerRender(Block block)
                    {
                    Item item = Item.getItemFromBlock(block);
                    Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(item, 0, new ModelResourceLocation(Reference.MOD_ID + ":" + item.getUnlocalizedName().substring(5), "inventory"));
                    }
                    
                        /**
                         * Get the Item that this Block should drop when harvested.
                         *  
                         * @param fortune the level of the Fortune enchantment on the player's tool
                         */
                    
                        public void onBlockAdded(World worldIn, BlockPos pos, IBlockState state)
                        {
                            this.setDefaultFacing(worldIn, pos, state);
                        }
                    
                        private void setDefaultFacing(World worldIn, BlockPos pos, IBlockState state)
                        {
                            if (!worldIn.isRemote)
                            {
                                Block block = worldIn.getBlockState(pos.north()).getBlock();
                                Block block1 = worldIn.getBlockState(pos.south()).getBlock();
                                Block block2 = worldIn.getBlockState(pos.west()).getBlock();
                                Block block3 = worldIn.getBlockState(pos.east()).getBlock();
                                EnumFacing enumfacing = (EnumFacing)state.getValue(FACING);
                    
                                if (enumfacing == EnumFacing.NORTH && block.isFullBlock() && !block1.isFullBlock())
                                {
                                    enumfacing = EnumFacing.SOUTH;
                                }
                                else if (enumfacing == EnumFacing.SOUTH && block1.isFullBlock() && !block.isFullBlock())
                                {
                                    enumfacing = EnumFacing.NORTH;
                                }
                                else if (enumfacing == EnumFacing.WEST && block2.isFullBlock() && !block3.isFullBlock())
                                {
                                    enumfacing = EnumFacing.EAST;
                                }
                                else if (enumfacing == EnumFacing.EAST && block3.isFullBlock() && !block2.isFullBlock())
                                {
                                    enumfacing = EnumFacing.WEST;
                                }
                    
                                worldIn.setBlockState(pos, state.withProperty(FACING, enumfacing), 2);
                            }
                        }
                    
                        @SideOnly(Side.CLIENT)
                        public void randomDisplayTick(World worldIn, BlockPos pos, IBlockState state, Random rand)
                        {
                            if (this.isBurning)
                            {
                                EnumFacing enumfacing = (EnumFacing)state.getValue(FACING);
                                double d0 = (double)pos.getX() + 0.5D;
                                double d1 = (double)pos.getY() + rand.nextDouble() * 6.0D / 16.0D;
                                double d2 = (double)pos.getZ() + 0.5D;
                                double d3 = 0.52D;
                                double d4 = rand.nextDouble() * 0.6D - 0.3D;
                    
                                switch (PlateCrafter.SwitchEnumFacing.FACING_LOOKUP[enumfacing.ordinal()])
                                {
                                    case 1:
                                        worldIn.spawnParticle(EnumParticleTypes.SMOKE_NORMAL, d0 - d3, d1, d2 + d4, 0.0D, 0.0D, 0.0D, new int[0]);
                                        worldIn.spawnParticle(EnumParticleTypes.FLAME, d0 - d3, d1, d2 + d4, 0.0D, 0.0D, 0.0D, new int[0]);
                                        break;
                                    case 2:
                                        worldIn.spawnParticle(EnumParticleTypes.SMOKE_NORMAL, d0 + d3, d1, d2 + d4, 0.0D, 0.0D, 0.0D, new int[0]);
                                        worldIn.spawnParticle(EnumParticleTypes.FLAME, d0 + d3, d1, d2 + d4, 0.0D, 0.0D, 0.0D, new int[0]);
                                        break;
                                    case 3:
                                        worldIn.spawnParticle(EnumParticleTypes.SMOKE_NORMAL, d0 + d4, d1, d2 - d3, 0.0D, 0.0D, 0.0D, new int[0]);
                                        worldIn.spawnParticle(EnumParticleTypes.FLAME, d0 + d4, d1, d2 - d3, 0.0D, 0.0D, 0.0D, new int[0]);
                                        break;
                                    case 4:
                                        worldIn.spawnParticle(EnumParticleTypes.SMOKE_NORMAL, d0 + d4, d1, d2 + d3, 0.0D, 0.0D, 0.0D, new int[0]);
                                        worldIn.spawnParticle(EnumParticleTypes.FLAME, d0 + d4, d1, d2 + d3, 0.0D, 0.0D, 0.0D, new int[0]);
                                }
                            }
                        }
                    
                        @Override
                        public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumFacing side, float hitX, float hitY, float hitZ)
                    {
                        playerIn.openGui(UsefulthingsMod.instance, 1, worldIn, pos.getX(), pos.getY(), pos.getZ());
                    return true;
                    }
                    
                        /**
                         * Returns a new instance of a block's tile entity class. Called on placing the block.
                         */
                        public TileEntity createNewTileEntity(World worldIn, int meta)
                        {
                            return new TileEntityPlateCrafter();
                        }
                    
                        public IBlockState onBlockPlaced(World worldIn, BlockPos pos, EnumFacing facing, float hitX, float hitY, float hitZ, int meta, EntityLivingBase placer)
                        {
                            return this.getDefaultState().withProperty(FACING, placer.getHorizontalFacing().getOpposite());
                        }
                    
                        public void onBlockPlacedBy(World worldIn, BlockPos pos, IBlockState state, EntityLivingBase placer, ItemStack stack)
                        {
                            worldIn.setBlockState(pos, state.withProperty(FACING, placer.getHorizontalFacing().getOpposite()), 2);
                    
                            if (stack.hasDisplayName())
                            {
                                TileEntity tileentity = worldIn.getTileEntity(pos);
                    
                                if (tileentity instanceof TileEntityPlateCrafter)
                                {
                                    ((TileEntityPlateCrafter)tileentity).setCustomInventoryName(stack.getDisplayName());
                                }
                            }
                        }
                    
                        public void breakBlock(World worldIn, BlockPos pos, IBlockState state)
                        {
                            if (!keepInventory)
                            {
                                TileEntity tileentity = worldIn.getTileEntity(pos);
                    
                                if (tileentity instanceof TileEntityPlateCrafter)
                                {
                                    InventoryHelper.dropInventoryItems(worldIn, pos, (TileEntityPlateCrafter)tileentity);
                                    worldIn.updateComparatorOutputLevel(pos, this);
                                }
                            }
                    
                            super.breakBlock(worldIn, pos, state);
                        }
                    
                        public boolean hasComparatorInputOverride()
                        {
                            return true;
                        }
                    
                        public int getComparatorInputOverride(World worldIn, BlockPos pos)
                        {
                            return Container.calcRedstone(worldIn.getTileEntity(pos));
                        }
                    
                        @SideOnly(Side.CLIENT)
                        public Item getItem(World worldIn, BlockPos pos)
                        {
                            return Item.getItemFromBlock(PlateCrafter.platecrafter);
                        }
                    
                        /**
                         * The type of render function that is called for this block
                         */
                    
                        /**
                         * Possibly modify the given BlockState before rendering it on an Entity (Minecarts, Endermen, …)
                         */
                        @SideOnly(Side.CLIENT)
                        public IBlockState getStateForEntityRender(IBlockState state)
                        {
                            return this.getDefaultState().withProperty(FACING, EnumFacing.SOUTH);
                        }
                    
                        /**
                         * Convert the given metadata into a BlockState for this Block
                         */
                        public IBlockState getStateFromMeta(int meta)
                        {
                            EnumFacing enumfacing = EnumFacing.getFront(meta);
                    
                            if (enumfacing.getAxis() == EnumFacing.Axis.Y)
                            {
                                enumfacing = EnumFacing.NORTH;
                            }
                    
                            return this.getDefaultState().withProperty(FACING, enumfacing);
                        }
                    
                        /**
                         * Convert the BlockState into the correct metadata value
                         */
                        public int getMetaFromState(IBlockState state)
                        {
                            return ((EnumFacing)state.getValue(FACING)).getIndex();
                        }
                    
                        protected BlockState createBlockState()
                        {
                            return new BlockState(this, new IProperty[] {FACING});
                        }
                    
                        @SideOnly(Side.CLIENT)
                    
                        static final class SwitchEnumFacing
                            {
                                static final int[] FACING_LOOKUP = new int[EnumFacing.values().length];
                                private static final String __OBFID = "CL_00002111";
                    
                                static
                                {
                                    try
                                    {
                                        FACING_LOOKUP[EnumFacing.WEST.ordinal()] = 1;
                                    }
                                    catch (NoSuchFieldError var4)
                                    {
                                        ;
                                    }
                    
                                    try
                                    {
                                        FACING_LOOKUP[EnumFacing.EAST.ordinal()] = 2;
                                    }
                                    catch (NoSuchFieldError var3)
                                    {
                                        ;
                                    }
                    
                                    try
                                    {
                                        FACING_LOOKUP[EnumFacing.NORTH.ordinal()] = 3;
                                    }
                                    catch (NoSuchFieldError var2)
                                    {
                                        ;
                                    }
                    
                                    try
                                    {
                                        FACING_LOOKUP[EnumFacing.SOUTH.ordinal()] = 4;
                                    }
                                    catch (NoSuchFieldError var1)
                                    {
                                        ;
                                    }
                                }
                            }
                    
                        public boolean isOpaqueCube()
                        {
                            return false;
                        }
                    
                        public boolean renderAsNormalBlock()
                        {
                            return false;
                        }
                    
                        public int getRenderType()
                        {
                            return -1;
                        }
                    
                        public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase living, ItemStack stack)
                        {
                            if(stack.getItemDamage() == 0)
                            {
                                TileEntity tile = world.***getTileEntity***(x, y, z);
                                if(tile instanceof ***TileEntityDirectional***)
                                {
                                    int direction = MathHelper.floor_double((double)(living.rotationYaw * 4.0F / 360.0F) + 2.5D) & 3;
                                    ((***TileEntityDirectional)tile***).setDirection((byte)direction);
                                }
                            }
                        }
                    
                        @SideOnly(Side.CLIENT)
                        public Icon getIcon(IBlockAccess world, int x, int y, int z, int side)
                        {
                            if(world***.getBlockMetadata***(x, y, z) == 0) // vérifie que le metadata est 0, car comme déjà dit je veux que seul mon bloc de metadata 0 soit orientable
                            {
                                if(side == 0 || side == 1) // si le side est en bas ou en haut
                                {
                                    return this.***icons***[0][0]; // je mets la texture que j'ai prévu pour le haut et le bas
                                }
                                TileEntity tile = world.***getTileEntity***(x, y, z); // on obtient l'entité de bloc
                                if(tile instanceof ***TileEntityDirectional***) // on vérifie son instance pour éviter un ClassCastException
                                {
                                    byte direction = ((**TileEntityDirectional)tile**).getDirection(); // on obtient la valeur de la direction
                                    return side == 3 && direction == 0 ? this.***icons***[0][1] : (side == 4 && direction == 1 ? this.***icons***[0][1] : (side == 2 && direction == 2 ? this.***icons***[0][1] : (side == 5 && direction == 3 ? this.***icons***[0][1] : this.***icons***[0][2]))); // et ici c'est la même condition ternaire que j'ai déjà utilisé dans le cas du bloc basique, sauf qu'on vérifie la direction et non le metadata
                                }
                            }
                            return this.getIcon(side, world.***getBlockMetadata***(x, y, z)); // dans les autres cas on cherche la texture dans la fonction getIcon(side, metadata)
                        }
                    
                        @Override
                        public boolean rotateBlock(World world, int x, int y, int z, ***ForgeDirection*** axis)
                        {
                            if((axis == ***ForgeDirection***.UP || axis == ***ForgeDirection***.DOWN) && !world.isRemote && world.***getBlockMetadata***(x, y, z) == 0)
                            {
                                TileEntity tile = world.***getTileEntity***(x, y, z);
                                if(tile instanceof ***TileEntityDirectional***)
                                {
                                    ***TileEntityDirectional*** tileDirectional = (***TileEntityDirectional***)tile;
                                    byte direction = tileDirectional.getDirection();
                                    direction++;
                                    if(direction > 3)
                                    {
                                        direction = 0;
                                    }
                                    tileDirectional.setDirection(direction);
                                    return true;
                                }
                            }
                            return false;
                        }
                    
                        public ***ForgeDirection***[] getValidRotations(World world, int x, int y, int z)
                        {
                            return world.***getBlockMetadata***(x, y, z) == 0 ? new ***ForgeDirection***[] {***ForgeDirection***.UP, ***ForgeDirection***.DOWN} : ***ForgeDirection***.VALID_DIRECTIONS; // si le metadata est 0, les deux directions sur lesquels on peut faire tourner le bloc, sinon toutes les directions ce qui est la valeur par défaut pour les blocs non directionnels.
                        }   
                    }
                    

                    Problèmes :

                    • getTileEntity - The method getTileEntity(BlockPos) in the type World is not applicable for the arguments (int, int, int)
                    • TileEntityDirectional - TileEntityDirectional cannot be resolved to a type
                    • getBlockMetadata - The method getBlockMetadata(int, int, int) is undefined for the type IBlockAccess
                    • icons - icons cannot be resolved or is not a field
                    • ForgeDirection - ForgeDirection cannot be resolved to a variable

                    TileEntity

                    ​package eryah.usefulthings.tileentity;
                    
                    import net.minecraft.block.Block;
                    import net.minecraft.block.material.Material;
                    import net.minecraft.entity.player.EntityPlayer;
                    import net.minecraft.entity.player.InventoryPlayer;
                    import net.minecraft.init.Blocks;
                    import net.minecraft.init.Items;
                    import net.minecraft.inventory.Container;
                    import net.minecraft.inventory.IInventory;
                    import net.minecraft.inventory.ISidedInventory;
                    import net.minecraft.inventory.SlotFurnaceFuel;
                    import net.minecraft.item.Item;
                    import net.minecraft.item.ItemBlock;
                    import net.minecraft.item.ItemHoe;
                    import net.minecraft.item.ItemStack;
                    import net.minecraft.item.ItemSword;
                    import net.minecraft.item.ItemTool;
                    import net.minecraft.nbt.NBTTagCompound;
                    import net.minecraft.nbt.NBTTagList;
                    import net.minecraft.network.NetworkManager;
                    import net.minecraft.network.Packet;
                    import net.minecraft.network.play.server.S35PacketUpdateTileEntity;
                    import net.minecraft.server.gui.IUpdatePlayerListBox;
                    import net.minecraft.tileentity.TileEntityLockable;
                    import net.minecraft.util.EnumFacing;
                    import net.minecraft.util.MathHelper;
                    import net.minecraftforge.fml.relauncher.Side;
                    import net.minecraftforge.fml.relauncher.SideOnly;
                    import eryah.usefulthings.container.ContainerPlateCrafter;
                    import eryah.usefulthings.recipes.PlateCrafterRecipes;
                    
                    public class TileEntityPlateCrafter extends TileEntityLockable implements IUpdatePlayerListBox, ISidedInventory, IInventory
                    {
                        private static final int[] slotsTop = new int[] {0};
                        private static final int[] slotsBottom = new int[] {2, 1};
                        private static final int[] slotsSides = new int[] {1};
                        /** The ItemStacks that hold the items currently being used in the plateCrafter */
                        private ItemStack[] plateCrafterItemStacks = new ItemStack[3];
                        /** The number of ticks that the plateCrafter will keep burning */
                        private int plateCrafterBurnTime;
                        /** The number of ticks that a fresh copy of the currently-burning item would keep the plateCrafter burning for */
                        private int currentItemBurnTime;
                        private int cookTime;
                        private int totalCookTime;
                        private String plateCrafterCustomName;
                        private static final String __OBFID = "CL_00000357";
                        private byte direction;
                    
                        /**
                         * Returns the number of slots in the inventory.
                         */
                        public int getSizeInventory()
                        {
                            return this.plateCrafterItemStacks.length;
                        }
                    
                        /**
                         * Returns the stack in slot i
                         */
                        public ItemStack getStackInSlot(int index)
                        {
                            return this.plateCrafterItemStacks[index];
                        }
                    
                        /**
                         * Removes from an inventory slot (first arg) up to a specified number (second arg) of items and returns them in a
                         * new stack.
                         */
                        public ItemStack decrStackSize(int index, int count)
                        {
                            if (this.plateCrafterItemStacks[index] != null)
                            {
                                ItemStack itemstack;
                    
                                if (this.plateCrafterItemStacks[index].stackSize <= count)
                                {
                                    itemstack = this.plateCrafterItemStacks[index];
                                    this.plateCrafterItemStacks[index] = null;
                                    return itemstack;
                                }
                                else
                                {
                                    itemstack = this.plateCrafterItemStacks[index].splitStack(count);
                    
                                    if (this.plateCrafterItemStacks[index].stackSize == 0)
                                    {
                                        this.plateCrafterItemStacks[index] = null;
                                    }
                    
                                    return itemstack;
                                }
                            }
                            else
                            {
                                return null;
                            }
                        }
                    
                        /**
                         * When some containers are closed they call this on each slot, then drop whatever it returns as an EntityItem -
                         * like when you close a workbench GUI.
                         */
                        public ItemStack getStackInSlotOnClosing(int index)
                        {
                            if (this.plateCrafterItemStacks[index] != null)
                            {
                                ItemStack itemstack = this.plateCrafterItemStacks[index];
                                this.plateCrafterItemStacks[index] = null;
                                return itemstack;
                            }
                            else
                            {
                                return null;
                            }
                        }
                    
                        /**
                         * Sets the given item stack to the specified slot in the inventory (can be crafting or armor sections).
                         */
                        public void setInventorySlotContents(int index, ItemStack stack)
                        {
                            boolean flag = stack != null && stack.isItemEqual(this.plateCrafterItemStacks[index]) && ItemStack.areItemStackTagsEqual(stack, this.plateCrafterItemStacks[index]);
                            this.plateCrafterItemStacks[index] = stack;
                    
                            if (stack != null && stack.stackSize > this.getInventoryStackLimit())
                            {
                                stack.stackSize = this.getInventoryStackLimit();
                            }
                    
                            if (index == 0 && !flag)
                            {
                                this.totalCookTime = this.func_174904_a(stack);
                                this.cookTime = 0;
                                this.markDirty();
                            }
                        }
                    
                        /**
                         * Gets the name of this command sender (usually username, but possibly "Rcon")
                         */
                        public String getName()
                        {
                            return this.hasCustomName() ? this.plateCrafterCustomName : "container.plateCrafter";
                        }
                    
                        /**
                         * Returns true if this thing is named
                         */
                        public boolean hasCustomName()
                        {
                            return this.plateCrafterCustomName != null && this.plateCrafterCustomName.length() > 0;
                        }
                    
                        public void setCustomInventoryName(String p_145951_1_)
                        {
                            this.plateCrafterCustomName = p_145951_1_;
                        }
                    
                        public void readFromNBT(NBTTagCompound compound)
                        {
                            super.readFromNBT(compound);
                            NBTTagList nbttaglist = compound.getTagList("Items", 10);
                            this.plateCrafterItemStacks = new ItemStack[this.getSizeInventory()];
                    
                            for (int i = 0; i < nbttaglist.tagCount(); ++i)
                            {
                                NBTTagCompound nbttagcompound1 = nbttaglist.getCompoundTagAt(i);
                                byte b0 = nbttagcompound1.getByte("Slot");
                    
                                if (b0 >= 0 && b0 < this.plateCrafterItemStacks.length)
                                {
                                    this.plateCrafterItemStacks[b0] = ItemStack.loadItemStackFromNBT(nbttagcompound1);
                                }
                            }
                    
                            this.plateCrafterBurnTime = compound.getShort("BurnTime");
                            this.cookTime = compound.getShort("CookTime");
                            this.totalCookTime = compound.getShort("CookTimeTotal");
                            this.currentItemBurnTime = getItemBurnTime(this.plateCrafterItemStacks[1]);
                    
                            if (compound.hasKey("CustomName", 8))
                            {
                                this.plateCrafterCustomName = compound.getString("CustomName");
                            }
                    
                            super.readFromNBT(compound);
                            this.direction = compound.getByte("Direction");
                    
                        }
                    
                        public void writeToNBT(NBTTagCompound compound)
                        {
                            super.writeToNBT(compound);
                            compound.setShort("BurnTime", (short)this.plateCrafterBurnTime);
                            compound.setShort("CookTime", (short)this.cookTime);
                            compound.setShort("CookTimeTotal", (short)this.totalCookTime);
                            NBTTagList nbttaglist = new NBTTagList();
                    
                            for (int i = 0; i < this.plateCrafterItemStacks.length; ++i)
                            {
                                if (this.plateCrafterItemStacks* != null)
                                {
                                    NBTTagCompound nbttagcompound1 = new NBTTagCompound();
                                    nbttagcompound1.setByte("Slot", (byte)i);
                                    this.plateCrafterItemStacks*.writeToNBT(nbttagcompound1);
                                    nbttaglist.appendTag(nbttagcompound1);
                                }
                            }
                    
                            compound.setTag("Items", nbttaglist);
                    
                            if (this.hasCustomName())
                            {
                                compound.setString("CustomName", this.plateCrafterCustomName);
                            }
                    
                            super.writeToNBT(compound);
                            compound.setByte("Direction", this.direction);
                    
                        }
                    
                        /**
                         * Returns the maximum stack size for a inventory slot. Seems to always be 64, possibly will be extended. *Isn't
                         * this more of a set than a get?*
                         */
                        public int getInventoryStackLimit()
                        {
                            return 64;
                        }
                    
                        /**
                         * plateCrafter isBurning
                         */
                        public boolean isBurning()
                        {
                            return this.plateCrafterBurnTime > 0;
                        }
                    
                        @SideOnly(Side.CLIENT)
                        public static boolean isBurning(IInventory p_174903_0_)
                        {
                            return p_174903_0_.getField(0) > 0;
                        }
                    
                        /**
                         * Updates the JList with a new model.
                         */
                        public void update()
                        {
                            boolean flag = this.isBurning();
                            boolean flag1 = false;
                    
                            if (this.isBurning())
                            {
                                –this.plateCrafterBurnTime;
                            }
                    
                            if (!this.worldObj.isRemote)
                            {
                                if (!this.isBurning() && (this.plateCrafterItemStacks[1] == null || this.plateCrafterItemStacks[0] == null))
                                {
                                    if (!this.isBurning() && this.cookTime > 0)
                                    {
                                        this.cookTime = MathHelper.clamp_int(this.cookTime - 2, 0, this.totalCookTime);
                                    }
                                }
                                else
                                {
                                    if (!this.isBurning() && this.canSmelt())
                                    {
                                        this.currentItemBurnTime = this.plateCrafterBurnTime = getItemBurnTime(this.plateCrafterItemStacks[1]);
                    
                                        if (this.isBurning())
                                        {
                                            flag1 = true;
                    
                                            if (this.plateCrafterItemStacks[1] != null)
                                            {
                                                –this.plateCrafterItemStacks[1].stackSize;
                    
                                                if (this.plateCrafterItemStacks[1].stackSize == 0)
                                                {
                                                    this.plateCrafterItemStacks[1] = plateCrafterItemStacks[1].getItem().getContainerItem(plateCrafterItemStacks[1]);
                                                }
                                            }
                                        }
                                    }
                    
                                    if (this.isBurning() && this.canSmelt())
                                    {
                                        ++this.cookTime;
                    
                                        if (this.cookTime == this.totalCookTime)
                                        {
                                            this.cookTime = 0;
                                            this.totalCookTime = this.func_174904_a(this.plateCrafterItemStacks[0]);
                                            this.smeltItem();
                                            flag1 = true;
                                        }
                                    }
                                    else
                                    {
                                        this.cookTime = 0;
                                    }
                                }
                    
                            }
                    
                            if (flag1)
                            {
                                this.markDirty();
                            }
                        }
                    
                        public int func_174904_a(ItemStack p_174904_1_)
                        {
                            return 200;
                        }
                    
                        /**
                         * Returns true if the plateCrafter can smelt an item, i.e. has a source item, destination stack isn't full, etc.
                         */
                        private boolean canSmelt()
                        {
                            if (this.plateCrafterItemStacks[0] == null)
                            {
                                return false;
                            }
                            else
                            {
                                ItemStack itemstack = PlateCrafterRecipes.instance().getSmeltingResult(this.plateCrafterItemStacks[0]);
                                if (itemstack == null) return false;
                                if (this.plateCrafterItemStacks[2] == null) return true;
                                if (!this.plateCrafterItemStacks[2].isItemEqual(itemstack)) return false;
                                int result = plateCrafterItemStacks[2].stackSize + itemstack.stackSize;
                                return result <= getInventoryStackLimit() && result <= this.plateCrafterItemStacks[2].getMaxStackSize(); //Forge BugFix: Make it respect stack sizes properly.
                            }
                        }
                    
                        /**
                         * Turn one item from the plateCrafter source stack into the appropriate smelted item in the plateCrafter result stack
                         */
                        public void smeltItem()
                        {
                            if (this.canSmelt())
                            {
                                ItemStack itemstack = PlateCrafterRecipes.instance().getSmeltingResult(this.plateCrafterItemStacks[0]);
                    
                                if (this.plateCrafterItemStacks[2] == null)
                                {
                                    this.plateCrafterItemStacks[2] = itemstack.copy();
                                }
                                else if (this.plateCrafterItemStacks[2].getItem() == itemstack.getItem())
                                {
                                    this.plateCrafterItemStacks[2].stackSize += itemstack.stackSize; // Forge BugFix: Results may have multiple items
                                }
                    
                                if (this.plateCrafterItemStacks[0].getItem() == Item.getItemFromBlock(Blocks.sponge) && this.plateCrafterItemStacks[0].getMetadata() == 1 && this.plateCrafterItemStacks[1] != null && this.plateCrafterItemStacks[1].getItem() == Items.bucket)
                                {
                                    this.plateCrafterItemStacks[1] = new ItemStack(Items.water_bucket);
                                }
                    
                                –this.plateCrafterItemStacks[0].stackSize;
                    
                                if (this.plateCrafterItemStacks[0].stackSize <= 0)
                                {
                                    this.plateCrafterItemStacks[0] = null;
                                }
                            }
                        }
                    
                        /**
                         * Returns the number of ticks that the supplied fuel item will keep the plateCrafter burning, or 0 if the item isn't
                         * fuel
                         */
                        public static int getItemBurnTime(ItemStack p_145952_0_)
                        {
                            if (p_145952_0_ == null)
                            {
                                return 0;
                            }
                            else
                            {
                                Item item = p_145952_0_.getItem();
                    
                                if (item instanceof ItemBlock && Block.getBlockFromItem(item) != Blocks.air)
                                {
                                    Block block = Block.getBlockFromItem(item);
                    
                                    if (block == Blocks.wooden_slab)
                                    {
                                        return 150;
                                    }
                    
                                    if (block.getMaterial() == Material.wood)
                                    {
                                        return 300;
                                    }
                    
                                    if (block == Blocks.coal_block)
                                    {
                                        return 16000;
                                    }
                                }
                    
                                if (item instanceof ItemTool && ((ItemTool)item).getToolMaterialName().equals("WOOD")) return 200;
                                if (item instanceof ItemSword && ((ItemSword)item).getToolMaterialName().equals("WOOD")) return 200;
                                if (item instanceof ItemHoe && ((ItemHoe)item).getMaterialName().equals("WOOD")) return 200;
                                if (item == Items.stick) return 100;
                                if (item == Items.coal) return 1600;
                                if (item == Items.lava_bucket) return 20000;
                                if (item == Item.getItemFromBlock(Blocks.sapling)) return 100;
                                if (item == Items.blaze_rod) return 2400;
                                return net.minecraftforge.fml.common.registry.GameRegistry.getFuelValue(p_145952_0_);
                            }
                        }
                    
                        public static boolean isItemFuel(ItemStack p_145954_0_)
                        {
                            /**
                             * Returns the number of ticks that the supplied fuel item will keep the plateCrafter burning, or 0 if the item isn't
                             * fuel
                             */
                            return getItemBurnTime(p_145954_0_) > 0;
                        }
                    
                        /**
                         * Do not make give this method the name canInteractWith because it clashes with Container
                         */
                        public boolean isUseableByPlayer(EntityPlayer player)
                        {
                            return this.worldObj.getTileEntity(this.pos) != this ? false : player.getDistanceSq((double)this.pos.getX() + 0.5D, (double)this.pos.getY() + 0.5D, (double)this.pos.getZ() + 0.5D) <= 64.0D;
                        }
                    
                        public void openInventory(EntityPlayer player) {}
                    
                        public void closeInventory(EntityPlayer player) {}
                    
                        /**
                         * Returns true if automation is allowed to insert the given stack (ignoring stack size) into the given slot.
                         */
                        public boolean isItemValidForSlot(int index, ItemStack stack)
                        {
                            return index == 2 ? false : (index != 1 ? true : isItemFuel(stack) || SlotFurnaceFuel.isBucket(stack));
                        }
                    
                        public int[] getSlotsForFace(EnumFacing side)
                        {
                            return side == EnumFacing.DOWN ? slotsBottom : (side == EnumFacing.UP ? slotsTop : slotsSides);
                        }
                    
                        /**
                         * Returns true if automation can insert the given item in the given slot from the given side. Args: slot, item,
                         * side
                         */
                        public boolean canInsertItem(int index, ItemStack itemStackIn, EnumFacing direction)
                        {
                            return this.isItemValidForSlot(index, itemStackIn);
                        }
                    
                        /**
                         * Returns true if automation can extract the given item in the given slot from the given side. Args: slot, item,
                         * side
                         */
                        public boolean canExtractItem(int index, ItemStack stack, EnumFacing direction)
                        {
                            if (direction == EnumFacing.DOWN && index == 1)
                            {
                                Item item = stack.getItem();
                    
                                if (item != Items.water_bucket && item != Items.bucket)
                                {
                                    return false;
                                }
                            }
                    
                            return true;
                        }
                    
                        public Container createContainer(InventoryPlayer playerInventory, EntityPlayer playerIn)
                        {
                            return new ContainerPlateCrafter(this, playerInventory);
                        }
                    
                        public int getField(int id)
                        {
                            switch (id)
                            {
                                case 0:
                                    return this.plateCrafterBurnTime;
                                case 1:
                                    return this.currentItemBurnTime;
                                case 2:
                                    return this.cookTime;
                                case 3:
                                    return this.totalCookTime;
                                default:
                                    return 0;
                            }
                        }
                    
                        public void setField(int id, int value)
                        {
                            switch (id)
                            {
                                case 0:
                                    this.plateCrafterBurnTime = value;
                                    break;
                                case 1:
                                    this.currentItemBurnTime = value;
                                    break;
                                case 2:
                                    this.cookTime = value;
                                    break;
                                case 3:
                                    this.totalCookTime = value;
                            }
                        }
                    
                        public int getFieldCount()
                        {
                            return 4;
                        }
                    
                        public void clear()
                        {
                            for (int i = 0; i < this.plateCrafterItemStacks.length; ++i)
                            {
                                this.plateCrafterItemStacks* = null;
                            }
                        }
                    
                        static final class SwitchEnumFacing
                        {
                            static final int[] field_177366_a = new int[EnumFacing.values().length];
                            private static final String __OBFID = "CL_00002041";
                    
                            static
                            {
                                try
                                {
                                    field_177366_a[EnumFacing.NORTH.ordinal()] = 1;
                                }
                                catch (NoSuchFieldError var4)
                                {
                                    ;
                                }
                    
                                try
                                {
                                    field_177366_a[EnumFacing.SOUTH.ordinal()] = 2;
                                }
                                catch (NoSuchFieldError var3)
                                {
                                    ;
                                }
                    
                                try
                                {
                                    field_177366_a[EnumFacing.EAST.ordinal()] = 3;
                                }
                                catch (NoSuchFieldError var2)
                                {
                                    ;
                                }
                    
                                try
                                {
                                    field_177366_a[EnumFacing.WEST.ordinal()] = 4;
                                }
                                catch (NoSuchFieldError var1)
                                {
                                    ;
                                }
                            }
                        }
                    
                        public byte getDirection()
                        {
                            return direction;
                        }
                    
                        public void setDirection(byte direction)
                        {
                            this.direction = direction;
                            this.worldObj.markBlockForUpdate(this.pos);
                        }
                    
                        public Packet getDescriptionPacket()
                        {
                            NBTTagCompound nbttagcompound = new NBTTagCompound();
                            this.writeToNBT(nbttagcompound);
                            return new S35PacketUpdateTileEntity(this.pos, 0, nbttagcompound);
                        }
                    
                        public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity pkt)
                        {
                            this.readFromNBT(pkt.***func_148857_g***());
                            this.worldObj.markBlockRangeForRenderUpdate(this.pos, this.pos);
                        }
                    
                    }
                    

                    Problème :

                    • func_148857_g - The method func_148857_g() is undefined for the type S35PacketUpdateTileEntity

                    Membre fantôme
                    Je développe maintenant un jeu sur UnrealEngine4


                    Contact :…

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

                      • getTileEntity - The method getTileEntity(BlockPos) in the type World is not applicable for the arguments (int, int, int)
                        -> Depuis la 1.8 on utilise les BlockPos, tu le saurais en regardant la méthode dans la classe World pour voir quels arguments sont bons
                      • TileEntityDirectional - TileEntityDirectional cannot be resolved to a type
                        ->Ta tileEntity n’est pas extends TileEntityDirectional, c’est pour le tutoriel
                      • getBlockMetadata - The method getBlockMetadata(int, int, int) is undefined for the type IBlockAccess
                        -> même chose : la 1.8 utilise les BlockPos
                      • icons - icons cannot be resolved or is not a field
                        -> Tu n’as pas d’icônes pour ton block, eclipse risque pas de les sortir du fin fond de l’espace : il faut les lui donner
                      • ForgeDirection - ForgeDirection cannot be resolved to a variable
                        -> Regarde la méthode getValidRotations pour voir si le nom a changé en 1.8

                      func_148857_g - The method func_148857_g() is undefined for the type S35PacketUpdateTileEntity
                      -> Regarde si le nom a changé entre temps

                      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
                      • EryahE Hors-ligne
                        Eryah
                        dernière édition par

                        Bon, je re-reprend le topic.
                        Donc j’ai fait les 4 .java pour les 4 directions, comment faire pour les bind ?
                        Faut faire un .json blockstates et models ?

                        Membre fantôme
                        Je développe maintenant un jeu sur UnrealEngine4


                        Contact :…

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

                          4 .java de quoi ? Pourquoi y’aurais besoin de créer 4 classes ?!

                          Il faut 1 JSON pour les blocks states, et 1 pour chaque model.

                          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
                          • EryahE Hors-ligne
                            Eryah
                            dernière édition par

                            4 .java, pour les 4 facing ( ce sont des models hein, mon bloc ne fonctionne pas avec des .json, ce sont des models .java, avec techne )
                            Et je demandais, comment faire pour bind les models .java, au bloc avec des .json ?

                            Membre fantôme
                            Je développe maintenant un jeu sur UnrealEngine4


                            Contact :…

                            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

                              @‘Eryah’:

                              4 .java, pour les 4 facing ( ce sont des models hein, mon bloc ne fonctionne pas avec des .json, ce sont des models .java, avec techne )

                              Il suffit de faire un glRotate de 90 * direction dans le code du rendu x) pas besoin de 4 modèles.

                              @‘Eryah’:

                              Et je demandais, comment faire pour bind les models .java, au bloc avec des .json ?

                              Pas possible, faut un rendu TESR

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

                                Eh bien, le glRotate est dans mon code depuis longtemps, et na jamais focntioné

                                package eryah.usefulthings.client.tesr;
                                
                                import net.minecraft.client.renderer.block.model.ModelBlock;
                                import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher;
                                import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
                                import net.minecraft.tileentity.TileEntity;
                                import net.minecraft.util.ResourceLocation;
                                
                                import org.lwjgl.opengl.GL11;
                                
                                import eryah.usefulthings.Reference;
                                import eryah.usefulthings.client.models.Modelplatecrafter;
                                import eryah.usefulthings.tileentity.TileEntityPlateCrafter;
                                
                                public class TileEntityPlateCrafterSpecialRenderer extends TileEntitySpecialRenderer {
                                public static Modelplatecrafter model = new Modelplatecrafter();
                                public static ResourceLocation texture = new ResourceLocation(Reference.MOD_ID, "textures/models/blocks/platecrafter.png");
                                
                                private void renderTileEntityPlateCrafterAt(TileEntityPlateCrafter tile, double x, double y, double z, float partialRenderTick) // ma propre fonction
                                {
                                GL11.glPushMatrix(); // ouvre une matrix
                                GL11.glTranslated(x + 0.5D, y + 1.5D, z + 0.5D); // déplace le bloc sur les coordonnés et le centre
                                GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); // met droit le bloc (par défaut il est à l'envers)
                                GL11.glRotatef(90F * tile.getDirection(), 0.0F, 1.0F, 0.0F);
                                this.bindTexture(texture); // affiche la texture
                                model.renderAll(); // rend le modèle
                                GL11.glPopMatrix(); // ferme la matrix
                                }
                                
                                @Override
                                public void renderTileEntityAt(TileEntity tile, double x,
                                double y, double z, float partialRenderTick, int i) {
                                this.renderTileEntityPlateCrafterAt((TileEntityPlateCrafter)tile, x, y, z, partialRenderTick); // j'appelle ma fonction renderTileEntityTutorielAt en castant TileEntityTutoriel à l'argument tile
                                }
                                
                                }
                                

                                Il y a surement une erreur

                                Membre fantôme
                                Je développe maintenant un jeu sur UnrealEngine4


                                Contact :…

                                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

                                  Envoie la classe TileEntityPlateCrafter ?

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

                                    Je me souviens avoir eu une erreut sur la méthode getDirection, mais je ne sais pas comment la corriger

                                    package eryah.usefulthings.blocks;
                                    
                                    import java.util.Iterator;
                                    import java.util.Random;
                                    
                                    import javax.swing.Icon;
                                    
                                    import net.minecraft.block.Block;
                                    import net.minecraft.block.BlockContainer;
                                    import net.minecraft.block.material.Material;
                                    import net.minecraft.block.properties.IProperty;
                                    import net.minecraft.block.properties.PropertyDirection;
                                    import net.minecraft.block.state.BlockState;
                                    import net.minecraft.block.state.IBlockState;
                                    import net.minecraft.client.Minecraft;
                                    import net.minecraft.client.resources.model.ModelResourceLocation;
                                    import net.minecraft.entity.EntityLivingBase;
                                    import net.minecraft.entity.player.EntityPlayer;
                                    import net.minecraft.inventory.Container;
                                    import net.minecraft.inventory.InventoryHelper;
                                    import net.minecraft.item.Item;
                                    import net.minecraft.item.ItemStack;
                                    import net.minecraft.tileentity.TileEntity;
                                    import net.minecraft.tileentity.TileEntityChest;
                                    import net.minecraft.util.BlockPos;
                                    import net.minecraft.util.EnumFacing;
                                    import net.minecraft.util.EnumParticleTypes;
                                    import net.minecraft.util.MathHelper;
                                    import net.minecraft.world.IBlockAccess;
                                    import net.minecraft.world.World;
                                    import net.minecraftforge.fml.common.registry.GameRegistry;
                                    import net.minecraftforge.fml.relauncher.Side;
                                    import net.minecraftforge.fml.relauncher.SideOnly;
                                    import eryah.usefulthings.Reference;
                                    import eryah.usefulthings.UsefulthingsMod;
                                    import eryah.usefulthings.tileentity.TileEntityPlateCrafter;
                                    
                                    public class PlateCrafter extends BlockContainer
                                    {
                                       public static final PropertyDirection FACING = PropertyDirection.create("facing", EnumFacing.Plane.HORIZONTAL);
                                       private static boolean isBurning;
                                       private static boolean keepInventory;
                                       private static final String __OBFID = "CL_00000248";
                                       public static Block platecrafter;
                                    
                                       protected PlateCrafter(Material mat, boolean isBurning)
                                       {
                                           super(Material.rock);
                                           this.setDefaultState(this.blockState.getBaseState().withProperty(FACING, EnumFacing.NORTH));
                                           this.isBurning = isBurning;
                                       }
                                    
                                    public static void init()
                                    {
                                    platecrafter = new PlateCrafter(Material.rock, isBurning).setUnlocalizedName("platecrafter").setCreativeTab(UsefulthingsMod.UTTab);
                                    }
                                    
                                    public static void register()
                                    {
                                    GameRegistry.registerBlock(platecrafter, platecrafter.getUnlocalizedName().substring(5));
                                    }
                                    
                                    public static void registerRenders()
                                    {
                                    registerRender(platecrafter);
                                    }
                                    
                                    public static void registerRender(Block block)
                                    {
                                    Item item = Item.getItemFromBlock(block);
                                    Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(item, 0, new ModelResourceLocation(Reference.MOD_ID + ":" + item.getUnlocalizedName().substring(5), "inventory"));
                                    }
                                    
                                       /**
                                        * Get the Item that this Block should drop when harvested.
                                        *  
                                        * @param fortune the level of the Fortune enchantment on the player's tool
                                        */
                                    
                                       public void onBlockAdded(World worldIn, BlockPos pos, IBlockState state)
                                       {
                                           this.setDefaultFacing(worldIn, pos, state);
                                           Iterator iterator = EnumFacing.Plane.HORIZONTAL.iterator();
                                    
                                           while (iterator.hasNext())
                                           {
                                               EnumFacing enumfacing = (EnumFacing)iterator.next();
                                               BlockPos blockpos1 = pos.offset(enumfacing);
                                               IBlockState iblockstate1 = worldIn.getBlockState(blockpos1);            
                                           }
                                       }
                                    
                                       private void setDefaultFacing(World worldIn, BlockPos pos, IBlockState state)
                                       {
                                           if (!worldIn.isRemote)
                                           {
                                               Block block = worldIn.getBlockState(pos.north()).getBlock();
                                               Block block1 = worldIn.getBlockState(pos.south()).getBlock();
                                               Block block2 = worldIn.getBlockState(pos.west()).getBlock();
                                               Block block3 = worldIn.getBlockState(pos.east()).getBlock();
                                               EnumFacing enumfacing = (EnumFacing)state.getValue(FACING);
                                    
                                               if (enumfacing == EnumFacing.NORTH && block.isFullBlock() && !block1.isFullBlock())
                                               {
                                                   enumfacing = EnumFacing.SOUTH;
                                               }
                                               else if (enumfacing == EnumFacing.SOUTH && block1.isFullBlock() && !block.isFullBlock())
                                               {
                                                   enumfacing = EnumFacing.NORTH;
                                               }
                                               else if (enumfacing == EnumFacing.WEST && block2.isFullBlock() && !block3.isFullBlock())
                                               {
                                                   enumfacing = EnumFacing.EAST;
                                               }
                                               else if (enumfacing == EnumFacing.EAST && block3.isFullBlock() && !block2.isFullBlock())
                                               {
                                                   enumfacing = EnumFacing.WEST;
                                               }
                                    
                                               worldIn.setBlockState(pos, state.withProperty(FACING, enumfacing), 2);
                                           }
                                       }
                                    
                                       @SideOnly(Side.CLIENT)
                                       public void randomDisplayTick(World worldIn, BlockPos pos, IBlockState state, Random rand)
                                       {
                                           if (this.isBurning)
                                           {
                                               EnumFacing enumfacing = (EnumFacing)state.getValue(FACING);
                                               double d0 = (double)pos.getX() + 0.5D;
                                               double d1 = (double)pos.getY() + rand.nextDouble() * 6.0D / 16.0D;
                                               double d2 = (double)pos.getZ() + 0.5D;
                                               double d3 = 0.52D;
                                               double d4 = rand.nextDouble() * 0.6D - 0.3D;
                                    
                                               switch (PlateCrafter.SwitchEnumFacing.FACING_LOOKUP[enumfacing.ordinal()])
                                               {
                                                   case 1:
                                                       worldIn.spawnParticle(EnumParticleTypes.SMOKE_NORMAL, d0 - d3, d1, d2 + d4, 0.0D, 0.0D, 0.0D, new int[0]);
                                                       worldIn.spawnParticle(EnumParticleTypes.FLAME, d0 - d3, d1, d2 + d4, 0.0D, 0.0D, 0.0D, new int[0]);
                                                       break;
                                                   case 2:
                                                       worldIn.spawnParticle(EnumParticleTypes.SMOKE_NORMAL, d0 + d3, d1, d2 + d4, 0.0D, 0.0D, 0.0D, new int[0]);
                                                       worldIn.spawnParticle(EnumParticleTypes.FLAME, d0 + d3, d1, d2 + d4, 0.0D, 0.0D, 0.0D, new int[0]);
                                                       break;
                                                   case 3:
                                                       worldIn.spawnParticle(EnumParticleTypes.SMOKE_NORMAL, d0 + d4, d1, d2 - d3, 0.0D, 0.0D, 0.0D, new int[0]);
                                                       worldIn.spawnParticle(EnumParticleTypes.FLAME, d0 + d4, d1, d2 - d3, 0.0D, 0.0D, 0.0D, new int[0]);
                                                       break;
                                                   case 4:
                                                       worldIn.spawnParticle(EnumParticleTypes.SMOKE_NORMAL, d0 + d4, d1, d2 + d3, 0.0D, 0.0D, 0.0D, new int[0]);
                                                       worldIn.spawnParticle(EnumParticleTypes.FLAME, d0 + d4, d1, d2 + d3, 0.0D, 0.0D, 0.0D, new int[0]);
                                               }
                                           }
                                       }
                                    
                                       @Override
                                       public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumFacing side, float hitX, float hitY, float hitZ)
                                    {
                                        playerIn.openGui(UsefulthingsMod.instance, 1, worldIn, pos.getX(), pos.getY(), pos.getZ());
                                    return true;
                                    }
                                    
                                       /**
                                        * Returns a new instance of a block's tile entity class. Called on placing the block.
                                        */
                                       public TileEntity createNewTileEntity(World worldIn, int meta)
                                       {
                                           return new TileEntityPlateCrafter();
                                       }
                                    
                                       public IBlockState onBlockPlaced(World worldIn, BlockPos pos, EnumFacing facing, float hitX, float hitY, float hitZ, int meta, EntityLivingBase placer)
                                       {
                                           return this.getDefaultState().withProperty(FACING, placer.getHorizontalFacing().getOpposite());
                                       }
                                    
                                       public void onBlockPlacedBy(World worldIn, BlockPos pos, IBlockState state, EntityLivingBase placer, ItemStack stack)
                                       {
                                           EnumFacing enumfacing = EnumFacing.getHorizontal(MathHelper.floor_double((double)(placer.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3).getOpposite();
                                           state = state.withProperty(FACING, enumfacing);
                                           BlockPos blockpos1 = pos.north();
                                           BlockPos blockpos2 = pos.south();
                                           BlockPos blockpos3 = pos.west();
                                           BlockPos blockpos4 = pos.east();
                                           boolean flag = this == worldIn.getBlockState(blockpos1).getBlock();
                                           boolean flag1 = this == worldIn.getBlockState(blockpos2).getBlock();
                                           boolean flag2 = this == worldIn.getBlockState(blockpos3).getBlock();
                                           boolean flag3 = this == worldIn.getBlockState(blockpos4).getBlock();
                                    
                                           if (!flag && !flag1 && !flag2 && !flag3)
                                           {
                                               worldIn.setBlockState(pos, state, 3);
                                           }
                                           else if (enumfacing.getAxis() == EnumFacing.Axis.X && (flag || flag1))
                                           {
                                               if (flag)
                                               {
                                                   worldIn.setBlockState(blockpos1, state, 3);
                                               }
                                               else
                                               {
                                                   worldIn.setBlockState(blockpos2, state, 3);
                                               }
                                    
                                               worldIn.setBlockState(pos, state, 3);
                                           }
                                           else if (enumfacing.getAxis() == EnumFacing.Axis.Z && (flag2 || flag3))
                                           {
                                               if (flag2)
                                               {
                                                   worldIn.setBlockState(blockpos3, state, 3);
                                               }
                                               else
                                               {
                                                   worldIn.setBlockState(blockpos4, state, 3);
                                               }
                                    
                                               worldIn.setBlockState(pos, state, 3);
                                           }      
                                           }
                                    
                                       public void breakBlock(World worldIn, BlockPos pos, IBlockState state)
                                       {
                                           if (!keepInventory)
                                           {
                                               TileEntity tileentity = worldIn.getTileEntity(pos);
                                    
                                               if (tileentity instanceof TileEntityPlateCrafter)
                                               {
                                                   InventoryHelper.dropInventoryItems(worldIn, pos, (TileEntityPlateCrafter)tileentity);
                                                   worldIn.updateComparatorOutputLevel(pos, this);
                                               }
                                           }
                                    
                                           super.breakBlock(worldIn, pos, state);
                                       }
                                    
                                       public boolean hasComparatorInputOverride()
                                       {
                                           return true;
                                       }
                                    
                                       public int getComparatorInputOverride(World worldIn, BlockPos pos)
                                       {
                                           return Container.calcRedstone(worldIn.getTileEntity(pos));
                                       }
                                    
                                       @SideOnly(Side.CLIENT)
                                       public Item getItem(World worldIn, BlockPos pos)
                                       {
                                           return Item.getItemFromBlock(PlateCrafter.platecrafter);
                                       }
                                    
                                       /**
                                        * The type of render function that is called for this block
                                        */
                                    
                                       /**
                                        * Possibly modify the given BlockState before rendering it on an Entity (Minecarts, Endermen, …)
                                        */
                                       @SideOnly(Side.CLIENT)
                                       public IBlockState getStateForEntityRender(IBlockState state)
                                       {
                                           return this.getDefaultState().withProperty(FACING, EnumFacing.SOUTH);
                                       }
                                    
                                       /**
                                        * Convert the given metadata into a BlockState for this Block
                                        */
                                       public IBlockState getStateFromMeta(int meta)
                                       {
                                           EnumFacing enumfacing = EnumFacing.getFront(meta);
                                    
                                           if (enumfacing.getAxis() == EnumFacing.Axis.Y)
                                           {
                                               enumfacing = EnumFacing.NORTH;
                                           }
                                    
                                           return this.getDefaultState().withProperty(FACING, enumfacing);
                                       }
                                    
                                       /**
                                        * Convert the BlockState into the correct metadata value
                                        */
                                       public int getMetaFromState(IBlockState state)
                                       {
                                           return ((EnumFacing)state.getValue(FACING)).getIndex();
                                       }
                                    
                                       protected BlockState createBlockState()
                                       {
                                           return new BlockState(this, new IProperty[] {FACING});
                                       }
                                    
                                       @SideOnly(Side.CLIENT)
                                    
                                       static final class SwitchEnumFacing
                                           {
                                               static final int[] FACING_LOOKUP = new int[EnumFacing.values().length];
                                               private static final String __OBFID = "CL_00002111";
                                    
                                               static
                                               {
                                                   try
                                                   {
                                                       FACING_LOOKUP[EnumFacing.WEST.ordinal()] = 1;
                                                   }
                                                   catch (NoSuchFieldError var4)
                                                   {
                                                       ;
                                                   }
                                    
                                                   try
                                                   {
                                                       FACING_LOOKUP[EnumFacing.EAST.ordinal()] = 2;
                                                   }
                                                   catch (NoSuchFieldError var3)
                                                   {
                                                       ;
                                                   }
                                    
                                                   try
                                                   {
                                                       FACING_LOOKUP[EnumFacing.NORTH.ordinal()] = 3;
                                                   }
                                                   catch (NoSuchFieldError var2)
                                                   {
                                                       ;
                                                   }
                                    
                                                   try
                                                   {
                                                       FACING_LOOKUP[EnumFacing.SOUTH.ordinal()] = 4;
                                                   }
                                                   catch (NoSuchFieldError var1)
                                                   {
                                                       ;
                                                   }
                                               }
                                           }
                                    
                                       public boolean isOpaqueCube()
                                       {
                                           return false;
                                       }
                                    
                                       public boolean renderAsNormalBlock()
                                       {
                                           return false;
                                       }
                                    
                                       public int getRenderType()
                                       {
                                           return -1;
                                       }
                                    
                                       public IBlockState correctFacing(World worldIn, BlockPos pos, IBlockState state)
                                       {
                                           EnumFacing enumfacing = null;
                                           Iterator iterator = EnumFacing.Plane.HORIZONTAL.iterator();
                                    
                                           while (iterator.hasNext())
                                           {
                                               EnumFacing enumfacing1 = (EnumFacing)iterator.next();
                                               IBlockState iblockstate1 = worldIn.getBlockState(pos.offset(enumfacing1));
                                    
                                               if (iblockstate1.getBlock() == this)
                                               {
                                                   return state;
                                               }
                                    
                                               if (iblockstate1.getBlock().isFullBlock())
                                               {
                                                   if (enumfacing != null)
                                                   {
                                                       enumfacing = null;
                                                       break;
                                                   }
                                    
                                                   enumfacing = enumfacing1;
                                               }
                                           }
                                    
                                           if (enumfacing != null)
                                           {
                                               return state.withProperty(FACING, enumfacing.getOpposite());
                                           }
                                           else
                                           {
                                               EnumFacing enumfacing2 = (EnumFacing)state.getValue(FACING);
                                    
                                               if (worldIn.getBlockState(pos.offset(enumfacing2)).getBlock().isFullBlock())
                                               {
                                                   enumfacing2 = enumfacing2.getOpposite();
                                               }
                                    
                                               if (worldIn.getBlockState(pos.offset(enumfacing2)).getBlock().isFullBlock())
                                               {
                                                   enumfacing2 = enumfacing2.rotateY();
                                               }
                                    
                                               if (worldIn.getBlockState(pos.offset(enumfacing2)).getBlock().isFullBlock())
                                               {
                                                   enumfacing2 = enumfacing2.getOpposite();
                                               }
                                    
                                               return state.withProperty(FACING, enumfacing2);
                                           }
                                       }
                                    
                                       public boolean canPlaceBlockAt(World worldIn, BlockPos pos)
                                       {
                                           int i = 0;
                                           BlockPos blockpos1 = pos.west();
                                           BlockPos blockpos2 = pos.east();
                                           BlockPos blockpos3 = pos.north();
                                           BlockPos blockpos4 = pos.south();
                                    
                                           if (worldIn.getBlockState(blockpos1).getBlock() == this)
                                           {            
                                    
                                               ++i;
                                           }
                                    
                                           if (worldIn.getBlockState(blockpos2).getBlock() == this)
                                           {
                                    
                                               ++i;
                                           }
                                    
                                           if (worldIn.getBlockState(blockpos3).getBlock() == this)
                                           {
                                    
                                               ++i;
                                           }
                                    
                                           if (worldIn.getBlockState(blockpos4).getBlock() == this)
                                           {
                                    
                                               ++i;
                                           }
                                    
                                           return i <= 1;
                                       }
                                    
                                    }
                                    

                                    EDIT : C’est moi ou y’a pas du tout la méthode ? Oo

                                    Membre fantôme
                                    Je développe maintenant un jeu sur UnrealEngine4


                                    Contact :…

                                    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

                                      J’ai dit la classe TileEntityPlateCrafter, pas la classe PlateCrafter …

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

                                        Ah désolé

                                        package eryah.usefulthings.tileentity;
                                        
                                        import javax.swing.Icon;
                                        
                                        import net.minecraft.block.Block;
                                        import net.minecraft.block.material.Material;
                                        import net.minecraft.entity.player.EntityPlayer;
                                        import net.minecraft.entity.player.InventoryPlayer;
                                        import net.minecraft.init.Blocks;
                                        import net.minecraft.init.Items;
                                        import net.minecraft.inventory.Container;
                                        import net.minecraft.inventory.IInventory;
                                        import net.minecraft.inventory.ISidedInventory;
                                        import net.minecraft.inventory.SlotFurnaceFuel;
                                        import net.minecraft.item.Item;
                                        import net.minecraft.item.ItemBlock;
                                        import net.minecraft.item.ItemHoe;
                                        import net.minecraft.item.ItemStack;
                                        import net.minecraft.item.ItemSword;
                                        import net.minecraft.item.ItemTool;
                                        import net.minecraft.nbt.NBTTagCompound;
                                        import net.minecraft.nbt.NBTTagList;
                                        import net.minecraft.network.NetworkManager;
                                        import net.minecraft.network.Packet;
                                        import net.minecraft.network.play.server.S35PacketUpdateTileEntity;
                                        import net.minecraft.server.gui.IUpdatePlayerListBox;
                                        import net.minecraft.tileentity.TileEntityLockable;
                                        import net.minecraft.util.EnumFacing;
                                        import net.minecraft.util.MathHelper;
                                        import net.minecraftforge.fml.relauncher.Side;
                                        import net.minecraftforge.fml.relauncher.SideOnly;
                                        import eryah.usefulthings.container.ContainerPlateCrafter;
                                        import eryah.usefulthings.recipes.PlateCrafterRecipes;
                                        
                                        public class TileEntityPlateCrafter extends TileEntityLockable implements IUpdatePlayerListBox, ISidedInventory, IInventory
                                        {
                                        private static final int[] slotsTop = new int[] {0};
                                        private static final int[] slotsBottom = new int[] {2, 1};
                                        private static final int[] slotsSides = new int[] {1};
                                        /** The ItemStacks that hold the items currently being used in the plateCrafter */
                                        private ItemStack[] plateCrafterItemStacks = new ItemStack[3];
                                        /** The number of ticks that the plateCrafter will keep burning */
                                        private int plateCrafterBurnTime;
                                        /** The number of ticks that a fresh copy of the currently-burning item would keep the plateCrafter burning for */
                                        private int currentItemBurnTime;
                                        private int cookTime;
                                        private int totalCookTime;
                                        private String plateCrafterCustomName;
                                        private static final String __OBFID = "CL_00000357";
                                        private Icon crea;
                                        private Icon blockIcon2;
                                        
                                        private byte direction;
                                        
                                        /**
                                        * Returns the number of slots in the inventory.
                                        */
                                        public int getSizeInventory()
                                        {
                                        return this.plateCrafterItemStacks.length;
                                        }
                                        
                                        /**
                                        * Returns the stack in slot i
                                        */
                                        public ItemStack getStackInSlot(int index)
                                        {
                                        return this.plateCrafterItemStacks[index];
                                        }
                                        
                                        /**
                                        * Removes from an inventory slot (first arg) up to a specified number (second arg) of items and returns them in a
                                        * new stack.
                                        */
                                        public ItemStack decrStackSize(int index, int count)
                                        {
                                        if (this.plateCrafterItemStacks[index] != null)
                                        {
                                        ItemStack itemstack;
                                        
                                        if (this.plateCrafterItemStacks[index].stackSize <= count)
                                        {
                                        itemstack = this.plateCrafterItemStacks[index];
                                        this.plateCrafterItemStacks[index] = null;
                                        return itemstack;
                                        }
                                        else
                                        {
                                        itemstack = this.plateCrafterItemStacks[index].splitStack(count);
                                        
                                        if (this.plateCrafterItemStacks[index].stackSize == 0)
                                        {
                                        this.plateCrafterItemStacks[index] = null;
                                        }
                                        
                                        return itemstack;
                                        }
                                        }
                                        else
                                        {
                                        return null;
                                        }
                                        }
                                        
                                        /**
                                        * When some containers are closed they call this on each slot, then drop whatever it returns as an EntityItem -
                                        * like when you close a workbench GUI.
                                        */
                                        public ItemStack getStackInSlotOnClosing(int index)
                                        {
                                        if (this.plateCrafterItemStacks[index] != null)
                                        {
                                        ItemStack itemstack = this.plateCrafterItemStacks[index];
                                        this.plateCrafterItemStacks[index] = null;
                                        return itemstack;
                                        }
                                        else
                                        {
                                        return null;
                                        }
                                        }
                                        
                                        /**
                                        * Sets the given item stack to the specified slot in the inventory (can be crafting or armor sections).
                                        */
                                        public void setInventorySlotContents(int index, ItemStack stack)
                                        {
                                        boolean flag = stack != null && stack.isItemEqual(this.plateCrafterItemStacks[index]) && ItemStack.areItemStackTagsEqual(stack, this.plateCrafterItemStacks[index]);
                                        this.plateCrafterItemStacks[index] = stack;
                                        
                                        if (stack != null && stack.stackSize > this.getInventoryStackLimit())
                                        {
                                        stack.stackSize = this.getInventoryStackLimit();
                                        }
                                        
                                        if (index == 0 && !flag)
                                        {
                                        this.totalCookTime = this.func_174904_a(stack);
                                        this.cookTime = 0;
                                        this.markDirty();
                                        }
                                        }
                                        
                                        /**
                                        * Gets the name of this command sender (usually username, but possibly "Rcon")
                                        */
                                        public String getName()
                                        {
                                        return this.hasCustomName() ? this.plateCrafterCustomName : "container.plateCrafter";
                                        }
                                        
                                        /**
                                        * Returns true if this thing is named
                                        */
                                        public boolean hasCustomName()
                                        {
                                        return this.plateCrafterCustomName != null && this.plateCrafterCustomName.length() > 0;
                                        }
                                        
                                        public void setCustomInventoryName(String p_145951_1_)
                                        {
                                        this.plateCrafterCustomName = p_145951_1_;
                                        }
                                        
                                        public void readFromNBT(NBTTagCompound compound)
                                        {
                                        super.readFromNBT(compound);
                                        NBTTagList nbttaglist = compound.getTagList("Items", 10);
                                        this.plateCrafterItemStacks = new ItemStack[this.getSizeInventory()];
                                        
                                        for (int i = 0; i < nbttaglist.tagCount(); ++i)
                                        {
                                        NBTTagCompound nbttagcompound1 = nbttaglist.getCompoundTagAt(i);
                                        byte b0 = nbttagcompound1.getByte("Slot");
                                        
                                        if (b0 >= 0 && b0 < this.plateCrafterItemStacks.length)
                                        {
                                        this.plateCrafterItemStacks[b0] = ItemStack.loadItemStackFromNBT(nbttagcompound1);
                                        }
                                        }
                                        
                                        this.plateCrafterBurnTime = compound.getShort("BurnTime");
                                        this.cookTime = compound.getShort("CookTime");
                                        this.totalCookTime = compound.getShort("CookTimeTotal");
                                        this.currentItemBurnTime = getItemBurnTime(this.plateCrafterItemStacks[1]);
                                        
                                        if (compound.hasKey("CustomName", 8))
                                        {
                                        this.plateCrafterCustomName = compound.getString("CustomName");
                                        }
                                        
                                        super.readFromNBT(compound);
                                        this.direction = compound.getByte("Direction");
                                        
                                        }
                                        
                                        public void writeToNBT(NBTTagCompound compound)
                                        {
                                        super.writeToNBT(compound);
                                        compound.setShort("BurnTime", (short)this.plateCrafterBurnTime);
                                        compound.setShort("CookTime", (short)this.cookTime);
                                        compound.setShort("CookTimeTotal", (short)this.totalCookTime);
                                        NBTTagList nbttaglist = new NBTTagList();
                                        
                                        for (int i = 0; i < this.plateCrafterItemStacks.length; ++i)
                                        {
                                        if (this.plateCrafterItemStacks* != null)
                                        {
                                        NBTTagCompound nbttagcompound1 = new NBTTagCompound();
                                        nbttagcompound1.setByte("Slot", (byte)i);
                                        this.plateCrafterItemStacks*.writeToNBT(nbttagcompound1);
                                        nbttaglist.appendTag(nbttagcompound1);
                                        }
                                        }
                                        
                                        compound.setTag("Items", nbttaglist);
                                        
                                        if (this.hasCustomName())
                                        {
                                        compound.setString("CustomName", this.plateCrafterCustomName);
                                        }
                                        
                                        super.writeToNBT(compound);
                                        compound.setByte("Direction", this.direction);
                                        
                                        }
                                        
                                        /**
                                        * Returns the maximum stack size for a inventory slot. Seems to always be 64, possibly will be extended. *Isn't
                                        * this more of a set than a get?*
                                        */
                                        public int getInventoryStackLimit()
                                        {
                                        return 64;
                                        }
                                        
                                        /**
                                        * plateCrafter isBurning
                                        */
                                        public boolean isBurning()
                                        {
                                        return this.plateCrafterBurnTime > 0;
                                        }
                                        
                                        @SideOnly(Side.CLIENT)
                                        public static boolean isBurning(IInventory p_174903_0_)
                                        {
                                        return p_174903_0_.getField(0) > 0;
                                        }
                                        
                                        /**
                                        * Updates the JList with a new model.
                                        */
                                        public void update()
                                        {
                                        boolean flag = this.isBurning();
                                        boolean flag1 = false;
                                        
                                        if (this.isBurning())
                                        {
                                        –this.plateCrafterBurnTime;
                                        }
                                        
                                        if (!this.worldObj.isRemote)
                                        {
                                        if (!this.isBurning() && (this.plateCrafterItemStacks[1] == null || this.plateCrafterItemStacks[0] == null))
                                        {
                                        if (!this.isBurning() && this.cookTime > 0)
                                        {
                                        this.cookTime = MathHelper.clamp_int(this.cookTime - 2, 0, this.totalCookTime);
                                        }
                                        }
                                        else
                                        {
                                        if (!this.isBurning() && this.canSmelt())
                                        {
                                        this.currentItemBurnTime = this.plateCrafterBurnTime = getItemBurnTime(this.plateCrafterItemStacks[1]);
                                        
                                        if (this.isBurning())
                                        {
                                        flag1 = true;
                                        
                                        if (this.plateCrafterItemStacks[1] != null)
                                        {
                                        –this.plateCrafterItemStacks[1].stackSize;
                                        
                                        if (this.plateCrafterItemStacks[1].stackSize == 0)
                                        {
                                        this.plateCrafterItemStacks[1] = plateCrafterItemStacks[1].getItem().getContainerItem(plateCrafterItemStacks[1]);
                                        }
                                        }
                                        }
                                        }
                                        
                                        if (this.isBurning() && this.canSmelt())
                                        {
                                        ++this.cookTime;
                                        
                                        if (this.cookTime == this.totalCookTime)
                                        {
                                        this.cookTime = 0;
                                        this.totalCookTime = this.func_174904_a(this.plateCrafterItemStacks[0]);
                                        this.smeltItem();
                                        flag1 = true;
                                        }
                                        }
                                        else
                                        {
                                        this.cookTime = 0;
                                        }
                                        }
                                        
                                        }
                                        
                                        if (flag1)
                                        {
                                        this.markDirty();
                                        }
                                        }
                                        
                                        public int func_174904_a(ItemStack p_174904_1_)
                                        {
                                        return 200;
                                        }
                                        
                                        /**
                                        * Returns true if the plateCrafter can smelt an item, i.e. has a source item, destination stack isn't full, etc.
                                        */
                                        private boolean canSmelt()
                                        {
                                        if (this.plateCrafterItemStacks[0] == null)
                                        {
                                        return false;
                                        }
                                        else
                                        {
                                        ItemStack itemstack = PlateCrafterRecipes.instance().getSmeltingResult(this.plateCrafterItemStacks[0]);
                                        if (itemstack == null) return false;
                                        if (this.plateCrafterItemStacks[2] == null) return true;
                                        if (!this.plateCrafterItemStacks[2].isItemEqual(itemstack)) return false;
                                        int result = plateCrafterItemStacks[2].stackSize + itemstack.stackSize;
                                        return result <= getInventoryStackLimit() && result <= this.plateCrafterItemStacks[2].getMaxStackSize(); //Forge BugFix: Make it respect stack sizes properly.
                                        }
                                        }
                                        
                                        /**
                                        * Turn one item from the plateCrafter source stack into the appropriate smelted item in the plateCrafter result stack
                                        */
                                        public void smeltItem()
                                        {
                                        if (this.canSmelt())
                                        {
                                        ItemStack itemstack = PlateCrafterRecipes.instance().getSmeltingResult(this.plateCrafterItemStacks[0]);
                                        
                                        if (this.plateCrafterItemStacks[2] == null)
                                        {
                                        this.plateCrafterItemStacks[2] = itemstack.copy();
                                        }
                                        else if (this.plateCrafterItemStacks[2].getItem() == itemstack.getItem())
                                        {
                                        this.plateCrafterItemStacks[2].stackSize += itemstack.stackSize; // Forge BugFix: Results may have multiple items
                                        }
                                        
                                        if (this.plateCrafterItemStacks[0].getItem() == Item.getItemFromBlock(Blocks.sponge) && this.plateCrafterItemStacks[0].getMetadata() == 1 && this.plateCrafterItemStacks[1] != null && this.plateCrafterItemStacks[1].getItem() == Items.bucket)
                                        {
                                        this.plateCrafterItemStacks[1] = new ItemStack(Items.water_bucket);
                                        }
                                        
                                        –this.plateCrafterItemStacks[0].stackSize;
                                        
                                        if (this.plateCrafterItemStacks[0].stackSize <= 0)
                                        {
                                        this.plateCrafterItemStacks[0] = null;
                                        }
                                        }
                                        }
                                        
                                        /**
                                        * Returns the number of ticks that the supplied fuel item will keep the plateCrafter burning, or 0 if the item isn't
                                        * fuel
                                        */
                                        public static int getItemBurnTime(ItemStack p_145952_0_)
                                        {
                                        if (p_145952_0_ == null)
                                        {
                                        return 0;
                                        }
                                        else
                                        {
                                        Item item = p_145952_0_.getItem();
                                        
                                        if (item instanceof ItemBlock && Block.getBlockFromItem(item) != Blocks.air)
                                        {
                                        Block block = Block.getBlockFromItem(item);
                                        
                                        if (block == Blocks.wooden_slab)
                                        {
                                        return 150;
                                        }
                                        
                                        if (block.getMaterial() == Material.wood)
                                        {
                                        return 300;
                                        }
                                        
                                        if (block == Blocks.coal_block)
                                        {
                                        return 16000;
                                        }
                                        }
                                        
                                        if (item instanceof ItemTool && ((ItemTool)item).getToolMaterialName().equals("WOOD")) return 200;
                                        if (item instanceof ItemSword && ((ItemSword)item).getToolMaterialName().equals("WOOD")) return 200;
                                        if (item instanceof ItemHoe && ((ItemHoe)item).getMaterialName().equals("WOOD")) return 200;
                                        if (item == Items.stick) return 100;
                                        if (item == Items.coal) return 1600;
                                        if (item == Items.lava_bucket) return 20000;
                                        if (item == Item.getItemFromBlock(Blocks.sapling)) return 100;
                                        if (item == Items.blaze_rod) return 2400;
                                        return net.minecraftforge.fml.common.registry.GameRegistry.getFuelValue(p_145952_0_);
                                        }
                                        }
                                        
                                        public static boolean isItemFuel(ItemStack p_145954_0_)
                                        {
                                        /**
                                        * Returns the number of ticks that the supplied fuel item will keep the plateCrafter burning, or 0 if the item isn't
                                        * fuel
                                        */
                                        return getItemBurnTime(p_145954_0_) > 0;
                                        }
                                        
                                        /**
                                        * Do not make give this method the name canInteractWith because it clashes with Container
                                        */
                                        public boolean isUseableByPlayer(EntityPlayer player)
                                        {
                                        return this.worldObj.getTileEntity(this.pos) != this ? false : player.getDistanceSq((double)this.pos.getX() + 0.5D, (double)this.pos.getY() + 0.5D, (double)this.pos.getZ() + 0.5D) <= 64.0D;
                                        }
                                        
                                        public void openInventory(EntityPlayer player) {}
                                        
                                        public void closeInventory(EntityPlayer player) {}
                                        
                                        /**
                                        * Returns true if automation is allowed to insert the given stack (ignoring stack size) into the given slot.
                                        */
                                        public boolean isItemValidForSlot(int index, ItemStack stack)
                                        {
                                        return index == 2 ? false : (index != 1 ? true : isItemFuel(stack) || SlotFurnaceFuel.isBucket(stack));
                                        }
                                        
                                        public int[] getSlotsForFace(EnumFacing side)
                                        {
                                        return side == EnumFacing.DOWN ? slotsBottom : (side == EnumFacing.UP ? slotsTop : slotsSides);
                                        }
                                        
                                        /**
                                        * Returns true if automation can insert the given item in the given slot from the given side. Args: slot, item,
                                        * side
                                        */
                                        public boolean canInsertItem(int index, ItemStack itemStackIn, EnumFacing direction)
                                        {
                                        return this.isItemValidForSlot(index, itemStackIn);
                                        }
                                        
                                        /**
                                        * Returns true if automation can extract the given item in the given slot from the given side. Args: slot, item,
                                        * side
                                        */
                                        public boolean canExtractItem(int index, ItemStack stack, EnumFacing direction)
                                        {
                                        if (direction == EnumFacing.DOWN && index == 1)
                                        {
                                        Item item = stack.getItem();
                                        
                                        if (item != Items.water_bucket && item != Items.bucket)
                                        {
                                        return false;
                                        }
                                        }
                                        
                                        return true;
                                        }
                                        
                                        public Container createContainer(InventoryPlayer playerInventory, EntityPlayer playerIn)
                                        {
                                        return new ContainerPlateCrafter(this, playerInventory);
                                        }
                                        
                                        public int getField(int id)
                                        {
                                        switch (id)
                                        {
                                        case 0:
                                        return this.plateCrafterBurnTime;
                                        case 1:
                                        return this.currentItemBurnTime;
                                        case 2:
                                        return this.cookTime;
                                        case 3:
                                        return this.totalCookTime;
                                        default:
                                        return 0;
                                        }
                                        }
                                        
                                        public void setField(int id, int value)
                                        {
                                        switch (id)
                                        {
                                        case 0:
                                        this.plateCrafterBurnTime = value;
                                        break;
                                        case 1:
                                        this.currentItemBurnTime = value;
                                        break;
                                        case 2:
                                        this.cookTime = value;
                                        break;
                                        case 3:
                                        this.totalCookTime = value;
                                        }
                                        }
                                        
                                        public int getFieldCount()
                                        {
                                        return 4;
                                        }
                                        
                                        public void clear()
                                        {
                                        for (int i = 0; i < this.plateCrafterItemStacks.length; ++i)
                                        {
                                        this.plateCrafterItemStacks* = null;
                                        }
                                        }
                                        
                                        static final class SwitchEnumFacing
                                        {
                                        static final int[] field_177366_a = new int[EnumFacing.values().length];
                                        private static final String __OBFID = "CL_00002041";
                                        
                                        static
                                        {
                                        try
                                        {
                                        field_177366_a[EnumFacing.NORTH.ordinal()] = 1;
                                        }
                                        catch (NoSuchFieldError var4)
                                        {
                                        ;
                                        }
                                        
                                        try
                                        {
                                        field_177366_a[EnumFacing.SOUTH.ordinal()] = 2;
                                        }
                                        catch (NoSuchFieldError var3)
                                        {
                                        ;
                                        }
                                        
                                        try
                                        {
                                        field_177366_a[EnumFacing.EAST.ordinal()] = 3;
                                        }
                                        catch (NoSuchFieldError var2)
                                        {
                                        ;
                                        }
                                        
                                        try
                                        {
                                        field_177366_a[EnumFacing.WEST.ordinal()] = 4;
                                        }
                                        catch (NoSuchFieldError var1)
                                        {
                                        ;
                                        }
                                        }
                                        }
                                        
                                        public byte getDirection()
                                        {
                                        return direction;
                                        }
                                        
                                        public void setDirection(byte direction)
                                        {
                                        this.direction = direction;
                                        this.worldObj.markBlockForUpdate(this.pos);
                                        }
                                        
                                        public Packet getDescriptionPacket()
                                        {
                                        NBTTagCompound nbttagcompound = new NBTTagCompound();
                                        this.writeToNBT(nbttagcompound);
                                        return new S35PacketUpdateTileEntity(this.pos, 0, nbttagcompound);
                                        }
                                        
                                        public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity pkt)
                                        {
                                        this.readFromNBT(pkt.getNbtCompound());
                                        this.worldObj.markBlockRangeForRenderUpdate(this.pos, this.pos);
                                        }
                                        
                                        @Override
                                        public String getGuiID() {
                                        // TODO Auto-generated method stub
                                        return null;
                                        }
                                        
                                        }
                                        

                                        Juste la méthode getDirection

                                        public void setDirection(byte direction)
                                        {
                                        this.direction = direction;
                                        this.worldObj.markBlockForUpdate(this.pos);
                                        }[
                                        

                                        je ne sais plus trop où je l’ai choppé, je crois dans la classe du coffre

                                        Membre fantôme
                                        Je développe maintenant un jeu sur UnrealEngine4


                                        Contact :…

                                        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

                                          Pour le tile entity c’est bon, le problème vient donc du bloc.
                                          Tout ce que tu as dans la fonction public void onBlockPlacedBy(World worldIn, BlockPos pos, IBlockState state, EntityLivingBase placer, ItemStack stack) ne sert à rien.
                                          Tu devrais avoir ça :

                                          @Override
                                          public void onBlockPlacedBy(World world, BlockPos pos, IBlockState state, EntityLivingBase entity, ItemStack stack)
                                          {
                                          TileEntity te = world.getTileEntity(pos);
                                          if(te instanceof TileEntityPlateCrafter)
                                          {
                                          TileEntityPlateCrafter tile = (TileEntityPlateCrafter)te;
                                          int l = (MathHelper.floor_double(entity.rotationYaw * 4.0F / 360.0F + 2.5D) & 3);
                                          tile.setDirection((byte)l);
                                          }
                                          }
                                          
                                          1 réponse Dernière réponse Répondre Citer 0
                                          • EryahE Hors-ligne
                                            Eryah
                                            dernière édition par

                                            Yaay, sa fonctionne enfin !
                                            Enfin presque, le bloc me montre ses fesses quand je le plac e:/
                                            Un petit rotate 180 devrait y remedier 🙂
                                            Merci robin

                                            Membre fantôme
                                            Je développe maintenant un jeu sur UnrealEngine4


                                            Contact :…

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

                                            MINECRAFT FORGE FRANCE © 2024

                                            Powered by NodeBB