2018-07-04 07:55:24 +00:00
|
|
|
From 4b300fd41621071f122933ad9400521cb46228a0 Mon Sep 17 00:00:00 2001
|
2015-07-01 03:22:24 +00:00
|
|
|
From: Byteflux <byte@byteflux.net>
|
2016-02-29 23:09:49 +00:00
|
|
|
Date: Wed, 2 Mar 2016 12:20:52 -0600
|
2015-07-01 03:22:24 +00:00
|
|
|
Subject: [PATCH] Fast draining
|
|
|
|
|
|
|
|
|
2016-02-29 23:09:49 +00:00
|
|
|
diff --git a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
|
2018-02-13 00:44:50 +00:00
|
|
|
index 15675efbf..dbd82d5a9 100644
|
2016-02-29 23:09:49 +00:00
|
|
|
--- a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
|
|
|
|
+++ b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
|
2018-02-13 00:44:50 +00:00
|
|
|
@@ -183,4 +183,11 @@ public class PaperWorldConfig {
|
2016-02-29 23:09:49 +00:00
|
|
|
optimizeExplosions = getBoolean("optimize-explosions", false);
|
|
|
|
log("Optimize explosions: " + optimizeExplosions);
|
|
|
|
}
|
|
|
|
+
|
|
|
|
+ public boolean fastDrainLava;
|
|
|
|
+ public boolean fastDrainWater;
|
|
|
|
+ private void fastDrain() {
|
|
|
|
+ fastDrainLava = getBoolean("fast-drain.lava", false);
|
|
|
|
+ fastDrainWater = getBoolean("fast-drain.water", false);
|
|
|
|
+ }
|
|
|
|
}
|
2015-07-01 03:22:24 +00:00
|
|
|
diff --git a/src/main/java/net/minecraft/server/BlockFlowing.java b/src/main/java/net/minecraft/server/BlockFlowing.java
|
2018-02-13 00:44:50 +00:00
|
|
|
index 3b47253a4..3aaa19b2f 100644
|
2015-07-01 03:22:24 +00:00
|
|
|
--- a/src/main/java/net/minecraft/server/BlockFlowing.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/BlockFlowing.java
|
2016-12-10 00:07:35 +00:00
|
|
|
@@ -69,7 +69,7 @@ public class BlockFlowing extends BlockFluids {
|
2015-07-01 03:22:24 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
- if (this.material == Material.LAVA && i < 8 && i1 < 8 && i1 > i && random.nextInt(4) != 0) {
|
2016-02-29 23:09:49 +00:00
|
|
|
+ if (!world.paperConfig.fastDrainLava && this.material == Material.LAVA && i < 8 && i1 < 8 && i1 > i && random.nextInt(4) != 0) { // Paper
|
2015-07-01 03:22:24 +00:00
|
|
|
j *= 4;
|
|
|
|
}
|
|
|
|
|
2016-12-10 00:07:35 +00:00
|
|
|
@@ -77,7 +77,7 @@ public class BlockFlowing extends BlockFluids {
|
2015-07-01 03:22:24 +00:00
|
|
|
this.f(world, blockposition, iblockdata);
|
|
|
|
} else {
|
|
|
|
i = i1;
|
|
|
|
- if (i1 < 0) {
|
2016-02-29 23:09:49 +00:00
|
|
|
+ if (i1 < 0 || canFastDrain(world, blockposition)) { // Paper - Fast draining
|
2015-07-01 03:22:24 +00:00
|
|
|
world.setAir(blockposition);
|
|
|
|
} else {
|
|
|
|
iblockdata = iblockdata.set(BlockFlowing.LEVEL, Integer.valueOf(i1));
|
2016-12-10 00:07:35 +00:00
|
|
|
@@ -267,6 +267,7 @@ public class BlockFlowing extends BlockFluids {
|
2016-05-12 02:07:46 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
+ // Paper start
|
|
|
|
/**
|
|
|
|
* Paper - Get flow speed. Throttle if its water and flowing adjacent to lava
|
|
|
|
*/
|
2016-12-10 00:07:35 +00:00
|
|
|
@@ -280,4 +281,57 @@ public class BlockFlowing extends BlockFluids {
|
2015-07-01 03:22:24 +00:00
|
|
|
}
|
|
|
|
return super.a(world);
|
|
|
|
}
|
|
|
|
+
|
2016-05-12 02:07:46 +00:00
|
|
|
+ private int getFluidLevel(IBlockAccess iblockaccess, BlockPosition blockposition) {
|
|
|
|
+ return iblockaccess.getType(blockposition).getMaterial() == this.material ? iblockaccess.getType(blockposition).get(BlockFluids.LEVEL) : -1;
|
|
|
|
+ }
|
|
|
|
+
|
2015-07-01 03:22:24 +00:00
|
|
|
+ /**
|
2016-02-29 23:09:49 +00:00
|
|
|
+ * Paper - Data check method for fast draining
|
2015-07-01 03:22:24 +00:00
|
|
|
+ */
|
|
|
|
+ public int getData(World world, BlockPosition position) {
|
2016-05-12 02:07:46 +00:00
|
|
|
+ int data = this.getFluidLevel((IBlockAccess) world, position);
|
2015-07-01 03:22:24 +00:00
|
|
|
+ return data < 8 ? data : 0;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
2016-02-29 23:09:49 +00:00
|
|
|
+ * Paper - Checks surrounding blocks to determine if block can be fast drained
|
2015-07-01 03:22:24 +00:00
|
|
|
+ */
|
|
|
|
+ public boolean canFastDrain(World world, BlockPosition position) {
|
|
|
|
+ boolean result = false;
|
2015-07-03 19:38:43 +00:00
|
|
|
+ int data = getData(world, position);
|
2015-07-01 03:22:24 +00:00
|
|
|
+ if (this.material == Material.WATER) {
|
2016-02-29 23:09:49 +00:00
|
|
|
+ if (world.paperConfig.fastDrainWater) {
|
2015-07-01 03:22:24 +00:00
|
|
|
+ result = true;
|
|
|
|
+ if (getData(world, position.down()) < 0) {
|
|
|
|
+ result = false;
|
2016-02-29 23:09:49 +00:00
|
|
|
+ } else if (world.getType(position.north()).getBlock().getBlockData().getMaterial() == Material.WATER && getData(world, position.north()) < data) {
|
2015-07-01 03:22:24 +00:00
|
|
|
+ result = false;
|
2016-02-29 23:09:49 +00:00
|
|
|
+ } else if (world.getType(position.south()).getBlock().getBlockData().getMaterial() == Material.WATER && getData(world, position.south()) < data) {
|
2015-07-01 03:22:24 +00:00
|
|
|
+ result = false;
|
2016-02-29 23:09:49 +00:00
|
|
|
+ } else if (world.getType(position.west()).getBlock().getBlockData().getMaterial() == Material.WATER && getData(world, position.west()) < data) {
|
2015-07-01 03:22:24 +00:00
|
|
|
+ result = false;
|
2016-02-29 23:09:49 +00:00
|
|
|
+ } else if (world.getType(position.east()).getBlock().getBlockData().getMaterial() == Material.WATER && getData(world, position.east()) < data) {
|
2015-07-01 03:22:24 +00:00
|
|
|
+ result = false;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ } else if (this.material == Material.LAVA) {
|
2016-02-29 23:09:49 +00:00
|
|
|
+ if (world.paperConfig.fastDrainLava) {
|
2015-07-01 03:22:24 +00:00
|
|
|
+ result = true;
|
2016-02-29 23:09:49 +00:00
|
|
|
+ if (getData(world, position.down()) < 0 || world.getType(position.up()).getBlock().getBlockData().getMaterial() != Material.AIR) {
|
2015-07-01 03:22:24 +00:00
|
|
|
+ result = false;
|
2016-02-29 23:09:49 +00:00
|
|
|
+ } else if (world.getType(position.north()).getBlock().getBlockData().getMaterial() == Material.LAVA && getData(world, position.north()) < data) {
|
2015-07-01 03:22:24 +00:00
|
|
|
+ result = false;
|
2016-02-29 23:09:49 +00:00
|
|
|
+ } else if (world.getType(position.south()).getBlock().getBlockData().getMaterial() == Material.LAVA && getData(world, position.south()) < data) {
|
2015-07-01 03:22:24 +00:00
|
|
|
+ result = false;
|
2016-02-29 23:09:49 +00:00
|
|
|
+ } else if (world.getType(position.west()).getBlock().getBlockData().getMaterial() == Material.LAVA && getData(world, position.west()) < data) {
|
2015-07-01 03:22:24 +00:00
|
|
|
+ result = false;
|
2016-02-29 23:09:49 +00:00
|
|
|
+ } else if (world.getType(position.east()).getBlock().getBlockData().getMaterial() == Material.LAVA && getData(world, position.east()) < data) {
|
2015-07-01 03:22:24 +00:00
|
|
|
+ result = false;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return result;
|
|
|
|
+ }
|
2016-05-12 02:07:46 +00:00
|
|
|
+ // Paper end
|
2015-07-01 03:22:24 +00:00
|
|
|
}
|
|
|
|
--
|
2018-07-04 07:55:24 +00:00
|
|
|
2.18.0
|
2015-07-01 03:22:24 +00:00
|
|
|
|