aboutsummaryrefslogtreecommitdiffhomepage
path: root/patch-remap/mache-vineflower/net/minecraft/world/level/block/LecternBlock.java.patch
diff options
context:
space:
mode:
Diffstat (limited to 'patch-remap/mache-vineflower/net/minecraft/world/level/block/LecternBlock.java.patch')
-rw-r--r--patch-remap/mache-vineflower/net/minecraft/world/level/block/LecternBlock.java.patch399
1 files changed, 399 insertions, 0 deletions
diff --git a/patch-remap/mache-vineflower/net/minecraft/world/level/block/LecternBlock.java.patch b/patch-remap/mache-vineflower/net/minecraft/world/level/block/LecternBlock.java.patch
new file mode 100644
index 0000000000..58d32abee4
--- /dev/null
+++ b/patch-remap/mache-vineflower/net/minecraft/world/level/block/LecternBlock.java.patch
@@ -0,0 +1,399 @@
+--- a/net/minecraft/world/level/block/LecternBlock.java
++++ b/net/minecraft/world/level/block/LecternBlock.java
+@@ -11,9 +11,9 @@
+ import net.minecraft.stats.Stats;
+ import net.minecraft.tags.ItemTags;
+ import net.minecraft.util.RandomSource;
+-import net.minecraft.world.InteractionHand;
++import net.minecraft.world.EnumHand;
++import net.minecraft.world.ITileInventory;
+ import net.minecraft.world.InteractionResult;
+-import net.minecraft.world.MenuProvider;
+ import net.minecraft.world.entity.Entity;
+ import net.minecraft.world.entity.item.ItemEntity;
+ import net.minecraft.world.entity.player.Player;
+@@ -25,140 +25,121 @@
+ import net.minecraft.world.level.block.entity.BlockEntity;
+ import net.minecraft.world.level.block.entity.LecternBlockEntity;
+ 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;
+ import net.minecraft.world.level.block.state.properties.DirectionProperty;
+ import net.minecraft.world.level.gameevent.GameEvent;
+-import net.minecraft.world.level.pathfinder.PathComputationType;
++import net.minecraft.world.level.pathfinder.PathMode;
+ import net.minecraft.world.phys.BlockHitResult;
+ import net.minecraft.world.phys.shapes.CollisionContext;
+ import net.minecraft.world.phys.shapes.Shapes;
+ import net.minecraft.world.phys.shapes.VoxelShape;
+
+ public class LecternBlock extends BaseEntityBlock {
++
+ public static final MapCodec<LecternBlock> CODEC = simpleCodec(LecternBlock::new);
+ public static final DirectionProperty FACING = HorizontalDirectionalBlock.FACING;
+ public static final BooleanProperty POWERED = BlockStateProperties.POWERED;
+ public static final BooleanProperty HAS_BOOK = BlockStateProperties.HAS_BOOK;
+- public static final VoxelShape SHAPE_BASE = Block.box(0.0, 0.0, 0.0, 16.0, 2.0, 16.0);
+- public static final VoxelShape SHAPE_POST = Block.box(4.0, 2.0, 4.0, 12.0, 14.0, 12.0);
+- public static final VoxelShape SHAPE_COMMON = Shapes.or(SHAPE_BASE, SHAPE_POST);
+- public static final VoxelShape SHAPE_TOP_PLATE = Block.box(0.0, 15.0, 0.0, 16.0, 15.0, 16.0);
+- public static final VoxelShape SHAPE_COLLISION = Shapes.or(SHAPE_COMMON, SHAPE_TOP_PLATE);
+- public static final VoxelShape SHAPE_WEST = Shapes.or(
+- Block.box(1.0, 10.0, 0.0, 5.333333, 14.0, 16.0),
+- Block.box(5.333333, 12.0, 0.0, 9.666667, 16.0, 16.0),
+- Block.box(9.666667, 14.0, 0.0, 14.0, 18.0, 16.0),
+- SHAPE_COMMON
+- );
+- public static final VoxelShape SHAPE_NORTH = Shapes.or(
+- Block.box(0.0, 10.0, 1.0, 16.0, 14.0, 5.333333),
+- Block.box(0.0, 12.0, 5.333333, 16.0, 16.0, 9.666667),
+- Block.box(0.0, 14.0, 9.666667, 16.0, 18.0, 14.0),
+- SHAPE_COMMON
+- );
+- public static final VoxelShape SHAPE_EAST = Shapes.or(
+- Block.box(10.666667, 10.0, 0.0, 15.0, 14.0, 16.0),
+- Block.box(6.333333, 12.0, 0.0, 10.666667, 16.0, 16.0),
+- Block.box(2.0, 14.0, 0.0, 6.333333, 18.0, 16.0),
+- SHAPE_COMMON
+- );
+- public static final VoxelShape SHAPE_SOUTH = Shapes.or(
+- Block.box(0.0, 10.0, 10.666667, 16.0, 14.0, 15.0),
+- Block.box(0.0, 12.0, 6.333333, 16.0, 16.0, 10.666667),
+- Block.box(0.0, 14.0, 2.0, 16.0, 18.0, 6.333333),
+- SHAPE_COMMON
+- );
++ public static final VoxelShape SHAPE_BASE = Block.box(0.0D, 0.0D, 0.0D, 16.0D, 2.0D, 16.0D);
++ public static final VoxelShape SHAPE_POST = Block.box(4.0D, 2.0D, 4.0D, 12.0D, 14.0D, 12.0D);
++ public static final VoxelShape SHAPE_COMMON = Shapes.or(LecternBlock.SHAPE_BASE, LecternBlock.SHAPE_POST);
++ public static final VoxelShape SHAPE_TOP_PLATE = Block.box(0.0D, 15.0D, 0.0D, 16.0D, 15.0D, 16.0D);
++ public static final VoxelShape SHAPE_COLLISION = Shapes.or(LecternBlock.SHAPE_COMMON, LecternBlock.SHAPE_TOP_PLATE);
++ public static final VoxelShape SHAPE_WEST = Shapes.or(Block.box(1.0D, 10.0D, 0.0D, 5.333333D, 14.0D, 16.0D), Block.box(5.333333D, 12.0D, 0.0D, 9.666667D, 16.0D, 16.0D), Block.box(9.666667D, 14.0D, 0.0D, 14.0D, 18.0D, 16.0D), LecternBlock.SHAPE_COMMON);
++ public static final VoxelShape SHAPE_NORTH = Shapes.or(Block.box(0.0D, 10.0D, 1.0D, 16.0D, 14.0D, 5.333333D), Block.box(0.0D, 12.0D, 5.333333D, 16.0D, 16.0D, 9.666667D), Block.box(0.0D, 14.0D, 9.666667D, 16.0D, 18.0D, 14.0D), LecternBlock.SHAPE_COMMON);
++ public static final VoxelShape SHAPE_EAST = Shapes.or(Block.box(10.666667D, 10.0D, 0.0D, 15.0D, 14.0D, 16.0D), Block.box(6.333333D, 12.0D, 0.0D, 10.666667D, 16.0D, 16.0D), Block.box(2.0D, 14.0D, 0.0D, 6.333333D, 18.0D, 16.0D), LecternBlock.SHAPE_COMMON);
++ public static final VoxelShape SHAPE_SOUTH = Shapes.or(Block.box(0.0D, 10.0D, 10.666667D, 16.0D, 14.0D, 15.0D), Block.box(0.0D, 12.0D, 6.333333D, 16.0D, 16.0D, 10.666667D), Block.box(0.0D, 14.0D, 2.0D, 16.0D, 18.0D, 6.333333D), LecternBlock.SHAPE_COMMON);
+ private static final int PAGE_CHANGE_IMPULSE_TICKS = 2;
+
+ @Override
+ public MapCodec<LecternBlock> codec() {
+- return CODEC;
++ return LecternBlock.CODEC;
+ }
+
+ protected LecternBlock(BlockBehaviour.Properties properties) {
+ super(properties);
+- this.registerDefaultState(
+- this.stateDefinition.any().setValue(FACING, Direction.NORTH).setValue(POWERED, Boolean.valueOf(false)).setValue(HAS_BOOK, Boolean.valueOf(false))
+- );
++ this.registerDefaultState((IBlockData) ((IBlockData) ((IBlockData) ((IBlockData) this.stateDefinition.any()).setValue(LecternBlock.FACING, Direction.NORTH)).setValue(LecternBlock.POWERED, false)).setValue(LecternBlock.HAS_BOOK, false));
+ }
+
+ @Override
+- public RenderShape getRenderShape(BlockState state) {
+- return RenderShape.MODEL;
++ public EnumRenderType getRenderShape(IBlockData state) {
++ return EnumRenderType.MODEL;
+ }
+
+ @Override
+- public VoxelShape getOcclusionShape(BlockState state, BlockGetter level, BlockPos pos) {
+- return SHAPE_COMMON;
++ public VoxelShape getOcclusionShape(IBlockData state, BlockGetter level, BlockPos pos) {
++ return LecternBlock.SHAPE_COMMON;
+ }
+
+ @Override
+- public boolean useShapeForLightOcclusion(BlockState state) {
++ public boolean useShapeForLightOcclusion(IBlockData state) {
+ return true;
+ }
+
+ @Override
+- public BlockState getStateForPlacement(BlockPlaceContext context) {
+- Level level = context.getLevel();
+- ItemStack itemInHand = context.getItemInHand();
+- Player player = context.getPlayer();
++ public IBlockData getStateForPlacement(BlockPlaceContext context) {
++ Level world = context.getLevel();
++ ItemStack itemstack = context.getItemInHand();
++ Player entityhuman = context.getPlayer();
+ boolean flag = false;
+- if (!level.isClientSide && player != null && player.canUseGameMasterBlocks()) {
+- CompoundTag blockEntityData = BlockItem.getBlockEntityData(itemInHand);
+- if (blockEntityData != null && blockEntityData.contains("Book")) {
++
++ if (!world.isClientSide && entityhuman != null && entityhuman.canUseGameMasterBlocks()) {
++ CompoundTag nbttagcompound = BlockItem.getBlockEntityData(itemstack);
++
++ if (nbttagcompound != null && nbttagcompound.contains("Book")) {
+ flag = true;
+ }
+ }
+
+- return this.defaultBlockState().setValue(FACING, context.getHorizontalDirection().getOpposite()).setValue(HAS_BOOK, Boolean.valueOf(flag));
++ return (IBlockData) ((IBlockData) this.defaultBlockState().setValue(LecternBlock.FACING, context.getHorizontalDirection().getOpposite())).setValue(LecternBlock.HAS_BOOK, flag);
+ }
+
+ @Override
+- public VoxelShape getCollisionShape(BlockState state, BlockGetter level, BlockPos pos, CollisionContext context) {
+- return SHAPE_COLLISION;
++ public VoxelShape getCollisionShape(IBlockData state, BlockGetter level, BlockPos pos, CollisionContext context) {
++ return LecternBlock.SHAPE_COLLISION;
+ }
+
+ @Override
+- public VoxelShape getShape(BlockState state, BlockGetter level, BlockPos pos, CollisionContext context) {
+- switch ((Direction)state.getValue(FACING)) {
++ public VoxelShape getShape(IBlockData state, BlockGetter level, BlockPos pos, CollisionContext context) {
++ switch ((Direction) state.getValue(LecternBlock.FACING)) {
+ case NORTH:
+- return SHAPE_NORTH;
++ return LecternBlock.SHAPE_NORTH;
+ case SOUTH:
+- return SHAPE_SOUTH;
++ return LecternBlock.SHAPE_SOUTH;
+ case EAST:
+- return SHAPE_EAST;
++ return LecternBlock.SHAPE_EAST;
+ case WEST:
+- return SHAPE_WEST;
++ return LecternBlock.SHAPE_WEST;
+ default:
+- return SHAPE_COMMON;
++ return LecternBlock.SHAPE_COMMON;
+ }
+ }
+
+ @Override
+- public BlockState rotate(BlockState state, Rotation rotation) {
+- return state.setValue(FACING, rotation.rotate(state.getValue(FACING)));
++ public IBlockData rotate(IBlockData state, Rotation rotation) {
++ return (IBlockData) state.setValue(LecternBlock.FACING, rotation.rotate((Direction) state.getValue(LecternBlock.FACING)));
+ }
+
+ @Override
+- public BlockState mirror(BlockState state, Mirror mirror) {
+- return state.rotate(mirror.getRotation(state.getValue(FACING)));
++ public IBlockData mirror(IBlockData state, Mirror mirror) {
++ return state.rotate(mirror.getRotation((Direction) state.getValue(LecternBlock.FACING)));
+ }
+
+ @Override
+- protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> builder) {
+- builder.add(FACING, POWERED, HAS_BOOK);
++ protected void createBlockStateDefinition(StateDefinition.Builder<Block, IBlockData> builder) {
++ builder.add(LecternBlock.FACING, LecternBlock.POWERED, LecternBlock.HAS_BOOK);
+ }
+
+ @Override
+- public BlockEntity newBlockEntity(BlockPos pos, BlockState state) {
++ public BlockEntity newBlockEntity(BlockPos pos, IBlockData state) {
+ return new LecternBlockEntity(pos, state);
+ }
+
+- public static boolean tryPlaceBook(@Nullable Entity entity, Level level, BlockPos pos, BlockState state, ItemStack stack) {
+- if (!state.getValue(HAS_BOOK)) {
++ public static boolean tryPlaceBook(@Nullable Entity entity, Level level, BlockPos pos, IBlockData state, ItemStack stack) {
++ if (!(Boolean) state.getValue(LecternBlock.HAS_BOOK)) {
+ if (!level.isClientSide) {
+ placeBook(entity, level, pos, state, stack);
+ }
+@@ -169,49 +150,55 @@
+ }
+ }
+
+- private static void placeBook(@Nullable Entity entity, Level level, BlockPos pos, BlockState state, ItemStack stack) {
+- if (level.getBlockEntity(pos) instanceof LecternBlockEntity lecternBlockEntity) {
+- lecternBlockEntity.setBook(stack.split(1));
++ private static void placeBook(@Nullable Entity entity, Level level, BlockPos pos, IBlockData state, ItemStack stack) {
++ BlockEntity tileentity = level.getBlockEntity(pos);
++
++ if (tileentity instanceof LecternBlockEntity) {
++ LecternBlockEntity tileentitylectern = (LecternBlockEntity) tileentity;
++
++ tileentitylectern.setBook(stack.split(1));
+ resetBookState(entity, level, pos, state, true);
+- level.playSound(null, pos, SoundEvents.BOOK_PUT, SoundSource.BLOCKS, 1.0F, 1.0F);
++ level.playSound((Player) null, pos, SoundEvents.BOOK_PUT, SoundSource.BLOCKS, 1.0F, 1.0F);
+ }
++
+ }
+
+- public static void resetBookState(@Nullable Entity entity, Level level, BlockPos pos, BlockState state, boolean hasBook) {
+- BlockState blockState = state.setValue(POWERED, Boolean.valueOf(false)).setValue(HAS_BOOK, Boolean.valueOf(hasBook));
+- level.setBlock(pos, blockState, 3);
+- level.gameEvent(GameEvent.BLOCK_CHANGE, pos, GameEvent.Context.of(entity, blockState));
++ public static void resetBookState(@Nullable Entity entity, Level level, BlockPos pos, IBlockData state, boolean hasBook) {
++ IBlockData iblockdata1 = (IBlockData) ((IBlockData) state.setValue(LecternBlock.POWERED, false)).setValue(LecternBlock.HAS_BOOK, hasBook);
++
++ level.setBlock(pos, iblockdata1, 3);
++ level.gameEvent(GameEvent.BLOCK_CHANGE, pos, GameEvent.Context.of(entity, iblockdata1));
+ updateBelow(level, pos, state);
+ }
+
+- public static void signalPageChange(Level level, BlockPos pos, BlockState state) {
++ public static void signalPageChange(Level level, BlockPos pos, IBlockData state) {
+ changePowered(level, pos, state, true);
+ level.scheduleTick(pos, state.getBlock(), 2);
+ level.levelEvent(1043, pos, 0);
+ }
+
+- private static void changePowered(Level level, BlockPos pos, BlockState state, boolean powered) {
+- level.setBlock(pos, state.setValue(POWERED, Boolean.valueOf(powered)), 3);
++ private static void changePowered(Level level, BlockPos pos, IBlockData state, boolean powered) {
++ level.setBlock(pos, (IBlockData) state.setValue(LecternBlock.POWERED, powered), 3);
+ updateBelow(level, pos, state);
+ }
+
+- private static void updateBelow(Level level, BlockPos pos, BlockState state) {
++ private static void updateBelow(Level level, BlockPos pos, IBlockData state) {
+ level.updateNeighborsAt(pos.below(), state.getBlock());
+ }
+
+ @Override
+- public void tick(BlockState state, ServerLevel level, BlockPos pos, RandomSource random) {
++ public void tick(IBlockData state, ServerLevel level, BlockPos pos, RandomSource random) {
+ changePowered(level, pos, state, false);
+ }
+
+ @Override
+- public void onRemove(BlockState state, Level level, BlockPos pos, BlockState newState, boolean isMoving) {
++ public void onRemove(IBlockData state, Level level, BlockPos pos, IBlockData newState, boolean isMoving) {
+ if (!state.is(newState.getBlock())) {
+- if (state.getValue(HAS_BOOK)) {
++ if ((Boolean) state.getValue(LecternBlock.HAS_BOOK)) {
+ this.popBook(state, level, pos);
+ }
+
+- if (state.getValue(POWERED)) {
++ if ((Boolean) state.getValue(LecternBlock.POWERED)) {
+ level.updateNeighborsAt(pos.below(), this);
+ }
+
+@@ -219,47 +206,52 @@
+ }
+ }
+
+- private void popBook(BlockState state, Level level, BlockPos pos) {
+- if (level.getBlockEntity(pos) instanceof LecternBlockEntity lecternBlockEntity) {
+- Direction direction = state.getValue(FACING);
+- ItemStack itemStack = lecternBlockEntity.getBook().copy();
+- float f = 0.25F * (float)direction.getStepX();
+- float f1 = 0.25F * (float)direction.getStepZ();
+- ItemEntity itemEntity = new ItemEntity(
+- level, (double)pos.getX() + 0.5 + (double)f, (double)(pos.getY() + 1), (double)pos.getZ() + 0.5 + (double)f1, itemStack
+- );
+- itemEntity.setDefaultPickUpDelay();
+- level.addFreshEntity(itemEntity);
+- lecternBlockEntity.clearContent();
++ private void popBook(IBlockData state, Level level, BlockPos pos) {
++ BlockEntity tileentity = level.getBlockEntity(pos, false); // CraftBukkit - don't validate, type may be changed already
++
++ if (tileentity instanceof LecternBlockEntity) {
++ LecternBlockEntity tileentitylectern = (LecternBlockEntity) tileentity;
++ Direction enumdirection = (Direction) state.getValue(LecternBlock.FACING);
++ ItemStack itemstack = tileentitylectern.getBook().copy();
++ if (itemstack.isEmpty()) return; // CraftBukkit - SPIGOT-5500
++ float f = 0.25F * (float) enumdirection.getStepX();
++ float f1 = 0.25F * (float) enumdirection.getStepZ();
++ ItemEntity entityitem = new ItemEntity(level, (double) pos.getX() + 0.5D + (double) f, (double) (pos.getY() + 1), (double) pos.getZ() + 0.5D + (double) f1, itemstack);
++
++ entityitem.setDefaultPickUpDelay();
++ level.addFreshEntity(entityitem);
++ tileentitylectern.clearContent();
+ }
++
+ }
+
+ @Override
+- public boolean isSignalSource(BlockState state) {
++ public boolean isSignalSource(IBlockData state) {
+ return true;
+ }
+
+ @Override
+- public int getSignal(BlockState blockState, BlockGetter blockAccess, BlockPos pos, Direction side) {
+- return blockState.getValue(POWERED) ? 15 : 0;
++ public int getSignal(IBlockData blockState, BlockGetter blockAccess, BlockPos pos, Direction side) {
++ return (Boolean) blockState.getValue(LecternBlock.POWERED) ? 15 : 0;
+ }
+
+ @Override
+- public int getDirectSignal(BlockState blockState, BlockGetter blockAccess, BlockPos pos, Direction side) {
+- return side == Direction.UP && blockState.getValue(POWERED) ? 15 : 0;
++ public int getDirectSignal(IBlockData blockState, BlockGetter blockAccess, BlockPos pos, Direction side) {
++ return side == Direction.UP && (Boolean) blockState.getValue(LecternBlock.POWERED) ? 15 : 0;
+ }
+
+ @Override
+- public boolean hasAnalogOutputSignal(BlockState state) {
++ public boolean hasAnalogOutputSignal(IBlockData state) {
+ return true;
+ }
+
+ @Override
+- public int getAnalogOutputSignal(BlockState blockState, Level level, BlockPos pos) {
+- if (blockState.getValue(HAS_BOOK)) {
+- BlockEntity blockEntity = level.getBlockEntity(pos);
+- if (blockEntity instanceof LecternBlockEntity) {
+- return ((LecternBlockEntity)blockEntity).getRedstoneSignal();
++ public int getAnalogOutputSignal(IBlockData blockState, Level level, BlockPos pos) {
++ if ((Boolean) blockState.getValue(LecternBlock.HAS_BOOK)) {
++ BlockEntity tileentity = level.getBlockEntity(pos);
++
++ if (tileentity instanceof LecternBlockEntity) {
++ return ((LecternBlockEntity) tileentity).getRedstoneSignal();
+ }
+ }
+
+@@ -267,35 +259,38 @@
+ }
+
+ @Override
+- public InteractionResult use(BlockState state, Level level, BlockPos pos, Player player, InteractionHand hand, BlockHitResult hit) {
+- if (state.getValue(HAS_BOOK)) {
++ public InteractionResult use(IBlockData state, Level level, BlockPos pos, Player player, EnumHand hand, BlockHitResult hit) {
++ if ((Boolean) state.getValue(LecternBlock.HAS_BOOK)) {
+ if (!level.isClientSide) {
+ this.openScreen(level, pos, player);
+ }
+
+ return InteractionResult.sidedSuccess(level.isClientSide);
+ } else {
+- ItemStack itemInHand = player.getItemInHand(hand);
+- return !itemInHand.isEmpty() && !itemInHand.is(ItemTags.LECTERN_BOOKS) ? InteractionResult.CONSUME : InteractionResult.PASS;
++ ItemStack itemstack = player.getItemInHand(hand);
++
++ return !itemstack.isEmpty() && !itemstack.is(ItemTags.LECTERN_BOOKS) ? InteractionResult.CONSUME : InteractionResult.PASS;
+ }
+ }
+
+ @Nullable
+ @Override
+- public MenuProvider getMenuProvider(BlockState state, Level level, BlockPos pos) {
+- return !state.getValue(HAS_BOOK) ? null : super.getMenuProvider(state, level, pos);
++ public ITileInventory getMenuProvider(IBlockData state, Level level, BlockPos pos) {
++ return !(Boolean) state.getValue(LecternBlock.HAS_BOOK) ? null : super.getMenuProvider(state, level, pos);
+ }
+
+ private void openScreen(Level level, BlockPos pos, Player player) {
+- BlockEntity blockEntity = level.getBlockEntity(pos);
+- if (blockEntity instanceof LecternBlockEntity) {
+- player.openMenu((LecternBlockEntity)blockEntity);
++ BlockEntity tileentity = level.getBlockEntity(pos);
++
++ if (tileentity instanceof LecternBlockEntity) {
++ player.openMenu((LecternBlockEntity) tileentity);
+ player.awardStat(Stats.INTERACT_WITH_LECTERN);
+ }
++
+ }
+
+ @Override
+- public boolean isPathfindable(BlockState state, BlockGetter level, BlockPos pos, PathComputationType type) {
++ public boolean isPathfindable(IBlockData state, BlockGetter level, BlockPos pos, PathMode type) {
+ return false;
+ }
+ }