Bloc type four en 1.8
-
Bonjour , bon me revoilà dans cette catégorie ^^ J’ai un nouveau soucis avec mes machines , en fait en les updates en 1.8 mon bloc a l’air d’être reconnu comme une machine , ce que j’entend par la c’est que quand je fais un clic droit avec un autre bloc ca ne pose pas le bloc comme si il voulais ouvrir quelques choses mais qu’il ne le faisait pas , actuellement j’ai essayé de régler le soucis mais à l’aveuglette car je n’ai aucun crash ou erreur dans ma console j’ai ajouté des débugs et ca semble fonctionne mais rien ne s’ouvre , je ne sais pas quelle classe pourrais causer cette ‘erreur’ donc si vous avez des idées de quelles classe dite le moi et je regarderais par moi même et je posterais également le code ici pour ceux qui veulent m’aider ^^ En sachant que j’ai refait le tuto de A à Z et que j’ai essayé , je dis bien essayé car je ne suis pas un pro de l’update en 1.8
Voila si vous avez des idées dites moi ^^
Merci à tous ::)
PS : Je pensais que ca avait avoir avec le GuiHandler ( jle met au cas ou ::)
```java
package mod.common.block.gui;import mod.common.block.container.ContainerAnalyzer;
import mod.common.block.container.ContainerCombiner;
import mod.common.block.container.ContainerCouveuse;
import mod.common.block.container.ContainerExtractor;
import mod.common.block.entity.TileEntityAnalyzer;
import mod.common.block.entity.TileEntityCombiner;
import mod.common.block.entity.TileEntityCouveuse;
import mod.common.block.entity.TileEntityExtractor;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.BlockPos;
import net.minecraft.world.World;
import net.minecraftforge.fml.common.network.IGuiHandler;public class GuiHandler implements IGuiHandler
{@Override
public Object getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) {switch (ID)
{case 0:
TileEntity tile = world.getTileEntity(new BlockPos(x, y, z));
if(tile instanceof TileEntityAnalyzer)
{
return new ContainerAnalyzer((TileEntityAnalyzer)tile, player.inventory);
}case 1:
TileEntity tile1 = world.getTileEntity(new BlockPos(x, y, z));
if(tile1 instanceof TileEntityCouveuse)
{
return new ContainerCouveuse((TileEntityCouveuse)tile1, player.inventory);
}case 2:
TileEntity tile2 = world.getTileEntity(new BlockPos(x, y, z));
if(tile2 instanceof TileEntityExtractor)
{
return new ContainerExtractor((TileEntityExtractor)tile2, player.inventory);
}
case 3:
TileEntity tile3 = world.getTileEntity(new BlockPos(x, y, z));
if(tile3 instanceof TileEntityCombiner)
{
return new ContainerCombiner((TileEntityCombiner)tile3, player.inventory);
}
}
return null;
}@Override
public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) {switch (ID)
{case 0:
TileEntity tile = world.getTileEntity(new BlockPos(x, y, z));
if(tile instanceof TileEntityAnalyzer)
{
return new ContainerAnalyzer((TileEntityAnalyzer)tile, player.inventory);
}case 1:
TileEntity tile1 = world.getTileEntity(new BlockPos(x, y, z));
if(tile1 instanceof TileEntityCouveuse)
{
return new ContainerCouveuse((TileEntityCouveuse)tile1, player.inventory);
}case 2:
TileEntity tile2 = world.getTileEntity(new BlockPos(x, y, z));
if(tile2 instanceof TileEntityExtractor)
{
return new ContainerExtractor((TileEntityExtractor)tile2, player.inventory);
}
case 3:
TileEntity tile3 = world.getTileEntity(new BlockPos(x, y, z));
if(tile3 instanceof TileEntityCombiner)
{
return new ContainerCombiner((TileEntityCombiner)tile3, player.inventory);
}
}
return null;
}}
-
Envoi la classe de ton block
-
bloc analyzer
package mod.common.block; import java.awt.Image; import java.util.List; import java.util.Random; import javax.swing.Icon; import javax.swing.ImageIcon; import mod.DinoCraft; import mod.common.block.entity.TileEntityAnalyzer; import net.minecraft.block.Block; import net.minecraft.block.ITileEntityProvider; import net.minecraft.block.material.Material; import net.minecraft.block.properties.IProperty; import net.minecraft.block.properties.PropertyDirection; import net.minecraft.block.properties.PropertyEnum; import net.minecraft.block.state.BlockState; import net.minecraft.block.state.IBlockState; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.item.EntityItem; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.IInventory; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntityFurnace; import net.minecraft.util.BlockPos; import net.minecraft.util.EnumFacing; import net.minecraft.util.IStringSerializable; import net.minecraft.util.MathHelper; import net.minecraft.world.IBlockAccess; import net.minecraft.world.IInteractionObject; import net.minecraft.world.World; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; public class BlockAnalyzer extends Block implements ITileEntityProvider { public BlockAnalyzer() { super(Material.rock); this.setResistance(8.0F); this.setHarvestLevel("pickaxe", 2); this.setCreativeTab(CreativeTabs.tabBlock); this.setUnlocalizedName("block_analyzer"); this.setDefaultState(this.blockState.getBaseState().withProperty(FACING, EnumFacing.NORTH)); } // FACING public static final PropertyDirection FACING = PropertyDirection.create("facing", EnumFacing.Plane.HORIZONTAL); 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); } } 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 TileEntityAnalyzer) { ((TileEntityAnalyzer)tileentity).setCustomInventoryName(stack.getDisplayName()); } } } public int getRenderType() { return 3; } @SideOnly(Side.CLIENT) public IBlockState getStateForEntityRender(IBlockState state) { return this.getDefaultState().withProperty(FACING, EnumFacing.SOUTH); } 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); } 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]; 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) { ; } } } // BLOCK public Item getItemDropped(IBlockState state, Random rand, int fortune) { return Item.getItemFromBlock(BlockRegister.BlockAnalyzer); } @Override public TileEntity createTileEntity(World world, IBlockState state) { if (hasTileEntity(state)) { return new TileEntityAnalyzer(); } return null; } @Override public boolean hasTileEntity(IBlockState state) { if (state.getBlock() == this) { return true; } return false; } @Override public void breakBlock(World world, BlockPos pos, IBlockState state) { TileEntity tileentity = world.getTileEntity(pos); if (tileentity instanceof IInventory) { IInventory inv = (IInventory) tileentity; for (int i1 = 0; i1 < inv.getSizeInventory(); ++i1) { ItemStack itemstack = inv.getStackInSlot(i1); if (itemstack != null) { float f = world.rand.nextFloat() * 0.8F + 0.1F; float f1 = world.rand.nextFloat() * 0.8F + 0.1F; EntityItem entityitem; for (float f2 = world.rand.nextFloat() * 0.8F + 0.1F; itemstack.stackSize > 0; world.spawnEntityInWorld(entityitem)) { int j1 = world.rand.nextInt(21) + 10; if (j1 > itemstack.stackSize) { j1 = itemstack.stackSize; } itemstack.stackSize -= j1; entityitem = new EntityItem(world, (double) ((float) pos.getX() + f), (double) ((float) pos.getY() + f1), (double) ((float) pos.getZ() + f2), new ItemStack(itemstack.getItem(), j1, itemstack.getItemDamage())); float f3 = 0.05F; entityitem.motionX = (double) ((float) world.rand.nextGaussian() * f3); entityitem.motionY = (double) ((float) world.rand.nextGaussian() * f3 + 0.2F); entityitem.motionZ = (double) ((float) world.rand.nextGaussian() * f3); if (itemstack.hasTagCompound()) { entityitem.getEntityItem().setTagCompound((NBTTagCompound) itemstack.getTagCompound().copy()); } } } } } super.breakBlock(world, pos, state); } public void onBlockPlacedBy(World world, BlockPos pos, EntityLivingBase living, ItemStack stack) { TileEntity tile = world.getTileEntity(pos); if(tile instanceof TileEntityAnalyzer) { if(stack.hasDisplayName()) { ((TileEntityAnalyzer)tile).setCustomName(stack.getDisplayName()); } } } @Override public boolean onBlockEventReceived(World worldIn, BlockPos pos, IBlockState state, int eventID, int eventParam) { super.onBlockEventReceived(worldIn, pos, state, eventID, eventParam); TileEntity tileentity = worldIn.getTileEntity(pos); return tileentity == null ? false : tileentity.receiveClientEvent(eventID, eventParam); } @Override public TileEntity createNewTileEntity(World worldIn, int meta) { return new TileEntityAnalyzer(); } public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumFacing side, float hitX, float hitY, float hitZ) { int x = pos.getX(); int z = pos.getZ(); int y = pos.getY(); if(world.isRemote) { return true; } else { TileEntity tileentity = world.getTileEntity(pos); if (tileentity instanceof TileEntityAnalyzer) { player.openGui(DinoCraft.instance, 0, world, x, y, z); System.out.println("It works ?"); } return true; } } }
-
Tu as 2 méthodes createTileEntity dont une inutile.
Dans ton GuiHandler, du côté client, tu dois retourner un Gui et non un Container
-
Ah oui , je ne l’avais pas remarqué Oo , merci j’ai enlevé celui qui fallait
Et effectivement , c’est un gui qui doit être retourné je sais pas pourquoi j’ai changer x) Cependant ca ne marche toujours pas en effectuant les modifs.
package mod.common.block.gui; import mod.common.block.container.ContainerAnalyzer; import mod.common.block.container.ContainerCombiner; import mod.common.block.container.ContainerCouveuse; import mod.common.block.container.ContainerExtractor; import mod.common.block.entity.TileEntityAnalyzer; import mod.common.block.entity.TileEntityCombiner; import mod.common.block.entity.TileEntityCouveuse; import mod.common.block.entity.TileEntityExtractor; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.BlockPos; import net.minecraft.world.World; import net.minecraftforge.fml.common.network.IGuiHandler; public class GuiHandler implements IGuiHandler { @Override public Object getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) { switch (ID) { case 0: TileEntity tile = world.getTileEntity(new BlockPos(x, y, z)); if(tile instanceof TileEntityAnalyzer) { return new ContainerAnalyzer((TileEntityAnalyzer)tile, player.inventory); } case 1: TileEntity tile1 = world.getTileEntity(new BlockPos(x, y, z)); if(tile1 instanceof TileEntityCouveuse) { return new ContainerCouveuse((TileEntityCouveuse)tile1, player.inventory); } case 2: TileEntity tile2 = world.getTileEntity(new BlockPos(x, y, z)); if(tile2 instanceof TileEntityExtractor) { return new ContainerExtractor((TileEntityExtractor)tile2, player.inventory); } case 3: TileEntity tile3 = world.getTileEntity(new BlockPos(x, y, z)); if(tile3 instanceof TileEntityCombiner) { return new ContainerCombiner((TileEntityCombiner)tile3, player.inventory); } } return null; } @Override public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) { switch (ID) { case 0: TileEntity tile = world.getTileEntity(new BlockPos(x, y, z)); if(tile instanceof TileEntityAnalyzer) { return new GuiAnalyzer((TileEntityAnalyzer)tile, player.inventory); } case 1: TileEntity tile1 = world.getTileEntity(new BlockPos(x, y, z)); if(tile1 instanceof TileEntityCouveuse) { return new GuiCouveuse((TileEntityCouveuse)tile1, player.inventory); } case 2: TileEntity tile2 = world.getTileEntity(new BlockPos(x, y, z)); if(tile2 instanceof TileEntityExtractor) { return new GuiExtractor((TileEntityExtractor)tile2, player.inventory); } case 3: TileEntity tile3 = world.getTileEntity(new BlockPos(x, y, z)); if(tile3 instanceof TileEntityCombiner) { return new GuiCombiner((TileEntityCombiner)tile3, player.inventory); } } return null; } }
^^^^^^^^^^ Nouveau GuiHandler ^^^^^^^^^^
-
Tu n’as pas besoin de l’implements ITileEntityProvider.
Envoie le code actuel de ton bloc. -
D’accord c’est enlevé , et voici le code actuel du coup
package mod.common.block; import java.awt.Image; import java.util.List; import java.util.Random; import javax.swing.Icon; import javax.swing.ImageIcon; import mod.DinoCraft; import mod.common.block.entity.TileEntityAnalyzer; import net.minecraft.block.Block; import net.minecraft.block.ITileEntityProvider; import net.minecraft.block.material.Material; import net.minecraft.block.properties.IProperty; import net.minecraft.block.properties.PropertyDirection; import net.minecraft.block.properties.PropertyEnum; import net.minecraft.block.state.BlockState; import net.minecraft.block.state.IBlockState; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.item.EntityItem; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.IInventory; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntityFurnace; import net.minecraft.util.BlockPos; import net.minecraft.util.EnumFacing; import net.minecraft.util.IStringSerializable; import net.minecraft.util.MathHelper; import net.minecraft.world.IBlockAccess; import net.minecraft.world.IInteractionObject; import net.minecraft.world.World; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; public class BlockAnalyzer extends Block { public BlockAnalyzer() { super(Material.rock); this.setResistance(8.0F); this.setHarvestLevel("pickaxe", 2); this.setCreativeTab(CreativeTabs.tabBlock); this.setUnlocalizedName("block_analyzer"); this.setDefaultState(this.blockState.getBaseState().withProperty(FACING, EnumFacing.NORTH)); } // FACING public static final PropertyDirection FACING = PropertyDirection.create("facing", EnumFacing.Plane.HORIZONTAL); 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); } } 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 TileEntityAnalyzer) { ((TileEntityAnalyzer)tileentity).setCustomInventoryName(stack.getDisplayName()); } } } public int getRenderType() { return 3; } /** * 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]; 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) { ; } } } // BLOCK public Item getItemDropped(IBlockState state, Random rand, int fortune) { return Item.getItemFromBlock(BlockRegister.BlockAnalyzer); } @Override public TileEntity createTileEntity(World world, IBlockState state) { if (hasTileEntity(state)) { return new TileEntityAnalyzer(); } return null; } @Override public boolean hasTileEntity(IBlockState state) { if (state.getBlock() == this) { return true; } return false; } @Override public void breakBlock(World world, BlockPos pos, IBlockState state) { TileEntity tileentity = world.getTileEntity(pos); if (tileentity instanceof IInventory) { IInventory inv = (IInventory) tileentity; for (int i1 = 0; i1 < inv.getSizeInventory(); ++i1) { ItemStack itemstack = inv.getStackInSlot(i1); if (itemstack != null) { float f = world.rand.nextFloat() * 0.8F + 0.1F; float f1 = world.rand.nextFloat() * 0.8F + 0.1F; EntityItem entityitem; for (float f2 = world.rand.nextFloat() * 0.8F + 0.1F; itemstack.stackSize > 0; world.spawnEntityInWorld(entityitem)) { int j1 = world.rand.nextInt(21) + 10; if (j1 > itemstack.stackSize) { j1 = itemstack.stackSize; } itemstack.stackSize -= j1; entityitem = new EntityItem(world, (double) ((float) pos.getX() + f), (double) ((float) pos.getY() + f1), (double) ((float) pos.getZ() + f2), new ItemStack(itemstack.getItem(), j1, itemstack.getItemDamage())); float f3 = 0.05F; entityitem.motionX = (double) ((float) world.rand.nextGaussian() * f3); entityitem.motionY = (double) ((float) world.rand.nextGaussian() * f3 + 0.2F); entityitem.motionZ = (double) ((float) world.rand.nextGaussian() * f3); if (itemstack.hasTagCompound()) { entityitem.getEntityItem().setTagCompound((NBTTagCompound) itemstack.getTagCompound().copy()); } } } } } super.breakBlock(world, pos, state); } public void onBlockPlacedBy(World world, BlockPos pos, EntityLivingBase living, ItemStack stack) { TileEntity tile = world.getTileEntity(pos); if(tile instanceof TileEntityAnalyzer) { if(stack.hasDisplayName()) { ((TileEntityAnalyzer)tile).setCustomName(stack.getDisplayName()); } } } @Override public boolean onBlockEventReceived(World worldIn, BlockPos pos, IBlockState state, int eventID, int eventParam) { super.onBlockEventReceived(worldIn, pos, state, eventID, eventParam); TileEntity tileentity = worldIn.getTileEntity(pos); return tileentity == null ? false : tileentity.receiveClientEvent(eventID, eventParam); } public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumFacing side, float hitX, float hitY, float hitZ) { int x = pos.getX(); int z = pos.getZ(); int y = pos.getY(); if(world.isRemote) { return true; } else { TileEntity tileentity = world.getTileEntity(pos); if (tileentity instanceof TileEntityAnalyzer) { player.openGui(DinoCraft.instance, 0, world, x, y, z); System.out.println("It works ?"); } return true; } } }
-
@Override public TileEntity createTileEntity(World world, IBlockState state) { if (hasTileEntity(state)) { return new TileEntityAnalyzer(); } return null; } @Override public boolean hasTileEntity(IBlockState state) { if (state.getBlock() == this) { return true; } return false; }
Tu as des conditions inutiles. Ceci est mieux :
@Override public TileEntity createTileEntity(World world, IBlockState state) { return new TileEntityAnalyzer(); } @Override public boolean hasTileEntity(IBlockState state) { return true; }
Par contre ça n’explique pas le problème. Ton gui handler est bien enregistré dans la classe principale ?
-
D’accord je vais changer ca
Oui dans mon Common Proxy , mais je pense qu’il dois pas être la en fait xD
public void init(FMLInitializationEvent e) { NetworkRegistry.INSTANCE.registerGuiHandler(DinoCraft.instance, new GuiHandler()); }
-
ça dépend si ton common proxy est exécuté côté client.
L’enregistrement du gui handler doit être côté client et serveur. -
Ahhh ca y est le gui s’affiche buggé , j’ai cru que c’était un bug de la texture mais non en fait la recette n’est pas enregistré j’ai l’impression Du coup le cookprocess est bizarre et la texture bug mais je ne sais pas comment et pourquoi le soucis arrive
Voici la classe de mes récipes ( encore merci à scarex )
La classeprincipale des Recipes de ma machine
package mod.common.recipes; import java.util.ArrayList; import java.util.Collections; import java.util.HashMap; import java.util.Iterator; import java.util.ListIterator; import mod.common.block.entity.TileEntityAnalyzer; import net.minecraft.item.ItemStack; public class AnalyzerRecipes { private static ArrayList <ianalyzerrecipe>recipes = new ArrayList<ianalyzerrecipe>(); /** * @param stacks tile content * @return the recipe output */ public static ItemStack getOutput(TileEntityAnalyzer tile, ItemStack … stacks) { ListIterator <ianalyzerrecipe>ite = recipes.listIterator(); while (ite.hasNext()) { IAnalyzerRecipe r = ite.next(); if (r.matches(tile, tile.getWorld())) return r.getOutput(tile, tile.getWorld()); } return null; } /** * @return the recipe map */ public static ArrayList <ianalyzerrecipe>getRecipes() { return recipes; } /** * init your recipes (called from your main class) */ public static void initRecipes() { AnalyzerRecipes.addRecipe(new AnalyzerSimpleRecipe()); AnalyzerRecipes.addRecipe(new AnalyzerFrogRecipe()); AnalyzerRecipes.addRecipe(new AnalyzerSimpleRecipe2()); } /** * @param recipe */ public static void addRecipe(IAnalyzerRecipe recipe) { recipes.add(recipe); } /** * @param stack first stack * @param stack1 second stack * @return true if the 2 stacks are equals */ public static boolean corresponds(ItemStack stack, ItemStack stack1) { if (stack == null && stack1 == null) return true; if (stack == null && stack1 != null) return false; if (stack != null && stack1 == null) return false; if (stack.getItem() != stack1.getItem()) return false; if (stack.getItemDamage() != stack1.getItemDamage()) return false; return true; } }
IAnalyzerRecipe
package mod.common.recipes; import mod.common.block.entity.TileEntityAnalyzer; import mod.common.block.entity.TileEntityCouveuse; import net.minecraft.item.ItemStack; import net.minecraft.world.World; public interface IAnalyzerRecipe { public boolean matches(TileEntityAnalyzer inv, World world); public ItemStack getOutput(TileEntityAnalyzer inv , World world); }
une recipe parmis les trois
package mod.common.recipes; import java.util.Random; import mod.common.block.BlockRegister; import mod.common.block.entity.TileEntityAnalyzer; import mod.common.item.ItemRegister; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.world.World; public class AnalyzerFrogRecipe implements IAnalyzerRecipe { public static final Item[] matrix = new Item[] { ItemRegister.itemSyringewithblood }; @Override public boolean matches(TileEntityAnalyzer tile, World world) { for (int i = 0; i < 1; i++) { if (!AnalyzerFrogRecipe.corresponds(AnalyzerFrogRecipe.matrix*, tile.getStackInSlot(i))) return false; } return true; } @Override public ItemStack getOutput(TileEntityAnalyzer tile, World world) { return new ItemStack(ItemRegister.itemADNofFrog); } public static boolean corresponds(Item item, ItemStack stack) { if (stack == null && item == null) return true; if (stack == null && item != null) return false; if (stack != null && item == null) return false; if (stack.getItem() != item) return false; return true; } }
TE analyzer
package mod.common.block.entity; import mod.common.recipes.AnalyzerRecipes; 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; import net.minecraftforge.fml.common.registry.GameRegistry; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; public class TileEntityAnalyzer extends TileEntity implements IInventory { private String customName; private ItemStack[] contents = new ItemStack[2]; private int workingTime = 1999; private int workingTimeNeeded = 256; @Override public void writeToNBT(NBTTagCompound compound) { super.writeToNBT(compound); NBTTagList nbttaglist = new NBTTagList(); for (int i = 0; i < this.contents.length; ++i) { 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); 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) { 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"); this.workingTimeNeeded = compound.getShort("workingTimeNeeded"); } @Override public int getSizeInventory() { return this.contents.length; } @Override public ItemStack getStackInSlot(int slotIndex) { return this.contents[slotIndex]; } @Override 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; } } @Override public ItemStack getStackInSlotOnClosing(int slotIndex) { if (this.contents[slotIndex] != null) { ItemStack itemstack = this.contents[slotIndex]; this.contents[slotIndex] = null; return itemstack; } else { return null; } } @Override public void setInventorySlotContents(int slotIndex, ItemStack stack) { this.contents[slotIndex] = stack; if (stack != null && stack.stackSize > this.getInventoryStackLimit()) { stack.stackSize = this.getInventoryStackLimit(); } this.markDirty(); } @Override public boolean isItemValidForSlot(int slot, ItemStack stack) { return slot == 1 ? false : true; } public boolean isBurning() { return this.workingTime > 0; } private boolean canSmelt() { if (this.contents[0] == null) { return false; } else { ItemStack itemstack = AnalyzerRecipes.getOutput(this); if (itemstack == null) return false; if (this.contents[1] == null) return true; if (!this.contents[1].isItemEqual(itemstack)) return false; int result = contents[1].stackSize + itemstack.stackSize; return result <= getInventoryStackLimit() && result <= this.contents[1].getMaxStackSize(); } } public static void init() { GameRegistry.registerTileEntity(TileEntityAnalyzer.class, "tile_entity_analyzer"); } public void updateEntity() { if (this.isBurning() && this.canSmelt()) { ++this.workingTime; } if (this.canSmelt() && !this.isBurning()) { this.workingTime = 1; } if (this.canSmelt() && this.workingTime == this.workingTimeNeeded) { this.smeltItem(); this.workingTime = 0; } if (!this.canSmelt()) { this.workingTime = 0; } } public void smeltItem() { if (this.canSmelt()) { ItemStack itemstack = AnalyzerRecipes.getOutput(this); if (this.contents[1] == null) { this.contents[1] = itemstack.copy(); } else if (this.contents[1].getItem() == itemstack.getItem()) { this.contents[1].stackSize += itemstack.stackSize; } –this.contents[0].stackSize; if (this.contents[0].stackSize <= 0) { this.contents[0] = null; } } } @SideOnly(Side.CLIENT) public int getCookProgress() { return this.workingTime * 40 / this.workingTimeNeeded; } @Override public String getName() { return "tile.BlockAnalyzer"; } @Override public boolean hasCustomName() { return false; } @Override public IChatComponent getDisplayName() { return null; } @Override public int getInventoryStackLimit() { return 64; } public void setCustomName(String customName) { this.customName = customName; } public void setCustomInventoryName(String displayName) { this.customName = displayName; } @Override public boolean isUseableByPlayer(EntityPlayer player) { return this.worldObj.getTileEntity(this.pos) != this ? false : player.getDistanceSq((double)this.getPos().getX() + 0.5D, (double)this.getPos().getY() + 0.5D, (double)this.getPos().getZ() + 0.5D) <= 64.0D; } @Override public void openInventory(EntityPlayer player) {} @Override public void closeInventory(EntityPlayer player) {} @Override public int getField(int id) { switch (id) { case 0: return this.workingTime; case 1: return this.workingTimeNeeded; default: return 0; } } @Override public void setField(int id, int value) { switch (id) { case 0: this.workingTime = value; break; case 1: this.workingTimeNeeded = value; } } @Override public int getFieldCount() { return 2; } @Override public void clear() { for (int i = 0; i < this.contents.length; ++i) { this.contents* = null; } } }
L’enregistrement dans le init
AnalyzerRecipes.initRecipes();
Mais je ne vois pas du tout pourquoi ca ne marche pas :/</ianalyzerrecipe></ianalyzerrecipe></ianalyzerrecipe></ianalyzerrecipe>
-
Je ne sais pas si c’est voulu mais ton working time est a 1999 et le working time needed a 256.
-
Ah oui c’est voulu ^^ La si je met l’item dans le slot d’input rien ne ce passe comme si la recette n’était pas reconnue :s
-
Rajoute des logs pour voir si le problème vient du manager ou de la tileEntity
-
C’est bien ca les logs
[13:26:22] [main/INFO] [GradleStart]: username: ******** [13:26:22] [main/INFO] [GradleStart]: Extra: [] [13:26:22] [main/INFO] [GradleStart]: Password found, attempting login [13:26:23] [main/INFO]: Logging in with username & password [13:26:23] [main/INFO] [GradleStart]: Login Succesful! [13:26:23] [main/INFO] [GradleStart]: Running with arguments: [–userProperties, [], –assetsDir, C:/Users/Legra/.gradle/caches/minecraft/assets, --assetIndex, 1.8, --userType, mojang, --accessToken, {REDACTED}, --version, 1.8, --uuid, 1180fda0fbd64eaaa86161fd3910f6fc, --username, Legrandfifou, --tweakClass, net.minecraftforge.fml.common.launcher.FMLTweaker, --tweakClass, net.minecraftforge.gradle.tweakers.CoremodTweaker] [13:26:24] [main/INFO] [LaunchWrapper]: Loading tweak class name net.minecraftforge.fml.common.launcher.FMLTweaker [13:26:24] [main/INFO] [LaunchWrapper]: Using primary tweak class name net.minecraftforge.fml.common.launcher.FMLTweaker [13:26:24] [main/INFO] [LaunchWrapper]: Loading tweak class name net.minecraftforge.gradle.tweakers.CoremodTweaker [13:26:24] [main/INFO] [LaunchWrapper]: Calling tweak class net.minecraftforge.fml.common.launcher.FMLTweaker [13:26:24] [main/INFO] [FML]: Forge Mod Loader version 8.99.124.1450 for Minecraft 1.8 loading [13:26:24] [main/INFO] [FML]: Java is Java HotSpot(TM) 64-Bit Server VM, version 1.8.0_60, running on Windows 10:amd64:10.0, installed at C:\Program Files\Java\jre1.8.0_60 [13:26:24] [main/INFO] [FML]: Managed to load a deobfuscated Minecraft name- we are in a deobfuscated environment. Skipping runtime deobfuscation [13:26:24] [main/INFO] [LaunchWrapper]: Calling tweak class net.minecraftforge.gradle.tweakers.CoremodTweaker [13:26:24] [main/INFO] [GradleStart]: Injecting location in coremod net.minecraftforge.fml.relauncher.FMLCorePlugin [13:26:24] [main/INFO] [GradleStart]: Injecting location in coremod net.minecraftforge.classloading.FMLForgePlugin [13:26:24] [main/INFO] [LaunchWrapper]: Loading tweak class name net.minecraftforge.fml.common.launcher.FMLInjectionAndSortingTweaker [13:26:24] [main/INFO] [LaunchWrapper]: Loading tweak class name net.minecraftforge.fml.common.launcher.FMLDeobfTweaker [13:26:24] [main/INFO] [LaunchWrapper]: Loading tweak class name net.minecraftforge.gradle.tweakers.AccessTransformerTweaker [13:26:24] [main/INFO] [LaunchWrapper]: Calling tweak class net.minecraftforge.fml.common.launcher.FMLInjectionAndSortingTweaker [13:26:24] [main/INFO] [LaunchWrapper]: Calling tweak class net.minecraftforge.fml.common.launcher.FMLInjectionAndSortingTweaker [13:26:24] [main/INFO] [LaunchWrapper]: Calling tweak class net.minecraftforge.fml.relauncher.CoreModManager$FMLPluginWrapper [13:26:24] [main/ERROR] [FML]: The binary patch set is missing. Either you are in a development environment, or things are not going to work! [13:26:25] [main/ERROR] [FML]: FML appears to be missing any signature data. This is not a good thing [13:26:25] [main/INFO] [LaunchWrapper]: Calling tweak class net.minecraftforge.fml.relauncher.CoreModManager$FMLPluginWrapper [13:26:25] [main/INFO] [LaunchWrapper]: Calling tweak class net.minecraftforge.fml.common.launcher.FMLDeobfTweaker [13:26:25] [main/INFO] [LaunchWrapper]: Calling tweak class net.minecraftforge.gradle.tweakers.AccessTransformerTweaker [13:26:25] [main/INFO] [LaunchWrapper]: Loading tweak class name net.minecraftforge.fml.common.launcher.TerminalTweaker [13:26:25] [main/INFO] [LaunchWrapper]: Calling tweak class net.minecraftforge.fml.common.launcher.TerminalTweaker [13:26:25] [main/INFO] [LaunchWrapper]: Launching wrapped minecraft {net.minecraft.client.main.Main} [13:26:26] [Client thread/INFO]: Setting user: Legrandfifou [13:26:28] [Client thread/INFO]: LWJGL Version: 2.9.1 [13:26:28] [Client thread/INFO] [STDOUT]: [net.minecraftforge.fml.client.SplashProgress:start:235]: –-- Minecraft Crash Report ---- // Surprise! Haha. Well, this is awkward. Time: 11/10/15 13:26 Description: Loading screen debug info This is just a prompt for computer specs to be printed. THIS IS NOT A ERROR A detailed walkthrough of the error, its code path and all known details is as follows: --------------------------------------------------------------------------------------- -- System Details -- Details: Minecraft Version: 1.8 Operating System: Windows 10 (amd64) version 10.0 Java Version: 1.8.0_60, Oracle Corporation Java VM Version: Java HotSpot(TM) 64-Bit Server VM (mixed mode), Oracle Corporation Memory: 747285152 bytes (712 MB) / 1037959168 bytes (989 MB) up to 1037959168 bytes (989 MB) JVM Flags: 3 total; -Xincgc -Xmx1024M -Xms1024M IntCache: cache: 0, tcache: 0, allocated: 0, tallocated: 0 FML: Loaded coremods (and transformers): GL info: ' Vendor: 'NVIDIA Corporation' Version: '4.5.0 NVIDIA 358.50' Renderer: 'GeForce GTX 770/PCIe/SSE2' [13:26:28] [Client thread/INFO] [MinecraftForge]: Attempting early MinecraftForge initialization [13:26:28] [Client thread/INFO] [FML]: MinecraftForge v11.14.3.1450 Initialized [13:26:28] [Client thread/INFO] [FML]: Replaced 204 ore recipies [13:26:28] [Client thread/INFO] [MinecraftForge]: Completed early MinecraftForge initialization [13:26:28] [Client thread/INFO] [FML]: Found 0 mods from the command line. Injecting into mod discoverer [13:26:28] [Client thread/INFO] [FML]: Searching C:\Users\Legra\Documents\forge1.8\eclipse\mods for mods [13:26:30] [Client thread/INFO] [FML]: Forge Mod Loader has identified 4 mods to load [13:26:30] [Client thread/INFO] [FML]: Attempting connection with missing mods [mcp, FML, Forge, dinocraft] at CLIENT [13:26:30] [Client thread/INFO] [FML]: Attempting connection with missing mods [mcp, FML, Forge, dinocraft] at SERVER [13:26:31] [Client thread/INFO]: Reloading ResourceManager: Default, FMLFileResourcePack:Forge Mod Loader, FMLFileResourcePack:Minecraft Forge, FMLFileResourcePack:DinoCraft [13:26:31] [Client thread/INFO] [FML]: Processing ObjectHolder annotations [13:26:31] [Client thread/INFO] [FML]: Found 384 ObjectHolder annotations [13:26:31] [Client thread/INFO] [FML]: Identifying ItemStackHolder annotations [13:26:31] [Client thread/INFO] [FML]: Found 0 ItemStackHolder annotations [13:26:31] [Client thread/INFO] [FML]: Configured a dormant chunk cache size of 0 [13:26:31] [Client thread/INFO] [FML]: Applying holder lookups [13:26:31] [Client thread/INFO] [FML]: Holder lookups applied [13:26:31] [Client thread/INFO] [FML]: Injecting itemstacks [13:26:31] [Client thread/INFO] [FML]: Itemstack injection complete [13:26:31] [Sound Library Loader/INFO]: Starting up SoundSystem… [13:26:32] [Thread-9/INFO]: Initializing LWJGL OpenAL [13:26:32] [Thread-9/INFO]: (The LWJGL binding of OpenAL. For more information, see http://www.lwjgl.org) [13:26:32] [Thread-9/INFO]: OpenAL initialized. [13:26:32] [Sound Library Loader/INFO]: Sound engine started [13:26:43] [Client thread/INFO]: Created: 512x512 textures-atlas [13:26:44] [Client thread/INFO] [STDOUT]: [mod.client.ClientProxy:register:53]: Rendering Entity/TileEntity [13:26:44] [Client thread/INFO] [STDOUT]: [mod.client.ClientProxy:register:68]: Rendering Items [13:26:44] [Client thread/INFO] [STDOUT]: [mod.client.ClientProxy:register:91]: Rendering Special Blocks [13:26:44] [Client thread/INFO] [FML]: Injecting itemstacks [13:26:44] [Client thread/INFO] [FML]: Itemstack injection complete [13:26:44] [Client thread/INFO] [FML]: Forge Mod Loader has successfully loaded 4 mods [13:26:44] [Client thread/INFO]: Reloading ResourceManager: Default, FMLFileResourcePack:Forge Mod Loader, FMLFileResourcePack:Minecraft Forge, FMLFileResourcePack:DinoCraft [13:26:44] [Client thread/INFO]: SoundSystem shutting down… [13:26:44] [Client thread/WARN]: Author: Paul Lamb, www.paulscode.com [13:26:44] [Sound Library Loader/INFO]: Starting up SoundSystem… [13:26:45] [Thread-11/INFO]: Initializing LWJGL OpenAL [13:26:45] [Thread-11/INFO]: (The LWJGL binding of OpenAL. For more information, see http://www.lwjgl.org) [13:26:45] [Thread-11/INFO]: OpenAL initialized. [13:26:45] [Sound Library Loader/INFO]: Sound engine started [13:26:46] [Client thread/INFO]: Created: 512x512 textures-atlas [13:28:22] [Server thread/INFO]: Starting integrated minecraft server version 1.8 [13:28:22] [Server thread/INFO]: Generating keypair [13:28:22] [Server thread/INFO] [FML]: Injecting existing block and item data into this server instance [13:28:22] [Server thread/INFO] [FML]: Applying holder lookups [13:28:22] [Server thread/INFO] [FML]: Holder lookups applied [13:28:22] [Server thread/INFO] [FML]: Loading dimension 0 (New World) (net.minecraft.server.integrated.IntegratedServer@2c60a005) [13:28:22] [Server thread/INFO] [FML]: Loading dimension 2 (New World) (net.minecraft.server.integrated.IntegratedServer@2c60a005) [13:28:22] [Server thread/INFO] [FML]: Loading dimension 1 (New World) (net.minecraft.server.integrated.IntegratedServer@2c60a005) [13:28:22] [Server thread/INFO] [FML]: Loading dimension -1 (New World) (net.minecraft.server.integrated.IntegratedServer@2c60a005) [13:28:22] [Server thread/INFO]: Preparing start region for level 0 [13:28:23] [Server thread/INFO]: Changing view distance to 12, from 10 [13:28:24] [Netty Local Client IO #0/INFO] [FML]: Server protocol version 2 [13:28:24] [Netty Server IO #1/INFO] [FML]: Client protocol version 2 [13:28:24] [Netty Server IO #1/INFO] [FML]: Client attempting to join with 4 mods : FML@8.0.99.99,Forge@11.14.3.1450,mcp@9.05,dinocraft@1.0 [13:28:24] [Netty Local Client IO #0/INFO] [FML]: [Netty Local Client IO #0] Client side modded connection established [13:28:24] [Server thread/INFO] [FML]: [Server thread] Server side modded connection established [13:28:24] [Server thread/INFO]: Legrandfifou[local:E:b5619dbe] logged in with entity id 341 at (-237.14529998748984, 73.0, 231.32560471922244) [13:28:24] [Server thread/INFO]: Legrandfifou joined the game [13:28:26] [Server thread/INFO] [STDOUT]: [mod.common.block.BlockAnalyzer:onBlockActivated:312]: It works ?
??
-
Oui mais il faut rajouter des System.out.println pour que quelque chose s’affiche. rajoutes en un peu partout pour savoir d’où vient le problème