diff options
Diffstat (limited to 'patch-remap/mache-vineflower/net/minecraft/world/level/block/LiquidBlock.java.patch')
-rw-r--r-- | patch-remap/mache-vineflower/net/minecraft/world/level/block/LiquidBlock.java.patch | 255 |
1 files changed, 255 insertions, 0 deletions
diff --git a/patch-remap/mache-vineflower/net/minecraft/world/level/block/LiquidBlock.java.patch b/patch-remap/mache-vineflower/net/minecraft/world/level/block/LiquidBlock.java.patch new file mode 100644 index 0000000000..0464db1371 --- /dev/null +++ b/patch-remap/mache-vineflower/net/minecraft/world/level/block/LiquidBlock.java.patch @@ -0,0 +1,255 @@ +--- a/net/minecraft/world/level/block/LiquidBlock.java ++++ b/net/minecraft/world/level/block/LiquidBlock.java +@@ -2,11 +2,11 @@ + + import com.google.common.collect.ImmutableList; + import com.google.common.collect.Lists; ++import com.google.common.collect.UnmodifiableIterator; + import com.mojang.serialization.Codec; + import com.mojang.serialization.DataResult; + import com.mojang.serialization.MapCodec; + import com.mojang.serialization.codecs.RecordCodecBuilder; +-import com.mojang.serialization.codecs.RecordCodecBuilder.Instance; + import java.util.Collections; + import java.util.List; + import java.util.Optional; +@@ -24,41 +24,51 @@ + import net.minecraft.world.level.Level; + import net.minecraft.world.level.LevelAccessor; + 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.material.FlowingFluid; +-import net.minecraft.world.level.material.Fluid; + import net.minecraft.world.level.material.FluidState; +-import net.minecraft.world.level.pathfinder.PathComputationType; ++import net.minecraft.world.level.pathfinder.PathMode; + import net.minecraft.world.level.storage.loot.LootParams; + import net.minecraft.world.phys.shapes.CollisionContext; + import net.minecraft.world.phys.shapes.Shapes; + import net.minecraft.world.phys.shapes.VoxelShape; + + public class LiquidBlock extends Block implements BucketPickup { +- private static final Codec<FlowingFluid> FLOWING_FLUID = BuiltInRegistries.FLUID +- .byNameCodec() +- .comapFlatMap( +- fluid -> fluid instanceof FlowingFluid flowingFluid ? DataResult.success(flowingFluid) : DataResult.error(() -> "Not a flowing fluid: " + fluid), +- flowingFluid -> (Fluid)flowingFluid +- ); +- public static final MapCodec<LiquidBlock> CODEC = RecordCodecBuilder.mapCodec( +- instance -> instance.group(FLOWING_FLUID.fieldOf("fluid").forGetter(liquidBlock -> liquidBlock.fluid), propertiesCodec()) +- .apply(instance, LiquidBlock::new) +- ); ++ ++ private static final Codec<FlowingFluid> FLOWING_FLUID = BuiltInRegistries.FLUID.byNameCodec().comapFlatMap((fluidtype) -> { ++ DataResult<FlowingFluid> dataresult; // CraftBukkit - decompile error ++ ++ if (fluidtype instanceof FlowingFluid) { ++ FlowingFluid fluidtypeflowing = (FlowingFluid) fluidtype; ++ ++ dataresult = DataResult.success(fluidtypeflowing); ++ } else { ++ dataresult = DataResult.error(() -> { ++ return "Not a flowing fluid: " + fluidtype; ++ }); ++ } ++ ++ return dataresult; ++ }, (fluidtypeflowing) -> { ++ return fluidtypeflowing; ++ }); ++ public static final MapCodec<LiquidBlock> CODEC = RecordCodecBuilder.mapCodec((instance) -> { ++ return instance.group(LiquidBlock.FLOWING_FLUID.fieldOf("fluid").forGetter((blockfluids) -> { ++ return blockfluids.fluid; ++ }), propertiesCodec()).apply(instance, LiquidBlock::new); ++ }); + public static final IntegerProperty LEVEL = BlockStateProperties.LEVEL; + protected final FlowingFluid fluid; + private final List<FluidState> stateCache; +- public static final VoxelShape STABLE_SHAPE = Block.box(0.0, 0.0, 0.0, 16.0, 8.0, 16.0); +- public static final ImmutableList<Direction> POSSIBLE_FLOW_DIRECTIONS = ImmutableList.of( +- Direction.DOWN, Direction.SOUTH, Direction.NORTH, Direction.EAST, Direction.WEST +- ); ++ public static final VoxelShape STABLE_SHAPE = Block.box(0.0D, 0.0D, 0.0D, 16.0D, 8.0D, 16.0D); ++ public static final ImmutableList<Direction> POSSIBLE_FLOW_DIRECTIONS = ImmutableList.of(Direction.DOWN, Direction.SOUTH, Direction.NORTH, Direction.EAST, Direction.WEST); + + @Override + public MapCodec<LiquidBlock> codec() { +- return CODEC; ++ return LiquidBlock.CODEC; + } + + protected LiquidBlock(FlowingFluid fluid, BlockBehaviour.Properties properties) { +@@ -67,78 +77,76 @@ + this.stateCache = Lists.newArrayList(); + this.stateCache.add(fluid.getSource(false)); + +- for (int i = 1; i < 8; i++) { ++ for (int i = 1; i < 8; ++i) { + this.stateCache.add(fluid.getFlowing(8 - i, false)); + } + + this.stateCache.add(fluid.getFlowing(8, true)); +- this.registerDefaultState(this.stateDefinition.any().setValue(LEVEL, Integer.valueOf(0))); ++ this.registerDefaultState((IBlockData) ((IBlockData) this.stateDefinition.any()).setValue(LiquidBlock.LEVEL, 0)); + } + + @Override +- public VoxelShape getCollisionShape(BlockState state, BlockGetter level, BlockPos pos, CollisionContext context) { +- return context.isAbove(STABLE_SHAPE, pos, true) +- && state.getValue(LEVEL) == 0 +- && context.canStandOnFluid(level.getFluidState(pos.above()), state.getFluidState()) +- ? STABLE_SHAPE +- : Shapes.empty(); ++ public VoxelShape getCollisionShape(IBlockData state, BlockGetter level, BlockPos pos, CollisionContext context) { ++ return context.isAbove(LiquidBlock.STABLE_SHAPE, pos, true) && (Integer) state.getValue(LiquidBlock.LEVEL) == 0 && context.canStandOnFluid(level.getFluidState(pos.above()), state.getFluidState()) ? LiquidBlock.STABLE_SHAPE : Shapes.empty(); + } + + @Override +- public boolean isRandomlyTicking(BlockState state) { ++ public boolean isRandomlyTicking(IBlockData state) { + return state.getFluidState().isRandomlyTicking(); + } + + @Override +- public void randomTick(BlockState state, ServerLevel level, BlockPos pos, RandomSource random) { ++ public void randomTick(IBlockData state, ServerLevel level, BlockPos pos, RandomSource random) { + state.getFluidState().randomTick(level, pos, random); + } + + @Override +- public boolean propagatesSkylightDown(BlockState state, BlockGetter reader, BlockPos pos) { ++ public boolean propagatesSkylightDown(IBlockData state, BlockGetter reader, BlockPos pos) { + return false; + } + + @Override +- public boolean isPathfindable(BlockState state, BlockGetter level, BlockPos pos, PathComputationType type) { ++ public boolean isPathfindable(IBlockData state, BlockGetter level, BlockPos pos, PathMode type) { + return !this.fluid.is(FluidTags.LAVA); + } + + @Override +- public FluidState getFluidState(BlockState state) { +- int i = state.getValue(LEVEL); +- return this.stateCache.get(Math.min(i, 8)); ++ public FluidState getFluidState(IBlockData state) { ++ int i = (Integer) state.getValue(LiquidBlock.LEVEL); ++ ++ return (FluidState) this.stateCache.get(Math.min(i, 8)); + } + + @Override +- public boolean skipRendering(BlockState state, BlockState adjacentBlockState, Direction side) { ++ public boolean skipRendering(IBlockData state, IBlockData adjacentBlockState, Direction side) { + return adjacentBlockState.getFluidState().getType().isSame(this.fluid); + } + + @Override +- public RenderShape getRenderShape(BlockState state) { +- return RenderShape.INVISIBLE; ++ public EnumRenderType getRenderShape(IBlockData state) { ++ return EnumRenderType.INVISIBLE; + } + + @Override +- public List<ItemStack> getDrops(BlockState state, LootParams.Builder params) { ++ public List<ItemStack> getDrops(IBlockData state, LootParams.Builder params) { + return Collections.emptyList(); + } + + @Override +- public VoxelShape getShape(BlockState state, BlockGetter level, BlockPos pos, CollisionContext context) { ++ public VoxelShape getShape(IBlockData state, BlockGetter level, BlockPos pos, CollisionContext context) { + return Shapes.empty(); + } + + @Override +- public void onPlace(BlockState state, Level level, BlockPos pos, BlockState oldState, boolean isMoving) { ++ public void onPlace(IBlockData state, Level level, BlockPos pos, IBlockData oldState, boolean isMoving) { + if (this.shouldSpreadLiquid(level, pos, state)) { + level.scheduleTick(pos, state.getFluidState().getType(), this.fluid.getTickDelay(level)); + } ++ + } + + @Override +- public BlockState updateShape(BlockState state, Direction facing, BlockState facingState, LevelAccessor level, BlockPos currentPos, BlockPos facingPos) { ++ public IBlockData updateShape(IBlockData state, Direction facing, IBlockData facingState, LevelAccessor level, BlockPos currentPos, BlockPos facingPos) { + if (state.getFluidState().isSource() || facingState.getFluidState().isSource()) { + level.scheduleTick(currentPos, state.getFluidState().getType(), this.fluid.getTickDelay(level)); + } +@@ -147,28 +155,39 @@ + } + + @Override +- public void neighborChanged(BlockState state, Level level, BlockPos pos, Block block, BlockPos fromPos, boolean isMoving) { ++ public void neighborChanged(IBlockData state, Level level, BlockPos pos, Block block, BlockPos fromPos, boolean isMoving) { + if (this.shouldSpreadLiquid(level, pos, state)) { + level.scheduleTick(pos, state.getFluidState().getType(), this.fluid.getTickDelay(level)); + } ++ + } + +- private boolean shouldSpreadLiquid(Level level, BlockPos pos, BlockState state) { ++ private boolean shouldSpreadLiquid(Level level, BlockPos pos, IBlockData state) { + if (this.fluid.is(FluidTags.LAVA)) { +- boolean isSoulSoil = level.getBlockState(pos.below()).is(Blocks.SOUL_SOIL); ++ boolean flag = level.getBlockState(pos.below()).is(Blocks.SOUL_SOIL); ++ UnmodifiableIterator unmodifiableiterator = LiquidBlock.POSSIBLE_FLOW_DIRECTIONS.iterator(); + +- for (Direction direction : POSSIBLE_FLOW_DIRECTIONS) { +- BlockPos blockPos = pos.relative(direction.getOpposite()); +- if (level.getFluidState(blockPos).is(FluidTags.WATER)) { ++ while (unmodifiableiterator.hasNext()) { ++ Direction enumdirection = (Direction) unmodifiableiterator.next(); ++ BlockPos blockposition1 = pos.relative(enumdirection.getOpposite()); ++ ++ if (level.getFluidState(blockposition1).is(FluidTags.WATER)) { + Block block = level.getFluidState(pos).isSource() ? Blocks.OBSIDIAN : Blocks.COBBLESTONE; +- level.setBlockAndUpdate(pos, block.defaultBlockState()); +- this.fizz(level, pos); ++ ++ // CraftBukkit start ++ if (org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockFormEvent(level, pos, block.defaultBlockState())) { ++ this.fizz(level, pos); ++ } ++ // CraftBukkit end + return false; + } + +- if (isSoulSoil && level.getBlockState(blockPos).is(Blocks.BLUE_ICE)) { +- level.setBlockAndUpdate(pos, Blocks.BASALT.defaultBlockState()); +- this.fizz(level, pos); ++ if (flag && level.getBlockState(blockposition1).is(Blocks.BLUE_ICE)) { ++ // CraftBukkit start ++ if (org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockFormEvent(level, pos, Blocks.BASALT.defaultBlockState())) { ++ this.fizz(level, pos); ++ } ++ // CraftBukkit end + return false; + } + } +@@ -182,14 +201,14 @@ + } + + @Override +- protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> builder) { +- builder.add(LEVEL); ++ protected void createBlockStateDefinition(StateDefinition.Builder<Block, IBlockData> builder) { ++ builder.add(LiquidBlock.LEVEL); + } + + @Override +- public ItemStack pickupBlock(@Nullable Player player, LevelAccessor levelAccessor, BlockPos blockPos, BlockState blockState) { +- if (blockState.getValue(LEVEL) == 0) { +- levelAccessor.setBlock(blockPos, Blocks.AIR.defaultBlockState(), 11); ++ public ItemStack pickupBlock(@Nullable Player entityhuman, LevelAccessor generatoraccess, BlockPos blockposition, IBlockData iblockdata) { ++ if ((Integer) iblockdata.getValue(LiquidBlock.LEVEL) == 0) { ++ generatoraccess.setBlock(blockposition, Blocks.AIR.defaultBlockState(), 11); + return new ItemStack(this.fluid.getBucket()); + } else { + return ItemStack.EMPTY; |