Paper/patches/server-remapped/0272-Configurable-speed-for-water-flowing-over-lava.patch

73 lines
3.9 KiB
Diff
Raw Normal View History

2021-06-11 14:02:28 +02: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 5ab0e7183e48134b7a0f736462516b1a8a333b04..f280dbff4a09bc611a9ca565c6d697d08801f53b 100644
--- a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
+++ b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
@@ -390,4 +390,10 @@ public class PaperWorldConfig {
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
index f99b90e4b3210747077f2bf3adbcf7b5fb9821ec..97f2d9082e49010fb8780c5fdd8957f71b31e43e 100644
--- a/src/main/java/net/minecraft/world/level/block/LiquidBlock.java
+++ b/src/main/java/net/minecraft/world/level/block/LiquidBlock.java
@@ -23,6 +23,7 @@ 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.material.Fluids;
+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;
@@ -100,11 +101,28 @@ 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.getLiquidTicks().a(pos, state.getFluidState().getType(), this.fluid.getTickDelay((LevelReader) world));
+ world.getLiquidTicks().a(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 (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
public BlockState updateShape(BlockState state, Direction direction, BlockState newState, LevelAccessor world, BlockPos pos, BlockPos posFrom) {
if (state.getFluidState().isSource() || newState.getFluidState().isSource()) {
@@ -117,7 +135,7 @@ public class LiquidBlock extends Block implements BucketPickup {
@Override
public void neighborChanged(BlockState state, Level world, BlockPos pos, Block block, BlockPos fromPos, boolean notify) {
if (this.shouldSpreadLiquid(world, pos, state)) {
- world.getLiquidTicks().a(pos, state.getFluidState().getType(), this.fluid.getTickDelay((LevelReader) world));
+ world.getLiquidTicks().a(pos, state.getFluidState().getType(), this.getFlowSpeed(world, pos)); // Paper
}
}