aboutsummaryrefslogtreecommitdiffhomepage
path: root/patch-remap/mache-vineflower/net/minecraft/world/level/block/SnowLayerBlock.java.patch
diff options
context:
space:
mode:
Diffstat (limited to 'patch-remap/mache-vineflower/net/minecraft/world/level/block/SnowLayerBlock.java.patch')
-rw-r--r--patch-remap/mache-vineflower/net/minecraft/world/level/block/SnowLayerBlock.java.patch185
1 files changed, 185 insertions, 0 deletions
diff --git a/patch-remap/mache-vineflower/net/minecraft/world/level/block/SnowLayerBlock.java.patch b/patch-remap/mache-vineflower/net/minecraft/world/level/block/SnowLayerBlock.java.patch
new file mode 100644
index 0000000000..f0a4428754
--- /dev/null
+++ b/patch-remap/mache-vineflower/net/minecraft/world/level/block/SnowLayerBlock.java.patch
@@ -0,0 +1,185 @@
+--- a/net/minecraft/world/level/block/SnowLayerBlock.java
++++ b/net/minecraft/world/level/block/SnowLayerBlock.java
+@@ -9,51 +9,42 @@
+ import net.minecraft.util.RandomSource;
+ import net.minecraft.world.item.context.BlockPlaceContext;
+ import net.minecraft.world.level.BlockGetter;
++import net.minecraft.world.level.EnumSkyBlock;
+ import net.minecraft.world.level.LevelAccessor;
+ import net.minecraft.world.level.LevelReader;
+-import net.minecraft.world.level.LightLayer;
+ 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.IntegerProperty;
+-import net.minecraft.world.level.pathfinder.PathComputationType;
++import net.minecraft.world.level.pathfinder.PathMode;
+ import net.minecraft.world.phys.shapes.CollisionContext;
+ import net.minecraft.world.phys.shapes.Shapes;
+ import net.minecraft.world.phys.shapes.VoxelShape;
+
+ public class SnowLayerBlock extends Block {
++
+ public static final MapCodec<SnowLayerBlock> CODEC = simpleCodec(SnowLayerBlock::new);
+ public static final int MAX_HEIGHT = 8;
+ public static final IntegerProperty LAYERS = BlockStateProperties.LAYERS;
+- protected static final VoxelShape[] SHAPE_BY_LAYER = new VoxelShape[]{
+- Shapes.empty(),
+- Block.box(0.0, 0.0, 0.0, 16.0, 2.0, 16.0),
+- Block.box(0.0, 0.0, 0.0, 16.0, 4.0, 16.0),
+- Block.box(0.0, 0.0, 0.0, 16.0, 6.0, 16.0),
+- Block.box(0.0, 0.0, 0.0, 16.0, 8.0, 16.0),
+- Block.box(0.0, 0.0, 0.0, 16.0, 10.0, 16.0),
+- Block.box(0.0, 0.0, 0.0, 16.0, 12.0, 16.0),
+- Block.box(0.0, 0.0, 0.0, 16.0, 14.0, 16.0),
+- Block.box(0.0, 0.0, 0.0, 16.0, 16.0, 16.0)
+- };
++ protected static final VoxelShape[] SHAPE_BY_LAYER = new VoxelShape[]{Shapes.empty(), Block.box(0.0D, 0.0D, 0.0D, 16.0D, 2.0D, 16.0D), Block.box(0.0D, 0.0D, 0.0D, 16.0D, 4.0D, 16.0D), Block.box(0.0D, 0.0D, 0.0D, 16.0D, 6.0D, 16.0D), Block.box(0.0D, 0.0D, 0.0D, 16.0D, 8.0D, 16.0D), Block.box(0.0D, 0.0D, 0.0D, 16.0D, 10.0D, 16.0D), Block.box(0.0D, 0.0D, 0.0D, 16.0D, 12.0D, 16.0D), Block.box(0.0D, 0.0D, 0.0D, 16.0D, 14.0D, 16.0D), Block.box(0.0D, 0.0D, 0.0D, 16.0D, 16.0D, 16.0D)};
+ public static final int HEIGHT_IMPASSABLE = 5;
+
+ @Override
+ public MapCodec<SnowLayerBlock> codec() {
+- return CODEC;
++ return SnowLayerBlock.CODEC;
+ }
+
+ protected SnowLayerBlock(BlockBehaviour.Properties properties) {
+ super(properties);
+- this.registerDefaultState(this.stateDefinition.any().setValue(LAYERS, Integer.valueOf(1)));
++ this.registerDefaultState((IBlockData) ((IBlockData) this.stateDefinition.any()).setValue(SnowLayerBlock.LAYERS, 1));
+ }
+
+ @Override
+- public boolean isPathfindable(BlockState state, BlockGetter level, BlockPos pos, PathComputationType type) {
++ public boolean isPathfindable(IBlockData state, BlockGetter level, BlockPos pos, PathMode type) {
+ switch (type) {
+ case LAND:
+- return state.getValue(LAYERS) < 5;
++ return (Integer) state.getValue(SnowLayerBlock.LAYERS) < 5;
+ case WATER:
+ return false;
+ case AIR:
+@@ -64,83 +55,84 @@
+ }
+
+ @Override
+- public VoxelShape getShape(BlockState state, BlockGetter level, BlockPos pos, CollisionContext context) {
+- return SHAPE_BY_LAYER[state.getValue(LAYERS)];
++ public VoxelShape getShape(IBlockData state, BlockGetter level, BlockPos pos, CollisionContext context) {
++ return SnowLayerBlock.SHAPE_BY_LAYER[(Integer) state.getValue(SnowLayerBlock.LAYERS)];
+ }
+
+ @Override
+- public VoxelShape getCollisionShape(BlockState state, BlockGetter level, BlockPos pos, CollisionContext context) {
+- return SHAPE_BY_LAYER[state.getValue(LAYERS) - 1];
++ public VoxelShape getCollisionShape(IBlockData state, BlockGetter level, BlockPos pos, CollisionContext context) {
++ return SnowLayerBlock.SHAPE_BY_LAYER[(Integer) state.getValue(SnowLayerBlock.LAYERS) - 1];
+ }
+
+ @Override
+- public VoxelShape getBlockSupportShape(BlockState state, BlockGetter reader, BlockPos pos) {
+- return SHAPE_BY_LAYER[state.getValue(LAYERS)];
++ public VoxelShape getBlockSupportShape(IBlockData state, BlockGetter reader, BlockPos pos) {
++ return SnowLayerBlock.SHAPE_BY_LAYER[(Integer) state.getValue(SnowLayerBlock.LAYERS)];
+ }
+
+ @Override
+- public VoxelShape getVisualShape(BlockState state, BlockGetter reader, BlockPos pos, CollisionContext context) {
+- return SHAPE_BY_LAYER[state.getValue(LAYERS)];
++ public VoxelShape getVisualShape(IBlockData state, BlockGetter reader, BlockPos pos, CollisionContext context) {
++ return SnowLayerBlock.SHAPE_BY_LAYER[(Integer) state.getValue(SnowLayerBlock.LAYERS)];
+ }
+
+ @Override
+- public boolean useShapeForLightOcclusion(BlockState state) {
++ public boolean useShapeForLightOcclusion(IBlockData state) {
+ return true;
+ }
+
+ @Override
+- public float getShadeBrightness(BlockState state, BlockGetter level, BlockPos pos) {
+- return state.getValue(LAYERS) == 8 ? 0.2F : 1.0F;
++ public float getShadeBrightness(IBlockData state, BlockGetter level, BlockPos pos) {
++ return (Integer) state.getValue(SnowLayerBlock.LAYERS) == 8 ? 0.2F : 1.0F;
+ }
+
+ @Override
+- public boolean canSurvive(BlockState state, LevelReader level, BlockPos pos) {
+- BlockState blockState = level.getBlockState(pos.below());
+- return !blockState.is(BlockTags.SNOW_LAYER_CANNOT_SURVIVE_ON)
+- && (
+- blockState.is(BlockTags.SNOW_LAYER_CAN_SURVIVE_ON)
+- || Block.isFaceFull(blockState.getCollisionShape(level, pos.below()), Direction.UP)
+- || blockState.is(this) && blockState.getValue(LAYERS) == 8
+- );
++ public boolean canSurvive(IBlockData state, LevelReader level, BlockPos pos) {
++ IBlockData iblockdata1 = level.getBlockState(pos.below());
++
++ return iblockdata1.is(BlockTags.SNOW_LAYER_CANNOT_SURVIVE_ON) ? false : (iblockdata1.is(BlockTags.SNOW_LAYER_CAN_SURVIVE_ON) ? true : Block.isFaceFull(iblockdata1.getCollisionShape(level, pos.below()), Direction.UP) || iblockdata1.is((Block) this) && (Integer) iblockdata1.getValue(SnowLayerBlock.LAYERS) == 8);
+ }
+
+ @Override
+- public BlockState updateShape(BlockState state, Direction facing, BlockState facingState, LevelAccessor level, BlockPos currentPos, BlockPos facingPos) {
+- return !state.canSurvive(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 !state.canSurvive(level, currentPos) ? Blocks.AIR.defaultBlockState() : super.updateShape(state, facing, facingState, level, currentPos, facingPos);
+ }
+
+ @Override
+- public void randomTick(BlockState state, ServerLevel level, BlockPos pos, RandomSource random) {
+- if (level.getBrightness(LightLayer.BLOCK, pos) > 11) {
++ public void randomTick(IBlockData state, ServerLevel level, BlockPos pos, RandomSource random) {
++ if (level.getBrightness(EnumSkyBlock.BLOCK, pos) > 11) {
++ // CraftBukkit start
++ if (org.bukkit.craftbukkit.event.CraftEventFactory.callBlockFadeEvent(level, pos, Blocks.AIR.defaultBlockState()).isCancelled()) {
++ return;
++ }
++ // CraftBukkit end
+ dropResources(state, level, pos);
+ level.removeBlock(pos, false);
+ }
++
+ }
+
+ @Override
+- public boolean canBeReplaced(BlockState state, BlockPlaceContext useContext) {
+- int i = state.getValue(LAYERS);
+- return !useContext.getItemInHand().is(this.asItem()) || i >= 8
+- ? i == 1
+- : !useContext.replacingClickedOnBlock() || useContext.getClickedFace() == Direction.UP;
++ public boolean canBeReplaced(IBlockData state, BlockPlaceContext useContext) {
++ int i = (Integer) state.getValue(SnowLayerBlock.LAYERS);
++
++ return useContext.getItemInHand().is(this.asItem()) && i < 8 ? (useContext.replacingClickedOnBlock() ? useContext.getClickedFace() == Direction.UP : true) : i == 1;
+ }
+
+ @Nullable
+ @Override
+- public BlockState getStateForPlacement(BlockPlaceContext context) {
+- BlockState blockState = context.getLevel().getBlockState(context.getClickedPos());
+- if (blockState.is(this)) {
+- int i = blockState.getValue(LAYERS);
+- return blockState.setValue(LAYERS, Integer.valueOf(Math.min(8, i + 1)));
++ public IBlockData getStateForPlacement(BlockPlaceContext context) {
++ IBlockData iblockdata = context.getLevel().getBlockState(context.getClickedPos());
++
++ if (iblockdata.is((Block) this)) {
++ int i = (Integer) iblockdata.getValue(SnowLayerBlock.LAYERS);
++
++ return (IBlockData) iblockdata.setValue(SnowLayerBlock.LAYERS, Math.min(8, i + 1));
+ } else {
+ return super.getStateForPlacement(context);
+ }
+ }
+
+ @Override
+- protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> builder) {
+- builder.add(LAYERS);
++ protected void createBlockStateDefinition(StateDefinition.Builder<Block, IBlockData> builder) {
++ builder.add(SnowLayerBlock.LAYERS);
+ }
+ }