mirror of
https://github.com/PurpurMC/Purpur.git
synced 2026-02-21 02:17:42 +01:00
Update to 1.15
This commit is contained in:
99
patches/server/0067-Add-block-and-fluid-tick-events.patch
Normal file
99
patches/server/0067-Add-block-and-fluid-tick-events.patch
Normal file
@@ -0,0 +1,99 @@
|
||||
From 3deb8c03cbe3d16b0906e037ebcb2be02aa17783 Mon Sep 17 00:00:00 2001
|
||||
From: William Blake Galbreath <blake.galbreath@gmail.com>
|
||||
Date: Fri, 18 Oct 2019 23:58:56 -0500
|
||||
Subject: [PATCH] Add block and fluid tick events
|
||||
|
||||
---
|
||||
.../java/net/minecraft/server/WorldServer.java | 8 ++++++--
|
||||
.../net/pl3x/purpur/PurpurWorldConfig.java | 7 +++++++
|
||||
.../org/bukkit/craftbukkit/CraftWorld.java | 18 ++++++++++++++++++
|
||||
3 files changed, 31 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/WorldServer.java b/src/main/java/net/minecraft/server/WorldServer.java
|
||||
index f6431f1de6..e70bc4d4dc 100644
|
||||
--- a/src/main/java/net/minecraft/server/WorldServer.java
|
||||
+++ b/src/main/java/net/minecraft/server/WorldServer.java
|
||||
@@ -580,13 +580,15 @@ public class WorldServer extends World {
|
||||
gameprofilerfiller.enter("randomTick");
|
||||
IBlockData iblockdata = chunksection.getType(blockposition2.getX() - j, blockposition2.getY() - j1, blockposition2.getZ() - k);
|
||||
|
||||
- if (iblockdata.q()) {
|
||||
+ if (iblockdata.q() && (!purpurConfig.blockTickEvent || new net.pl3x.purpur.event.block.BlockTickEvent(getWorld(), blockposition2.x, blockposition2.y, blockposition2.z, true).callEvent())) { // Purpur
|
||||
+ iblockdata.getBlock().randomTick = true; // Paper - fix MC-113809
|
||||
iblockdata.b(this, blockposition2, this.random);
|
||||
+ iblockdata.getBlock().randomTick = false; // Paper - fix MC-113809
|
||||
}
|
||||
|
||||
Fluid fluid = iblockdata.getFluid();
|
||||
|
||||
- if (fluid.h()) {
|
||||
+ if (fluid.h() && (!purpurConfig.fluidTickEvent || new net.pl3x.purpur.event.block.FluidTickEvent(getWorld(), blockposition2.x, blockposition2.y, blockposition2.z, true).callEvent())) { // Purpur
|
||||
fluid.b(this, blockposition2, this.random);
|
||||
}
|
||||
|
||||
@@ -675,6 +677,7 @@ public class WorldServer extends World {
|
||||
Fluid fluid = this.getFluid(nextticklistentry.a);
|
||||
|
||||
if (fluid.getType() == nextticklistentry.b()) {
|
||||
+ if (purpurConfig.fluidTickEvent && !new net.pl3x.purpur.event.block.FluidTickEvent(getWorld(), nextticklistentry.a.x, nextticklistentry.a.y, nextticklistentry.a.z).callEvent()) return; // Purpur
|
||||
fluid.a((World) this, nextticklistentry.a);
|
||||
}
|
||||
|
||||
@@ -684,6 +687,7 @@ public class WorldServer extends World {
|
||||
IBlockData iblockdata = this.getType(nextticklistentry.a);
|
||||
|
||||
if (iblockdata.getBlock() == nextticklistentry.b()) {
|
||||
+ if (purpurConfig.blockTickEvent && !new net.pl3x.purpur.event.block.BlockTickEvent(getWorld(), nextticklistentry.a.x, nextticklistentry.a.y, nextticklistentry.a.z).callEvent()) return; // Purpur
|
||||
iblockdata.getBlock().randomTick = true; // Paper - fix MC-113809
|
||||
iblockdata.a(this, nextticklistentry.a, this.random);
|
||||
iblockdata.getBlock().randomTick = false; // Paper - fix MC-113809
|
||||
diff --git a/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java b/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
|
||||
index f687444604..3ad3415c4a 100644
|
||||
--- a/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
|
||||
+++ b/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
|
||||
@@ -62,6 +62,13 @@ public class PurpurWorldConfig {
|
||||
return config.getString("world-settings." + worldName + "." + path, config.getString("world-settings.default." + path));
|
||||
}
|
||||
|
||||
+ public boolean blockTickEvent = false;
|
||||
+ public boolean fluidTickEvent = false;
|
||||
+ private void tickEvents() {
|
||||
+ blockTickEvent = getBoolean("block-tick-events", false);
|
||||
+ fluidTickEvent = getBoolean("fluid-tick-events", false);
|
||||
+ }
|
||||
+
|
||||
public boolean editableSigns = false;
|
||||
private void editableSigns() {
|
||||
editableSigns = getBoolean("editable-signs", editableSigns);
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
|
||||
index a974391025..05389f5bbe 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
|
||||
@@ -2384,6 +2384,24 @@ public class CraftWorld implements World {
|
||||
return persistentRaid.raids.values().stream().map(CraftRaid::new).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
+ // Purpur start
|
||||
+ public boolean isBlockTickEventEnabled() {
|
||||
+ return getHandle().purpurConfig.blockTickEvent;
|
||||
+ }
|
||||
+
|
||||
+ public void setBlockTickEventEnabled(boolean enabled) {
|
||||
+ getHandle().purpurConfig.blockTickEvent = enabled;
|
||||
+ }
|
||||
+
|
||||
+ public boolean isFluidTickEventEnabled() {
|
||||
+ return getHandle().purpurConfig.fluidTickEvent;
|
||||
+ }
|
||||
+
|
||||
+ public void setFluidTickEventEnabled(boolean enabled) {
|
||||
+ getHandle().purpurConfig.fluidTickEvent = enabled;
|
||||
+ }
|
||||
+ // Purpur end
|
||||
+
|
||||
// Paper start
|
||||
@Override
|
||||
public CompletableFuture<Chunk> getChunkAtAsync(int x, int z, boolean gen) {
|
||||
--
|
||||
2.24.0.rc1
|
||||
|
||||
Reference in New Issue
Block a user