Jump to content

Recommended Posts

Posted
...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...

 

 

Posted

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.

Posted

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.

Posted

...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.

Posted

...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.

Posted
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?

Posted
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?

Posted

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.

Posted

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.

Posted

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.

Posted

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.

Posted
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.

Posted
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.

Posted

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.

Posted

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.

Posted

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.

Posted

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.