Posted March 17, 20205 yr 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 March 17, 20205 yr by Corgam
March 17, 20205 yr 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/
March 26, 20205 yr 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 March 26, 20205 yr by Corgam
March 26, 20205 yr I think you need to leave the default implementation of canStickTo, just override isStickyBlock
March 28, 20205 yr 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 March 28, 20205 yr by Corgam
March 28, 20205 yr 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.