diff options
Diffstat (limited to 'patch-remap/mache-spigotflower/net/minecraft/world/level/block/LecternBlock.java.patch')
-rw-r--r-- | patch-remap/mache-spigotflower/net/minecraft/world/level/block/LecternBlock.java.patch | 379 |
1 files changed, 379 insertions, 0 deletions
diff --git a/patch-remap/mache-spigotflower/net/minecraft/world/level/block/LecternBlock.java.patch b/patch-remap/mache-spigotflower/net/minecraft/world/level/block/LecternBlock.java.patch new file mode 100644 index 0000000000..20097f8fde --- /dev/null +++ b/patch-remap/mache-spigotflower/net/minecraft/world/level/block/LecternBlock.java.patch @@ -0,0 +1,379 @@ +--- 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,13 +25,13 @@ + 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; +@@ -55,63 +55,56 @@ + private static final int PAGE_CHANGE_IMPULSE_TICKS = 2; + + @Override +- @Override + public MapCodec<LecternBlock> codec() { + return LecternBlock.CODEC; + } + +- protected LecternBlock(BlockBehaviour.Properties blockbehaviour_properties) { +- super(blockbehaviour_properties); +- this.registerDefaultState((BlockState) ((BlockState) ((BlockState) ((BlockState) this.stateDefinition.any()).setValue(LecternBlock.FACING, Direction.NORTH)).setValue(LecternBlock.POWERED, false)).setValue(LecternBlock.HAS_BOOK, false)); ++ protected LecternBlock(BlockBehaviour.Properties properties) { ++ super(properties); ++ this.registerDefaultState((IBlockData) ((IBlockData) ((IBlockData) ((IBlockData) this.stateDefinition.any()).setValue(LecternBlock.FACING, Direction.NORTH)).setValue(LecternBlock.POWERED, false)).setValue(LecternBlock.HAS_BOOK, false)); + } + + @Override +- @Override +- public RenderShape getRenderShape(BlockState blockstate) { +- return RenderShape.MODEL; ++ public EnumRenderType getRenderShape(IBlockData state) { ++ return EnumRenderType.MODEL; + } + + @Override +- @Override +- public VoxelShape getOcclusionShape(BlockState blockstate, BlockGetter blockgetter, BlockPos blockpos) { ++ public VoxelShape getOcclusionShape(IBlockData state, BlockGetter level, BlockPos pos) { + return LecternBlock.SHAPE_COMMON; + } + + @Override +- @Override +- public boolean useShapeForLightOcclusion(BlockState blockstate) { ++ public boolean useShapeForLightOcclusion(IBlockData state) { + return true; + } + + @Override +- @Override +- public BlockState getStateForPlacement(BlockPlaceContext blockplacecontext) { +- Level level = blockplacecontext.getLevel(); +- ItemStack itemstack = blockplacecontext.getItemInHand(); +- Player player = blockplacecontext.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 compoundtag = BlockItem.getBlockEntityData(itemstack); ++ if (!world.isClientSide && entityhuman != null && entityhuman.canUseGameMasterBlocks()) { ++ CompoundTag nbttagcompound = BlockItem.getBlockEntityData(itemstack); + +- if (compoundtag != null && compoundtag.contains("Book")) { ++ if (nbttagcompound != null && nbttagcompound.contains("Book")) { + flag = true; + } + } + +- return (BlockState) ((BlockState) this.defaultBlockState().setValue(LecternBlock.FACING, blockplacecontext.getHorizontalDirection().getOpposite())).setValue(LecternBlock.HAS_BOOK, flag); ++ return (IBlockData) ((IBlockData) this.defaultBlockState().setValue(LecternBlock.FACING, context.getHorizontalDirection().getOpposite())).setValue(LecternBlock.HAS_BOOK, flag); + } + + @Override +- @Override +- public VoxelShape getCollisionShape(BlockState blockstate, BlockGetter blockgetter, BlockPos blockpos, CollisionContext collisioncontext) { ++ public VoxelShape getCollisionShape(IBlockData state, BlockGetter level, BlockPos pos, CollisionContext context) { + return LecternBlock.SHAPE_COLLISION; + } + + @Override +- @Override +- public VoxelShape getShape(BlockState blockstate, BlockGetter blockgetter, BlockPos blockpos, CollisionContext collisioncontext) { +- switch ((Direction) blockstate.getValue(LecternBlock.FACING)) { ++ public VoxelShape getShape(IBlockData state, BlockGetter level, BlockPos pos, CollisionContext context) { ++ switch ((Direction) state.getValue(LecternBlock.FACING)) { + case NORTH: + return LecternBlock.SHAPE_NORTH; + case SOUTH: +@@ -126,33 +119,29 @@ + } + + @Override +- @Override +- public BlockState rotate(BlockState blockstate, Rotation rotation) { +- return (BlockState) blockstate.setValue(LecternBlock.FACING, rotation.rotate((Direction) blockstate.getValue(LecternBlock.FACING))); ++ public IBlockData rotate(IBlockData state, Rotation rotation) { ++ return (IBlockData) state.setValue(LecternBlock.FACING, rotation.rotate((Direction) state.getValue(LecternBlock.FACING))); + } + + @Override +- @Override +- public BlockState mirror(BlockState blockstate, Mirror mirror) { +- return blockstate.rotate(mirror.getRotation((Direction) blockstate.getValue(LecternBlock.FACING))); ++ public IBlockData mirror(IBlockData state, Mirror mirror) { ++ return state.rotate(mirror.getRotation((Direction) state.getValue(LecternBlock.FACING))); + } + + @Override +- @Override +- protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> statedefinition_builder) { +- statedefinition_builder.add(LecternBlock.FACING, LecternBlock.POWERED, LecternBlock.HAS_BOOK); ++ protected void createBlockStateDefinition(StateDefinition.Builder<Block, IBlockData> builder) { ++ builder.add(LecternBlock.FACING, LecternBlock.POWERED, LecternBlock.HAS_BOOK); + } + + @Override +- @Override +- public BlockEntity newBlockEntity(BlockPos blockpos, BlockState blockstate) { +- return new LecternBlockEntity(blockpos, blockstate); ++ public BlockEntity newBlockEntity(BlockPos pos, IBlockData state) { ++ return new LecternBlockEntity(pos, state); + } + +- public static boolean tryPlaceBook(@Nullable Entity entity, Level level, BlockPos blockpos, BlockState blockstate, ItemStack itemstack) { +- if (!(Boolean) blockstate.getValue(LecternBlock.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, blockpos, blockstate, itemstack); ++ placeBook(entity, level, pos, state, stack); + } + + return true; +@@ -161,114 +150,108 @@ + } + } + +- private static void placeBook(@Nullable Entity entity, Level level, BlockPos blockpos, BlockState blockstate, ItemStack itemstack) { +- BlockEntity blockentity = level.getBlockEntity(blockpos); ++ private static void placeBook(@Nullable Entity entity, Level level, BlockPos pos, IBlockData state, ItemStack stack) { ++ BlockEntity tileentity = level.getBlockEntity(pos); + +- if (blockentity instanceof LecternBlockEntity) { +- LecternBlockEntity lecternblockentity = (LecternBlockEntity) blockentity; ++ if (tileentity instanceof LecternBlockEntity) { ++ LecternBlockEntity tileentitylectern = (LecternBlockEntity) tileentity; + +- lecternblockentity.setBook(itemstack.split(1)); +- resetBookState(entity, level, blockpos, blockstate, true); +- level.playSound((Player) null, blockpos, SoundEvents.BOOK_PUT, SoundSource.BLOCKS, 1.0F, 1.0F); ++ tileentitylectern.setBook(stack.split(1)); ++ resetBookState(entity, level, pos, state, true); ++ level.playSound((Player) null, pos, SoundEvents.BOOK_PUT, SoundSource.BLOCKS, 1.0F, 1.0F); + } + + } + +- public static void resetBookState(@Nullable Entity entity, Level level, BlockPos blockpos, BlockState blockstate, boolean flag) { +- BlockState blockstate1 = (BlockState) ((BlockState) blockstate.setValue(LecternBlock.POWERED, false)).setValue(LecternBlock.HAS_BOOK, flag); ++ 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(blockpos, blockstate1, 3); +- level.gameEvent(GameEvent.BLOCK_CHANGE, blockpos, GameEvent.Context.of(entity, blockstate1)); +- updateBelow(level, blockpos, blockstate); ++ 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 blockpos, BlockState blockstate) { +- changePowered(level, blockpos, blockstate, true); +- level.scheduleTick(blockpos, blockstate.getBlock(), 2); +- level.levelEvent(1043, blockpos, 0); ++ 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 blockpos, BlockState blockstate, boolean flag) { +- level.setBlock(blockpos, (BlockState) blockstate.setValue(LecternBlock.POWERED, flag), 3); +- updateBelow(level, blockpos, blockstate); ++ 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 blockpos, BlockState blockstate) { +- level.updateNeighborsAt(blockpos.below(), blockstate.getBlock()); ++ private static void updateBelow(Level level, BlockPos pos, IBlockData state) { ++ level.updateNeighborsAt(pos.below(), state.getBlock()); + } + + @Override +- @Override +- public void tick(BlockState blockstate, ServerLevel serverlevel, BlockPos blockpos, RandomSource randomsource) { +- changePowered(serverlevel, blockpos, blockstate, false); ++ public void tick(IBlockData state, ServerLevel level, BlockPos pos, RandomSource random) { ++ changePowered(level, pos, state, false); + } + + @Override +- @Override +- public void onRemove(BlockState blockstate, Level level, BlockPos blockpos, BlockState blockstate1, boolean flag) { +- if (!blockstate.is(blockstate1.getBlock())) { +- if ((Boolean) blockstate.getValue(LecternBlock.HAS_BOOK)) { +- this.popBook(blockstate, level, blockpos); ++ public void onRemove(IBlockData state, Level level, BlockPos pos, IBlockData newState, boolean isMoving) { ++ if (!state.is(newState.getBlock())) { ++ if ((Boolean) state.getValue(LecternBlock.HAS_BOOK)) { ++ this.popBook(state, level, pos); + } + +- if ((Boolean) blockstate.getValue(LecternBlock.POWERED)) { +- level.updateNeighborsAt(blockpos.below(), this); ++ if ((Boolean) state.getValue(LecternBlock.POWERED)) { ++ level.updateNeighborsAt(pos.below(), this); + } + +- super.onRemove(blockstate, level, blockpos, blockstate1, flag); ++ super.onRemove(state, level, pos, newState, isMoving); + } + } + +- private void popBook(BlockState blockstate, Level level, BlockPos blockpos) { +- BlockEntity blockentity = level.getBlockEntity(blockpos); ++ 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 (blockentity instanceof LecternBlockEntity) { +- LecternBlockEntity lecternblockentity = (LecternBlockEntity) blockentity; +- Direction direction = (Direction) blockstate.getValue(LecternBlock.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) blockpos.getX() + 0.5D + (double) f, (double) (blockpos.getY() + 1), (double) blockpos.getZ() + 0.5D + (double) f1, itemstack); ++ 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); + +- itementity.setDefaultPickUpDelay(); +- level.addFreshEntity(itementity); +- lecternblockentity.clearContent(); ++ entityitem.setDefaultPickUpDelay(); ++ level.addFreshEntity(entityitem); ++ tileentitylectern.clearContent(); + } + + } + + @Override +- @Override +- public boolean isSignalSource(BlockState blockstate) { ++ public boolean isSignalSource(IBlockData state) { + return true; + } + + @Override +- @Override +- public int getSignal(BlockState blockstate, BlockGetter blockgetter, BlockPos blockpos, Direction direction) { +- return (Boolean) blockstate.getValue(LecternBlock.POWERED) ? 15 : 0; ++ public int getSignal(IBlockData blockState, BlockGetter blockAccess, BlockPos pos, Direction side) { ++ return (Boolean) blockState.getValue(LecternBlock.POWERED) ? 15 : 0; + } + + @Override +- @Override +- public int getDirectSignal(BlockState blockstate, BlockGetter blockgetter, BlockPos blockpos, Direction direction) { +- return direction == Direction.UP && (Boolean) blockstate.getValue(LecternBlock.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 +- @Override +- public boolean hasAnalogOutputSignal(BlockState blockstate) { ++ public boolean hasAnalogOutputSignal(IBlockData state) { + return true; + } + + @Override +- @Override +- public int getAnalogOutputSignal(BlockState blockstate, Level level, BlockPos blockpos) { +- if ((Boolean) blockstate.getValue(LecternBlock.HAS_BOOK)) { +- BlockEntity blockentity = level.getBlockEntity(blockpos); ++ public int getAnalogOutputSignal(IBlockData blockState, Level level, BlockPos pos) { ++ if ((Boolean) blockState.getValue(LecternBlock.HAS_BOOK)) { ++ BlockEntity tileentity = level.getBlockEntity(pos); + +- if (blockentity instanceof LecternBlockEntity) { +- return ((LecternBlockEntity) blockentity).getRedstoneSignal(); ++ if (tileentity instanceof LecternBlockEntity) { ++ return ((LecternBlockEntity) tileentity).getRedstoneSignal(); + } + } + +@@ -276,16 +259,15 @@ + } + + @Override +- @Override +- public InteractionResult use(BlockState blockstate, Level level, BlockPos blockpos, Player player, InteractionHand interactionhand, BlockHitResult blockhitresult) { +- if ((Boolean) blockstate.getValue(LecternBlock.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, blockpos, player); ++ this.openScreen(level, pos, player); + } + + return InteractionResult.sidedSuccess(level.isClientSide); + } else { +- ItemStack itemstack = player.getItemInHand(interactionhand); ++ ItemStack itemstack = player.getItemInHand(hand); + + return !itemstack.isEmpty() && !itemstack.is(ItemTags.LECTERN_BOOKS) ? InteractionResult.CONSUME : InteractionResult.PASS; + } +@@ -293,24 +275,22 @@ + + @Nullable + @Override +- @Override +- public MenuProvider getMenuProvider(BlockState blockstate, Level level, BlockPos blockpos) { +- return !(Boolean) blockstate.getValue(LecternBlock.HAS_BOOK) ? null : super.getMenuProvider(blockstate, level, blockpos); ++ 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 blockpos, Player player) { +- BlockEntity blockentity = level.getBlockEntity(blockpos); ++ private void openScreen(Level level, BlockPos pos, Player player) { ++ BlockEntity tileentity = level.getBlockEntity(pos); + +- if (blockentity instanceof LecternBlockEntity) { +- player.openMenu((LecternBlockEntity) blockentity); ++ if (tileentity instanceof LecternBlockEntity) { ++ player.openMenu((LecternBlockEntity) tileentity); + player.awardStat(Stats.INTERACT_WITH_LECTERN); + } + + } + + @Override +- @Override +- public boolean isPathfindable(BlockState blockstate, BlockGetter blockgetter, BlockPos blockpos, PathComputationType pathcomputationtype) { ++ public boolean isPathfindable(IBlockData state, BlockGetter level, BlockPos pos, PathMode type) { + return false; + } + } |