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

The background: I have a tile entity which can sometimes (depending on how it's configured by the player) be a redstone power provider, and sometimes (probably more commonly) not.

 

When it's a power provider, I obviously want Block#canProvidePower() to return true.  But when it isn't a power provider, I want that method to return false (having it return true messes up things like propagating a strong redstone signal).

 

Now, canProvidePower() only takes an IBlockState parameter, so I don't have access to the tile entity to see if it's currently able to provide power.  Therefore I figured I'd probably need to store ability that in the blockstate, i.e. have the tile entity update a boolean property of the block when its ability to provide power is toggled.

 

I don't want to use a regular listed block property, because a) this property has no bearing on the rendering of the block, and b) I already have several listed properties which do affect the rendering, and I don't want to double the number of models by adding another boolean property.

 

So, my question: is IUnlistedProperty the right way to go here?  My research so far suggests that it's really intended (along with Block#getExtendedState) only for block rendering, so would this be an appropriate usage?  Or is there a better way to do this?

No, you should use the normal PropertyBool and in your ClientProxy in PreInit you need to call ModelLoader.setCustomStateMapper(yourBlockInstance, new StateMapBase.Builder.ignore(booleanPropertyToIgnore).build()).

  • Author

Works nicely, thanks :)  One very minor note: it's

StateMap.Builder

rather than

StateMapBase.Builder

.

Yeah, I didn't have the source at hand at that moment.

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.