SizzleBae Posted March 13, 2019 Posted March 13, 2019 (edited) Hey! I have tried to make somewhat of a "battery" block, that charges over time and when it reaches certain power thresholds it changes the block state to update the block's texture. I do this by having a tile entity, since I want a lot of power, and I don't want to generate thousands of block states. However, when I change the block state containing the tile entity, it is destroyed and gets recreated at 0 charge again, this loop then repeats. At https://mcforge.readthedocs.io/en/latest/tileentities/tileentity/, there is a section labeled "Keeping a TileEntity through changing BlockStates" that says I can achieve this by overriding the function "TileEntity#shouldRefresh". This function appears to be removed entirely in [1.13.2], is there a new way to do this? I have tried to look at the furnace block and tile entity for help, but I have had no success so far... Edited March 13, 2019 by SizzleBae Quote
Toma™ Posted March 13, 2019 Posted March 13, 2019 (edited) There should be method in TileEntity called shouldRefresh (atleast in 1.12). Try overriding that I'm stupid, and I can't read... Edited March 13, 2019 by Toma™ Quote
SizzleBae Posted March 13, 2019 Author Posted March 13, 2019 (edited) On 3/13/2019 at 6:47 PM, SizzleBae said: "TileEntity#shouldRefresh". This function appears to be removed entirely in [1.13.2], is there a new way to do this? Expand On 3/13/2019 at 8:23 PM, Toma™ said: There should be method in TileEntity called shouldRefresh (atleast in 1.12). Try overriding that Expand It no longer exists I am afraid... Edited March 13, 2019 by SizzleBae Quote
SizzleBae Posted March 13, 2019 Author Posted March 13, 2019 Umm, so I overrode the network functions in tile entity, and now it seems that the tile entity persists. This happens both on remote world and not remote world. So I think it is okay now, because I can easily destroy the tile entity when I do not want it anymore Is it supposed to be persistent by default, or have I done something wrong? Quote
SizzleBae Posted March 13, 2019 Author Posted March 13, 2019 On 3/13/2019 at 9:18 PM, diesieben07 said: TEs are removed by Block#onReplaced now. You can override that to provide custom functionality. Expand Oh, that explains it! I recently overrided it Thank you! Quote
SizzleBae Posted March 13, 2019 Author Posted March 13, 2019 @Override public void onReplaced(IBlockState state, World worldIn, BlockPos pos, IBlockState newState, boolean isMoving) { if(worldIn.isRemote()) { return; } if(!(newState.getBlock() instanceof BlockCrystal)) { worldIn.removeTileEntity(pos); } } Yeah, I did this to prevent that. It kept on spawning my block when I tried to remove it ^^ Quote
Draco18s Posted March 13, 2019 Posted March 13, 2019 Probably because there's behavior in the supermethod that you still want to call. Quote 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.
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.