Posted January 3, 20205 yr 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.