Jump to content

Methods utilizing IBlockAccess instead of World get Tile Entities wrong


myoKun345

Recommended Posts

I'm trying to update a render (and collision box/bounding box) of a block with a short value stored in a Tile Entity. It was not updating, so I added debug outputs to all related methods (renderWorldBlock in my rendering handler class and getCollisionBoundingBoxFromPool and getBoundingBoxFromPool in my block class), and, lo and behold, only the method that is being given an instance of World and not IBlockAccess was getting the short value correctly. My theory at this point is that either IBlockAccess's getBlockTileEntity is broken or I am casting the tile entity wrongly. What is confusing to me is that it would update the render properly before I made the render update on a random tick, but not now.

 

Related code:

https://github.com/myoKun345/Ars-Herbologica/blob/master/herbologica_common/herbologica/block/crop/BlockHerbologicaBush.java

 

https://github.com/myoKun345/Ars-Herbologica/blob/master/herbologica_common/herbologica/render/BushRender.java

 

https://github.com/myoKun345/Ars-Herbologica/blob/master/herbologica_common/herbologica/tileentity/crop/TileEntityBush.java

 

The rest of the code is in the repository if needed.

 

Thanks in advance.

Link to comment
Share on other sites

Indeed, I just puzzled this out in my getLightValue() thread. Short version: the TileEntity from World is a server-side one while IBlockAccess is client-side.

 

You can look at my explanation of what's happening as well as a possible workaround.

 

http://www.minecraftforge.net/forum/index.php/topic,12125.msg63300.html#msg63300

 

Link to comment
Share on other sites

Well, it only half fixed it. Saving and reloading the world just breaks it again, meaning the client version of the tile entity is not being saved between loads.

 

EDIT: And then placing a new instance of this block in the world both breaks any further updates and crashes the game after a while of ticking.

Link to comment
Share on other sites

Well, it only half fixed it. Saving and reloading the world just breaks it again, meaning the client version of the tile entity is not being saved between loads.

 

EDIT: And then placing a new instance of this block in the world both breaks any further updates and crashes the game after a while of ticking.

 

Is your TileEntity using NBT to save data? I don't have the problem you mention.

Link to comment
Share on other sites

Yes, I am using NBT.

 

Well while researching more on my issue from my thread, I realized that when you load a world with blocks already placed, updateTick gets called right away which means the cached World objects are NULL causing a crash.

 

Perhaps that's what you've encountered? I'm still working on a better resolution.

Link to comment
Share on other sites

After following this through the debugger, the bottome line is when IBlockAccess calls World.getBlockTileEntity() the "world" is always a WorldClient according to the "variables" window in Eclipse.

 

I guess the only workaround would be to make sure you're always interacting with a client TileEntity. The problem here is some methods such as updateTick are server only so the World parameter that is passed in the function definition is never a WorldClient.

Link to comment
Share on other sites

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.