Jump to content

[SOLVED][1.13.2] Keeping a tile entity through block state change


SizzleBae

Recommended Posts

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 by SizzleBae
Link to comment
Share on other sites

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 by SizzleBae
Link to comment
Share on other sites

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 xD Is it supposed to be persistent by default, or have I done something wrong? :) 

Link to comment
Share on other sites

@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 ^^

Link to comment
Share on other sites

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.

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.