2018-12-17 05:18:06 +00:00
|
|
|
From 370c7181c7102186b298dd9d2427d8e7280bdd78 Mon Sep 17 00:00:00 2001
|
2016-03-28 23:57:13 +00:00
|
|
|
From: Aikar <aikar@aikar.co>
|
|
|
|
Date: Mon, 28 Mar 2016 19:55:45 -0400
|
|
|
|
Subject: [PATCH] Option to disable BlockPhysicsEvent for Redstone
|
|
|
|
|
|
|
|
Not sure of any reason a plugin would need to act on a Physics event
|
|
|
|
for redstone. There is a BlockRedstoneEvent that plugins can also use
|
|
|
|
for accessing redstone activity.
|
|
|
|
|
|
|
|
Defaulting this to false will provide substantial performance improvement
|
|
|
|
by saving millions of event calls on redstone heavy servers.
|
|
|
|
|
|
|
|
diff --git a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
|
2018-12-17 05:18:06 +00:00
|
|
|
index 0faef7cf2..deb4ec254 100644
|
2016-03-28 23:57:13 +00:00
|
|
|
--- a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
|
|
|
|
+++ b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
|
2018-09-26 04:57:59 +00:00
|
|
|
@@ -228,4 +228,9 @@ public class PaperWorldConfig {
|
2018-08-26 18:11:49 +00:00
|
|
|
skeleHorseSpawnChance = 0.01D; // Vanilla value
|
|
|
|
}
|
2016-03-28 23:57:13 +00:00
|
|
|
}
|
|
|
|
+
|
|
|
|
+ public boolean firePhysicsEventForRedstone = false;
|
|
|
|
+ private void firePhysicsEventForRedstone() {
|
|
|
|
+ firePhysicsEventForRedstone = getBoolean("fire-physics-event-for-redstone", firePhysicsEventForRedstone);
|
|
|
|
+ }
|
|
|
|
}
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/World.java b/src/main/java/net/minecraft/server/World.java
|
2018-12-17 05:18:06 +00:00
|
|
|
index e109016b7..e614ac33a 100644
|
2016-03-28 23:57:13 +00:00
|
|
|
--- a/src/main/java/net/minecraft/server/World.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/World.java
|
2018-09-18 01:50:02 +00:00
|
|
|
@@ -620,7 +620,7 @@ public abstract class World implements IEntityAccess, GeneratorAccess, IIBlockAc
|
2016-03-28 23:57:13 +00:00
|
|
|
try {
|
|
|
|
// CraftBukkit start
|
|
|
|
CraftWorld world = ((WorldServer) this).getWorld();
|
|
|
|
- if (world != null) {
|
|
|
|
+ if (world != null && !((WorldServer)this).stopPhysicsEvent) { // Paper
|
2018-07-15 01:53:17 +00:00
|
|
|
BlockPhysicsEvent event = new BlockPhysicsEvent(world.getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ()), CraftBlockData.fromData(iblockdata));
|
2016-03-28 23:57:13 +00:00
|
|
|
this.getServer().getPluginManager().callEvent(event);
|
|
|
|
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/WorldServer.java b/src/main/java/net/minecraft/server/WorldServer.java
|
2018-12-17 05:18:06 +00:00
|
|
|
index e98ba11dc..b5983957b 100644
|
2016-03-28 23:57:13 +00:00
|
|
|
--- a/src/main/java/net/minecraft/server/WorldServer.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/WorldServer.java
|
2018-08-26 18:11:49 +00:00
|
|
|
@@ -37,6 +37,7 @@ import org.bukkit.event.weather.LightningStrikeEvent;
|
2016-03-28 23:57:13 +00:00
|
|
|
public class WorldServer extends World implements IAsyncTaskHandler {
|
|
|
|
|
|
|
|
private static final Logger a = LogManager.getLogger();
|
|
|
|
+ boolean stopPhysicsEvent = false; // Paper
|
|
|
|
private final MinecraftServer server;
|
|
|
|
public EntityTracker tracker;
|
|
|
|
private final PlayerChunkMap manager;
|
2018-12-17 05:18:06 +00:00
|
|
|
@@ -677,6 +678,7 @@ public class WorldServer extends World implements IAsyncTaskHandler {
|
2018-07-15 01:53:17 +00:00
|
|
|
IBlockData iblockdata = this.getType(nextticklistentry.a);
|
2016-03-28 23:57:13 +00:00
|
|
|
|
2018-07-15 01:53:17 +00:00
|
|
|
if (iblockdata.getBlock() == nextticklistentry.a()) {
|
|
|
|
+ stopPhysicsEvent = !paperConfig.firePhysicsEventForRedstone && (iblockdata.getBlock() instanceof BlockDiodeAbstract || iblockdata.getBlock() instanceof BlockRedstoneTorch); // Paper
|
|
|
|
iblockdata.a((World) this, nextticklistentry.a, this.random);
|
|
|
|
}
|
2016-03-28 23:57:13 +00:00
|
|
|
|
|
|
|
--
|
2018-12-17 05:18:06 +00:00
|
|
|
2.20.0
|
2016-03-28 23:57:13 +00:00
|
|
|
|