May 29, 20169 yr Author ...made TileEntityRedChest#writeToNBT return NBTTagCompound, renamed BlockRedChest#onBlockEventReceived to eventReceived... I don't quite understand. The writeToNBT method in the TileEntity super class returns void, and there is no eventReceived method in the Block class...
May 29, 20169 yr super() only handles the basic TE info. You need to call myStacks.writeToNBT() Or the capability.writeToNTB() I haven't poked 1.9 yet. Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable. If you think this is the case, JUST REPORT ME. Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice. Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked. DO NOT PM ME WITH PROBLEMS. No help will be given.
May 29, 20169 yr super() only handles the basic TE info. You need to call myStacks.writeToNBT() Or the capability.writeToNTB() I haven't poked 1.9 yet. Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable. If you think this is the case, JUST REPORT ME. Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice. Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked. DO NOT PM ME WITH PROBLEMS. No help will be given.
May 29, 20169 yr ...made TileEntityRedChest#writeToNBT return NBTTagCompound, renamed BlockRedChest#onBlockEventReceived to eventReceived... I don't quite understand. The writeToNBT method in the TileEntity super class returns void, and there is no eventReceived method in the Block class... I think you're using 1.9, not 1.9.4 as your title says. The changes I mentioned were made in 1.9.4. super() only handles the basic TE info. You need to call myStacks.writeToNBT() Or the capability.writeToNTB() I haven't poked 1.9 yet. The OP is doing this in their latest code. 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.
May 29, 20169 yr ...made TileEntityRedChest#writeToNBT return NBTTagCompound, renamed BlockRedChest#onBlockEventReceived to eventReceived... I don't quite understand. The writeToNBT method in the TileEntity super class returns void, and there is no eventReceived method in the Block class... I think you're using 1.9, not 1.9.4 as your title says. The changes I mentioned were made in 1.9.4. super() only handles the basic TE info. You need to call myStacks.writeToNBT() Or the capability.writeToNTB() I haven't poked 1.9 yet. The OP is doing this in their latest code. 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.
May 29, 20169 yr Author I think you're using 1.9, not 1.9.4 as your title says. You're absolutely right! I switched to 1.9.4, and did the changes you recommended, and now the block holds items via hopper. I have one more question though. Do you have any advise on how I can set the block up such that it will drop the stored items upon destruction?
May 29, 20169 yr Author I think you're using 1.9, not 1.9.4 as your title says. You're absolutely right! I switched to 1.9.4, and did the changes you recommended, and now the block holds items via hopper. I have one more question though. Do you have any advise on how I can set the block up such that it will drop the stored items upon destruction?
May 29, 20169 yr I have one more question though. Do you have any advise on how I can set the block up such that it will drop the stored items upon destruction? First, delay the removal of the TileEntity until after Block#getDrops has been called (see Forge's patches to BlockFlowerPot for an example of this. Then override Block#getDrops to call the super method, add the inventory contents to the returned list and then return the list. I do this for my chest here, here and here. This splits the stacks randomly to mimic the InventoryHelper.dropInventoryItems method used by vanilla inventories. 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.
May 29, 20169 yr I have one more question though. Do you have any advise on how I can set the block up such that it will drop the stored items upon destruction? First, delay the removal of the TileEntity until after Block#getDrops has been called (see Forge's patches to BlockFlowerPot for an example of this. Then override Block#getDrops to call the super method, add the inventory contents to the returned list and then return the list. I do this for my chest here, here and here. This splits the stacks randomly to mimic the InventoryHelper.dropInventoryItems method used by vanilla inventories. 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.
May 29, 20169 yr Author So I added the code into my own, though I had to do some editing, since the getTileEntity(world, pos) no longer accepted those parameters. The program does not work as expected. Here's the TileEntityRedChest class: http://pastebin.com/WucCAgcy And the BlockRedChest class: http://pastebin.com/cXUjshQ6 And finally the Chest (Main) class: http://pastebin.com/BgSudHca
May 29, 20169 yr Author So I added the code into my own, though I had to do some editing, since the getTileEntity(world, pos) no longer accepted those parameters. The program does not work as expected. Here's the TileEntityRedChest class: http://pastebin.com/WucCAgcy And the BlockRedChest class: http://pastebin.com/cXUjshQ6 And finally the Chest (Main) class: http://pastebin.com/BgSudHca
May 29, 20169 yr So I added the code into my own, though I had to do some editing, since the getTileEntity(world, pos) no longer accepted those parameters. getTileEntity is a method from the BlockTileEntity class extended by BlockModChest , it's not a vanilla method. It is just a wrapper around World#getTileEntity though. BlockRedChest has a copy of this method, did it not work? The program does not work as expected. That doesn't tell me much. What actually happens? Side note: BlockRedChest#removedByPlayer is missing the @Override annotation, I suggest you add it so the compiler ensures that it actually is an override method. 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.
May 29, 20169 yr So I added the code into my own, though I had to do some editing, since the getTileEntity(world, pos) no longer accepted those parameters. getTileEntity is a method from the BlockTileEntity class extended by BlockModChest , it's not a vanilla method. It is just a wrapper around World#getTileEntity though. BlockRedChest has a copy of this method, did it not work? The program does not work as expected. That doesn't tell me much. What actually happens? Side note: BlockRedChest#removedByPlayer is missing the @Override annotation, I suggest you add it so the compiler ensures that it actually is an override method. 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.
May 29, 20169 yr Author getTileEntity is a method from the BlockTileEntity class extended by BlockModChest, it's not a vanilla method. It is just a wrapper around World#getTileEntity though. BlockRedChest has a copy of this method, did it not work? No, since the world variable in the getDrops method is of type IBlockAccess, and not of the World type, which is what the BlockRedChest#getTileEntity method takes as a parameter. The program does not work as expected. That doesn't tell me much. What actually happens? Sorry for the lack of clarity. The block takes the items from the hopper, but upon destruction, does not drop them.
May 29, 20169 yr Author getTileEntity is a method from the BlockTileEntity class extended by BlockModChest, it's not a vanilla method. It is just a wrapper around World#getTileEntity though. BlockRedChest has a copy of this method, did it not work? No, since the world variable in the getDrops method is of type IBlockAccess, and not of the World type, which is what the BlockRedChest#getTileEntity method takes as a parameter. The program does not work as expected. That doesn't tell me much. What actually happens? Sorry for the lack of clarity. The block takes the items from the hopper, but upon destruction, does not drop them.
May 29, 20169 yr No, since the world variable in the getDrops method is of type IBlockAccess, and not of the World type, which is what the BlockRedChest#getTileEntity method takes as a parameter. Ah, my version of the method takes an IBlockAccess argument. Sorry for the lack of clarity. The block takes the items from the hopper, but upon destruction, does not drop them. I can't see any obvious issues. I suggest you step through the code in a debugger. 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.
May 29, 20169 yr No, since the world variable in the getDrops method is of type IBlockAccess, and not of the World type, which is what the BlockRedChest#getTileEntity method takes as a parameter. Ah, my version of the method takes an IBlockAccess argument. Sorry for the lack of clarity. The block takes the items from the hopper, but upon destruction, does not drop them. I can't see any obvious issues. I suggest you step through the code in a debugger. 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.
May 30, 20169 yr Author I solved it! I kept destroying the block with my fists in creative mode, which is why nothing dropped. However, when I harvested it using an axe, then the items stored in the block were dropped as expected.
May 30, 20169 yr Author I solved it! I kept destroying the block with my fists in creative mode, which is why nothing dropped. However, when I harvested it using an axe, then the items stored in the block were dropped as expected.
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.