mirror of
https://github.com/PurpurMC/Purpur.git
synced 2026-02-17 16:37:43 +01:00
96 lines
4.5 KiB
Diff
96 lines
4.5 KiB
Diff
From 215b5058ec04eb3901fa9edb3470c5febbe4216c Mon Sep 17 00:00:00 2001
|
|
From: William Blake Galbreath <blake.galbreath@gmail.com>
|
|
Date: Thu, 6 Jun 2019 23:23:52 -0500
|
|
Subject: [PATCH] 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 92aad060e..01b77528e 100644
|
|
--- a/src/main/java/net/minecraft/server/WorldServer.java
|
|
+++ b/src/main/java/net/minecraft/server/WorldServer.java
|
|
@@ -446,13 +446,13 @@ 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.b((World) this, blockposition2, this.random);
|
|
}
|
|
|
|
Fluid fluid = chunksection.b(blockposition2.getX() - j, blockposition2.getY() - j1, blockposition2.getZ() - k);
|
|
|
|
- if (fluid.g()) {
|
|
+ if (fluid.g() && (!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);
|
|
}
|
|
|
|
@@ -541,6 +541,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);
|
|
}
|
|
|
|
@@ -550,6 +551,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((World) 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 a649a4c35..92eeaca42 100644
|
|
--- a/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
|
|
+++ b/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
|
|
@@ -106,4 +106,11 @@ public class PurpurWorldConfig {
|
|
private void itemsCanBreakTurtleEggs() {
|
|
itemsCanBreakTurtleEggs = getBoolean("items-can-break-turtle-eggs", itemsCanBreakTurtleEggs);
|
|
}
|
|
+
|
|
+ public boolean blockTickEvent = true;
|
|
+ public boolean fluidTickEvent = true;
|
|
+ private void tickEvents() {
|
|
+ blockTickEvent = getBoolean("block-tick-events", blockTickEvent);
|
|
+ fluidTickEvent = getBoolean("fluid-tick-events", fluidTickEvent);
|
|
+ }
|
|
}
|
|
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
|
|
index 0c5379530..07f980158 100644
|
|
--- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
|
|
@@ -2157,6 +2157,24 @@ public class CraftWorld implements World {
|
|
}
|
|
// Paper end
|
|
|
|
+ // 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
|
|
+
|
|
// Spigot start
|
|
private final Spigot spigot = new Spigot()
|
|
{
|
|
--
|
|
2.20.1
|
|
|