Heltrato Posted April 23, 2017 Posted April 23, 2017 Hello im back again after fixing the glitch on armor ( lol it was about the getArmorModel ) anyways im having crash whenever i right click my hunter bench block. This does not happen from 1.7.10. Almost all code is the same no changes Here is the crash report ---- Minecraft Crash Report ---- // You're mean. Time: 4/23/17 12:50 AM Description: Unexpected error java.lang.NullPointerException: The validated object is null at org.apache.commons.lang3.Validate.notNull(Validate.java:222) at org.apache.commons.lang3.Validate.notNull(Validate.java:203) at net.minecraft.util.NonNullList.set(NonNullList.java:48) at net.minecraft.inventory.InventoryCraftResult.setInventorySlotContents(InventoryCraftResult.java:88) at mhfc.net.client.container.ContainerHunterBench.onCraftMatrixChanged(ContainerHunterBench.java:106) at mhfc.net.client.container.ContainerHunterBench.<init>(ContainerHunterBench.java:101) at mhfc.net.client.gui.GuiHunterBench.<init>(GuiHunterBench.java:392) at mhfc.net.common.eventhandler.MHFCGuiHandler.getClientGuiElement(MHFCGuiHandler.java:39) at net.minecraftforge.fml.common.network.NetworkRegistry.getLocalGuiContainer(NetworkRegistry.java:273) at net.minecraftforge.fml.common.network.internal.FMLNetworkHandler.openGui(FMLNetworkHandler.java:110) at net.minecraft.entity.player.EntityPlayer.openGui(EntityPlayer.java:2725) at mhfc.net.common.block.container.BlockHunterBench.onBlockActivated(BlockHunterBench.java:48) at net.minecraft.client.multiplayer.PlayerControllerMP.processRightClickBlock(PlayerControllerMP.java:442) at net.minecraft.client.Minecraft.rightClickMouse(Minecraft.java:1612) at net.minecraft.client.Minecraft.processKeyBinds(Minecraft.java:2282) at net.minecraft.client.Minecraft.runTickKeyboard(Minecraft.java:2059) at net.minecraft.client.Minecraft.runTick(Minecraft.java:1847) at net.minecraft.client.Minecraft.runGameLoop(Minecraft.java:1125) at net.minecraft.client.Minecraft.run(Minecraft.java:405) at net.minecraft.client.main.Main.main(Main.java:118) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at net.minecraft.launchwrapper.Launch.launch(Launch.java:135) at net.minecraft.launchwrapper.Launch.main(Launch.java:28) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at net.minecraftforge.gradle.GradleStartCommon.launch(GradleStartCommon.java:97) at GradleStart.main(GradleStart.java:26) The first crash heading to @Override public void onCraftMatrixChanged(IInventory par1IInventory) { this.craftResult.setInventorySlotContents(0,MHFCCraftingManager.getInstance() .findMatchingRecipe(this.craftMatrix, this.worldObj)); } 2nd crash pointing this.onCraftMatrixChanged(this.craftMatrix); 3rd public GuiHunterBench( InventoryPlayer par1InventoryPlayer, World par2World, TileHunterBench tileEntity, int x, int y, int z) { super(new ContainerHunterBench(par1InventoryPlayer, par2World, tileEntity, x, y, z)); this.tileEntity = tileEntity; this.xSize = 374; this.ySize = 220; mc = Minecraft.getMinecraft(); width = MHFCGuiUtil.minecraftWidth(mc); height = MHFCGuiUtil.minecraftHeight(mc); this.guiLeft = (width - this.xSize - tabWidth) / 2 + tabWidth; this.guiTop = (height - this.ySize) / 2; this.addTab(new CraftArmorTab(tileEntity), "Armor"); this.addTab(new CraftWeaponTab(tileEntity), "Weapons"); this.addTab(new CraftUpgradeTab(tileEntity), "Upgrade"); this.addTab(new WeaponTreeTab(), "Weapon tree"); startCrafting = new GuiButton(0, guiLeft + 228 + (xSize - 228 - 60) / 2, guiTop + 166, 40, 20, "Craft") { @Override public void mouseReleased(int p_146118_1_, int p_146118_2_) { GuiHunterBench.this.tileEntity.beginCrafting(); } }; selectTab(); } Lastly @Override public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) { switch (ID) { case MHFCContainerRegistry.gui_hunterbench_id: TileEntity tE = world.getTileEntity(new BlockPos(x, y, z)); if (tE instanceof TileHunterBench) { return new GuiHunterBench(player.inventory, world, (TileHunterBench) tE, x, y, z); } else { MHFCMain.logger().debug( "Tried to open hunter bench gui for block at {} {} {} which does not have a hunter bench tile entity", x, y, z); } break; case MHFCContainerRegistry.gui_questgiver_id: return GuiQuestGiver.getScreen(x, player); case MHFCContainerRegistry.gui_questboard_id: return GuiQuestBoard.getQuestBoard(player); case MHFCContainerRegistry.gui_queststatus_id: return new QuestStatusInventory(player); case MHFCContainerRegistry.gui_changearea_id: return getChangeAreaGui(world, x, y, z); } return null; } Here is my block class package mhfc.net.common.block.container; import mhfc.net.MHFCMain; import mhfc.net.common.core.registry.MHFCContainerRegistry; import mhfc.net.common.index.ResourceInterface; import mhfc.net.common.tile.TileHunterBench; import net.minecraft.block.BlockContainer; import net.minecraft.block.material.Material; import net.minecraft.block.state.IBlockState; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.EnumFacing; import net.minecraft.util.EnumHand; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; public class BlockHunterBench extends BlockContainer { public BlockHunterBench() { super(Material.ROCK); setUnlocalizedName(ResourceInterface.block_hunterbench_name); setHardness(1.2F); setCreativeTab(MHFCMain.mhfctabs); } @Override public TileEntity createNewTileEntity(World world, int var1) { return new TileHunterBench(); } @Override public boolean isOpaqueCube(IBlockState state) { return false; } @Override public boolean onBlockActivated( World worldIn, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) { if (!player.isSneaking()) { player.openGui( MHFCMain.instance(), MHFCContainerRegistry.gui_hunterbench_id, worldIn, pos.getX(), pos.getY(), pos.getZ()); return true; } return false; } } Quote
Choonster Posted April 23, 2017 Posted April 23, 2017 (edited) You're calling IInventory#setInventorySlotContents with a null value (returned by MHFCCraftingManager#findMatchingRecipe), which is invalid. ItemStacks can no longer be null in 1.11.x, the default value is now the empty ItemStack (i.e. any ItemStack that returns true from ItemStack#isEmpty). The ItemStack.EMPTY field contains an ItemStack that's always empty. Edited April 23, 2017 by Choonster 1 Quote Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.
Heltrato Posted April 23, 2017 Author Posted April 23, 2017 Wait im confused. Which parrt is where the ItemStack is empty? Am i called it right? Quote
Choonster Posted April 23, 2017 Posted April 23, 2017 17 minutes ago, Heltrato said: Wait im confused. Which parrt is where the ItemStack is empty? Am i called it right? MHFCCraftingManager#findMatchingRecipe is returning null (presumably because there's no matching recipe), which is no longer a valid value for an ItemStack. Instead of returning null, return ItemStack.EMPTY. 1 Quote Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.
Heltrato Posted April 23, 2017 Author Posted April 23, 2017 Okay so this is what i did. As you can see i replace return null in ItemStack.EMPTY. package mhfc.net.common.crafting; import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; import java.util.LinkedHashSet; import java.util.List; import java.util.Set; import mhfc.net.common.crafting.recipes.MHFCShapedRecipes; import mhfc.net.common.crafting.recipes.MHFCShapelessRecipe; import net.minecraft.block.Block; import net.minecraft.inventory.InventoryCrafting; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.item.crafting.IRecipe; import net.minecraft.world.World; public class MHFCCraftingManager { private static final MHFCCraftingManager instance = new MHFCCraftingManager(); private Set<IRecipe> recipes; public static final MHFCCraftingManager getInstance() { return instance; } public MHFCCraftingManager() { recipes = new LinkedHashSet<>(); } // TODO: beautify this, is an akward method to add recipes // TODO rework this, pls, separation of concerns public ItemStack findMatchingRecipe(InventoryCrafting par1InventoryCrafting, World par2World) { int var3 = 0; ItemStack var4 = null; ItemStack var5 = null; int var6; for (var6 = 0; var6 < par1InventoryCrafting.getSizeInventory(); ++var6) { ItemStack var7 = par1InventoryCrafting.getStackInSlot(var6); if (var7 != null) { if (var3 == 0) { var4 = var7; } if (var3 == 1) { var5 = var7; } ++var3; } } if (var3 == 2 && var4.getItem() == var5.getItem() && var4.getCount() == 1 && var5.getCount() == 1 && var5.getItem().isRepairable()) { Item var11 = var5.getItem(); int var13 = var11.getMaxDamage() - var4.getItemDamage(); int var8 = var11.getMaxDamage() - var5.getItemDamage(); int var9 = var13 + var8 + var11.getMaxDamage() * 5 / 100; int var10 = var11.getMaxDamage() - var9; if (var10 < 0) { var10 = 0; } return new ItemStack(var4.getItem(), 1, var10); } for (IRecipe var12 : this.recipes) { if (var12.matches(par1InventoryCrafting, par2World)) { return var12.getCraftingResult(par1InventoryCrafting); } } return ItemStack.EMPTY; } public Set<IRecipe> getRecipeList() { return this.recipes; } public MHFCShapedRecipes addShapedRecipe(ItemStack par1ItemStack, Object... par2ArrayOfObj) { // TODO this should be moved into an constructor of shaped recipe String var3 = ""; int var4 = 0; int var5 = 0; int var6 = 0; if (par2ArrayOfObj[var4] instanceof String[]) { String[] var7 = ((String[]) par2ArrayOfObj[var4++]); for (String var9 : var7) { ++var6; var5 = var9.length(); var3 = var3 + var9; } } else { while (par2ArrayOfObj[var4] instanceof String) { String var11 = (String) par2ArrayOfObj[var4++]; ++var6; var5 = var11.length(); var3 = var3 + var11; } } HashMap<Character, ItemStack> var12 = new HashMap<>(); for (; var4 < par2ArrayOfObj.length; var4 += 2) { Character var13 = (Character) par2ArrayOfObj[var4]; ItemStack var14 = null; if (par2ArrayOfObj[var4 + 1] instanceof Item) { var14 = new ItemStack((Item) par2ArrayOfObj[var4 + 1]); } else if (par2ArrayOfObj[var4 + 1] instanceof Block) { var14 = new ItemStack((Block) par2ArrayOfObj[var4 + 1], 1, -1); } else if (par2ArrayOfObj[var4 + 1] instanceof ItemStack) { var14 = (ItemStack) par2ArrayOfObj[var4 + 1]; } var12.put(var13, var14); } ItemStack[] var15 = new ItemStack[var5 * var6]; for (int var16 = 0; var16 < var5 * var6; ++var16) { char var10 = var3.charAt(var16); if (var12.containsKey(Character.valueOf(var10))) { var15[var16] = var12.get(Character.valueOf(var10)).copy(); } else { var15[var16] = null; } } MHFCShapedRecipes var17 = new MHFCShapedRecipes(var5, var6, var15, par1ItemStack); this.recipes.add(var17); return var17; } public void addShapelessRecipe(ItemStack par1ItemStack, ItemStack... recipeStacks) { List<ItemStack> var3 = new ArrayList<>(); var3.addAll(Arrays.asList(recipeStacks)); this.recipes.add(new MHFCShapelessRecipe(par1ItemStack, var3)); } } And ended up with this crash. It seems there is no mhfc package related. ---- Minecraft Crash Report ---- // You should try our sister game, Minceraft! Time: 4/23/17 1:02 PM Description: Rendering screen java.lang.NullPointerException: Rendering screen at net.minecraft.client.gui.inventory.GuiContainer.drawSlot(GuiContainer.java:274) at net.minecraft.client.gui.inventory.GuiContainer.drawScreen(GuiContainer.java:117) at net.minecraftforge.client.ForgeHooksClient.drawScreen(ForgeHooksClient.java:382) at net.minecraft.client.renderer.EntityRenderer.updateCameraAndRender(EntityRenderer.java:1164) at net.minecraft.client.Minecraft.runGameLoop(Minecraft.java:1146) at net.minecraft.client.Minecraft.run(Minecraft.java:405) at net.minecraft.client.main.Main.main(Main.java:118) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at net.minecraft.launchwrapper.Launch.launch(Launch.java:135) at net.minecraft.launchwrapper.Launch.main(Launch.java:28) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at net.minecraftforge.gradle.GradleStartCommon.launch(GradleStartCommon.java:97) at GradleStart.main(GradleStart.java:26) A detailed walkthrough of the error, its code path and all known details is as follows: --------------------------------------------------------------------------------------- -- Head -- Thread: Client thread Stacktrace: at net.minecraft.client.gui.inventory.GuiContainer.drawSlot(GuiContainer.java:274) at net.minecraft.client.gui.inventory.GuiContainer.drawScreen(GuiContainer.java:117) at net.minecraftforge.client.ForgeHooksClient.drawScreen(ForgeHooksClient.java:382) -- Screen render details -- Details: Screen name: mhfc.net.client.gui.GuiHunterBench Mouse location: Scaled: (213, 119). Absolute: (427, 240) Screen size: Scaled: (427, 240). Absolute: (854, 480). Scale factor of 2 -- Affected level -- Details: Level name: MpServer All players: 1 total; [EntityPlayerSP['Player694'/0, l='MpServer', x=522.75, y=4.00, z=319.43]] Chunk stats: MultiplayerChunkCache: 81, 81 Level seed: 0 Level generator: ID 01 - flat, ver 0. Features enabled: false Level generator options: Level spawn location: World: (529,4,332), Chunk: (at 1,0,12 in 33,20; contains blocks 528,0,320 to 543,255,335), Region: (1,0; contains chunks 32,0 to 63,31, blocks 512,0,0 to 1023,255,511) Level time: 3932 game time, 1 day time Level dimension: 0 Level storage version: 0x00000 - Unknown? Level weather: Rain time: 0 (now: false), thunder time: 0 (now: false) Level game mode: Game mode: creative (ID 1). Hardcore: false. Cheats: false Forced entities: 1 total; [EntityPlayerSP['Player694'/0, l='MpServer', x=522.75, y=4.00, z=319.43]] Retry entities: 0 total; [] Server brand: fml,forge Server type: Integrated singleplayer server Stacktrace: at net.minecraft.client.multiplayer.WorldClient.addWorldInfoToCrashReport(WorldClient.java:451) at net.minecraft.client.Minecraft.addGraphicsAndWorldToCrashReport(Minecraft.java:2780) at net.minecraft.client.Minecraft.run(Minecraft.java:426) at net.minecraft.client.main.Main.main(Main.java:118) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at net.minecraft.launchwrapper.Launch.launch(Launch.java:135) at net.minecraft.launchwrapper.Launch.main(Launch.java:28) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at net.minecraftforge.gradle.GradleStartCommon.launch(GradleStartCommon.java:97) at GradleStart.main(GradleStart.java:26) -- System Details -- Details: Minecraft Version: 1.11 Operating System: Windows 10 (amd64) version 10.0 Java Version: 1.8.0_102, Oracle Corporation Java VM Version: Java HotSpot(TM) 64-Bit Server VM (mixed mode), Oracle Corporation Memory: 872090520 bytes (831 MB) / 1621098496 bytes (1546 MB) up to 3797417984 bytes (3621 MB) JVM Flags: 0 total; IntCache: cache: 0, tcache: 0, allocated: 0, tallocated: 0 FML: MCP 9.35 Powered by Forge 13.19.1.2189 6 mods loaded, 6 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.11-13.19.1.2189.jar) UCHIJAAAA forge{13.19.1.2189} [Minecraft Forge] (forgeSrc-1.11-13.19.1.2189.jar) UCHIJAAAA mcanm{2.6.0.125} [Minecraft Animated] (MCAnm-v2.6.0-deobf.jar) UCHIJAAAA worldedit{6.1.6} [WorldEdit] (worldedit-forge-mc1.11-6.1.6-dev.jar) UCHIJAAAA mhfc{${version}} [§6Monster Hunter Frontier Craft] (bin) Loaded coremods (and transformers): GL info: ' Vendor: 'NVIDIA Corporation' Version: '4.5.0 NVIDIA 353.82' Renderer: 'GeForce 920M/PCIe/SSE2' Launched Version: 1.11 LWJGL: 2.9.4 OpenGL: GeForce 920M/PCIe/SSE2 GL version 4.5.0 NVIDIA 353.82, NVIDIA Corporation GL Caps: Using GL 1.3 multitexturing. Using GL 1.3 texture combiners. Using framebuffer objects because OpenGL 3.0 is supported and separate blending is supported. Shaders are available because OpenGL 2.1 is supported. VBOs are available because OpenGL 1.5 is supported. Using VBOs: Yes Is Modded: Definitely; Client brand changed to 'fml,forge' Type: Client (map_client.txt) Resource Packs: PureBDcraft 64x MC19.zip Current Language: English (US) Profiler Position: N/A (disabled) CPU: 4x Intel(R) Core(TM) i5-5200U CPU @ 2.20GHz Quote
Choonster Posted April 23, 2017 Posted April 23, 2017 (edited) 8 minutes ago, Heltrato said: java.lang.NullPointerException: Rendering screen at net.minecraft.client.gui.inventory.GuiContainer.drawSlot(GuiContainer.java:274) at net.minecraft.client.gui.inventory.GuiContainer.drawScreen(GuiContainer.java:117) This exception is thrown when GuiContainer tries to render a Slot with a null ItemStack in it. MHFCCraftingManager is still using null ItemStacks in several places, you need to fix this. Edited April 23, 2017 by Choonster Quote Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.
Heltrato Posted April 23, 2017 Author Posted April 23, 2017 so i have to find all itemstack that returns null and replace it with ItemStack.EMPTY? sorry late reply my net suddenly broke out Quote
Heltrato Posted April 23, 2017 Author Posted April 23, 2017 Update: What i did is similar to the vanilla Crafting Manager. I replaced every ItemStack including variables from null to ItemStack.EMPTY afterwards here's what happen the minecraft or game hangs after i right click the block and this is the crash or console that shows me . crash-2017-04-23_01.13.25-client.txt Quote
Heltrato Posted April 23, 2017 Author Posted April 23, 2017 (edited) Update:gone to slothunter bench and replaced all null into ItemStack.Empty . but holly molyy now my minecraft hangs.. ---- Minecraft Crash Report ---- // Uh... Did I do that? Time: 4/23/17 2:40 PM Description: Ticking player java.lang.NullPointerException: Ticking player at net.minecraft.item.ItemStack.areItemStacksEqual(ItemStack.java:442) at net.minecraft.inventory.Container.detectAndSendChanges(Container.java:89) at net.minecraft.entity.player.EntityPlayerMP.onUpdate(EntityPlayerMP.java:292) at net.minecraft.world.World.updateEntityWithOptionalForce(World.java:2134) at net.minecraft.world.WorldServer.updateEntityWithOptionalForce(WorldServer.java:879) at net.minecraft.world.World.updateEntity(World.java:2101) at net.minecraft.world.WorldServer.tickPlayers(WorldServer.java:676) at net.minecraft.world.World.updateEntities(World.java:1890) at net.minecraft.world.WorldServer.updateEntities(WorldServer.java:647) at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:794) at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:698) at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:156) at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:547) at java.lang.Thread.run(Unknown Source) A detailed walkthrough of the error, its code path and all known details is as follows: --------------------------------------------------------------------------------------- -- Head -- Thread: Server thread Stacktrace: at net.minecraft.item.ItemStack.areItemStacksEqual(ItemStack.java:442) at net.minecraft.inventory.Container.detectAndSendChanges(Container.java:89) at net.minecraft.entity.player.EntityPlayerMP.onUpdate(EntityPlayerMP.java:292) at net.minecraft.world.World.updateEntityWithOptionalForce(World.java:2134) at net.minecraft.world.WorldServer.updateEntityWithOptionalForce(WorldServer.java:879) at net.minecraft.world.World.updateEntity(World.java:2101) -- Player being ticked -- Details: Entity Type: null (net.minecraft.entity.player.EntityPlayerMP) Entity ID: 0 Entity Name: Player512 Entity's Exact location: 634.70, 4.00, -736.15 Entity's Block location: World: (634,4,-737), Chunk: (at 10,0,15 in 39,-47; contains blocks 624,0,-752 to 639,255,-737), Region: (1,-2; contains chunks 32,-64 to 63,-33, blocks 512,0,-1024 to 1023,255,-513) 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:676) at net.minecraft.world.World.updateEntities(World.java:1890) at net.minecraft.world.WorldServer.updateEntities(WorldServer.java:647) -- Affected level -- Details: Level name: New World All players: 1 total; [EntityPlayerMP['Player512'/0, l='New World', x=634.70, y=4.00, z=-736.15]] Chunk stats: ServerChunkCache: 256 Drop: 0 Level seed: 1928336456568822493 Level generator: ID 01 - flat, ver 0. Features enabled: false Level generator options: Level spawn location: World: (645,4,-733), Chunk: (at 5,0,3 in 40,-46; contains blocks 640,0,-736 to 655,255,-721), Region: (1,-2; contains chunks 32,-64 to 63,-33, blocks 512,0,-1024 to 1023,255,-513) Level time: 2825 game time, 0 day time Level dimension: 0 Level storage version: 0x04ABD - Anvil Level weather: Rain time: 98798 (now: false), thunder time: 45343 (now: false) Level game mode: Game mode: creative (ID 1). Hardcore: false. Cheats: true Stacktrace: at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:794) at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:698) at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:156) at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:547) at java.lang.Thread.run(Unknown Source) -- System Details -- Details: Minecraft Version: 1.11 Operating System: Windows 10 (amd64) version 10.0 Java Version: 1.8.0_102, Oracle Corporation Java VM Version: Java HotSpot(TM) 64-Bit Server VM (mixed mode), Oracle Corporation Memory: 533167192 bytes (508 MB) / 1945108480 bytes (1855 MB) up to 3797417984 bytes (3621 MB) JVM Flags: 0 total; IntCache: cache: 0, tcache: 0, allocated: 0, tallocated: 0 FML: MCP 9.35 Powered by Forge 13.19.1.2189 6 mods loaded, 6 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.11-13.19.1.2189.jar) UCHIJAAAA forge{13.19.1.2189} [Minecraft Forge] (forgeSrc-1.11-13.19.1.2189.jar) UCHIJAAAA mcanm{2.6.0.125} [Minecraft Animated] (MCAnm-v2.6.0-deobf.jar) UCHIJAAAA worldedit{6.1.6} [WorldEdit] (worldedit-forge-mc1.11-6.1.6-dev.jar) UCHIJAAAA mhfc{${version}} [§6Monster Hunter Frontier Craft] (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['Player512'/0, l='New World', x=634.70, y=4.00, z=-736.15]] Type: Integrated Server (map_client.txt) Is Modded: Definitely; Client brand changed to 'fml,forge' [14:39:59] [pool-2-thread-1/WARN]: Couldn't look up profile properties for com.mojang.authlib.GameProfile@6eb98739[id=4296a45d-fd1d-3a8b-9f25-0f078d10cc6b,name=Player512,properties={},legacy=false] com.mojang.authlib.exceptions.AuthenticationException: The client has sent too many requests within a certain amount of time at com.mojang.authlib.yggdrasil.YggdrasilAuthenticationService.makeRequest(YggdrasilAuthenticationService.java:79) ~[YggdrasilAuthenticationService.class:?] at com.mojang.authlib.yggdrasil.YggdrasilMinecraftSessionService.fillGameProfile(YggdrasilMinecraftSessionService.java:180) [YggdrasilMinecraftSessionService.class:?] at com.mojang.authlib.yggdrasil.YggdrasilMinecraftSessionService$1.load(YggdrasilMinecraftSessionService.java:60) [YggdrasilMinecraftSessionService$1.class:?] at com.mojang.authlib.yggdrasil.YggdrasilMinecraftSessionService$1.load(YggdrasilMinecraftSessionService.java:57) [YggdrasilMinecraftSessionService$1.class:?] at com.google.common.cache.LocalCache$LoadingValueReference.loadFuture(LocalCache.java:3524) [guava-17.0.jar:?] at com.google.common.cache.LocalCache$Segment.loadSync(LocalCache.java:2317) [guava-17.0.jar:?] at com.google.common.cache.LocalCache$Segment.lockedGetOrLoad(LocalCache.java:2280) [guava-17.0.jar:?] at com.google.common.cache.LocalCache$Segment.get(LocalCache.java:2195) [guava-17.0.jar:?] at com.google.common.cache.LocalCache.get(LocalCache.java:3934) [guava-17.0.jar:?] at com.google.common.cache.LocalCache.getOrLoad(LocalCache.java:3938) [guava-17.0.jar:?] at com.google.common.cache.LocalCache$LocalLoadingCache.get(LocalCache.java:4821) [guava-17.0.jar:?] at com.google.common.cache.LocalCache$LocalLoadingCache.getUnchecked(LocalCache.java:4827) [guava-17.0.jar:?] at com.mojang.authlib.yggdrasil.YggdrasilMinecraftSessionService.fillProfileProperties(YggdrasilMinecraftSessionService.java:170) [YggdrasilMinecraftSessionService.class:?] at net.minecraft.client.Minecraft.getProfileProperties(Minecraft.java:3062) [Minecraft.class:?] at net.minecraft.client.resources.SkinManager$3.run(SkinManager.java:138) [SkinManager$3.class:?] at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source) [?:1.8.0_102] at java.util.concurrent.FutureTask.run(Unknown Source) [?:1.8.0_102] at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) [?:1.8.0_102] at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) [?:1.8.0_102] at java.lang.Thread.run(Unknown Source) [?:1.8.0_102] [14:40:07] [Server thread/FATAL]: Error executing task java.util.concurrent.ExecutionException: java.lang.NullPointerException: The validated object is null at java.util.concurrent.FutureTask.report(Unknown Source) ~[?:1.8.0_102] at java.util.concurrent.FutureTask.get(Unknown Source) ~[?:1.8.0_102] at net.minecraft.util.Util.runTask(Util.java:27) [Util.class:?] at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:753) [MinecraftServer.class:?] at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:698) [MinecraftServer.class:?] at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:156) [IntegratedServer.class:?] at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:547) [MinecraftServer.class:?] at java.lang.Thread.run(Unknown Source) [?:1.8.0_102] Caused by: java.lang.NullPointerException: The validated object is null at org.apache.commons.lang3.Validate.notNull(Validate.java:222) ~[commons-lang3-3.3.2.jar:3.3.2] at org.apache.commons.lang3.Validate.notNull(Validate.java:203) ~[commons-lang3-3.3.2.jar:3.3.2] at net.minecraft.util.NonNullList.add(NonNullList.java:54) ~[NonNullList.class:?] at java.util.AbstractList.add(Unknown Source) ~[?:1.8.0_102] at net.minecraft.inventory.Container.getInventory(Container.java:64) ~[Container.class:?] at net.minecraft.inventory.Container.addListener(Container.java:53) ~[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:2725) ~[EntityPlayer.class:?] at mhfc.net.common.block.container.BlockHunterBench.onBlockActivated(BlockHunterBench.java:41) ~[BlockHunterBench.class:?] at net.minecraft.server.management.PlayerInteractionManager.processRightClickBlock(PlayerInteractionManager.java:474) ~[PlayerInteractionManager.class:?] at net.minecraft.network.NetHandlerPlayServer.processTryUseItemOnBlock(NetHandlerPlayServer.java:701) ~[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:15) ~[PacketThreadUtil$1.class:?] at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source) ~[?:1.8.0_102] at java.util.concurrent.FutureTask.run(Unknown Source) ~[?:1.8.0_102] at net.minecraft.util.Util.runTask(Util.java:26) ~[Util.class:?] ... 5 more Edited April 23, 2017 by Heltrato not ocmplete Quote
Choonster Posted April 23, 2017 Posted April 23, 2017 (edited) You still have a null ItemStack somewhere in the inventory used by the Container. To narrow it down, set a breakpoint inside the for loop Container#getInventory with the condition inventorySlots.get(i).getStack() == null (i.e. the Slot's ItemStack is null). When the breakpoint is hit, look at the Slot's inventory (Slot#inventory or SlotItemHandler#itemHandler) and index (Slot#slotIndex) to see which inventory slot contains the null ItemStack. Once you know where the null ItemStack is, you can figure out where that slot is set from and why it's being set to null. To help avoid errors like this, annotate any ItemStack return value or parameter with @Nonnull. Your IDE will warn you when you return a nullable value from a @Nonnull method or pass a nullable value to a @Nonnull parameter. If you copy the package-info.java file from a vanilla package into your own packages, the @MethodsReturnNonnullByDefault and @ParametersAreNonnullByDefault annotations will tell your IDE that the methods and parameters in that package are @Nonnull by default. Use @Nullable if a method can return or accept null values. Edited April 23, 2017 by Choonster 1 Quote Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.
Heltrato Posted April 23, 2017 Author Posted April 23, 2017 (edited) ahh the debug method wait ill try that. but ill try copying that package info so that i can have warnings as fast. Edited April 23, 2017 by Heltrato Quote
Heltrato Posted April 23, 2017 Author Posted April 23, 2017 (edited) Update i started debugging this line public NonNullList<ItemStack> getInventory() { NonNullList<ItemStack> nonnulllist = NonNullList.<ItemStack>create(); for (int i = 0; i < this.inventorySlots.size(); ++i) { nonnulllist.add(((Slot)this.inventorySlots.get(i)).getStack()); // <--- BREAKPOINT HERE. } return nonnulllist; } But after i created a new world it begans to stop havent opening the block yet. Edited April 23, 2017 by Heltrato Quote
Heltrato Posted April 23, 2017 Author Posted April 23, 2017 (edited) [/img] Edited April 23, 2017 by Heltrato Quote
Heltrato Posted April 23, 2017 Author Posted April 23, 2017 I able to bypass the world load by disabling the line and enabiling as soon as i right click the block. Now i see a NULL at defaultElement then i set it as ItemStack.EMPTY. Quote
Matryoshika Posted April 23, 2017 Posted April 23, 2017 Quote NonNullList<ItemStack> nonnulllist = NonNullList.<ItemStack>create(); Don't think that that is proper Java syntax there Just call NonNullList.create(). Quote Also previously known as eAndPi. "Pi, is there a station coming up where we can board your train of thought?" -Kronnn Published Mods: Underworld Handy links: Vic_'s Forge events Own WIP Tutorials.
Choonster Posted April 23, 2017 Posted April 23, 2017 57 minutes ago, Heltrato said: Update i started debugging this line But after i created a new world it begans to stop havent opening the block yet. Did you set a condition for the breakpoint like I said? If you did, it should only trigger when you right click on the block to open the GUI. 30 minutes ago, Heltrato said: I able to bypass the world load by disabling the line and enabiling as soon as i right click the block. Now i see a NULL at defaultElement then i set it as ItemStack.EMPTY. That's not the field I told you to look at. It's normal for that field to be null. 16 minutes ago, Matryoshika said: Don't think that that is proper Java syntax there Just call NonNullList.create(). It is valid, though not normally needed. That snippet of code is from vanilla, not the OP's mod. Quote Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.
Heltrato Posted April 23, 2017 Author Posted April 23, 2017 3 hours ago, Choonster said: Did you set a condition for the breakpoint like I said? If you did, it should only trigger when you right click on the block to open the GUI. That's not the field I told you to look at. It's normal for that field to be null. It is valid, though not normally needed. That snippet of code is from vanilla, not the OP's mod. Sorry Late reply i just took a nap anyways here is the progress. I added the conditions and as far as my searching for nulls this is what i found Inside inventorySlots>elementData>[0..99]>[0](which is the Hunter Bench>inventory>stackresults etc. Quote
Heltrato Posted April 23, 2017 Author Posted April 23, 2017 I dont know if the slotIndex has a null value. all has a range from 0 - 99 Quote
Choonster Posted April 23, 2017 Posted April 23, 2017 Somehow the InventoryCraftResult#stackResult NonNullList has an instance of Arrays.ArrayList as its delegate list but null as its default element. This shouldn't be possible unless the protected NonNullList(List<E>, E) constructor was called directly rather than being called through NonNullList#create or NonNullList#withSize. Does ContainerHunterBench use the vanilla InventoryCraftResult class? Post the ContainerHunterBench, TileEntityHunterBench and InventoryCraftResult (if it's your own) classes. 1 Quote Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.
Heltrato Posted April 23, 2017 Author Posted April 23, 2017 42 minutes ago, Choonster said: Somehow the InventoryCraftResult#stackResult NonNullList has an instance of Arrays.ArrayList as its delegate list but null as its default element. This shouldn't be possible unless the protected NonNullList(List<E>, E) constructor was called directly rather than being called through NonNullList#create or NonNullList#withSize. Does ContainerHunterBench use the vanilla InventoryCraftResult class? Post the ContainerHunterBench, TileEntityHunterBench and InventoryCraftResult (if it's your own) classes. Yes it does wait up Container Hunter Bench package mhfc.net.client.container; import mhfc.net.client.gui.slot.SlotHunterBench; import mhfc.net.common.core.registry.MHFCBlockRegistry; import mhfc.net.common.crafting.MHFCCraftingManager; import mhfc.net.common.tile.TileHunterBench; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.inventory.Container; import net.minecraft.inventory.IInventory; import net.minecraft.inventory.InventoryCraftResult; import net.minecraft.inventory.InventoryCrafting; import net.minecraft.inventory.Slot; import net.minecraft.item.ItemStack; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; public class ContainerHunterBench extends Container { public InventoryCrafting craftMatrix = new InventoryCrafting(this, 3, 5); public IInventory craftResult = new InventoryCraftResult(); private World worldObj; private int posX; private int posY; private int posZ; public ContainerHunterBench(InventoryPlayer par1InventoryPlayer, World par2World, TileHunterBench tileEntity, int x,int y,int z) { this.worldObj = par2World; this.posX = x; this.posY = y; this.posZ = z; this.addSlotToContainer( new SlotHunterBench( par1InventoryPlayer.player, this.craftMatrix, this.craftResult, 0, 124 + 8, 35 + 1)); int var6; int var7; for (var6 = 0; var6 < 5; ++var6) { for (var7 = 0; var7 < 3; ++var7) { this.addSlotToContainer(new Slot(this.craftMatrix, var7 + var6 * 3, 30 + var7 * 18, var6 * 18 + 15)); } } for (var6 = 0; var6 < 3; ++var6) { for (var7 = 0; var7 < 9; ++var7) { this.addSlotToContainer( new Slot(par1InventoryPlayer, var7 + var6 * 9 + 9, 158 + var7 * 18, var6 * 18 + 15)); } } for (var6 = 0; var6 < 9; ++var6) { this.addSlotToContainer(new Slot(par1InventoryPlayer, var6, 158 + var6 * 18, 84)); } for (var6 = 0; var6 < 7; ++var6) { Slot s = new Slot(tileEntity, var6 + 3, var6 * 18 + 229, 28) { @Override public boolean isItemValid(ItemStack stack) { return false; } @Override public boolean canTakeStack(EntityPlayer p) { return false; } }; this.addSlotToContainer(s); } for (var6 = 0; var6 < 7; ++var6) { this.addSlotToContainer(new Slot(tileEntity, var6 + 10, var6 * 18 + 229, 191) { }); } this.addSlotToContainer(new Slot(tileEntity, TileHunterBench.resultSlot, 280, 146) { @Override public boolean isItemValid(ItemStack stack) { return false; } }); this.addSlotToContainer(new Slot(tileEntity, TileHunterBench.fuelSlot, 354, 168)); this.addSlotToContainer(new Slot(tileEntity, TileHunterBench.outputSlot, 335, 146)); for (var6 = 0; var6 < 4; ++var6) { for (var7 = 0; var7 < 9; ++var7) { this.addSlotToContainer(new Slot(par1InventoryPlayer, var7 + var6 * 9, 7 + var6 * 18, var7 * 18 + 28)); } } this.onCraftMatrixChanged(this.craftMatrix); } @Override public void onCraftMatrixChanged(IInventory par1IInventory) { this.craftResult.setInventorySlotContents(0,MHFCCraftingManager.getInstance().findMatchingRecipe(this.craftMatrix, this.worldObj)); } @Override public boolean canInteractWith(EntityPlayer par1EntityPlayer) { return this.worldObj.getBlockState(new BlockPos(this.posX, this.posY, this.posZ)) .getBlock() != MHFCBlockRegistry.getRegistry().mhfcblockhunterbench ? false : par1EntityPlayer.getDistanceSq(this.posX + 0.5D, this.posY + 0.5D, this.posZ + 0.5D) <= 64.0D; } @Override public void onContainerClosed(EntityPlayer par1EntityPlayer) { super.onContainerClosed(par1EntityPlayer); if (!this.worldObj.isRemote) { for (int i = 0; i < 15; ++i) { ItemStack itemstack = this.craftMatrix.getStackInSlot(i); if (itemstack != null) { par1EntityPlayer.dropItem(itemstack, false); } } } } @Override public ItemStack transferStackInSlot(EntityPlayer par1EntityPlayer, int par2) { ItemStack var3 = null; Slot var4 = this.inventorySlots.get(par2); if (var4 != null && var4.getHasStack()) { ItemStack var5 = var4.getStack(); var3 = var5.copy(); if (par2 == 0) { if (!this.mergeItemStack(var5, 10, 46, true)) { return null; } var4.onSlotChange(var5, var3); } else if (par2 >= 10 && par2 < 37) { if (!this.mergeItemStack(var5, 37, 46, false)) { return null; } } else if (par2 >= 37 && par2 < 46) { if (!this.mergeItemStack(var5, 10, 37, false)) { return null; } } else if (!this.mergeItemStack(var5, 10, 46, false)) { return null; } if (var5.getCount() == 0) { var4.putStack((ItemStack) null); } else { var4.onSlotChanged(); } if (var5.getCount() == var3.getCount()) { return null; } var4.onTake(par1EntityPlayer, var5); } return var3; } @Override public boolean canMergeSlot(ItemStack par1ItemStack, Slot par2Slot) { return par2Slot.inventory != this.craftResult && super.canMergeSlot(par1ItemStack, par2Slot); } } Tile Entity package mhfc.net.common.tile; import mhfc.net.common.core.registry.MHFCEquipementRecipeRegistry; import mhfc.net.common.crafting.recipes.equipment.EquipmentRecipe; import mhfc.net.common.crafting.recipes.equipment.EquipmentRecipe.RecipeType; import mhfc.net.common.index.ResourceInterface; import mhfc.net.common.network.PacketPipeline; import mhfc.net.common.network.message.bench.MessageBeginCrafting; import mhfc.net.common.network.message.bench.MessageBenchRefreshRequest; import mhfc.net.common.network.message.bench.MessageCancelRecipe; import mhfc.net.common.network.message.bench.MessageCraftingUpdate; import mhfc.net.common.network.message.bench.MessageSetRecipe; 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.nbt.NBTTagList; import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntityFurnace; import net.minecraft.util.ITickable; import net.minecraft.util.text.ITextComponent; import net.minecraft.util.text.TextComponentTranslation; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; public class TileHunterBench extends TileEntity implements ITickable, IInventory, TileMHFCUpdateStream { public static final int outputSlot = 2; public static final int fuelSlot = 0; public static final int resultSlot = 1; private ItemStack fuelStack; private ItemStack resultStack; private ItemStack[] recipeStacks; private ItemStack[] inputStacks; private ItemStack outputStack; /** * How hot the furnace currently is */ volatile private int heatStrength; /** * How hot the fire produced by the currently burning item is */ volatile private int heatFromItem; /** * How long the furnace stays hot */ volatile private int heatLength; /** * How long the furnace stayed hot initially with the burning item */ private int heatLengthInit; /** * How long the current item has been smelting */ volatile private int itemSmeltDuration; /** * The selected recipe */ private EquipmentRecipe recipe; /** * If the recipe is currently worked on */ volatile private boolean workingMHFCBench; public TileHunterBench() { recipeStacks = new ItemStack[7]; inputStacks = new ItemStack[recipeStacks.length]; workingMHFCBench = false; heatLengthInit = 1; } @Override public int getSizeInventory() { return recipeStacks.length + inputStacks.length + 3; } @Override public void update() { if (heatLength > 0) { --heatLength; heatStrength = getNewHeat(heatStrength, heatFromItem); if (TileHunterBench.this.workingMHFCBench && recipe != null && heatStrength >= recipe.getRequiredHeat()) { ++itemSmeltDuration; } } else { if (fuelStack != null && TileHunterBench.this.workingMHFCBench) { heatLength = TileEntityFurnace.getItemBurnTime(fuelStack); heatLengthInit = heatLength; heatFromItem = getItemHeat(fuelStack); decrStackSize(fuelSlot, 1); if (!world.isRemote) { sendUpdateCraft(); } } else { heatStrength = getNewHeat(heatStrength, 0); } } if (recipe != null && itemSmeltDuration >= recipe.getDuration()) { finishRecipe(); } } private void finishRecipe() { if (world.isRemote) { return; } inputStacks = new ItemStack[inputStacks.length]; outputStack = resultStack.copy(); workingMHFCBench = false; itemSmeltDuration = 0; sendUpdateCraft(); } /** * Forces the client to end the crafting and put the stack into the output slot. Unused * * @param stack */ @SideOnly(Side.CLIENT) public void forceEndCrafting(ItemStack stack) { outputStack = stack; inputStacks = new ItemStack[inputStacks.length]; TileHunterBench.this.workingMHFCBench = false; itemSmeltDuration = 0; } public boolean isWorking() { return TileHunterBench.this.workingMHFCBench; } public void changeRecipe(EquipmentRecipe recipe) { if (world.isRemote) { sendSetRecipe(recipe); } if (recipe != this.recipe) { cancelRecipe(); setRecipe(recipe); } } protected void setRecipe(EquipmentRecipe recipe) { if (recipe == null) { recipeStacks = new ItemStack[7]; this.recipe = null; resultStack = null; } else { resultStack = recipe.getRecipeOutput(); this.recipe = recipe; setIngredients(recipe); } } public void setIngredients(EquipmentRecipe recipe) { this.recipeStacks = recipe.getRequirements(7); } public static int getItemHeat(ItemStack itemStack) { if (itemStack == null) { return 0; } if (itemStack.getItem() == Item.getItemById(327)) { return 1000; } return 200; } private int getNewHeat(int heatOld, int heatAim) { int diff = heatAim - heatOld; // Some math to confuse the hell out of everyone reading this double change = Math.ceil(Math.log(Math.abs(diff) + 1.0)); return heatOld + (int) (Math.ceil(change / 3.0) * Math.signum(diff)); } @Override public ItemStack decrStackSize(int slot, int count) { markDirty(); if (count <= 0) { return null; } // FIXME: can do that better... if (slot > recipeStacks.length + 2) { ItemStack stack = inputStacks[slot - recipeStacks.length - 3]; if (stack == null) { return null; } cancelRecipe(); if (count > stack.getCount()) { count = stack.getCount(); } if (count == stack.getCount()) { inputStacks[slot - recipeStacks.length - 3] = null; return stack; } return stack.splitStack(count); } if (slot > 2) { return null; // You cant get anything from the recipe slots } else if (slot == outputSlot) { if (outputStack == null) { return null; } if (count > outputStack.getCount()) { count = outputStack.getCount(); } if (count == outputStack.getCount()) { ItemStack fuel = outputStack; outputStack = null; return fuel; } return outputStack.splitStack(count); } else if (slot == resultSlot) { return null; } else { if (fuelStack == null) { return null; } if (count > fuelStack.getCount()) { count = fuelStack.getCount(); } if (count == fuelStack.getCount()) { ItemStack fuel = fuelStack; fuelStack = null; return fuel; } return fuelStack.splitStack(count); } } /** * Resets all working progress but leaves the recipe set */ public void cancelRecipe() { if (world.isRemote) { sendCancelRecipe(); } TileHunterBench.this.workingMHFCBench = false; itemSmeltDuration = 0; } @Override public ItemStack removeStackFromSlot(int index) { ItemStack stack = getStackInSlot(index); setInventorySlotContents(index, null); return stack; } @Override public ItemStack getStackInSlot(int i) { if (i < 0 || i >= getSizeInventory()) { return null; } else if (i >= recipeStacks.length + 3) { return inputStacks[i - 3 - recipeStacks.length]; } else if (i >= 3) { return recipeStacks[i - 3]; } else if (i == outputSlot) { return outputStack; } else if (i == resultSlot) { return resultStack; } else { return fuelStack; } } @Override public void setInventorySlotContents(int i, ItemStack itemstack) { if (i < 0 || i >= getSizeInventory()) { return; } if (i >= recipeStacks.length + 3) { inputStacks[i - recipeStacks.length - 3] = itemstack; } else if (i >= 3) { recipeStacks[i - 3] = itemstack; } else if (i == outputSlot) { outputStack = itemstack; } else if (i == resultSlot) { resultStack = itemstack; } else if (i == fuelSlot) { fuelStack = itemstack; } markDirty(); } public boolean isInvNameLocalized() { return false; } @Override public boolean isEmpty() { for (ItemStack stack : inputStacks) { if (!stack.isEmpty()) { return false; } } return true; } @Override public int getInventoryStackLimit() { return 64; } @Override public boolean isUsableByPlayer(EntityPlayer entityplayer) { return getDistanceSq(entityplayer.posX, entityplayer.posY, entityplayer.posZ) <= 64.0f; } @Override public boolean isItemValidForSlot(int i, ItemStack itemstack) { return (i == fuelSlot && TileEntityFurnace.isItemFuel(itemstack)) || (i > recipeStacks.length + 2 && i < recipeStacks.length * 2 + 3); } @Override public ITextComponent getDisplayName() { return new TextComponentTranslation(getName()); } public boolean beginCrafting() { if (world.isRemote) { sendBeginCraft(); } if (canBeginCrafting()) { TileHunterBench.this.workingMHFCBench = true; } return TileHunterBench.this.workingMHFCBench; } @SideOnly(Side.CLIENT) private void sendBeginCraft() { PacketPipeline.networkPipe.sendToServer(new MessageBeginCrafting(this)); } @SideOnly(Side.CLIENT) private void sendSetRecipe(EquipmentRecipe recipeToSend) { PacketPipeline.networkPipe.sendToServer(new MessageSetRecipe(this, recipeToSend)); } @SideOnly(Side.CLIENT) private void sendCancelRecipe() { PacketPipeline.networkPipe.sendToServer(new MessageCancelRecipe(this)); } @Override public void refreshState() { if (world.isRemote) { PacketPipeline.networkPipe.sendToServer(new MessageBenchRefreshRequest(this)); } } private void sendUpdateCraft() { PacketPipeline.networkPipe.sendToAll(new MessageCraftingUpdate(this)); } public boolean canBeginCrafting() { return (recipe != null) && matchesInputOutput() && (outputStack == null); } protected boolean matchesInputOutput() { for (int i = 0; i < inputStacks.length; i++) { if (!ItemStack.areItemStacksEqual(inputStacks[i], recipeStacks[i])) { return false; } } return true; } public int getHeatStrength() { return heatStrength; } public int getBurningItemHeat() { return heatFromItem; } public int getHeatLength() { return heatLength; } public int getHeatLengthOriginal() { return heatLengthInit; } public int getItemSmeltDuration() { return itemSmeltDuration; } @Override public void readFromNBT(NBTTagCompound nbtTag) { super.readFromNBT(nbtTag); readCustomUpdate(nbtTag); NBTTagList items = nbtTag.getTagList("Items", 10); for (int a = 0; a < items.tagCount(); a++) { NBTTagCompound stack = items.getCompoundTagAt(a); byte id = stack.getByte("Slot"); if (id >= 0 && id < getSizeInventory()) { setInventorySlotContents(id, new ItemStack(stack)); } } } @Override public NBTTagCompound writeToNBT(NBTTagCompound nbtTag) { nbtTag = super.writeToNBT(nbtTag); storeCustomUpdate(nbtTag); NBTTagList itemsStored = new NBTTagList(); for (int a = 0; a < getSizeInventory(); a++) { ItemStack s = getStackInSlot(a); if (s != null) { NBTTagCompound tag = new NBTTagCompound(); tag.setByte("Slot", (byte) a); s.writeToNBT(tag); itemsStored.appendTag(tag); } } nbtTag.setTag("Items", itemsStored); return nbtTag; } public EquipmentRecipe getRecipe() { return recipe; } private static final String heatStrID = "heatStrength"; private static final String heatFromItemID = "heatFromItem"; private static final String heatLengthID = "heatLength"; private static final String heatLengthInitID = "heatLengthInit"; private static final String itemSmeltDurationID = "itemSmeltDuration"; private static final String workingID = "workingID"; private static final String recipeTypeID = "recipeType"; private static final String recipeIDID = "recipeID"; @Override public void storeCustomUpdate(NBTTagCompound nbtTag) { nbtTag.setInteger(heatStrID, heatStrength); nbtTag.setInteger(heatFromItemID, heatFromItem); nbtTag.setInteger(heatLengthID, heatLength); nbtTag.setInteger(heatLengthInitID, heatLengthInit); nbtTag.setInteger(itemSmeltDurationID, itemSmeltDuration); nbtTag.setBoolean(workingID, TileHunterBench.this.workingMHFCBench); RecipeType type = recipe != null ? recipe.getRecipeType() : RecipeType.MHFC; int recipeID = MHFCEquipementRecipeRegistry.getIDFor(recipe); nbtTag.setInteger(recipeTypeID, type.ordinal()); nbtTag.setInteger(recipeIDID, recipeID); } @Override public void readCustomUpdate(NBTTagCompound nbtTag) { heatStrength = nbtTag.getInteger(heatStrID); heatFromItem = nbtTag.getInteger(heatFromItemID); heatLength = nbtTag.getInteger(heatLengthID); heatLengthInit = nbtTag.getInteger(heatLengthInitID); itemSmeltDuration = nbtTag.getInteger(itemSmeltDurationID); TileHunterBench.this.workingMHFCBench = nbtTag.getBoolean(workingID); int irecType = nbtTag.getInteger(recipeTypeID); int recId = nbtTag.getInteger(recipeIDID); RecipeType recType = RecipeType.values()[irecType]; setRecipe(MHFCEquipementRecipeRegistry.getRecipeFor(recId, recType)); } @Override public String getName() { return "container" + ResourceInterface.block_hunterbench_name; } @Override public boolean hasCustomName() { return false; } @Override public void openInventory(EntityPlayer player) {} @Override public void closeInventory(EntityPlayer player) {} @Override public void clear() { for (int i = 0; i < getSizeInventory(); ++i) { removeStackFromSlot(i); } } @Override public int getField(int id) { throw new IllegalArgumentException("No such field: " + id); } @Override public void setField(int id, int value) { throw new IllegalArgumentException("No such field: " + id); } @Override public int getFieldCount() { return 0; } } I dont have my own inventory crafting i uses vanilla. Quote
Heltrato Posted April 23, 2017 Author Posted April 23, 2017 Shit! looks like my team found a fix and its all in TileCraftingBench all along !!!! fak it Thank you for telling us the ItemStack.NULL. *phew Anyways here it is Quote
Choonster Posted April 23, 2017 Posted April 23, 2017 (edited) You shouldn't be using or implementing IInventory or storing ItemStacks in arrays, create an IItemHandler field for each of the TileEntity's inventories and expose them using the Capability system. If you just need a temporary collection of ItemStacks without a formal inventory, use a NonNullList (created by calling NonNullList#withSize with ItemStack.EMPTY as the second argument) instead of an array. This will help to eliminate any potential null ItemStacks. Edited April 24, 2017 by Choonster Fixed typo 1 Quote Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.