Posted March 13, 20196 yr 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, 20196 yr by SizzleBae
March 13, 20196 yr 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, 20196 yr by Toma™
March 13, 20196 yr Author 1 hour ago, SizzleBae said: "TileEntity#shouldRefresh". This function appears to be removed entirely in [1.13.2], is there a new way to do this? 5 minutes ago, Toma™ said: There should be method in TileEntity called shouldRefresh (atleast in 1.12). Try overriding that It no longer exists I am afraid... Edited March 13, 20196 yr by SizzleBae
March 13, 20196 yr Author 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?
March 13, 20196 yr Author 2 minutes ago, diesieben07 said: TEs are removed by Block#onReplaced now. You can override that to provide custom functionality. Oh, that explains it! I recently overrided it Thank you!
March 13, 20196 yr Author @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 ^^
March 13, 20196 yr Probably because there's behavior in the supermethod that you still want to call. 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.
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.