Résolu [1.12.2] problème avec mon GUI
-
j’ais des problème avec mon gui quand je clique sur le bloque mon jeux crash et me mais plein de log dans la console les voici.
java.util.concurrent.ExecutionException: java.lang.NullPointerException: The validated object is null at java.util.concurrent.FutureTask.report(FutureTask.java:122) ~[?:1.8.0_181] at java.util.concurrent.FutureTask.get(FutureTask.java:192) ~[?:1.8.0_181] at net.minecraft.util.Util.runTask(Util.java:54) [Util.class:?] at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:796) [MinecraftServer.class:?] at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:741) [MinecraftServer.class:?] at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:192) [IntegratedServer.class:?] at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:590) [MinecraftServer.class:?] at java.lang.Thread.run(Thread.java:748) [?:1.8.0_181] Caused by: java.lang.NullPointerException: The validated object is null at org.apache.commons.lang3.Validate.notNull(Validate.java:225) ~[commons-lang3-3.5.jar:3.5] at org.apache.commons.lang3.Validate.notNull(Validate.java:206) ~[commons-lang3-3.5.jar:3.5] at net.minecraft.util.NonNullList.add(NonNullList.java:62) ~[NonNullList.class:?] at java.util.AbstractList.add(AbstractList.java:108) ~[?:1.8.0_181] at net.minecraft.inventory.Container.getInventory(Container.java:75) ~[Container.class:?] at net.minecraft.inventory.Container.addListener(Container.java:61) ~[Container.class:?] at net.minecraftforge.fml.common.network.internal.FMLNetworkHandler.openGui(FMLNetworkHandler.java:100) ~[FMLNetworkHandler.class:?] at net.minecraft.entity.player.EntityPlayer.openGui(EntityPlayer.java:2809) ~[EntityPlayer.class:?] ==> at fr.thexrayfr.familygame.blocks.BlockBarrel.onBlockActivated(BlockBarrel.java:75) ~[BlockBarrel.class:?] at net.minecraft.server.management.PlayerInteractionManager.processRightClickBlock(PlayerInteractionManager.java:472) ~[PlayerInteractionManager.class:?] at net.minecraft.network.NetHandlerPlayServer.processTryUseItemOnBlock(NetHandlerPlayServer.java:767) ~[NetHandlerPlayServer.class:?] at net.minecraft.network.play.client.CPacketPlayerTryUseItemOnBlock.processPacket(CPacketPlayerTryUseItemOnBlock.java:68) ~[CPacketPlayerTryUseItemOnBlock.class:?] at net.minecraft.network.play.client.CPacketPlayerTryUseItemOnBlock.processPacket(CPacketPlayerTryUseItemOnBlock.java:13) ~[CPacketPlayerTryUseItemOnBlock.class:?] at net.minecraft.network.PacketThreadUtil$1.run(PacketThreadUtil.java:21) ~[PacketThreadUtil$1.class:?] at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) ~[?:1.8.0_181] at java.util.concurrent.FutureTask.run(FutureTask.java:266) ~[?:1.8.0_181] at net.minecraft.util.Util.runTask(Util.java:53) ~[Util.class:?] ... 5 more [18:29:47] [Server thread/ERROR]: Encountered an unexpected exception net.minecraft.util.ReportedException: Ticking player at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:846) ~[MinecraftServer.class:?] at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:741) ~[MinecraftServer.class:?] at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:192) ~[IntegratedServer.class:?] at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:590) [MinecraftServer.class:?] at java.lang.Thread.run(Thread.java:748) [?:1.8.0_181] Caused by: java.lang.NullPointerException at net.minecraft.item.ItemStack.areItemStacksEqual(ItemStack.java:495) ~[ItemStack.class:?] at net.minecraft.inventory.Container.detectAndSendChanges(Container.java:100) ~[Container.class:?] at net.minecraft.entity.player.EntityPlayerMP.onUpdate(EntityPlayerMP.java:365) ~[EntityPlayerMP.class:?] at net.minecraft.world.World.updateEntityWithOptionalForce(World.java:2168) ~[World.class:?] at net.minecraft.world.WorldServer.updateEntityWithOptionalForce(WorldServer.java:870) ~[WorldServer.class:?] at net.minecraft.world.World.updateEntity(World.java:2127) ~[World.class:?] at net.minecraft.world.WorldServer.tickPlayers(WorldServer.java:671) ~[WorldServer.class:?] at net.minecraft.world.World.updateEntities(World.java:1903) ~[World.class:?] at net.minecraft.world.WorldServer.updateEntities(WorldServer.java:642) ~[WorldServer.class:?] at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:840) ~[MinecraftServer.class:?] ... 4 more4 more
et je me ramaine a cette ligne la:
public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) { playerIn.openGui(Main.instance, 3, worldIn, pos.getX(), pos.getY(), pos.getZ()); return true; }
si une personne aurais une ider dous sa peux provenir sa me serais très utile sa fait des joure que je planche dessus et je ni arrive pas
-
bas sa le fait avec tous les gui de mon mod voici un plus:
package fr.thexrayfr.familygame.gui; import fr.thexrayfr.familygame.container.*; import fr.thexrayfr.familygame.tile.TileEntityBarrel; import fr.thexrayfr.familygame.tile.TileEntityCrate; import fr.thexrayfr.familygame.tile.TileEntityCratePlus; import fr.thexrayfr.familygame.tile.TileEntityKitchen; import fr.thexrayfr.familygame.tile.TileEntityTable; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; public class GuiHandler implements net.minecraftforge.fml.common.network.IGuiHandler { public Object getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) { TileEntity tile = world.getTileEntity(new BlockPos(x, y, z)); if (ID == 0) { return new ContainerOakCrate((TileEntityCrate)tile, player.inventory); } if (ID == 1) { return new ContainerOakCratePlus((TileEntityCratePlus)tile, player.inventory); } if (ID == 2) { return new ContainerBaseTable((TileEntityTable)tile, player.inventory); } if (ID == 3) { return new ContainerBarrel((TileEntityBarrel)tile, player.inventory); } if (ID == 4) { return new ContainerKitchen((TileEntityKitchen)tile, player.inventory); } return null; } public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) { TileEntity tile = world.getTileEntity(new BlockPos(x, y, z)); if (ID == 0) { return new fr.thexrayfr.familygame.gui.GuiCrate((TileEntityCrate)tile, player.inventory); } if (ID == 1) { return new fr.thexrayfr.familygame.gui.GuiCratePlus((TileEntityCratePlus)tile, player.inventory); } if (ID == 2) { return new fr.thexrayfr.familygame.gui.GuiTable((TileEntityTable)tile, player.inventory); } if (ID == 3) { return new fr.thexrayfr.familygame.gui.GuiBarrel((TileEntityBarrel)tile, player.inventory); } if (ID == 4) { return new fr.thexrayfr.familygame.gui.GuiKitchen((TileEntityKitchen)tile, player.inventory); } return null; } }
-
Salut,
Main.instance est null, surement car l’annotation@Mod.Instance
n’est plus au-dessus de cette dernière. -
je veriffy
-
@Mod.Instance("familygame") public static Main instance;
pourtemp sy ses bizard
Voicy tous mon Main.java
package fr.thexrayfr.familygame; import fr.thexrayfr.familygame.blocks.FamilyBlocks; import fr.thexrayfr.familygame.gui.GuiHandler; import fr.thexrayfr.familygame.init.FamilygameRecipe; import fr.thexrayfr.familygame.items.FamilyItems; import fr.thexrayfr.familygame.tile.*; import fr.thexrayfr.familygame.util.ObjectRegistry; import fr.thexrayfr.familygame.world.FamilyWorldGen; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.util.ResourceLocation; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.common.SidedProxy; import net.minecraftforge.fml.common.event.FMLInitializationEvent; import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; import net.minecraftforge.fml.common.network.NetworkRegistry; import net.minecraftforge.fml.common.registry.GameRegistry; @Mod(modid = "familygame", name = "Family-Game", version = "8.5.1", acceptedMinecraftVersions = "[1.12.2]") public class Main { public static final String MODID = "familygame"; public static final CreativeTabs TABFAMILYGAME = new CreativeTabs("tab_familygame") { public ItemStack getTabIconItem() { return new ItemStack(Item.getItemFromBlock(FamilyBlocks.KITCHEN_FURNITURE_1_DIORITE_OAK)); } }; public static final CreativeTabs TABFAMILYGAMETOOLS = new CreativeTabs("tab_familygame_tools") { public ItemStack getTabIconItem() { return new ItemStack(FamilyItems.PALADIUM_HELMET); } }; public static final CreativeTabs TABFAMILYGAMEKITCHEN = new CreativeTabs("tab_familygame_kitchen") { public ItemStack getTabIconItem() { return new ItemStack(Item.getItemFromBlock(FamilyBlocks.KITCHEN_FURNITURE_1_DIORITE_OAK)); } }; public static final CreativeTabs TABFAMILYGAMEPAINT = new CreativeTabs("tab_familygame_paint") { public ItemStack getTabIconItem() { return new ItemStack(Item.getItemFromBlock(FamilyBlocks.YL_PAINT)); } }; @Mod.Instance("familygame") public static Main instance; @SidedProxy(clientSide = "fr.thexrayfr.familygame.proxy.FamilyClient", serverSide = "fr.thexrayfr.familygame.proxy.FamilyServer") public static FamilyCommon proxy; private ObjectRegistry registry; @Mod.EventHandler public void preInit(FMLPreInitializationEvent event) { proxy.preInit(event.getSuggestedConfigurationFile()); this.registry = new ObjectRegistry("familygame"); FamilyBlocks.init(this.registry); FamilyItems.init(this.registry); GameRegistry.registerWorldGenerator(new FamilyWorldGen(), 3); } @Mod.EventHandler public void init(FMLInitializationEvent event) { proxy.init(); FamilygameRecipe.init(); NetworkRegistry.INSTANCE.registerGuiHandler(instance, new GuiHandler()); GameRegistry.registerTileEntity(TileEntityCrate.class, String.valueOf(new ResourceLocation("familygame", "TileEntityCrate"))); GameRegistry.registerTileEntity(TileEntityCratePlus.class, String.valueOf(new ResourceLocation("familygame", "TileEntityCratePlus"))); GameRegistry.registerTileEntity(TileEntityTable.class, String.valueOf(new ResourceLocation("familygame", "TileEntityTable"))); GameRegistry.registerTileEntity(TileEntityBarrel.class, String.valueOf(new ResourceLocation("familygame", "TileEntityBarrel"))); GameRegistry.registerTileEntity(TileEntityKitchen.class, String.valueOf(new ResourceLocation("familygame", "TileEntityKitchen"))); } }
-
Ah non au temps pour moi, j’ai mal lu le rapport de crash.
C’est un item de l’inventaire associé au gui qui est null.
Il faut utiliser des NonNullList en 1.12. -
et comment on utilisa sa svp je débute un peut en java
-
Regardes dans le code du tile entity du coffre.
-
ok je vais regarder
-
dans le tile ya pas de onBlockActivated
et dans la clase du block chest sa resemble a sa!
public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) { if (worldIn.isRemote) { return true; } else { ILockableContainer ilockablecontainer = this.getLockableContainer(worldIn, pos); if (ilockablecontainer != null) { playerIn.displayGUIChest(ilockablecontainer); if (this.chestType == BlockChest.Type.BASIC) { playerIn.addStat(StatList.CHEST_OPENED); } else if (this.chestType == BlockChest.Type.TRAP) { playerIn.addStat(StatList.TRAPPED_CHEST_TRIGGERED); } } return true; } }
ses pas du tous la même chose
-
Le problème ne se trouve pas dans ton bloc mais dans ton tile entity.
-
package fr.thexrayfr.familygame.tile; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.ItemStackHelper; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; public class TileEntityBarrel extends TileEntityStorage { public int getSizeInventory() { return 18; } @Override public boolean isEmpty() { return false; } @Override public ItemStack getStackInSlot(int index) { return null; } @Override public ItemStack decrStackSize(int index, int count) { return null; } @Override public ItemStack removeStackFromSlot(int index) { return null; } @Override public int getInventoryStackLimit() { return 0; } @Override public boolean isUsableByPlayer(EntityPlayer player) { return false; } @Override public void openInventory(EntityPlayer player) { } @Override public void closeInventory(EntityPlayer player) { } @Override public boolean isItemValidForSlot(int index, ItemStack stack) { return false; } @Override public int getField(int id) { return 0; } @Override public void setField(int id, int value) { } @Override public int getFieldCount() { return 0; } @Override public void clear() { } public void readFromNBT(NBTTagCompound compound) { super.readFromNBT(compound); ItemStackHelper.loadAllItems(compound, this.stacks); } public NBTTagCompound writeToNBT(NBTTagCompound compound) { ItemStackHelper.saveAllItems(compound, this.stacks); return super.writeToNBT(compound); } @Override public String getName() { return null; } @Override public boolean hasCustomName() { return false; } }
il ma demander quand je lais mise a joue d’importer ca donc apret
-
TileEntityStorage contient quoi ?
Et tu as pleins de fonction non implémenté qui retourne null, ce n’est pas bon. getStackInSlot, decrStackSize, removeStackFromSlot etc.
-
package fr.thexrayfr.familygame.tile; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.IInventory; import net.minecraft.inventory.ItemStackHelper; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.NonNullList; public abstract class TileEntityStorage extends TileEntity implements IInventory { public NonNullList<ItemStack> stacks = NonNullList.withSize(getSizeInventory(), ItemStack.EMPTY); public String getName() { return null; } public boolean hasCustomName() { return false; } public boolean isEmpty() { for (ItemStack itemstack : this.stacks) { if (!itemstack.isEmpty()) { return false; } } return true; } public ItemStack getStackInSlot(int index) { return (ItemStack)this.stacks.get(index); } public ItemStack decrStackSize(int index, int count) { return ItemStackHelper.getAndSplit(this.stacks, index, count); } public ItemStack removeStackFromSlot(int index) { this.stacks.set(index, ItemStack.EMPTY); return getStackInSlot(index); } public void setInventorySlotContents(int index, ItemStack stack) { this.stacks.set(index, stack); } public int getInventoryStackLimit() { return 64; } public boolean isUsableByPlayer(EntityPlayer player) { if (this.world.getTileEntity(this.pos) != this) { return false; } return player.getDistanceSq(this.pos.getX() + 0.5D, this.pos.getY() + 0.5D, this.pos.getZ() + 0.5D) <= 64.0D; } public void openInventory(EntityPlayer player) {} public void closeInventory(EntityPlayer player) {} public boolean isItemValidForSlot(int index, ItemStack stack) { return true; } public int getField(int id) { return 0; } public void setField(int id, int value) {} public int getFieldCount() { return 0; } public void clear() { this.stacks.clear(); } }
-
jais fait le ménage
package fr.thexrayfr.familygame.tile; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.ItemStackHelper; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; public class TileEntityBarrel extends TileEntityStorage { public int getSizeInventory() { return 18; } @Override public boolean isEmpty() { return false; } @Override public int getInventoryStackLimit() { return 0; } @Override public boolean isUsableByPlayer(EntityPlayer player) { return false; } @Override public void openInventory(EntityPlayer player) { } @Override public void closeInventory(EntityPlayer player) { } @Override public boolean isItemValidForSlot(int index, ItemStack stack) { return false; } @Override public int getField(int id) { return 0; } @Override public void setField(int id, int value) { } @Override public int getFieldCount() { return 0; } @Override public void clear() { } public void readFromNBT(NBTTagCompound compound) { super.readFromNBT(compound); ItemStackHelper.loadAllItems(compound, this.stacks); } public NBTTagCompound writeToNBT(NBTTagCompound compound) { ItemStackHelper.saveAllItems(compound, this.stacks); return super.writeToNBT(compound); } @Override public boolean hasCustomName() { return false; } }
-
déja sa crash plus sa ouvre et referme le gui
-
-
Ta fonction
isUsableByPlayer
retourne toujours faux, c’est pour ça que cela ne fonctionne pas. -
une petite vidéo pour te montrer se qui se passe
-
ses bon le hui s’ouvre mes maintenant ses le snift clique qui pose problème