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

While updating my blocks I've found some issues with rotate, so I'm sharing my thoughts and proving a suggested fix.

 

Starting with the parameters.

The addition of 'Rotation' is quite helpful as now tools can indicate direction, but the removal of EnumFacing(Direction) hurts the usability as you can no longer rotate based on the face clicked (eg. axis rotation)

Therefore I'm suggesting re-adding Direction, and while we're at it there is no harm in adding Entity as well

 

Now for the bigger issue, the return type changing from boolean to BlockState. This should be reverted.

Prior to 1.13 the boolean return was simple, true if the block rotated and false if not. Therefore blocks handled their own rotation and tools handled their durability based on the boolean.

1.13 and beyond returns a BlockState, and looking at the vanilla blocks indicates the tool is now responsible for rotating the block to the value returned.

This works fine for single blocks that only rotate, but causes issues with blocks that need to update connected blocks. (even the vanilla beds don't rotate correctly)

If the block updates it's connected blocks, then the tool doesn't update the originals state, the multi block is broken. You could just use the neighbor changed method to update connected blocks, but that requires additional checks etc, and fails if the tool didn't have the state change flag set to notify.

 

Here is the proposed reworked method:

default boolean rotate(BlockState state, IWorld world, BlockPos pos, Rotation rotation, Direction direction, Entity entity)
{
    Block block = state.getBlock();
    if (!(block instanceof BedBlock) && !(block instanceof PistonHeadBlock))
    {
        BlockState result = state.rotate(rotation);
        if (result != world.getBlockState(pos))
        {
            return world.setBlockState(pos, state, 3);
        }
    }
    return false;
}

 

If others agree, anyone is free to take the code and create a pull request.

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.