2017-09-18 13:04:01 +02:00
|
|
|
From 64683f371daad0082a825007f7f531cc5c55d029 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
|
2017-07-28 15:45:16 +02:00
|
|
|
index adc810720..e706efff5 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
|
2017-03-25 04:18:58 +01:00
|
|
|
@@ -268,4 +268,9 @@ public class PaperWorldConfig {
|
2016-11-17 03:23:38 +01:00
|
|
|
private void skeleHorseSpawnChance() {
|
|
|
|
skeleHorseSpawnChance = getDouble("skeleton-horse-thunder-spawn-chance", 0.01D); // -1.0D represents a "vanilla" state
|
2016-03-29 01:57:13 +02: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
|
2017-09-18 13:04:01 +02:00
|
|
|
index e93c45cfc..f079d62e7 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
|
2017-08-03 16:36:06 +02:00
|
|
|
@@ -582,7 +582,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
|
2017-09-18 13:04:01 +02:00
|
|
|
index 72dc20087..f2ddc22dd 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
|
2017-09-18 13:04:01 +02:00
|
|
|
@@ -35,6 +35,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;
|
2017-06-11 19:03:07 +02:00
|
|
|
@@ -774,6 +775,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 {
|
2016-04-06 05:20:46 +02:00
|
|
|
+ stopPhysicsEvent = !paperConfig.firePhysicsEventForRedstone && (iblockdata.getBlock() instanceof BlockDiodeAbstract || iblockdata.getBlock() instanceof BlockRedstoneTorch); // Paper
|
2016-03-29 01:57:13 +02:00
|
|
|
iblockdata.getBlock().b((World) this, nextticklistentry.a, iblockdata, this.random);
|
|
|
|
} catch (Throwable throwable) {
|
|
|
|
CrashReport crashreport = CrashReport.a(throwable, "Exception while ticking a block");
|
2017-06-11 19:03:07 +02:00
|
|
|
@@ -781,7 +783,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 {
|
|
|
|
--
|
2017-09-18 13:04:01 +02:00
|
|
|
2.14.1
|
2016-03-29 01:57:13 +02:00
|
|
|
|