Aidas1000 Posted March 22, 2016 Posted March 22, 2016 Hello everybody. I'm making a custom crafting table, but I get this error: [18:52:53] [Client thread/FATAL] [FML]: Exception caught executing FutureTask: java.util.concurrent.ExecutionException: java.lang.ClassCastException: aidas.morestuff.guicontainer.BigContainer cannot be cast to net.minecraft.client.gui.GuiScreen java.util.concurrent.ExecutionException: java.lang.ClassCastException: aidas.morestuff.guicontainer.BigContainer cannot be cast to net.minecraft.client.gui.GuiScreen at java.util.concurrent.FutureTask.report(FutureTask.java:122) ~[?:1.8.0_31] at java.util.concurrent.FutureTask.get(FutureTask.java:192) ~[?:1.8.0_31] at net.minecraftforge.fml.common.FMLCommonHandler.callFuture(FMLCommonHandler.java:715) [FMLCommonHandler.class:?] at net.minecraft.client.Minecraft.runGameLoop(Minecraft.java:1077) [Minecraft.class:?] at net.minecraft.client.Minecraft.run(Minecraft.java:376) [Minecraft.class:?] at net.minecraft.client.main.Main.main(Main.java:117) [Main.class:?] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_31] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_31] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_31] at java.lang.reflect.Method.invoke(Method.java:483) ~[?:1.8.0_31] 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_31] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_31] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_31] at java.lang.reflect.Method.invoke(Method.java:483) ~[?:1.8.0_31] at net.minecraftforge.gradle.GradleStartCommon.launch(Unknown Source) [start/:?] at GradleStart.main(Unknown Source) [start/:?] Caused by: java.lang.ClassCastException: aidas.morestuff.guicontainer.BigContainer cannot be cast to net.minecraft.client.gui.GuiScreen at net.minecraftforge.fml.client.FMLClientHandler.showGuiScreen(FMLClientHandler.java:478) ~[FMLClientHandler.class:?] at net.minecraftforge.fml.common.FMLCommonHandler.showGuiScreen(FMLCommonHandler.java:344) ~[FMLCommonHandler.class:?] at net.minecraftforge.fml.common.network.internal.FMLNetworkHandler.openGui(FMLNetworkHandler.java:103) ~[FMLNetworkHandler.class:?] at net.minecraft.entity.player.EntityPlayer.openGui(EntityPlayer.java:2579) ~[EntityPlayer.class:?] at net.minecraftforge.fml.common.network.internal.OpenGuiHandler.process(OpenGuiHandler.java:39) ~[OpenGuiHandler.class:?] at net.minecraftforge.fml.common.network.internal.OpenGuiHandler.access$000(OpenGuiHandler.java:15) ~[OpenGuiHandler.class:?] at net.minecraftforge.fml.common.network.internal.OpenGuiHandler$1.run(OpenGuiHandler.java:30) ~[OpenGuiHandler$1.class:?] at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) ~[?:1.8.0_31] at java.util.concurrent.FutureTask.run(FutureTask.java:266) ~[?:1.8.0_31] at net.minecraftforge.fml.common.FMLCommonHandler.callFuture(FMLCommonHandler.java:714) ~[FMLCommonHandler.class:?] ... 15 more [18:52:54] [Client thread/FATAL] [FML]: Exception caught executing FutureTask: java.util.concurrent.ExecutionException: java.lang.ClassCastException: aidas.morestuff.guicontainer.BigContainer cannot be cast to net.minecraft.client.gui.GuiScreen java.util.concurrent.ExecutionException: java.lang.ClassCastException: aidas.morestuff.guicontainer.BigContainer cannot be cast to net.minecraft.client.gui.GuiScreen at java.util.concurrent.FutureTask.report(FutureTask.java:122) ~[?:1.8.0_31] at java.util.concurrent.FutureTask.get(FutureTask.java:192) ~[?:1.8.0_31] at net.minecraftforge.fml.common.FMLCommonHandler.callFuture(FMLCommonHandler.java:715) [FMLCommonHandler.class:?] at net.minecraft.client.Minecraft.runGameLoop(Minecraft.java:1077) [Minecraft.class:?] at net.minecraft.client.Minecraft.run(Minecraft.java:376) [Minecraft.class:?] at net.minecraft.client.main.Main.main(Main.java:117) [Main.class:?] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_31] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_31] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_31] at java.lang.reflect.Method.invoke(Method.java:483) ~[?:1.8.0_31] 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_31] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_31] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_31] at java.lang.reflect.Method.invoke(Method.java:483) ~[?:1.8.0_31] at net.minecraftforge.gradle.GradleStartCommon.launch(Unknown Source) [start/:?] at GradleStart.main(Unknown Source) [start/:?] Caused by: java.lang.ClassCastException: aidas.morestuff.guicontainer.BigContainer cannot be cast to net.minecraft.client.gui.GuiScreen at net.minecraftforge.fml.client.FMLClientHandler.showGuiScreen(FMLClientHandler.java:478) ~[FMLClientHandler.class:?] at net.minecraftforge.fml.common.FMLCommonHandler.showGuiScreen(FMLCommonHandler.java:344) ~[FMLCommonHandler.class:?] at net.minecraftforge.fml.common.network.internal.FMLNetworkHandler.openGui(FMLNetworkHandler.java:103) ~[FMLNetworkHandler.class:?] at net.minecraft.entity.player.EntityPlayer.openGui(EntityPlayer.java:2579) ~[EntityPlayer.class:?] at net.minecraftforge.fml.common.network.internal.OpenGuiHandler.process(OpenGuiHandler.java:39) ~[OpenGuiHandler.class:?] at net.minecraftforge.fml.common.network.internal.OpenGuiHandler.access$000(OpenGuiHandler.java:15) ~[OpenGuiHandler.class:?] at net.minecraftforge.fml.common.network.internal.OpenGuiHandler$1.run(OpenGuiHandler.java:30) ~[OpenGuiHandler$1.class:?] at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) ~[?:1.8.0_31] at java.util.concurrent.FutureTask.run(FutureTask.java:266) ~[?:1.8.0_31] at net.minecraftforge.fml.common.FMLCommonHandler.callFuture(FMLCommonHandler.java:714) ~[FMLCommonHandler.class:?] ... 15 more [18:52:54] [Client thread/FATAL] [FML]: Exception caught executing FutureTask: java.util.concurrent.ExecutionException: java.lang.ClassCastException: aidas.morestuff.guicontainer.BigContainer cannot be cast to net.minecraft.client.gui.GuiScreen java.util.concurrent.ExecutionException: java.lang.ClassCastException: aidas.morestuff.guicontainer.BigContainer cannot be cast to net.minecraft.client.gui.GuiScreen at java.util.concurrent.FutureTask.report(FutureTask.java:122) ~[?:1.8.0_31] at java.util.concurrent.FutureTask.get(FutureTask.java:192) ~[?:1.8.0_31] at net.minecraftforge.fml.common.FMLCommonHandler.callFuture(FMLCommonHandler.java:715) [FMLCommonHandler.class:?] at net.minecraft.client.Minecraft.runGameLoop(Minecraft.java:1077) [Minecraft.class:?] at net.minecraft.client.Minecraft.run(Minecraft.java:376) [Minecraft.class:?] at net.minecraft.client.main.Main.main(Main.java:117) [Main.class:?] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_31] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_31] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_31] at java.lang.reflect.Method.invoke(Method.java:483) ~[?:1.8.0_31] 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_31] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_31] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_31] at java.lang.reflect.Method.invoke(Method.java:483) ~[?:1.8.0_31] at net.minecraftforge.gradle.GradleStartCommon.launch(Unknown Source) [start/:?] at GradleStart.main(Unknown Source) [start/:?] Caused by: java.lang.ClassCastException: aidas.morestuff.guicontainer.BigContainer cannot be cast to net.minecraft.client.gui.GuiScreen at net.minecraftforge.fml.client.FMLClientHandler.showGuiScreen(FMLClientHandler.java:478) ~[FMLClientHandler.class:?] at net.minecraftforge.fml.common.FMLCommonHandler.showGuiScreen(FMLCommonHandler.java:344) ~[FMLCommonHandler.class:?] at net.minecraftforge.fml.common.network.internal.FMLNetworkHandler.openGui(FMLNetworkHandler.java:103) ~[FMLNetworkHandler.class:?] at net.minecraft.entity.player.EntityPlayer.openGui(EntityPlayer.java:2579) ~[EntityPlayer.class:?] at net.minecraftforge.fml.common.network.internal.OpenGuiHandler.process(OpenGuiHandler.java:39) ~[OpenGuiHandler.class:?] at net.minecraftforge.fml.common.network.internal.OpenGuiHandler.access$000(OpenGuiHandler.java:15) ~[OpenGuiHandler.class:?] at net.minecraftforge.fml.common.network.internal.OpenGuiHandler$1.run(OpenGuiHandler.java:30) ~[OpenGuiHandler$1.class:?] at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) ~[?:1.8.0_31] at java.util.concurrent.FutureTask.run(FutureTask.java:266) ~[?:1.8.0_31] at net.minecraftforge.fml.common.FMLCommonHandler.callFuture(FMLCommonHandler.java:714) ~[FMLCommonHandler.class:?] ... 15 more My block class: package aidas.morestuff.blocks; import aidas.morestuff.Main; import aidas.morestuff.items.MItems; import aidas.morestuff.network.MGuiHandler; import net.minecraft.block.Block; import net.minecraft.block.BlockWorkbench; import net.minecraft.block.material.Material; import net.minecraft.block.state.IBlockState; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.init.Blocks; import net.minecraft.inventory.Container; import net.minecraft.inventory.ContainerWorkbench; import net.minecraft.util.BlockPos; import net.minecraft.util.ChatComponentTranslation; import net.minecraft.util.EnumFacing; import net.minecraft.util.IChatComponent; import net.minecraft.world.IInteractionObject; import net.minecraft.world.World; public class BigWorkbench extends Block { protected BigWorkbench(String uName) { super(Material.wood); this.setCreativeTab(MItems.tabMS); this.setUnlocalizedName(uName); } @Override public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumFacing side, float hitX, float hitY, float hitZ) { if (!worldIn.isRemote) { playerIn.openGui(Main.instance, MGuiHandler.BIG_GUI, worldIn, pos.getX(), pos.getY(), pos.getZ()); } return true; } } The MGuiHandler code: package aidas.morestuff.network; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.util.BlockPos; import net.minecraft.world.World; import net.minecraftforge.fml.common.network.IGuiHandler; import aidas.morestuff.client.gui.CabinGui; import aidas.morestuff.guicontainer.BigContainer; import aidas.morestuff.guicontainer.ContainerCabin; import aidas.morestuff.tileentity.CabinTileEntity; public class MGuiHandler implements IGuiHandler { public static final int CABIN_GUI = 0; public static final int BIG_GUI = 1; @Override public Object getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) { if (ID == CABIN_GUI) return new ContainerCabin(player.inventory, (CabinTileEntity) world.getTileEntity(new BlockPos(x, y, z))); else if(ID == BIG_GUI) return new BigContainer(player.inventory, world, new BlockPos(x, y, z)); return null; } @Override public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) { if (ID == CABIN_GUI) return new CabinGui(new ContainerCabin(player.inventory, (CabinTileEntity) world.getTileEntity(new BlockPos(x, y, z)))); else if(ID == BIG_GUI) return new BigContainer(player.inventory, world, new BlockPos(x, y, z)); return null; } } BigContainer: package aidas.morestuff.guicontainer; import aidas.morestuff.blocks.MBlocks; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.init.Blocks; 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.inventory.SlotCrafting; import net.minecraft.item.ItemStack; import net.minecraft.item.crafting.CraftingManager; import net.minecraft.util.BlockPos; import net.minecraft.world.World; public class BigContainer extends Container { /** The crafting matrix inventory (4x4). */ public InventoryCrafting craftMatrix = new InventoryCrafting(this, 4, 4); public IInventory craftResult = new InventoryCraftResult(); private World worldObj; private BlockPos field_178145_h; private static final String __OBFID = "CL_00001744"; public BigContainer(InventoryPlayer playerInventory, World worldIn, BlockPos p_i45800_3_) { this.worldObj = worldIn; this.field_178145_h = p_i45800_3_; this.addSlotToContainer(new SlotCrafting(playerInventory.player, this.craftMatrix, this.craftResult, 0, 124, 35)); int i; int j; int counter = 0; for (i = 0; i < 4; ++i) { for (j = 0; j < 4; ++j) { this.addSlotToContainer(new Slot(this.craftMatrix, counter, 30 + j * 18, 17 + i * 18)); } } for (i = 0; i < 3; ++i) { for (j = 0; j < 9; ++j) { this.addSlotToContainer(new Slot(playerInventory, j + i * 9 + 9, 8 + j * 18, 84 + i * 18)); } } for (i = 0; i < 9; ++i) { this.addSlotToContainer(new Slot(playerInventory, i, 8 + i * 18, 142)); } this.onCraftMatrixChanged(this.craftMatrix); } /** * Callback for when the crafting matrix is changed. */ public void onCraftMatrixChanged(IInventory inventoryIn) { this.craftResult.setInventorySlotContents(0, CraftingManager.getInstance().findMatchingRecipe(this.craftMatrix, this.worldObj)); } /** * Called when the container is closed. */ public void onContainerClosed(EntityPlayer playerIn) { super.onContainerClosed(playerIn); if (!this.worldObj.isRemote) { for (int i = 0; i < 16; ++i) { ItemStack itemstack = this.craftMatrix.getStackInSlotOnClosing(i); if (itemstack != null) { playerIn.dropPlayerItemWithRandomChoice(itemstack, false); } } } } public boolean canInteractWith(EntityPlayer playerIn) { return this.worldObj.getBlockState(this.field_178145_h).getBlock() != MBlocks.big_workbench ? false : playerIn.getDistanceSq((double)this.field_178145_h.getX() + 0.5D, (double)this.field_178145_h.getY() + 0.5D, (double)this.field_178145_h.getZ() + 0.5D) <= 64.0D; } /** * Take a stack from the specified inventory slot. */ public ItemStack transferStackInSlot(EntityPlayer playerIn, int index) { ItemStack itemstack = null; Slot slot = (Slot)this.inventorySlots.get(index); if (slot != null && slot.getHasStack()) { ItemStack itemstack1 = slot.getStack(); itemstack = itemstack1.copy(); if (index == 0) { if (!this.mergeItemStack(itemstack1, 10, 46, true)) { return null; } slot.onSlotChange(itemstack1, itemstack); } else if (index >= 10 && index < 37) { if (!this.mergeItemStack(itemstack1, 37, 46, false)) { return null; } } else if (index >= 37 && index < 46) { if (!this.mergeItemStack(itemstack1, 10, 37, false)) { return null; } } else if (!this.mergeItemStack(itemstack1, 10, 46, false)) { return null; } if (itemstack1.stackSize == 0) { slot.putStack((ItemStack)null); } else { slot.onSlotChanged(); } if (itemstack1.stackSize == itemstack.stackSize) { return null; } slot.onPickupFromSlot(playerIn, itemstack1); } return itemstack; } /** * Called to determine if the current slot is valid for the stack merging (double-click) code. The stack passed in * is null for the initial slot that was double-clicked. */ public boolean canMergeSlot(ItemStack p_94530_1_, Slot p_94530_2_) { return p_94530_2_.inventory != this.craftResult && super.canMergeSlot(p_94530_1_, p_94530_2_); } } BigGui: package aidas.morestuff.client.gui; import net.minecraft.client.gui.inventory.GuiContainer; import net.minecraft.client.renderer.GlStateManager; import net.minecraft.client.resources.I18n; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.util.BlockPos; import net.minecraft.util.ResourceLocation; import net.minecraft.world.World; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; import aidas.morestuff.guicontainer.BigContainer; @SideOnly(Side.CLIENT) public class BigGui extends GuiContainer { private static final ResourceLocation craftingTableGuiTextures = new ResourceLocation("ms:textures/gui/container/big.png"); public BigGui(InventoryPlayer playerInv, World worldIn) { this(playerInv, worldIn, BlockPos.ORIGIN); } public BigGui(InventoryPlayer playerInv, World worldIn, BlockPos blockPosition) { super(new BigContainer(playerInv, worldIn, blockPosition)); } /** * Draw the foreground layer for the GuiContainer (everything in front of the items). Args : mouseX, mouseY */ protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) { this.fontRendererObj.drawString(I18n.format("container.crafting", new Object[0]), 28, 6, 4210752); this.fontRendererObj.drawString(I18n.format("container.inventory", new Object[0]), 8, this.ySize - 96 + 2, 4210752); } /** * Args : renderPartialTicks, mouseX, mouseY */ protected void drawGuiContainerBackgroundLayer(float partialTicks, int mouseX, int mouseY) { GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); this.mc.getTextureManager().bindTexture(craftingTableGuiTextures); int k = (this.width - this.xSize) / 2; int l = (this.height - this.ySize) / 2; this.drawTexturedModalRect(k, l, 0, 0, this.xSize, this.ySize); } } I have followed this tutorial (I understand German) , but I still can't fix it . Sorry if this question is dumb. I am kinda new to modding. Quote
Aidas1000 Posted March 23, 2016 Author Posted March 23, 2016 getClientGuiElement must return a GuiScreen. Thank you. That worked. If I had not have skipped the gui handler part, I wouldn't post this. Quote
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.