Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

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

There should be method in TileEntity called shouldRefresh (atleast in 1.12). Try overriding that

I'm stupid, and I can't read... 

Edited by Toma™

  • 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 by SizzleBae

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

  • 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 xD Thank you!

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

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.

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

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.