mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-28 15:30:19 +01:00
52 lines
2.8 KiB
Diff
52 lines
2.8 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: Byteflux <byte@byteflux.net>
|
|
Date: Wed, 8 Aug 2018 16:33:21 -0600
|
|
Subject: [PATCH] Configurable speed for water flowing over lava
|
|
|
|
|
|
diff --git a/src/main/java/net/minecraft/world/level/block/LiquidBlock.java b/src/main/java/net/minecraft/world/level/block/LiquidBlock.java
|
|
index 3d8def659e017e3d525c7b40eacaf579a5ba3b5b..4a1830f85f47014da63e4584f411d13f0f0cd8b3 100644
|
|
--- a/src/main/java/net/minecraft/world/level/block/LiquidBlock.java
|
|
+++ b/src/main/java/net/minecraft/world/level/block/LiquidBlock.java
|
|
@@ -108,11 +108,31 @@ public class LiquidBlock extends Block implements BucketPickup {
|
|
@Override
|
|
public void onPlace(BlockState state, Level world, BlockPos pos, BlockState oldState, boolean notify) {
|
|
if (this.shouldSpreadLiquid(world, pos, state)) {
|
|
- world.scheduleTick(pos, state.getFluidState().getType(), this.fluid.getTickDelay(world));
|
|
+ world.scheduleTick(pos, state.getFluidState().getType(), this.getFlowSpeed(world, pos)); // Paper
|
|
}
|
|
|
|
}
|
|
|
|
+ // Paper start - Get flow speed. Throttle if its water and flowing adjacent to lava
|
|
+ public int getFlowSpeed(Level world, BlockPos blockposition) {
|
|
+ if (net.minecraft.core.registries.BuiltInRegistries.FLUID.wrapAsHolder(this.fluid).is(FluidTags.WATER)) {
|
|
+ if (
|
|
+ isLava(world, blockposition.north(1)) ||
|
|
+ isLava(world, blockposition.south(1)) ||
|
|
+ isLava(world, blockposition.west(1)) ||
|
|
+ isLava(world, blockposition.east(1))
|
|
+ ) {
|
|
+ return world.paperConfig().environment.waterOverLavaFlowSpeed;
|
|
+ }
|
|
+ }
|
|
+ return this.fluid.getTickDelay(world);
|
|
+ }
|
|
+ private static boolean isLava(Level world, BlockPos blockPos) {
|
|
+ final FluidState fluidState = world.getFluidIfLoaded(blockPos);
|
|
+ return fluidState != null && fluidState.is(FluidTags.LAVA);
|
|
+ }
|
|
+ // Paper end
|
|
+
|
|
@Override
|
|
public BlockState updateShape(BlockState state, Direction direction, BlockState neighborState, LevelAccessor world, BlockPos pos, BlockPos neighborPos) {
|
|
if (state.getFluidState().isSource() || neighborState.getFluidState().isSource()) {
|
|
@@ -125,7 +145,7 @@ public class LiquidBlock extends Block implements BucketPickup {
|
|
@Override
|
|
public void neighborChanged(BlockState state, Level world, BlockPos pos, Block sourceBlock, BlockPos sourcePos, boolean notify) {
|
|
if (this.shouldSpreadLiquid(world, pos, state)) {
|
|
- world.scheduleTick(pos, state.getFluidState().getType(), this.fluid.getTickDelay(world));
|
|
+ world.scheduleTick(pos, state.getFluidState().getType(), this.getFlowSpeed(world, pos)); // Paper
|
|
}
|
|
|
|
}
|