Résolu Code 1.8 qui fait crash en 1.10
-
Bonsoir,
J’ai quelques problème avec mon mod 1.10.
Je vous explique:
J’ai un item panier à linge qui permet de stocker du linge sauf que quand je clique droit pour ouvrir le panier à linge avec l’item mon jeu crash:
java.lang.NullPointerException at com.CSC.net.GUI.InventoryLinge.<init>(InventoryLinge.java:22) ~[InventoryLinge.class:?] at com.CSC.net.GUI.GuiHandler.getClientGuiElement(GuiHandler.java:76) ~[GuiHandler.class:?] at net.minecraftforge.fml.common.network.NetworkRegistry.getLocalGuiContainer(NetworkRegistry.java:273) ~[NetworkRegistry.class:?] at net.minecraftforge.fml.common.network.internal.FMLNetworkHandler.openGui(FMLNetworkHandler.java:110) ~[FMLNetworkHandler.class:?] at net.minecraft.entity.player.EntityPlayer.openGui(EntityPlayer.java:2723) ~[EntityPlayer.class:?] at com.CSC.net.item.panierlinger.onItemRightClick(panierlinger.java:25) ~[panierlinger.class:?] at net.minecraft.item.ItemStack.useItemRightClick(ItemStack.java:176) ~[ItemStack.class:?] at net.minecraft.client.multiplayer.PlayerControllerMP.processRightClick(PlayerControllerMP.java:527) ~[PlayerControllerMP.class:?] at net.minecraft.client.Minecraft.rightClickMouse(Minecraft.java:1629) ~[Minecraft.class:?] at net.minecraft.client.Minecraft.processKeyBinds(Minecraft.java:2281) ~[Minecraft.class:?] at net.minecraft.client.Minecraft.runTickKeyboard(Minecraft.java:2058) ~[Minecraft.class:?] at net.minecraft.client.Minecraft.runTick(Minecraft.java:1846) ~[Minecraft.class:?] at net.minecraft.client.Minecraft.runGameLoop(Minecraft.java:1118) ~[Minecraft.class:?] at net.minecraft.client.Minecraft.run(Minecraft.java:406) [Minecraft.class:?] at net.minecraft.client.main.Main.main(Main.java:118) [Main.class:?] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_45] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_45] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_45] at java.lang.reflect.Method.invoke(Method.java:497) ~[?:1.8.0_45] at net.minecraft.launchwrapper.Launch.launch(Launch.java:135) [launchwrapper-1.12.jar:?] at net.minecraft.launchwrapper.Launch.main(Launch.java:28) [launchwrapper-1.12.jar:?] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_45] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_45] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_45] at java.lang.reflect.Method.invoke(Method.java:497) ~[?:1.8.0_45] at net.minecraftforge.gradle.GradleStartCommon.launch(GradleStartCommon.java:97) [start/:?] at GradleStart.main(GradleStart.java:26) [start/:?] [20:01:39] [Client thread/INFO] [STDOUT]: [net.minecraft.init.Bootstrap:printToSYSOUT:649]: –-- Minecraft Crash Report ---- // I just don't know what went wrong :( Time: 10/12/16 20:01 Description: Unexpected error
InventoryLinge:
package com.CSC.net.GUI; import com.CSC.net.item.panierlinger; 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.util.text.ITextComponent; import net.minecraftforge.common.util.Constants; public class InventoryLinge implements IInventory { public ItemStack[] content;[/font] public int size; public InventoryLinge(ItemStack container, int size) { this.size = size; this.content = new ItemStack; if(!container.hasTagCompound()) // crash ici container.setTagCompound(new NBTTagCompound()); this.readFromNBT(container.getTagCompound()); } /** * This methods reads the content of the NBTTagCompound inside the container * * @param comp * the container NBTTagCompound */ public void readFromNBT(NBTTagCompound comp) { NBTTagList nbtlist = comp.getTagList("Inventory", Constants.NBT.TAG_COMPOUND); for(int i = 0; i < nbtlist.tagCount(); i++) { NBTTagCompound comp1 = nbtlist.getCompoundTagAt(i); int slot = comp1.getInteger("Slot"); this.content[slot] = ItemStack.loadItemStackFromNBT(comp1); } } /** * This methods saves the content inside the container * * @param comp * the NBTTagCompound to write in */ public void writeToNBT(NBTTagCompound comp) { NBTTagList nbtlist = new NBTTagList(); for(int i = 0; i < this.size; i++) { if(this.content* != null) { NBTTagCompound comp1 = new NBTTagCompound(); comp1.setInteger("Slot", i); this.content*.writeToNBT(comp1); nbtlist.appendTag(comp1); } } comp.setTag("Inventory", nbtlist); } @Override public int getSizeInventory() { return this.size; } @Override public ItemStack getStackInSlot(int index) { return this.content[index]; } @Override public ItemStack decrStackSize(int index, int amount) { ItemStack stack = getStackInSlot(index); if(stack != null) { if(stack.stackSize > amount) { stack = stack.splitStack(amount); if(stack.stackSize == 0) this.content[index] = null; } else { this.content[index] = null; } } return stack; } @Override public ItemStack removeStackFromSlot(int index) { ItemStack stack = getStackInSlot(index); if(stack != null) this.content[index] = null; return stack; } @Override public void setInventorySlotContents(int index, ItemStack stack) { this.content[index] = stack; } @Override public int getInventoryStackLimit() { return 64; } @Override public void markDirty() {} @Override public boolean isItemValidForSlot(int index, ItemStack stack) { return !(stack.getItem() instanceof panierlinger); } @Override public String getName() { // TODO Auto-generated method stub return "amm" + ".container.backpack"; } @Override public boolean hasCustomName() { return false; } @Override public ITextComponent 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 } }
Aussi avec quelques Container que j’ai modifier mais bon ça crash.
Je vous passe mon ancienne classe (1.8):
%(#000000)[package com.CSC.net.GUI; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.inventory.Container; import net.minecraft.inventory.ICrafting; import net.minecraft.inventory.Slot; import net.minecraft.item.ItemStack; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; import com.CSC.net.block.TileEntitySecheLinge; public class ContainerSecheLinge extends Container { private TileEntitySecheLinge tile; private int currentWorkingTime; private int totalWorkingTime; private int remainingFuelTime; public ContainerSecheLinge(TileEntitySecheLinge tile, InventoryPlayer inventory) { this.tile = tile; // INPUTS this.addSlotToContainer(new Slotlingemouiller(tile, 0, 21, 0)); this.addSlotToContainer(new Slotlingemouiller(tile, 1, 45, 0)); this.addSlotToContainer(new Slotlingemouiller(tile, 2, 69, 0)); this.addSlotToContainer(new Slotlingemouiller(tile, 3, 93, 0)); // FUEL this.addSlotToContainer(new Slotlingette(tile, 4, 21, 34)); // OUTPUTS this.addSlotToContainer(new SlotOutput(tile, 5, 149, 0)); this.addSlotToContainer(new SlotOutput(tile, 6, 149, 25)); this.addSlotToContainer(new SlotOutput(tile, 7, 149, 49)); this.addSlotToContainer(new SlotOutput(tile, 8, 149, 74)); this.bindPlayerInventory(inventory); } private void bindPlayerInventory(InventoryPlayer inventory) { int i; int j; for(i = 0; i < 3; ++i) { for(j = 0; j < 9; ++j) { this.addSlotToContainer(new Slot(inventory, j + i * 9 + 9, 8 + j * 18, 84 + i * 18 + 12)); } } for(i = 0; i < 9; ++i) { this.addSlotToContainer(new Slot(inventory, i, 8 + i * 18, 142 + 12)); } } @Override public ItemStack transferStackInSlot(EntityPlayer player, int quantity) { ItemStack itemstack = null; Slot slot = (Slot)this.inventorySlots.get(quantity); if(slot != null && slot.getHasStack()) { ItemStack itemstack1 = slot.getStack(); itemstack = itemstack1.copy(); if(quantity < this.tile.getSizeInventory()) { if(!this.mergeItemStack(itemstack1, this.tile.getSizeInventory(), this.inventorySlots.size(), true)) { return null; } } else if(!this.mergeItemStack(itemstack1, 0, this.tile.getSizeInventory(), false)) { return null; } if(itemstack1.stackSize == 0) { slot.putStack((ItemStack)null); } else { slot.onSlotChanged(); } } return itemstack; } @Override public boolean canInteractWith(EntityPlayer player) { return this.tile.isUseableByPlayer(player); } @Override public void onContainerClosed(EntityPlayer player) { super.onContainerClosed(player); this.tile.closeInventory(player); } @Override public void onCraftGuiOpened(ICrafting crafting) { super.onCraftGuiOpened(crafting); for(int i = 0; i < this.tile.getFieldCount(); i++) { crafting.sendProgressBarUpdate(this, i, this.tile.getField(i)); } crafting.sendAllWindowProperties(this, this.tile); } @Override public void detectAndSendChanges() { super.detectAndSendChanges(); for(int i = 0; i < this.crafters.size(); ++i) { ICrafting icrafting = (ICrafting)this.crafters.get(i); for(int j = 0; j < this.tile.getFieldCount(); j++) { if(this.getField(j) != this.tile.getField(j)) { icrafting.sendProgressBarUpdate(this, j, this.tile.getField(j)); } } } for(int i = 0; i < this.tile.getFieldCount(); i++) { this.setField(i, this.tile.getField(i)); } } @Override @SideOnly(Side.CLIENT) public void updateProgressBar(int id, int value) { this.tile.setField(id, value); } private int getField(int id) { switch(id) { case 0: return this.currentWorkingTime; case 1: return this.totalWorkingTime; case 2: return this.remainingFuelTime; default: return 0; } } private void setField(int id, int value) { switch(id) { case 0: this.currentWorkingTime = value; break; case 1: this.totalWorkingTime = value; break; case 2: this.remainingFuelTime = value; } } }]
Et ma nouvelle classe:
package com.CSC.net.GUI; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.inventory.Container; import net.minecraft.inventory.IContainerListener; import net.minecraft.inventory.IInventory; import net.minecraft.inventory.InventoryCrafting; import net.minecraft.inventory.Slot; import net.minecraft.item.ItemStack; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; import com.CSC.net.block.TileEntitySecheLinge; public class ContainerSecheLinge extends Container { private TileEntitySecheLinge tile; private int currentWorkingTime; private int totalWorkingTime; private int remainingFuelTime; public ContainerSecheLinge(TileEntitySecheLinge tile, InventoryPlayer inventory) { this.tile = tile; // INPUTS this.addSlotToContainer(new Slotlingemouiller(tile, 0, 21, 0)); this.addSlotToContainer(new Slotlingemouiller(tile, 1, 45, 0)); this.addSlotToContainer(new Slotlingemouiller(tile, 2, 69, 0)); this.addSlotToContainer(new Slotlingemouiller(tile, 3, 93, 0)); // FUEL this.addSlotToContainer(new Slotlingette(tile, 4, 21, 34)); // OUTPUTS this.addSlotToContainer(new SlotOutput(tile, 5, 149, 0)); this.addSlotToContainer(new SlotOutput(tile, 6, 149, 25)); this.addSlotToContainer(new SlotOutput(tile, 7, 149, 49)); this.addSlotToContainer(new SlotOutput(tile, 8, 149, 74)); this.bindPlayerInventory(inventory); } private void bindPlayerInventory(InventoryPlayer inventory) { int i; int j; for(i = 0; i < 3; ++i) { for(j = 0; j < 9; ++j) { this.addSlotToContainer(new Slot(inventory, j + i * 9 + 9, 8 + j * 18, 84 + i * 18 + 12)); } } for(i = 0; i < 9; ++i) { this.addSlotToContainer(new Slot(inventory, i, 8 + i * 18, 142 + 12)); } } @Override public ItemStack transferStackInSlot(EntityPlayer player, int quantity) { ItemStack itemstack = null; Slot slot = (Slot)this.inventorySlots.get(quantity); if(slot != null && slot.getHasStack()) { ItemStack itemstack1 = slot.getStack(); itemstack = itemstack1.copy(); if(quantity < this.tile.getSizeInventory()) { if(!this.mergeItemStack(itemstack1, this.tile.getSizeInventory(), this.inventorySlots.size(), true)) { return null; } } else if(!this.mergeItemStack(itemstack1, 0, this.tile.getSizeInventory(), false)) { return null; } if(itemstack1.stackSize == 0) { slot.putStack((ItemStack)null); } else { slot.onSlotChanged(); } } return itemstack; } @Override public boolean canInteractWith(EntityPlayer player) { return this.tile.isUseableByPlayer(player); } @Override public void onContainerClosed(EntityPlayer player) { super.onContainerClosed(player); this.tile.closeInventory(player); } // @Override // public void onCraftGuiOpened(InventoryCrafting crafting) // { // super.onCraftGuiOpened(crafting); // for(int i = 0; i < this.tile.getFieldCount(); i++) // { // crafting.sendProgressBarUpdate(this, i, this.tile.getField(i)); // } // crafting.sendAllWindowProperties(this, this.tile); // } public void onCraftMatrixChanged(IInventory inventoryIn) { this.detectAndSendChanges(); } @Override public void detectAndSendChanges() { super.detectAndSendChanges(); for(int i = 0; i < this.listeners.size(); ++i) { ItemStack itemstack1 = (ItemStack)this.inventoryItemStacks.get(i); InventoryCrafting icrafting = (InventoryCrafting)this.listeners.get(i); // prob ici for(int j = 0; j < this.tile.getFieldCount(); j++) { if(this.getField(j) != this.tile.getField(j)) { ((IContainerListener)this.listeners.get(j)).sendSlotContents(this, j, itemstack1); } } } for(int i = 0; i < this.tile.getFieldCount(); i++) { this.setField(i, this.tile.getField(i)); } } @Override @SideOnly(Side.CLIENT) public void updateProgressBar(int id, int value) { this.tile.setField(id, value); } private int getField(int id) { switch(id) { case 0: return this.currentWorkingTime; case 1: return this.totalWorkingTime; case 2: return this.remainingFuelTime; default: return 0; } } private void setField(int id, int value) { switch(id) { case 0: this.currentWorkingTime = value; break; case 1: this.totalWorkingTime = value; break; case 2: this.remainingFuelTime = value; } } }
Je crois que c’est tout si j’ai d’autres problème je reviens vers vous.</init>
-
Salut,
Je ne vois aucune référence à ton container dans le crash.En revanche dans le stack trace il y a le gui handler :
at com.CSC.net.GUI.GuiHandler.getClientGuiElement(GuiHandler.java:76) ~[GuiHandler.class:?]Tu peux nous passer cette classe ?
-
@‘robin4002’:
Salut,
Je ne vois aucune référence à ton container dans le crash.En revanche dans le stack trace il y a le gui handler :
at com.CSC.net.GUI.GuiHandler.getClientGuiElement(GuiHandler.java:76) ~[GuiHandler.class:?]Tu peux nous passer cette classe ?
Tien:
package com.CSC.net.GUI; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; import net.minecraftforge.fml.common.network.IGuiHandler; import com.CSC.net.block.TileEntityCuve; import com.CSC.net.block.TileEntityMachineLaver; import com.CSC.net.block.TileEntitySecheLinge; public class GuiHandler implements IGuiHandler { public static EntityPlayer currentTarget; @Override public Object getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) { if(ID == 0) { return new ContainerLinge(player.inventory, new InventoryLinge(player.getHeldItemOffhand(), 54)); } if(ID == 1) { return new ContainerPlayerCustom(currentTarget.inventory, world.isRemote, currentTarget); } if(ID == 2) { TileEntity tile = world.getTileEntity(new BlockPos(x, y, z)); if(tile instanceof TileEntitySecheLinge) { return new ContainerSecheLinge((TileEntitySecheLinge)tile, player.inventory); } } if(ID == 3) { return new ContainerColi(player.inventory, new InventoryColi(player.getHeldItemOffhand(), 54)); } if(ID == 4) { TileEntity te = world.getTileEntity(new BlockPos(x, y, z)); if(te instanceof TileEntityCuve) { return new ContainerCuve(player.inventory, (TileEntityCuve)te); } return null; } if(ID == 5) { TileEntity tile = world.getTileEntity(new BlockPos(x, y, z)); if(tile instanceof TileEntityMachineLaver) { return new ContainerMachineLaver((TileEntityMachineLaver)tile, player.inventory); } } if(ID == 6) { return null; } if(ID == 7) { return null; } return null; } @Override public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) { if(ID == 0) { return new GuiLinge(player.inventory, new InventoryLinge(player.getHeldItemOffhand(), 54)); } if(ID == 1) { return new GuiInv(currentTarget); } if(ID == 2) { TileEntity tile = world.getTileEntity(new BlockPos(x, y, z)); if(tile instanceof TileEntitySecheLinge) { return new GuiSecheLinge((TileEntitySecheLinge)tile, player.inventory); } } if(ID == 3) { return new GuiColi(player.inventory, new InventoryColi(player.getHeldItemOffhand(), 54)); } if(ID == 4) { TileEntity te = world.getTileEntity(new BlockPos(x, y, z)); if(te instanceof TileEntityCuve) { return new GuiCuve(player.inventory, (TileEntityCuve)te); } return null; } if(ID == 5) { TileEntity tile = world.getTileEntity(new BlockPos(x, y, z)); if(tile instanceof TileEntityMachineLaver) { return new GuiMachineLaver((TileEntityMachineLaver)tile, player.inventory); } } if(ID == 6) { return new Prison(); } if(ID == 7) { return new QuestionGui1(); } return null; } }
Du coup les problèmes viennent de cette classe ?
-
player.getHeldItemOffhand est surement null.
Mets la valeur de x sur 0 si le joueur à l’item dans la main droite, sur 1 si c’est la main gauche dans l’item.
Et ensuite faire une condition en fonction de la valeur de x dans le gui handler. -
@‘robin4002’:
player.getHeldItemOffhand est surement null.
Mets la valeur de x sur 0 si le joueur à l’item dans la main droite, sur 1 si c’est la main gauche dans l’item.
Et ensuite faire une condition en fonction de la valeur de x dans le gui handler.J’ai fais ça:
J’ai pas compris pour la condition en fonction de la valeur de x.
package com.CSC.net.GUI; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.EnumHand; import net.minecraft.util.EnumHandSide; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; import net.minecraftforge.fml.common.network.IGuiHandler; import com.CSC.net.block.TileEntityCuve; import com.CSC.net.block.TileEntityMachineLaver; import com.CSC.net.block.TileEntitySecheLinge; public class GuiHandler implements IGuiHandler { public static EntityPlayer currentTarget; @Override public Object getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) { if(ID == 0) { return new ContainerLinge(player.inventory, new InventoryLinge(player.getHeldItemOffhand(), 54)); } if(ID == 1) { return new ContainerPlayerCustom(currentTarget.inventory, world.isRemote, currentTarget); } if(ID == 2) { TileEntity tile = world.getTileEntity(new BlockPos(x, y, z)); if(tile instanceof TileEntitySecheLinge) { return new ContainerSecheLinge((TileEntitySecheLinge)tile, player.inventory); } } if(ID == 3) { return new ContainerColi(player.inventory, new InventoryColi(player.getHeldItemOffhand(), 54)); } if(ID == 4) { TileEntity te = world.getTileEntity(new BlockPos(x, y, z)); if(te instanceof TileEntityCuve) { return new ContainerCuve(player.inventory, (TileEntityCuve)te); } return null; } if(ID == 5) { TileEntity tile = world.getTileEntity(new BlockPos(x, y, z)); if(tile instanceof TileEntityMachineLaver) { return new ContainerMachineLaver((TileEntityMachineLaver)tile, player.inventory); } } if(ID == 6) { return null; } if(ID == 7) { return null; } return null; } @Override public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) { EnumHandSide side = player.getPrimaryHand(); EnumHand hand = getHandForSide(side, player); if(hand == EnumHand.MAIN_HAND) { x = 0; System.out.println(x); } else { x = 1; System.out.println(x); } if(ID == 0) { return new GuiLinge(player.inventory, new InventoryLinge(player.getHeldItemOffhand(), 54)); } if(ID == 1) { return new GuiInv(currentTarget); } if(ID == 2) { TileEntity tile = world.getTileEntity(new BlockPos(x, y, z)); if(tile instanceof TileEntitySecheLinge) { return new GuiSecheLinge((TileEntitySecheLinge)tile, player.inventory); } } if(ID == 3) { return new GuiColi(player.inventory, new InventoryColi(player.getHeldItemOffhand(), 54)); } if(ID == 4) { TileEntity te = world.getTileEntity(new BlockPos(x, y, z)); if(te instanceof TileEntityCuve) { return new GuiCuve(player.inventory, (TileEntityCuve)te); } return null; } if(ID == 5) { TileEntity tile = world.getTileEntity(new BlockPos(x, y, z)); if(tile instanceof TileEntityMachineLaver) { return new GuiMachineLaver((TileEntityMachineLaver)tile, player.inventory); } } if(ID == 6) { return new Prison(); } if(ID == 7) { return new QuestionGui1(); } return null; } public static EnumHand getHandForSide(EnumHandSide side, EntityLivingBase entity) { return side == entity.getPrimaryHand() ? EnumHand.MAIN_HAND : EnumHand.OFF_HAND; } }
-
Reviens en arrière, tu as en effet pas du tout compris.
Dans ton item tu as surement une fonction comme celle-ci :
public ActionResult <itemstack>onItemRightClick(World world, EntityPlayer player, EnumHand hand) { player.openGui(ClassePrincipale.instance, 0, world, 0, 0, 0); // instance, id, world, x, y, z return new ActionResult(EnumActionResult.PASS, player.getHeldItem(hand)); }
Remplaces par :
public ActionResult <itemstack>onItemRightClick(World world, EntityPlayer player, EnumHand hand) { if(hand == EnumHand.MAIN_HAND) // main principale { player.openGui(ClassePrincipale.instance, 0, world, 0, 0, 0); // instance, id, world, x, y, z } else // seconde main { player.openGui(ClassePrincipale.instance, 0, world, 1, 0, 0); // instance, id, world, x, y, z } return new ActionResult(EnumActionResult.PASS, player.getHeldItem(hand)); }
ou en plus compact :
public ActionResult <itemstack>onItemRightClick(World world, EntityPlayer player, EnumHand hand) { player.openGui(ClassePrincipale.instance, 0, world, hand == EnumHand.MAIN_HAND ? 0 : 1, 0, 0); // instance, id, world, x, y, z return new ActionResult(EnumActionResult.PASS, player.getHeldItem(hand)); }
Et ensuite dans ton gui handler :
@Override public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) { if(ID == 0) { if(x == 0) { return new GuiLinge(player.inventory, new InventoryLinge(player.getHeldItemMainhand(), 54)); // 0 donc main principale } else { return new GuiLinge(player.inventory, new InventoryLinge(player.getHeldItemOffhand(), 54)); // 1 donc seconde main } } …. ```</itemstack></itemstack></itemstack>
-
Ah ouais j’avais pas du tout compris ça ^^ je savais pas du tout pour getHeldItemMainHand et OffHand j’avais pas fais gaffe.
Pour se qui est du TileEntity tu sais d’ou ça vient ou non?
J’ai oublier de te passer le crash report…
Je te le passe tien:
java.lang.ClassCastException: net.minecraft.entity.player.EntityPlayerMP cannot be cast to net.minecraft.inventory.InventoryCrafting at com.CSC.net.GUI.ContainerSecheLinge.detectAndSendChanges(ContainerSecheLinge.java:132) at net.minecraft.entity.player.EntityPlayerMP.onUpdate(EntityPlayerMP.java:292) at net.minecraft.world.World.updateEntityWithOptionalForce(World.java:2099) at net.minecraft.world.WorldServer.updateEntityWithOptionalForce(WorldServer.java:872) at net.minecraft.world.World.updateEntity(World.java:2066) at net.minecraft.world.WorldServer.tickPlayers(WorldServer.java:673) at net.minecraft.world.World.updateEntities(World.java:1862) at net.minecraft.world.WorldServer.updateEntities(WorldServer.java:644) at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:783) at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:687) at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:156) at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:536) at java.lang.Thread.run(Thread.java:745) A detailed walkthrough of the error, its code path and all known details is as follows: --------------------------------------------------------------------------------------- -- Head -- Thread: Client thread Stacktrace: at com.CSC.net.GUI.ContainerSecheLinge.detectAndSendChanges(ContainerSecheLinge.java:132) at net.minecraft.entity.player.EntityPlayerMP.onUpdate(EntityPlayerMP.java:292) at net.minecraft.world.World.updateEntityWithOptionalForce(World.java:2099) at net.minecraft.world.WorldServer.updateEntityWithOptionalForce(WorldServer.java:872) at net.minecraft.world.World.updateEntity(World.java:2066) -- Player being ticked -- Details: Entity Type: null (net.minecraft.entity.player.EntityPlayerMP) Entity ID: 353 Entity Name: Darkmayke Entity's Exact location: -44,47, 72,00, 280,77 Entity's Block location: World: (-45,72,280), Chunk: (at 3,4,8 in -3,17; contains blocks -48,0,272 to -33,255,287), Region: (-1,0; contains chunks -32,0 to -1,31, blocks -512,0,0 to -1,255,511) Entity's Momentum: 0,00, -0,08, 0,00 Entity's Passengers: [] Entity's Vehicle: ~~ERROR~~ NullPointerException: null Stacktrace: at net.minecraft.world.WorldServer.tickPlayers(WorldServer.java:673) at net.minecraft.world.World.updateEntities(World.java:1862) at net.minecraft.world.WorldServer.updateEntities(WorldServer.java:644) -- Affected level -- Details: Level name: New World All players: 1 total; [EntityPlayerMP['Darkmayke'/353, l='New World', x=-44,47, y=72,00, z=280,77]] Chunk stats: ServerChunkCache: 350 Drop: 0 Level seed: -8076992039048543240 Level generator: ID 00 - default, ver 1\. Features enabled: true Level generator options: Level spawn location: World: (-40,64,256), Chunk: (at 8,4,0 in -3,16; contains blocks -48,0,256 to -33,255,271), Region: (-1,0; contains chunks -32,0 to -1,31, blocks -512,0,0 to -1,255,511) Level time: 145365 game time, 39921 day time Level dimension: 0 Level storage version: 0x04ABD - Anvil Level weather: Rain time: 15845 (now: true), thunder time: 71400 (now: false) Level game mode: Game mode: creative (ID 1). Hardcore: false. Cheats: true Stacktrace: at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:783) at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:687) at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:156) at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:536) at java.lang.Thread.run(Thread.java:745) – System Details -- Details: Minecraft Version: 1.10 Operating System: Windows 7 (x86) version 6.1 Java Version: 1.8.0_45, Oracle Corporation Java VM Version: Java HotSpot(TM) Client VM (mixed mode), Oracle Corporation Memory: 504680536 bytes (481 MB) / 1037959168 bytes (989 MB) up to 1037959168 bytes (989 MB) JVM Flags: 3 total; -Xincgc -Xmx1024M -Xms1024M IntCache: cache: 0, tcache: 0, allocated: 12, tallocated: 94 FML: MCP 9.32 Powered by Forge 12.18.0.2000 4 mods loaded, 4 mods active States: 'U' = Unloaded 'L' = Loaded 'C' = Constructed 'H' = Pre-initialized 'I' = Initialized 'J' = Post-initialized 'A' = Available 'D' = Disabled 'E' = Errored UCHIJAAAA mcp{9.19} [Minecraft Coder Pack] (minecraft.jar) UCHIJAAAA FML{8.0.99.99} [Forge Mod Loader] (forgeSrc-1.10-12.18.0.2000-1.10.0.jar) UCHIJAAAA Forge{12.18.0.2000} [Minecraft Forge] (forgeSrc-1.10-12.18.0.2000-1.10.0.jar) UCHIJAAAA csc{1.0} [Cite Sous Controle] (bin) Loaded coremods (and transformers): GL info: ~~ERROR~~ RuntimeException: No OpenGL context found in the current thread. Profiler Position: N/A (disabled) Player Count: 1 / 8; [EntityPlayerMP['Darkmayke'/353, l='New World', x=-44,47, y=72,00, z=280,77]] Type: Integrated Server (map_client.txt) Is Modded: Definitely; Client brand changed to 'fml,forge' [22:29:25] [Client thread/INFO] [STDOUT]: [net.minecraft.init.Bootstrap:printToSYSOUT:649]: #@!@# Game crashed! Crash report saved to: #@!@# .\crash-reports\crash-2016-12-10_22.29.25-server.txt [22:29:25] [Client thread/INFO] [FML]: Waiting for the server to terminate/save. [22:29:25] [Server thread/INFO]: Saving chunks for level 'New World'/Nether [22:29:25] [Server thread/INFO]: Saving chunks for level 'New World'/The End [22:29:26] [Server thread/INFO] [FML]: Unloading dimension 0 [22:29:26] [Server thread/INFO] [FML]: Unloading dimension -1 [22:29:26] [Server thread/INFO] [FML]: Unloading dimension 1 [22:29:26] [Server thread/INFO] [FML]: Applying holder lookups [22:29:26] [Server thread/INFO] [FML]: Holder lookups applied [22:29:26] [Server thread/INFO] [FML]: The state engine was in incorrect state SERVER_STOPPING and forced into state SERVER_STOPPED. Errors may have been discarded. [22:29:26] [Client thread/INFO] [FML]: Server terminated. [22:29:26] [Client Shutdown Thread/INFO]: Stopping server [22:29:26] [Client Shutdown Thread/INFO]: Saving players AL lib: (EE) alc_cleanup: 1 device not closed Java HotSpot(TM) Client VM warning: Using incremental CMS is deprecated and will likely be removed in a future release
-
this.listeners.get(i) est un entity player, or toi tu essaie de le cast à InventoryCrafting.
Donc le type de this.listeners.get(i) à surement changé. Regardes le code de la table de craft.
-
@‘robin4002’:
this.listeners.get(i) est un entity player, or toi tu essaie de le cast à InventoryCrafting.
Donc le type de this.listeners.get(i) à surement changé. Regardes le code de la table de craft.
J’ai trouvé super merci, par contre c’était dans la classe de la furnace en soit j’avais compris x) merci !
Un dernier truc:
J’ai trois block container donc mon mod et deux sont buggé, je sais d’ou ça vient car pour les trois c’est le même type de json et en 1.8 ça marchais nickel.
Je te passe un screen pour que tu comprennes le problème, (les blocks sont invisible).
-
Rajoute ceci dans la classe de ton bloc :
@Override public int getRenderType() { return 3; }
-
@‘BrokenSwing’:
Rajoute ceci dans la classe de ton bloc :
@Override public int getRenderType() { return 3; }
En 1.10 ça exite plus getRenderType.
J’ai trouvé ça du coup:
@Override public EnumBlockRenderType getRenderType(IBlockState state) { return EnumBlockRenderType.MODEL; }
ça marche nickel merci
-
Ah oui désolé je suis pas aller regarder, mais c’est bien t’as trouvé tout seul