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

Hi,

I would like to add a new slime block to the game, which works in a simular way to the original slime block, that is: it can move other blocks around and other slime blocks of the same type, but not other sticky blocks (honey blocks).

I found two functions in IForgeBlock file:

 

default boolean isStickyBlock(BlockState state)
{
   return state.getBlock() == Blocks.SLIME_BLOCK || state.getBlock() == Blocks.field_226907_mc_;
}

 

default boolean canStickTo(BlockState state, BlockState other)
{
        if (state.getBlock() == Blocks.field_226907_mc_ && other.getBlock() == Blocks.SLIME_BLOCK) return false;
        if (state.getBlock() == Blocks.SLIME_BLOCK && other.getBlock() == Blocks.field_226907_mc_) return false;
        return state.isStickyBlock() || other.isStickyBlock();
}

Is there a way to replace them and add the new block to the functions so they also check for it?

Or is there another way to do that?

 

Cheers,

Corgam

Edited by Corgam

Override the methods in your Block class and make them return true.

Don't PM me with questions. They will be ignored! Make a thread on the appropriate board for support.

 

1.12 -> 1.13 primer by williewillus.

 

1.7.10 and older versions of Minecraft are no longer supported due to it's age! Update to the latest version for support.

 

http://www.howoldisminecraft1710.today/

  • 2 weeks later...
  • Author
On 3/17/2020 at 11:54 PM, larsgerrits said:

Override the methods in your Block class and make them return true.

It works but only in one way. When slime and honey blocks are pushed they don't move the new slime block, but when you try to push the new slime block with the piston is moves normal slime block and honey with it. 

Any idea how to fix that?

I think I would need to override canStickTo() methode in normal SlimeBlock and honey block, but how can I do it, If I cannot modify the vanilla code?

Edited by Corgam

I think you need to leave the default implementation of canStickTo, just override isStickyBlock

  • Author
On 3/26/2020 at 6:03 PM, Alpvax said:

I think you need to leave the default implementation of canStickTo, just override isStickyBlock

Unfortunately no, isStickyBlock makes that it can move other blocks (all of movable blocks), but doesn't prevent it from sticking to another slime block or honeyblock.

canStickTo makes it that other sticky blocks cannot move it, but as for now I didn't find a way to stop the new block from moving other sticky blocks while being moved. (so it works only one way)

 

Edit: This is what I mean: https://imgur.com/J6TRxXx

Edited by Corgam

Oh, re-reading the code, I think you need to override canStickTo to only return true if the other block is itself or non sticky. To be honest, I'm surprised that slime doesn't push your block.

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.