Jump to content

[1.15.2] New sticky block for piston


Corgam

Recommended Posts

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

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

  • Thanks 1

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/

Link to comment
Share on other sites

  • 2 weeks later...
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
Link to comment
Share on other sites

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