Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

Zodsmar

Members
  • Posts

    52
  • Joined

  • Last visited

Converted

  • Gender
    Undisclosed
  • Personal Text
    I am new!

Zodsmar's Achievements

Stone Miner

Stone Miner (3/8)

3

Reputation

  1. Is there any github repos which are using this new functionality which I could look at to understand better?
  2. Caused by: java.lang.ClassCastException: com.koopamillion.tile_entity.TileEntityMatter cannot be cast to com.koopamillion.tile_entity.TileEntityMT at com.koopamillion.inventory.ContainerMT.<init>(ContainerMT.java:30) ~[ContainerMT.class:?] It is saying that the cast error is happening on line 30. But like 30 is blanks... so I am at a loss. DO you have the TileEntityMatter class? Can you show it please
  3. Okay but in my case how should I be doing slots tho. Like for this: public FabTabSlot(EntityPlayer par1EntityPlayer, InventoryCrafting craftResult, IInventory iinv, int par4, int par5, int par6) { super(par1EntityPlayer, craftResult, iinv, par4, par5, par6); this.thePlayer = par1EntityPlayer; this.craftMatrix = craftResult; } I cannot change it to IItemHandler because then it errors since I am extending SlotCrafting
  4. Okay now I am a little confused. I am looking at the gui code for hoppers and so on and I still see IInventory everywhere.
  5. Okay so for my class fabTabSlot I figure why it was null pointering thank you Choonster for that. But Here: fabTabSlot = new FabTabSlot(playerInv.player, craftMatrix, fabTile, 0, 143, 36); addSlotToContainer(fabTabSlot); And I pass in this: public FabTabSlot(EntityPlayer par1EntityPlayer, InventoryCrafting craftResult, IInventory iinv, int par4, int par5, int par6) { super(par1EntityPlayer, craftResult, iinv, par4, par5, par6); this.thePlayer = par1EntityPlayer; this.craftMatrix = craftResult; } Before I had craftmatrix being put into an IInventory and the craft fabTile into an InventoryCrafting. Now that line does not null pointer however I feel like I may have found the cause to my problem but because TileEntities and IInventory is kinda newer to me I am not sure. So here it goes with the explanation. When I create my Container I pass in a Tile, InventoryPlayer, World, and 3 int. But when I create slots I am using the Tile, which I passed in, as the IInventory. Is that right? Can my Tile Entity hold the IInventory. Like is that what it is suppose to do or did I royally mess up and need a new variable or something LOL
  6. Why are you casting a block to a block? Item.getItemFromBlock((Block) blockRedstoneAnvil); That may be your issue. Other than that I am looking at this code and it looks fine.
  7. Ikr like same. Normally after starring at the code something jumps out but fucken nothing. Like even if I comment it out. Then I get the null pointer on saveCraftingMatrix(); finally if I comment that then I get this null pointer..... Description: Unexpected error java.lang.NullPointerException: Unexpected error at net.minecraft.inventory.Slot.getStack(Slot.java:81) at net.minecraft.inventory.Container.detectAndSendChanges(Container.java:84) at net.minecraft.inventory.Container.onCraftMatrixChanged(Container.java:567) at com.zodsmar.entities.ContainerFabTable.<init>(ContainerFabTable.java:69) at com.zodsmar.entities.FabTableGui.<init>(FabTableGui.java:21) at com.zodsmar.entities.GuiHandler.getClientGuiElement(GuiHandler.java:27) at net.minecraftforge.fml.common.network.NetworkRegistry.getLocalGuiContainer(NetworkRegistry.java:266) at net.minecraftforge.fml.common.network.internal.FMLNetworkHandler.openGui(FMLNetworkHandler.java:102) at net.minecraft.entity.player.EntityPlayer.openGui(EntityPlayer.java:2694) at com.zodsmar.blocks.FabricationTable.onBlockActivated(FabricationTable.java:36) at net.minecraft.client.multiplayer.PlayerControllerMP.processRightClickBlock(PlayerControllerMP.java:425) at net.minecraft.client.Minecraft.rightClickMouse(Minecraft.java:1597) at net.minecraft.client.Minecraft.processKeyBinds(Minecraft.java:2268) at net.minecraft.client.Minecraft.runTickKeyboard(Minecraft.java:2052) at net.minecraft.client.Minecraft.runTick(Minecraft.java:1840) at net.minecraft.client.Minecraft.runGameLoop(Minecraft.java:1114) at net.minecraft.client.Minecraft.run(Minecraft.java:401) 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) ITS LITERALLY NULL POINTERING ON at net.minecraft.inventory.Slot.getStack(Slot.java:81); HOW LIKE WHAT AM I MISSING HERE...... Jeez I love programming to death but things like this just get to me LOL <3
  8. I am aware of that. Using VANILLA Command blocks (which work on a server) you can make text appear on the players HUD... this should not be new info to you. Please
  9. So the idea is with commands, you can set an area, then if you are within this area have a specific text display on screen, which you would set when inside that space. Question. Why make a FORGE mod for this. You can easily (well easily enough) do this in vanilla with command blocks..... and if u really want a server mod for this make it bukkit. Just saying
  10. Here: public class ContainerFabTable extends Container implements ISlotChanged { private World worldObj; public TileEntityFabTable tileEntity; FabTabSlot FabSlot; private int posX; private int posY; private int posZ; /** The crafting matrix inventory (3x3). */ // container, width, length public InventoryCrafting craftMatrix = new InventoryCrafting(this, 3, 3); private FabTabSlot fabTabSlot; public ContainerFabTable(TileEntityFabTable fabTile, InventoryPlayer playerInv, World world, int x, int y, int z) { worldObj = world; tileEntity = fabTile; //ERROR HERE posX = x; posY = y; posZ = z; fabTabSlot = new FabTabSlot(playerInv.player, this.craftMatrix, tileEntity.craftResult, 0, 143, 36); addSlotToContainer(fabTabSlot); int row; int col; updateCraftingMatrix(); for (row = 0; row < 3; ++row) { for (col = 0; col < 3; ++col) { this.addSlotToContainer(new Slot(this.craftMatrix, col + row * 3, 48 + col * 18, 18 + row * 18)); } } for (int row1 = 0; row1 < 2; row1++) { for (int col1 = 0; col1 < 9; col1++) this.addSlotToContainer(new Slot(tileEntity, col1 + row1 * 9, 8 + col1 * 18, 90 + row1 * 18)); } this.addSlotToContainer(new SlotStartsWith(tileEntity, "fabUpgrade", 28, 16, 10).setSlotChange(tileEntity)); this.addSlotToContainer(new SlotStartsWith(tileEntity, "fabUpgrade", 29, 16, 36).setSlotChange(tileEntity)); this.addSlotToContainer(new SlotStartsWith(tileEntity, "fabUpgrade", 30, 16, 62).setSlotChange(tileEntity)); this.addSlotToContainer(new SlotStartsWith(tileEntity, "fabPlan", 31, 143, 10).setSlotChange(this)); for (int row2 = 0; row2 < 3; row2++) { for (int col2 = 0; col2 < 9; col2++) this.addSlotToContainer(new Slot(playerInv, col2 + row2 * 9 + 9, 8 + col2 * 18, 140 + row2 * 18)); } for (row = 0; row < 9; ++row) { this.addSlotToContainer(new Slot(playerInv, row, 8 + row * 18, 198)); } this.onCraftMatrixChanged(this.craftMatrix); // addSlotToContainer(new Slot(playerInv, 36, 17, 36)); } private void updateCraftingMatrix() { for (int i = 0; i < craftMatrix.getSizeInventory(); i++) { craftMatrix.setInventorySlotContents(i, tileEntity.craftMatrixInventory[i]); } } @Override public void onContainerClosed(EntityPlayer par1EntityPlayer) { super.onContainerClosed(par1EntityPlayer); saveCraftingMatrix(); } private void saveCraftingMatrix() { for (int i = 0; i < craftMatrix.getSizeInventory(); i++) { tileEntity.craftMatrixInventory[i] = craftMatrix.getStackInSlot(i); } } @Override public void onCraftMatrixChanged(IInventory IInv) { tileEntity.craftResult.setInventorySlotContents(0, CraftingManager.getInstance().findMatchingRecipe(this.craftMatrix, this.worldObj)); } @Override public boolean canInteractWith(EntityPlayer entityPlayer) { return tileEntity.isUseableByPlayer(entityPlayer); } @Override public ItemStack transferStackInSlot(EntityPlayer entityPlayer, int par2) { ItemStack itemstack = null; Slot slot = (Slot) this.inventorySlots.get(par2); if (slot != null && slot.getHasStack()) { ItemStack itemstack1 = slot.getStack(); itemstack = itemstack1.copy(); if (par2 == 0) { if (!this.mergeItemStack(itemstack1, 32, 67, false)) { if (itemstack1.stackSize == 0) { slot.putStack((ItemStack) null); } else { slot.onSlotChanged(); } return null; } else { slot.putStack((ItemStack) null); } fabTabSlot.onPickupFromSlot(entityPlayer, itemstack); this.onCraftMatrixChanged(this.craftMatrix); return itemstack; } else if (par2 >= 32 && par2 <= 67) { if (itemstack1.getUnlocalizedName().startsWith("fabUpgrade")) { return null; } else if (!this.mergeItemStack(itemstack1, 10, 27, false)) { if (itemstack1.stackSize == 0) { slot.putStack((ItemStack) null); } else { slot.onSlotChanged(); } return null; } } else if (par2 >= 10 && par2 <= 27 || par2 <= 9 || par2 >= 28 && par2 <= 31) { if (!this.mergeItemStack(itemstack1, 32, 67, false)) { if (itemstack1.stackSize == 0) { slot.putStack((ItemStack) null); } else { slot.onSlotChanged(); } return null; } } } return itemstack; } @Override public void onSlotChange(Slot slot, int id, ItemStack itemStack) { System.out.println("Plans changed"); }
  11. Well your right. That is where the Errors occur. If I comment out the slots, and leave the crafting matrix here is the error: java.lang.NullPointerException: Unexpected error at com.zodsmar.entities.ContainerFabTable.updateCraftingMatrix(ContainerFabTable.java:76) at com.zodsmar.entities.ContainerFabTable.<init>(ContainerFabTable.java:39) at com.zodsmar.entities.FabTableGui.<init>(FabTableGui.java:21) at com.zodsmar.entities.GuiHandler.getClientGuiElement(GuiHandler.java:27) at net.minecraftforge.fml.common.network.NetworkRegistry.getLocalGuiContainer(NetworkRegistry.java:266) at net.minecraftforge.fml.common.network.internal.FMLNetworkHandler.openGui(FMLNetworkHandler.java:102) at net.minecraft.entity.player.EntityPlayer.openGui(EntityPlayer.java:2694) at com.zodsmar.blocks.FabricationTable.onBlockActivated(FabricationTable.java:36) at net.minecraft.client.multiplayer.PlayerControllerMP.processRightClickBlock(PlayerControllerMP.java:425) at net.minecraft.client.Minecraft.rightClickMouse(Minecraft.java:1597) at net.minecraft.client.Minecraft.processKeyBinds(Minecraft.java:2268) at net.minecraft.client.Minecraft.runTickKeyboard(Minecraft.java:2052) at net.minecraft.client.Minecraft.runTick(Minecraft.java:1840) at net.minecraft.client.Minecraft.runGameLoop(Minecraft.java:1114) at net.minecraft.client.Minecraft.run(Minecraft.java:401) 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 thing is I do not understand what I would be doing wrong. Here is the code: /** The craft matrix inventory linked to this result slot. */ private final IInventory craftMatrix; /** The player that is using the GUI where this slot resides. */ private EntityPlayer thePlayer; /** * The number of items that have been crafted so far. Gets passed to ItemStack.onCrafting before being reset. */ private int amountCrafted; public FabTabSlot(EntityPlayer par1EntityPlayer, InventoryCrafting par2IInventory, InventoryCraftResult craftResult, int par4, int par5, int par6) { super(par1EntityPlayer, par2IInventory, craftResult, par4, par5, par6); this.thePlayer = par1EntityPlayer; this.craftMatrix = par2IInventory; } /** * Check if the stack is a valid item for this slot. Always true beside for the armor slots. */ @Override public boolean isItemValid(ItemStack par1ItemStack) { return false; } /** * Decrease the size of the stack in slot (first int arg) by the amount of the second int arg. Returns the new * stack. */ @Override public ItemStack decrStackSize(int par1) { if (this.getHasStack()) { this.amountCrafted += Math.min(par1, this.getStack().stackSize); } return super.decrStackSize(par1); } /** * the itemStack passed in is the output - ie, iron ingots, and pickaxes, not ore and wood. Typically increases an * internal count then calls onCrafting(item). */ @Override protected void onCrafting(ItemStack par1ItemStack, int par2) { this.amountCrafted += par2; this.onCrafting(par1ItemStack); } and the crafting matrix: private void updateCraftingMatrix() { for (int i = 0; i < craftMatrix.getSizeInventory(); i++) { craftMatrix.setInventorySlotContents(i, tileEntity.craftMatrixInventory[i]); } } @Override public void onContainerClosed(EntityPlayer par1EntityPlayer) { super.onContainerClosed(par1EntityPlayer); saveCraftingMatrix(); } private void saveCraftingMatrix() { for (int i = 0; i < craftMatrix.getSizeInventory(); i++) { tileEntity.craftMatrixInventory[i] = craftMatrix.getStackInSlot(i); } } @Override public void onCraftMatrixChanged(IInventory IInv) { tileEntity.craftResult.setInventorySlotContents(0, CraftingManager.getInstance().findMatchingRecipe(this.craftMatrix, this.worldObj)); }
  12. If I don't tho then I get A ticking Player error. Or it starts to null pointer everywhere which makes no sense what so ever.
  13. Okay so everything is working now and all I had to do was change one thing. As to how this makes sense I am unsure but now I do not think that my methods in my tile entity class are being called. Here is what I changed: public ContainerFabTable(TileEntityFabTable fabTile, InventoryPlayer playerInv, World world, int x, int y, int z) { worldObj = world; tileEntity = new TileEntityFabTable(); Before it was: tileEntity = fabTile; can someone explain why that makes sense. Also now in the tile entity class the NBT data for saving items when the gui is closed, does not work. Here is the code for the NBT Tags? Am I not calling them right or? @Override public void readFromNBT(NBTTagCompound nbtTagCompound) { super.readFromNBT(nbtTagCompound); // Read in the ItemStacks in the inventory from NBT NBTTagList tagList = nbtTagCompound.getTagList("Items", 18); inventory = new ItemStack[this.getSizeInventory()]; for (int i = 0; i < tagList.tagCount(); ++i) { NBTTagCompound tagCompound = tagList.getCompoundTagAt(i); byte slot = tagCompound.getByte("Slot"); if (slot >= 0 && slot < inventory.length) { inventory[slot] = ItemStack.loadItemStackFromNBT(tagCompound); } } // Read in the Crafting Matrix from NBT NBTTagList craftingTag = nbtTagCompound.getTagList("CraftingMatrix", 9); craftMatrixInventory = new ItemStack[9]; // TODO: magic number for (int i = 0; i < craftingTag.tagCount(); ++i) { NBTTagCompound tagCompound = (NBTTagCompound) craftingTag.getCompoundTagAt(i); byte slot = tagCompound.getByte("Slot"); if (slot >= 0 && slot < craftMatrixInventory.length) { craftMatrixInventory[slot] = ItemStack.loadItemStackFromNBT(tagCompound); } } // Read craftingResult from NBT NBTTagCompound tagCraftResult = nbtTagCompound.getCompoundTag("CraftingResult"); craftResult.setInventorySlotContents(0, ItemStack.loadItemStackFromNBT(tagCraftResult)); } @Override public void writeToNBT(NBTTagCompound nbtTagCompound) { super.writeToNBT(nbtTagCompound); // Write the ItemStacks in the inventory to NBT NBTTagList tagList = new NBTTagList(); for (int currentIndex = 0; currentIndex < inventory.length; ++currentIndex) { if (inventory[currentIndex] != null) { NBTTagCompound tagCompound = new NBTTagCompound(); tagCompound.setByte("Slot", (byte) currentIndex); inventory[currentIndex].writeToNBT(tagCompound); tagList.appendTag(tagCompound); } } nbtTagCompound.setTag("Items", tagList); // Write Crafting Matrix to NBT NBTTagList craftingTag = new NBTTagList(); for (int currentIndex = 0; currentIndex < craftMatrixInventory.length; ++currentIndex) { if (craftMatrixInventory[currentIndex] != null) { NBTTagCompound tagCompound = new NBTTagCompound(); tagCompound.setByte("Slot", (byte) currentIndex); craftMatrixInventory[currentIndex].writeToNBT(tagCompound); craftingTag.appendTag(tagCompound); } } nbtTagCompound.setTag("CraftingMatrix", craftingTag); // Write craftingResult to NBT if (craftResult.getStackInSlot(0) != null) nbtTagCompound.setTag("CraftingResult", craftResult.getStackInSlot(0).writeToNBT(new NBTTagCompound())); }
  14. Okay so in regards to the GUI not opening it works now kinda. My issue was @Override public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumHand hand, ItemStack heldItem, EnumFacing side, float hitX, float hitY, float hitZ) I was using the wrong method so essentially right clicking did nothing. Now it works and I am getting errors in this class only pretty much Even by commenting most of it out I get this error: [23:55:33] [server thread/FATAL]: Error executing task java.util.concurrent.ExecutionException: java.lang.NullPointerException at java.util.concurrent.FutureTask.report(Unknown Source) ~[?:1.7.0_79] at java.util.concurrent.FutureTask.get(Unknown Source) ~[?:1.7.0_79] at net.minecraft.util.Util.runTask(Util.java:24) [util.class:?] at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:738) [MinecraftServer.class:?] at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:683) [MinecraftServer.class:?] at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:155) [integratedServer.class:?] at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:532) [MinecraftServer.class:?] at java.lang.Thread.run(Unknown Source) [?:1.7.0_79] Caused by: java.lang.NullPointerException at net.minecraft.inventory.Slot.getStack(Slot.java:81) ~[slot.class:?] at net.minecraft.inventory.Container.getInventory(Container.java:62) ~[Container.class:?] at net.minecraft.inventory.Container.onCraftGuiOpened(Container.java:51) ~[Container.class:?] at net.minecraftforge.fml.common.network.internal.FMLNetworkHandler.openGui(FMLNetworkHandler.java:93) ~[FMLNetworkHandler.class:?] at net.minecraft.entity.player.EntityPlayer.openGui(EntityPlayer.java:2694) ~[EntityPlayer.class:?] at com.zodsmar.blocks.FabricationTable.onBlockActivated(FabricationTable.java:36) ~[FabricationTable.class:?] at net.minecraft.server.management.PlayerInteractionManager.processRightClickBlock(PlayerInteractionManager.java:455) ~[PlayerInteractionManager.class:?] at net.minecraft.network.NetHandlerPlayServer.processRightClickBlock(NetHandlerPlayServer.java:706) ~[NetHandlerPlayServer.class:?] at net.minecraft.network.play.client.CPacketPlayerTryUseItem.processPacket(CPacketPlayerTryUseItem.java:68) ~[CPacketPlayerTryUseItem.class:?] at net.minecraft.network.play.client.CPacketPlayerTryUseItem.processPacket(CPacketPlayerTryUseItem.java:13) ~[CPacketPlayerTryUseItem.class:?] at net.minecraft.network.PacketThreadUtil$1.run(PacketThreadUtil.java:15) ~[PacketThreadUtil$1.class:?] at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source) ~[?:1.7.0_79] at java.util.concurrent.FutureTask.run(Unknown Source) ~[?:1.7.0_79] at net.minecraft.util.Util.runTask(Util.java:23) ~[util.class:?] ... 5 more [23:55:33] [server thread/ERROR]: Encountered an unexpected exception net.minecraft.util.ReportedException: Ticking player at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:785) ~[MinecraftServer.class:?] at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:683) ~[MinecraftServer.class:?] at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:155) ~[integratedServer.class:?] at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:532) [MinecraftServer.class:?] at java.lang.Thread.run(Unknown Source) [?:1.7.0_79] Caused by: java.lang.NullPointerException at net.minecraft.inventory.Slot.getStack(Slot.java:81) ~[slot.class:?] at net.minecraft.inventory.Container.detectAndSendChanges(Container.java:84) ~[Container.class:?] at net.minecraft.entity.player.EntityPlayerMP.onUpdate(EntityPlayerMP.java:290) ~[EntityPlayerMP.class:?] at net.minecraft.world.World.updateEntityWithOptionalForce(World.java:2086) ~[World.class:?] at net.minecraft.world.WorldServer.updateEntityWithOptionalForce(WorldServer.java:864) ~[WorldServer.class:?] at net.minecraft.world.World.updateEntity(World.java:2051) ~[World.class:?] at net.minecraft.world.WorldServer.tickPlayers(WorldServer.java:666) ~[WorldServer.class:?] at net.minecraft.world.World.updateEntities(World.java:1858) ~[World.class:?] at net.minecraft.world.WorldServer.updateEntities(WorldServer.java:637) ~[WorldServer.class:?] at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:779) ~[MinecraftServer.class:?] ... 4 more By trying code I have come to the conclusion that it is happening for 2 reasons. One it is something to do with the way I am dealing with slots. And second is: @Override public boolean canInteractWith(EntityPlayer entityPlayer) { return tileEntity.isUseableByPlayer(entityPlayer); } The Ticking Player is erroring. Even if I comment out everything and leave only the fundamentals and important stuff (pretty much no Slot stuff) it works but crashes on Ticking Player so yeah? Any thoughts guys? Oh also at the end of the error was this no idea what it means tho and if its important. [23:55:33] [server thread/INFO] [FML]: The state engine was in incorrect state SERVER_STOPPING and forced into state SERVER_STOPPED. Errors may have been discarded.
×
×
  • Create New...

Important Information

By using this site, you agree to our Privacy Policy.