diff options
Diffstat (limited to 'patch-remap/mache-vineflower/net/minecraft/world/level/block/CeilingHangingSignBlock.java.patch')
-rw-r--r-- | patch-remap/mache-vineflower/net/minecraft/world/level/block/CeilingHangingSignBlock.java.patch | 230 |
1 files changed, 230 insertions, 0 deletions
diff --git a/patch-remap/mache-vineflower/net/minecraft/world/level/block/CeilingHangingSignBlock.java.patch b/patch-remap/mache-vineflower/net/minecraft/world/level/block/CeilingHangingSignBlock.java.patch new file mode 100644 index 0000000000..f4b329b0bb --- /dev/null +++ b/patch-remap/mache-vineflower/net/minecraft/world/level/block/CeilingHangingSignBlock.java.patch @@ -0,0 +1,230 @@ +--- a/net/minecraft/world/level/block/CeilingHangingSignBlock.java ++++ b/net/minecraft/world/level/block/CeilingHangingSignBlock.java +@@ -4,14 +4,13 @@ + import com.google.common.collect.Maps; + import com.mojang.serialization.MapCodec; + import com.mojang.serialization.codecs.RecordCodecBuilder; +-import com.mojang.serialization.codecs.RecordCodecBuilder.Instance; + import java.util.Map; + import java.util.Optional; + import javax.annotation.Nullable; + import net.minecraft.core.BlockPos; + import net.minecraft.core.Direction; + import net.minecraft.tags.BlockTags; +-import net.minecraft.world.InteractionHand; ++import net.minecraft.world.EnumHand; + import net.minecraft.world.InteractionResult; + import net.minecraft.world.entity.player.Player; + import net.minecraft.world.item.HangingSignItem; +@@ -27,7 +26,7 @@ + import net.minecraft.world.level.block.entity.HangingSignBlockEntity; + import net.minecraft.world.level.block.entity.SignBlockEntity; + import net.minecraft.world.level.block.state.BlockBehaviour; +-import net.minecraft.world.level.block.state.BlockState; ++import net.minecraft.world.level.block.state.IBlockData; + import net.minecraft.world.level.block.state.StateDefinition; + import net.minecraft.world.level.block.state.properties.BlockStateProperties; + import net.minecraft.world.level.block.state.properties.BooleanProperty; +@@ -41,48 +40,35 @@ + import net.minecraft.world.phys.shapes.VoxelShape; + + public class CeilingHangingSignBlock extends SignBlock { +- public static final MapCodec<CeilingHangingSignBlock> CODEC = RecordCodecBuilder.mapCodec( +- instance -> instance.group(WoodType.CODEC.fieldOf("wood_type").forGetter(SignBlock::type), propertiesCodec()) +- .apply(instance, CeilingHangingSignBlock::new) +- ); ++ ++ public static final MapCodec<CeilingHangingSignBlock> CODEC = RecordCodecBuilder.mapCodec((instance) -> { ++ return instance.group(WoodType.CODEC.fieldOf("wood_type").forGetter(SignBlock::type), propertiesCodec()).apply(instance, CeilingHangingSignBlock::new); ++ }); + public static final IntegerProperty ROTATION = BlockStateProperties.ROTATION_16; + public static final BooleanProperty ATTACHED = BlockStateProperties.ATTACHED; + protected static final float AABB_OFFSET = 5.0F; +- protected static final VoxelShape SHAPE = Block.box(3.0, 0.0, 3.0, 13.0, 16.0, 13.0); +- private static final Map<Integer, VoxelShape> AABBS = Maps.newHashMap( +- ImmutableMap.of( +- 0, +- Block.box(1.0, 0.0, 7.0, 15.0, 10.0, 9.0), +- 4, +- Block.box(7.0, 0.0, 1.0, 9.0, 10.0, 15.0), +- 8, +- Block.box(1.0, 0.0, 7.0, 15.0, 10.0, 9.0), +- 12, +- Block.box(7.0, 0.0, 1.0, 9.0, 10.0, 15.0) +- ) +- ); ++ protected static final VoxelShape SHAPE = Block.box(3.0D, 0.0D, 3.0D, 13.0D, 16.0D, 13.0D); ++ private static final Map<Integer, VoxelShape> AABBS = Maps.newHashMap(ImmutableMap.of(0, Block.box(1.0D, 0.0D, 7.0D, 15.0D, 10.0D, 9.0D), 4, Block.box(7.0D, 0.0D, 1.0D, 9.0D, 10.0D, 15.0D), 8, Block.box(1.0D, 0.0D, 7.0D, 15.0D, 10.0D, 9.0D), 12, Block.box(7.0D, 0.0D, 1.0D, 9.0D, 10.0D, 15.0D))); + + @Override + public MapCodec<CeilingHangingSignBlock> codec() { +- return CODEC; ++ return CeilingHangingSignBlock.CODEC; + } + +- public CeilingHangingSignBlock(WoodType woodType, BlockBehaviour.Properties properties) { +- super(woodType, properties.sound(woodType.hangingSignSoundType())); +- this.registerDefaultState( +- this.stateDefinition +- .any() +- .setValue(ROTATION, Integer.valueOf(0)) +- .setValue(ATTACHED, Boolean.valueOf(false)) +- .setValue(WATERLOGGED, Boolean.valueOf(false)) +- ); ++ public CeilingHangingSignBlock(WoodType blockpropertywood, BlockBehaviour.Properties blockbase_info) { ++ super(blockpropertywood, blockbase_info.sound(blockpropertywood.hangingSignSoundType())); ++ this.registerDefaultState((IBlockData) ((IBlockData) ((IBlockData) ((IBlockData) this.stateDefinition.any()).setValue(CeilingHangingSignBlock.ROTATION, 0)).setValue(CeilingHangingSignBlock.ATTACHED, false)).setValue(CeilingHangingSignBlock.WATERLOGGED, false)); + } + + @Override +- public InteractionResult use(BlockState state, Level level, BlockPos pos, Player player, InteractionHand hand, BlockHitResult hit) { +- if (level.getBlockEntity(pos) instanceof SignBlockEntity signBlockEntity) { +- ItemStack itemInHand = player.getItemInHand(hand); +- if (this.shouldTryToChainAnotherHangingSign(player, hit, signBlockEntity, itemInHand)) { ++ public InteractionResult use(IBlockData state, Level level, BlockPos pos, Player player, EnumHand hand, BlockHitResult hit) { ++ BlockEntity tileentity = level.getBlockEntity(pos); ++ ++ if (tileentity instanceof SignBlockEntity) { ++ SignBlockEntity tileentitysign = (SignBlockEntity) tileentity; ++ ItemStack itemstack = player.getItemInHand(hand); ++ ++ if (this.shouldTryToChainAnotherHangingSign(player, hit, tileentitysign, itemstack)) { + return InteractionResult.PASS; + } + } +@@ -91,92 +77,90 @@ + } + + private boolean shouldTryToChainAnotherHangingSign(Player player, BlockHitResult hitResult, SignBlockEntity sign, ItemStack stack) { +- return !sign.canExecuteClickCommands(sign.isFacingFrontText(player), player) +- && stack.getItem() instanceof HangingSignItem +- && hitResult.getDirection().equals(Direction.DOWN); ++ return !sign.canExecuteClickCommands(sign.isFacingFrontText(player), player) && stack.getItem() instanceof HangingSignItem && hitResult.getDirection().equals(Direction.DOWN); + } + + @Override +- public boolean canSurvive(BlockState state, LevelReader level, BlockPos pos) { ++ public boolean canSurvive(IBlockData state, LevelReader level, BlockPos pos) { + return level.getBlockState(pos.above()).isFaceSturdy(level, pos.above(), Direction.DOWN, SupportType.CENTER); + } + + @Override +- public BlockState getStateForPlacement(BlockPlaceContext context) { +- Level level = context.getLevel(); +- FluidState fluidState = level.getFluidState(context.getClickedPos()); +- BlockPos blockPos = context.getClickedPos().above(); +- BlockState blockState = level.getBlockState(blockPos); +- boolean isAllHangingSigns = blockState.is(BlockTags.ALL_HANGING_SIGNS); +- Direction direction = Direction.fromYRot((double)context.getRotation()); +- boolean flag = !Block.isFaceFull(blockState.getCollisionShape(level, blockPos), Direction.DOWN) || context.isSecondaryUseActive(); +- if (isAllHangingSigns && !context.isSecondaryUseActive()) { +- if (blockState.hasProperty(WallHangingSignBlock.FACING)) { +- Direction direction1 = blockState.getValue(WallHangingSignBlock.FACING); +- if (direction1.getAxis().test(direction)) { +- flag = false; ++ public IBlockData getStateForPlacement(BlockPlaceContext context) { ++ Level world = context.getLevel(); ++ FluidState fluid = world.getFluidState(context.getClickedPos()); ++ BlockPos blockposition = context.getClickedPos().above(); ++ IBlockData iblockdata = world.getBlockState(blockposition); ++ boolean flag = iblockdata.is(BlockTags.ALL_HANGING_SIGNS); ++ Direction enumdirection = Direction.fromYRot((double) context.getRotation()); ++ boolean flag1 = !Block.isFaceFull(iblockdata.getCollisionShape(world, blockposition), Direction.DOWN) || context.isSecondaryUseActive(); ++ ++ if (flag && !context.isSecondaryUseActive()) { ++ if (iblockdata.hasProperty(WallHangingSignBlock.FACING)) { ++ Direction enumdirection1 = (Direction) iblockdata.getValue(WallHangingSignBlock.FACING); ++ ++ if (enumdirection1.getAxis().test(enumdirection)) { ++ flag1 = false; + } +- } else if (blockState.hasProperty(ROTATION)) { +- Optional<Direction> optional = RotationSegment.convertToDirection(blockState.getValue(ROTATION)); +- if (optional.isPresent() && optional.get().getAxis().test(direction)) { +- flag = false; ++ } else if (iblockdata.hasProperty(CeilingHangingSignBlock.ROTATION)) { ++ Optional<Direction> optional = RotationSegment.convertToDirection((Integer) iblockdata.getValue(CeilingHangingSignBlock.ROTATION)); ++ ++ if (optional.isPresent() && ((Direction) optional.get()).getAxis().test(enumdirection)) { ++ flag1 = false; + } + } + } + +- int i = !flag ? RotationSegment.convertToSegment(direction.getOpposite()) : RotationSegment.convertToSegment(context.getRotation() + 180.0F); +- return this.defaultBlockState() +- .setValue(ATTACHED, Boolean.valueOf(flag)) +- .setValue(ROTATION, Integer.valueOf(i)) +- .setValue(WATERLOGGED, Boolean.valueOf(fluidState.getType() == Fluids.WATER)); ++ int i = !flag1 ? RotationSegment.convertToSegment(enumdirection.getOpposite()) : RotationSegment.convertToSegment(context.getRotation() + 180.0F); ++ ++ return (IBlockData) ((IBlockData) ((IBlockData) this.defaultBlockState().setValue(CeilingHangingSignBlock.ATTACHED, flag1)).setValue(CeilingHangingSignBlock.ROTATION, i)).setValue(CeilingHangingSignBlock.WATERLOGGED, fluid.getType() == Fluids.WATER); + } + + @Override +- public VoxelShape getShape(BlockState state, BlockGetter level, BlockPos pos, CollisionContext context) { +- VoxelShape voxelShape = AABBS.get(state.getValue(ROTATION)); +- return voxelShape == null ? SHAPE : voxelShape; ++ public VoxelShape getShape(IBlockData state, BlockGetter level, BlockPos pos, CollisionContext context) { ++ VoxelShape voxelshape = (VoxelShape) CeilingHangingSignBlock.AABBS.get(state.getValue(CeilingHangingSignBlock.ROTATION)); ++ ++ return voxelshape == null ? CeilingHangingSignBlock.SHAPE : voxelshape; + } + + @Override +- public VoxelShape getBlockSupportShape(BlockState state, BlockGetter level, BlockPos pos) { ++ public VoxelShape getBlockSupportShape(IBlockData state, BlockGetter level, BlockPos pos) { + return this.getShape(state, level, pos, CollisionContext.empty()); + } + + @Override +- public BlockState updateShape(BlockState state, Direction facing, BlockState facingState, LevelAccessor level, BlockPos currentPos, BlockPos facingPos) { +- return facing == Direction.UP && !this.canSurvive(state, level, currentPos) +- ? Blocks.AIR.defaultBlockState() +- : super.updateShape(state, facing, facingState, level, currentPos, facingPos); ++ public IBlockData updateShape(IBlockData state, Direction facing, IBlockData facingState, LevelAccessor level, BlockPos currentPos, BlockPos facingPos) { ++ return facing == Direction.UP && !this.canSurvive(state, level, currentPos) ? Blocks.AIR.defaultBlockState() : super.updateShape(state, facing, facingState, level, currentPos, facingPos); + } + + @Override +- public float getYRotationDegrees(BlockState state) { +- return RotationSegment.convertToDegrees(state.getValue(ROTATION)); ++ public float getYRotationDegrees(IBlockData state) { ++ return RotationSegment.convertToDegrees((Integer) state.getValue(CeilingHangingSignBlock.ROTATION)); + } + + @Override +- public BlockState rotate(BlockState state, Rotation rotation) { +- return state.setValue(ROTATION, Integer.valueOf(rotation.rotate(state.getValue(ROTATION), 16))); ++ public IBlockData rotate(IBlockData state, Rotation rotation) { ++ return (IBlockData) state.setValue(CeilingHangingSignBlock.ROTATION, rotation.rotate((Integer) state.getValue(CeilingHangingSignBlock.ROTATION), 16)); + } + + @Override +- public BlockState mirror(BlockState state, Mirror mirror) { +- return state.setValue(ROTATION, Integer.valueOf(mirror.mirror(state.getValue(ROTATION), 16))); ++ public IBlockData mirror(IBlockData state, Mirror mirror) { ++ return (IBlockData) state.setValue(CeilingHangingSignBlock.ROTATION, mirror.mirror((Integer) state.getValue(CeilingHangingSignBlock.ROTATION), 16)); + } + + @Override +- protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> builder) { +- builder.add(ROTATION, ATTACHED, WATERLOGGED); ++ protected void createBlockStateDefinition(StateDefinition.Builder<Block, IBlockData> builder) { ++ builder.add(CeilingHangingSignBlock.ROTATION, CeilingHangingSignBlock.ATTACHED, CeilingHangingSignBlock.WATERLOGGED); + } + + @Override +- public BlockEntity newBlockEntity(BlockPos pos, BlockState state) { ++ public BlockEntity newBlockEntity(BlockPos pos, IBlockData state) { + return new HangingSignBlockEntity(pos, state); + } + + @Nullable + @Override +- public <T extends BlockEntity> BlockEntityTicker<T> getTicker(Level level, BlockState state, BlockEntityType<T> blockEntityType) { +- return createTickerHelper(blockEntityType, BlockEntityType.HANGING_SIGN, SignBlockEntity::tick); ++ public <T extends BlockEntity> BlockEntityTicker<T> getTicker(Level level, IBlockData state, BlockEntityType<T> blockEntityType) { ++ return null; // Craftbukkit - remove unnecessary sign ticking + } + } |