2016-04-02 04:08:40 +02:00
|
|
|
From 2c031d019c95d2361b3a1cff4e12ace56697ff9a Mon Sep 17 00:00:00 2001
|
2016-03-29 01:57:13 +02: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
|
2016-03-31 05:55:46 +02:00
|
|
|
index 55b211e..d6b8f72 100644
|
2016-03-29 01:57:13 +02:00
|
|
|
--- a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
|
|
|
|
+++ b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
|
2016-03-31 05:55:46 +02:00
|
|
|
@@ -296,4 +296,9 @@ public class PaperWorldConfig {
|
2016-03-29 01:57:13 +02:00
|
|
|
private void skeleHorseSpawnChance() {
|
|
|
|
skeleHorseSpawnChance = getDouble("skeleton-horse-thunder-spawn-chance", -1.0D); // -1.0D represents a "vanilla" state
|
|
|
|
}
|
|
|
|
+
|
|
|
|
+ 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
|
2016-04-01 06:35:44 +02:00
|
|
|
index 1a9a847..c6463b2 100644
|
2016-03-29 01:57:13 +02:00
|
|
|
--- a/src/main/java/net/minecraft/server/World.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/World.java
|
2016-04-01 06:35:44 +02:00
|
|
|
@@ -568,7 +568,7 @@ public abstract class World implements IBlockAccess {
|
2016-03-29 01:57:13 +02:00
|
|
|
try {
|
|
|
|
// CraftBukkit start
|
|
|
|
CraftWorld world = ((WorldServer) this).getWorld();
|
|
|
|
- if (world != null) {
|
|
|
|
+ if (world != null && !((WorldServer)this).stopPhysicsEvent) { // Paper
|
|
|
|
BlockPhysicsEvent event = new BlockPhysicsEvent(world.getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ()), CraftMagicNumbers.getId(block));
|
|
|
|
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
|
2016-04-01 06:35:44 +02:00
|
|
|
index 0acce3e..c8e536c 100644
|
2016-03-29 01:57:13 +02:00
|
|
|
--- a/src/main/java/net/minecraft/server/WorldServer.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/WorldServer.java
|
2016-03-31 02:50:23 +02:00
|
|
|
@@ -32,6 +32,7 @@ import org.bukkit.event.weather.LightningStrikeEvent;
|
2016-03-29 01:57:13 +02: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;
|
2016-04-01 06:35:44 +02:00
|
|
|
@@ -741,6 +742,7 @@ public class WorldServer extends World implements IAsyncTaskHandler {
|
2016-03-29 01:57:13 +02:00
|
|
|
|
|
|
|
if (iblockdata.getMaterial() != Material.AIR && Block.a(iblockdata.getBlock(), nextticklistentry.a())) {
|
|
|
|
try {
|
|
|
|
+ stopPhysicsEvent = !paperConfig.firePhysicsEventForRedstone && iblockdata.getBlock() instanceof BlockDiodeAbstract; // Paper
|
|
|
|
iblockdata.getBlock().b((World) this, nextticklistentry.a, iblockdata, this.random);
|
|
|
|
} catch (Throwable throwable) {
|
|
|
|
CrashReport crashreport = CrashReport.a(throwable, "Exception while ticking a block");
|
2016-04-01 06:35:44 +02:00
|
|
|
@@ -748,7 +750,7 @@ public class WorldServer extends World implements IAsyncTaskHandler {
|
2016-03-29 01:57:13 +02:00
|
|
|
|
|
|
|
CrashReportSystemDetails.a(crashreportsystemdetails, nextticklistentry.a, iblockdata);
|
|
|
|
throw new ReportedException(crashreport);
|
|
|
|
- }
|
|
|
|
+ } finally { stopPhysicsEvent = false; } // Paper
|
|
|
|
}
|
|
|
|
timing.stopTiming(); // Paper
|
|
|
|
} else {
|
|
|
|
--
|
2016-04-01 06:35:44 +02:00
|
|
|
2.8.0
|
2016-03-29 01:57:13 +02:00
|
|
|
|