papermc/patches/server/0245-Configurable-speed-for-water-flowing-over-lava.patch

72 lines
3.9 KiB
Diff
Raw Normal View History

2021-06-11 12:02:28 +00:00
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/com/destroystokyo/paper/PaperWorldConfig.java b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
index 6e7eb2134186e530f31eef6f86e30e8dbf523c4d..85ad9a1a29d0cb11f552d8f34b210f1bf4bdd810 100644
2021-06-11 12:02:28 +00:00
--- a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
+++ b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
@@ -446,4 +446,10 @@ public class PaperWorldConfig {
2021-06-11 12:02:28 +00:00
this.armorStandTick = this.getBoolean("armor-stands-tick", this.armorStandTick);
log("ArmorStand ticking is " + (this.armorStandTick ? "enabled" : "disabled") + " by default");
}
+
+ public int waterOverLavaFlowSpeed;
+ private void waterOverLavaFlowSpeed() {
+ waterOverLavaFlowSpeed = getInt("water-over-lava-flow-speed", 5);
+ log("Water over lava flow speed: " + waterOverLavaFlowSpeed);
+ }
}
diff --git a/src/main/java/net/minecraft/world/level/block/LiquidBlock.java b/src/main/java/net/minecraft/world/level/block/LiquidBlock.java
2022-06-07 21:45:11 +00:00
index 7d180d71d5b23319b26735e0d2fe187512a14842..f0cbb9e44b9434a69ea0ee7a5b403373d3680908 100644
2021-06-11 12:02:28 +00:00
--- a/src/main/java/net/minecraft/world/level/block/LiquidBlock.java
+++ b/src/main/java/net/minecraft/world/level/block/LiquidBlock.java
2022-03-01 05:43:03 +00:00
@@ -23,6 +23,7 @@ import net.minecraft.world.level.block.state.properties.BlockStateProperties;
import net.minecraft.world.level.block.state.properties.IntegerProperty;
2021-06-12 23:45:00 +00:00
import net.minecraft.world.level.material.FlowingFluid;
2021-06-11 12:02:28 +00:00
import net.minecraft.world.level.material.FluidState;
+import net.minecraft.world.level.material.Material;
import net.minecraft.world.level.pathfinder.PathComputationType;
import net.minecraft.world.level.storage.loot.LootContext;
import net.minecraft.world.phys.shapes.CollisionContext;
2022-03-01 05:43:03 +00:00
@@ -106,11 +107,27 @@ public class LiquidBlock extends Block implements BucketPickup {
2021-06-11 12:02:28 +00:00
@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
2021-06-11 12:02:28 +00:00
}
}
+ // Paper start - Get flow speed. Throttle if its water and flowing adjacent to lava
+ public int getFlowSpeed(Level world, BlockPos blockposition) {
+ if (this.material == Material.WATER) {
+ if (
+ world.getMaterialIfLoaded(blockposition.north(1)) == Material.LAVA ||
+ world.getMaterialIfLoaded(blockposition.south(1)) == Material.LAVA ||
+ world.getMaterialIfLoaded(blockposition.west(1)) == Material.LAVA ||
+ world.getMaterialIfLoaded(blockposition.east(1)) == Material.LAVA
+ ) {
+ return world.paperConfig.waterOverLavaFlowSpeed;
+ }
+ }
+ return this.fluid.getTickDelay(world);
+ }
+ // Paper end
+
@Override
2021-06-12 23:45:00 +00:00
public BlockState updateShape(BlockState state, Direction direction, BlockState neighborState, LevelAccessor world, BlockPos pos, BlockPos neighborPos) {
if (state.getFluidState().isSource() || neighborState.getFluidState().isSource()) {
2022-03-01 05:43:03 +00:00
@@ -123,7 +140,7 @@ public class LiquidBlock extends Block implements BucketPickup {
2021-06-11 12:02:28 +00:00
@Override
2022-06-07 21:45:11 +00:00
public void neighborChanged(BlockState state, Level world, BlockPos pos, Block sourceBlock, BlockPos sourcePos, boolean notify) {
2021-06-11 12:02:28 +00:00
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
2021-06-11 12:02:28 +00:00
}
}