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

Hello,

 

Is it possible to get an instance of my

TileEntity

from the

IBlockState

, which is passed to the

handleBlockState

function of

ISmartBlockModel

?

 

Basically, I need to render a block based on the data from my

TileEntity

.

 

My first idea was to use a

TileEntitySpecialRenderer

, but that was too inefficient for my case of rendering.

 

Then I found the excellent tutorial from @herbix, that explained the use of the new

IBakedModel

in 1.8.

 

Unfortunately, it seems that you can only use the block state from a block in the

handleBlockState

method.

 

But I need to store more than 4 bits in my block.

 

I hope you can help me :)

 

ss7

You sir are a god damn hero.

You could store ANYTHING in IExtendedBlockState, in case the property is unlisted.

For example:

    public static final IUnlistedProperty<TileEntity> TILE_ENTITY = new IUnlistedProperty<TileEntity>() {
        @Override
        public String getName() {
            return "tileEntity";
        }
        @Override
        public boolean isValid(TileEntity value) {
            return true;
        }
        @Override
        public Class<TileEntity> getType() {
            return TileEntity.class;
        }
        @Override
        public String valueToString(TileEntity value) {
            return value.toString();
        }
    };
    ...
    @Override
    public IBlockState getExtendedState(IBlockState state, IBlockAccess world, BlockPos pos) {
        if(state instanceof IExtendedBlockState) {
            TileEntity te = ... // Get your tile entity here
            return ((IExtendedBlockState)state).withProperty(TILE_ENTITY, te);
        }
        return state;
    }

Author of Tao Land Mod.

width=200 height=69http://taoland.herbix.me/images/1/14/TaoLandLogo.png[/img]

Also, author of RenderTo

----

I'm not an English native speaker. I just try my best.

  • Author

Thank you very much guys!

 

At first, I tried overriding the

getActualState

method, but for some reason my

BakedModel

wasn't rendering anymore.

 

So I tried herbix' solution, and it worked like a charm!

 

Thank you very much again and this thread is now

 

SOLVED

You sir are a god damn hero.

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.