mirror of
https://github.com/PurpurMC/Purpur.git
synced 2026-02-17 16:37:43 +01:00
Upstream has released updates that appears to apply and compile correctly Paper Changes: 01b965e0 Fix getChunkAtIfCachedImmediately (#2915) 0a897d6e Rebuild patches 5792c862 Updated Upstream (Bukkit/CraftBukkit/Spigot) c9eebbb8 Fix Player#applyMending NPE (#2917) d16a5d88 Performance patches prerequisite (#2802)
100 lines
4.9 KiB
Diff
100 lines
4.9 KiB
Diff
From 3fe2fbbd1250a9665a0cf53d27b1731fe9d2aa28 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 | 6 ++++--
|
|
.../net/pl3x/purpur/PurpurWorldConfig.java | 7 +++++++
|
|
.../org/bukkit/craftbukkit/CraftWorld.java | 18 ++++++++++++++++++
|
|
3 files changed, 29 insertions(+), 2 deletions(-)
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/WorldServer.java b/src/main/java/net/minecraft/server/WorldServer.java
|
|
index 04685efc52..0a41997edd 100644
|
|
--- a/src/main/java/net/minecraft/server/WorldServer.java
|
|
+++ b/src/main/java/net/minecraft/server/WorldServer.java
|
|
@@ -604,7 +604,7 @@ 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
|
|
@@ -612,7 +612,7 @@ public class WorldServer extends World {
|
|
|
|
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);
|
|
}
|
|
|
|
@@ -701,6 +701,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);
|
|
}
|
|
|
|
@@ -710,6 +711,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.a(this, nextticklistentry.a, this.random);
|
|
}
|
|
|
|
diff --git a/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java b/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
|
|
index b2c62de053..b82fc8d19f 100644
|
|
--- a/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
|
|
+++ b/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
|
|
@@ -58,6 +58,13 @@ public class PurpurWorldConfig {
|
|
return PurpurConfig.config.getString("world-settings." + worldName + "." + path, PurpurConfig.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 7654519c9e..65cf1e7016 100644
|
|
--- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
|
|
@@ -2396,6 +2396,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
|
|
|