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

53 Zeilen
2.8 KiB
Diff

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/net/minecraft/world/level/block/LiquidBlock.java b/src/main/java/net/minecraft/world/level/block/LiquidBlock.java
2023-06-07 23:46:56 +02:00
index fd7a7772eef7e2e4418539a11cefa98046b087e1..bbabe4ad8afcc3a2069f6e9d4a9adcb643266894 100644
2021-06-11 14:02:28 +02:00
--- a/src/main/java/net/minecraft/world/level/block/LiquidBlock.java
+++ b/src/main/java/net/minecraft/world/level/block/LiquidBlock.java
2023-06-07 23:46:56 +02:00
@@ -106,11 +106,31 @@ public class LiquidBlock extends Block implements BucketPickup {
2021-06-11 14:02:28 +02: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 14:02:28 +02:00
}
}
+ // Paper start - Get flow speed. Throttle if its water and flowing adjacent to lava
+ public int getFlowSpeed(Level world, BlockPos blockposition) {
2023-06-07 23:46:56 +02:00
+ if (net.minecraft.core.registries.BuiltInRegistries.FLUID.wrapAsHolder(this.fluid).is(FluidTags.WATER)) {
2021-06-11 14:02:28 +02:00
+ if (
2023-06-07 23:46:56 +02:00
+ isLava(world, blockposition.north(1)) ||
+ isLava(world, blockposition.south(1)) ||
+ isLava(world, blockposition.west(1)) ||
+ isLava(world, blockposition.east(1))
2021-06-11 14:02:28 +02:00
+ ) {
+ return world.paperConfig().environment.waterOverLavaFlowSpeed;
2021-06-11 14:02:28 +02:00
+ }
+ }
+ return this.fluid.getTickDelay(world);
+ }
2023-06-07 23:46:56 +02:00
+ private static boolean isLava(Level world, BlockPos blockPos) {
+ final FluidState fluidState = world.getFluidIfLoaded(blockPos);
+ return fluidState != null && fluidState.is(FluidTags.LAVA);
+ }
2021-06-11 14:02:28 +02:00
+ // Paper end
+
@Override
2021-06-13 01:45:00 +02:00
public BlockState updateShape(BlockState state, Direction direction, BlockState neighborState, LevelAccessor world, BlockPos pos, BlockPos neighborPos) {
if (state.getFluidState().isSource() || neighborState.getFluidState().isSource()) {
2023-06-07 23:46:56 +02:00
@@ -123,7 +143,7 @@ public class LiquidBlock extends Block implements BucketPickup {
2021-06-11 14:02:28 +02:00
@Override
2022-06-07 23:45:11 +02:00
public void neighborChanged(BlockState state, Level world, BlockPos pos, Block sourceBlock, BlockPos sourcePos, boolean notify) {
2021-06-11 14:02:28 +02: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 14:02:28 +02:00
}
}