From db4ecc9d9d49c8ecc536fbeaa29fe9b25291c21c Mon Sep 17 00:00:00 2001 From: Aikar Date: Thu, 12 Jul 2018 16:42:56 -0400 Subject: [PATCH] Multitude of changes to attempt to fix #1199 --- ...to-current-Chunk-for-Entity-and-Bloc.patch | 23 +++++++++------- ...ck-and-tnt-entities-at-the-specified.patch | 6 ++--- .../0025-Entity-Origin-API.patch | 6 ++--- ...oreboards-for-non-players-by-default.patch | 6 ++--- .../0086-Don-t-teleport-dead-entities.patch | 6 ++--- ...nilla-per-world-scoreboard-coloring-.patch | 6 ++--- ...2-Vehicle-Event-Cancellation-Changes.patch | 8 +++--- ...6-Optional-TNT-doesn-t-move-in-water.patch | 6 ++--- .../0188-Activation-Range-Improvements.patch | 26 ++++++++++++++----- ...llow-entities-to-ride-themselves-572.patch | 6 ++--- ...emove-entities-on-dimension-teleport.patch | 6 ++--- ...ups-for-Entity-TileEntity-Current-Ch.patch | 10 +++---- 12 files changed, 67 insertions(+), 48 deletions(-) diff --git a/Spigot-Server-Patches/0006-Store-reference-to-current-Chunk-for-Entity-and-Bloc.patch b/Spigot-Server-Patches/0006-Store-reference-to-current-Chunk-for-Entity-and-Bloc.patch index 5f8db9ad02..03a225440e 100644 --- a/Spigot-Server-Patches/0006-Store-reference-to-current-Chunk-for-Entity-and-Bloc.patch +++ b/Spigot-Server-Patches/0006-Store-reference-to-current-Chunk-for-Entity-and-Bloc.patch @@ -1,4 +1,4 @@ -From 3fbe4af7bcafee200f8492e070b8ea2d98a00181 Mon Sep 17 00:00:00 2001 +From 12051b946e1a2fbe7faba1a7011db4dd05b3e727 Mon Sep 17 00:00:00 2001 From: Aikar Date: Wed, 4 Jul 2018 02:10:36 -0400 Subject: [PATCH] Store reference to current Chunk for Entity and Block @@ -81,25 +81,30 @@ index 4bbebb25a..68008fe6a 100644 } diff --git a/src/main/java/net/minecraft/server/Entity.java b/src/main/java/net/minecraft/server/Entity.java -index 3a8902bf1..f7750a05c 100644 +index 3a8902bf1..f140d5e28 100644 --- a/src/main/java/net/minecraft/server/Entity.java +++ b/src/main/java/net/minecraft/server/Entity.java -@@ -1703,6 +1703,19 @@ public abstract class Entity implements ICommandListener, KeyedObject { // Paper +@@ -1703,6 +1703,24 @@ public abstract class Entity implements ICommandListener, KeyedObject { // Paper } // Paper start + private java.lang.ref.WeakReference currentChunk = null; + public Chunk getCurrentChunk() { + final Chunk chunk = currentChunk != null ? currentChunk.get() : null; -+ final int cx = getChunkX(); -+ final int cz = getChunkZ(); -+ if (chunk != null && chunk.isLoaded() && chunk.locX == cx && chunk.locZ == cz) { -+ return chunk; -+ } -+ return world.getChunkIfLoaded(cx, cz); ++ return chunk != null && chunk.isLoaded() ? chunk : null; + } + public void setCurrentChunk(Chunk chunk) { + this.currentChunk = chunk != null ? new java.lang.ref.WeakReference<>(chunk) : null; ++ } ++ public Chunk getCurrentChunkAt(int x, int z) { ++ if (getChunkX() == x && getChunkZ() == z) { ++ return getCurrentChunk(); ++ } else { ++ return world.getChunkIfLoaded(x, z); ++ } ++ } ++ public Chunk getChunkAtLocation() { ++ return getCurrentChunkAt((int)Math.floor(locX) >> 4, (int)Math.floor(locZ) >> 4); + } public final MinecraftKey entityKey = EntityTypes.getKey(this); public final String entityKeyString = entityKey != null ? entityKey.toString() : null; diff --git a/Spigot-Server-Patches/0016-Drop-falling-block-and-tnt-entities-at-the-specified.patch b/Spigot-Server-Patches/0016-Drop-falling-block-and-tnt-entities-at-the-specified.patch index 0b2892ce22..d3d25e0b88 100644 --- a/Spigot-Server-Patches/0016-Drop-falling-block-and-tnt-entities-at-the-specified.patch +++ b/Spigot-Server-Patches/0016-Drop-falling-block-and-tnt-entities-at-the-specified.patch @@ -1,4 +1,4 @@ -From 63c7daaef2f42d527197a8df4878ed44813ad87f Mon Sep 17 00:00:00 2001 +From 16ff74ebe1e80730259a60e6803bad44733cb728 Mon Sep 17 00:00:00 2001 From: Byteflux Date: Tue, 1 Mar 2016 14:14:15 -0600 Subject: [PATCH] Drop falling block and tnt entities at the specified height @@ -24,10 +24,10 @@ index 0094d1a87..4da846719 100644 + } } diff --git a/src/main/java/net/minecraft/server/Entity.java b/src/main/java/net/minecraft/server/Entity.java -index 9d7fe97ce..c7513622e 100644 +index 05aad7dd0..bee8e632a 100644 --- a/src/main/java/net/minecraft/server/Entity.java +++ b/src/main/java/net/minecraft/server/Entity.java -@@ -1775,6 +1775,7 @@ public abstract class Entity implements ICommandListener, KeyedObject { // Paper +@@ -1780,6 +1780,7 @@ public abstract class Entity implements ICommandListener, KeyedObject { // Paper return this.a(new ItemStack(item, i, 0), f); } diff --git a/Spigot-Server-Patches/0025-Entity-Origin-API.patch b/Spigot-Server-Patches/0025-Entity-Origin-API.patch index 334c6da527..301af522fd 100644 --- a/Spigot-Server-Patches/0025-Entity-Origin-API.patch +++ b/Spigot-Server-Patches/0025-Entity-Origin-API.patch @@ -1,11 +1,11 @@ -From 6254651ac3eeee042d9b4f6b1aabca609f242122 Mon Sep 17 00:00:00 2001 +From 5ad883e113f3989db0ce7fdb198f9b1990955142 Mon Sep 17 00:00:00 2001 From: Byteflux Date: Tue, 1 Mar 2016 23:45:08 -0600 Subject: [PATCH] Entity Origin API diff --git a/src/main/java/net/minecraft/server/Entity.java b/src/main/java/net/minecraft/server/Entity.java -index c7513622e..72efe282b 100644 +index bee8e632a..7f66f7579 100644 --- a/src/main/java/net/minecraft/server/Entity.java +++ b/src/main/java/net/minecraft/server/Entity.java @@ -149,6 +149,7 @@ public abstract class Entity implements ICommandListener, KeyedObject { // Paper @@ -42,7 +42,7 @@ index c7513622e..72efe282b 100644 } catch (Throwable throwable) { CrashReport crashreport = CrashReport.a(throwable, "Loading entity NBT"); CrashReportSystemDetails crashreportsystemdetails = crashreport.a("Entity being loaded"); -@@ -1737,6 +1750,7 @@ public abstract class Entity implements ICommandListener, KeyedObject { // Paper +@@ -1742,6 +1755,7 @@ public abstract class Entity implements ICommandListener, KeyedObject { // Paper protected abstract void b(NBTTagCompound nbttagcompound); diff --git a/Spigot-Server-Patches/0065-Disable-Scoreboards-for-non-players-by-default.patch b/Spigot-Server-Patches/0065-Disable-Scoreboards-for-non-players-by-default.patch index 5eaa15950e..f6def8b450 100644 --- a/Spigot-Server-Patches/0065-Disable-Scoreboards-for-non-players-by-default.patch +++ b/Spigot-Server-Patches/0065-Disable-Scoreboards-for-non-players-by-default.patch @@ -1,4 +1,4 @@ -From 427ed2e030aab48f93a55b805946fa07fba593ae Mon Sep 17 00:00:00 2001 +From bb523c50d224b2ed674f592b66fb3bf6195269dc Mon Sep 17 00:00:00 2001 From: Aikar Date: Tue, 8 Mar 2016 23:25:45 -0500 Subject: [PATCH] Disable Scoreboards for non players by default @@ -37,10 +37,10 @@ index ec9a87239..b08274d93 100644 if (scoreboard.addPlayerToTeam(s2, s)) { diff --git a/src/main/java/net/minecraft/server/Entity.java b/src/main/java/net/minecraft/server/Entity.java -index a4c5b780c..c620667e0 100644 +index 158ee9e37..0e761997c 100644 --- a/src/main/java/net/minecraft/server/Entity.java +++ b/src/main/java/net/minecraft/server/Entity.java -@@ -2104,6 +2104,7 @@ public abstract class Entity implements ICommandListener, KeyedObject { // Paper +@@ -2109,6 +2109,7 @@ public abstract class Entity implements ICommandListener, KeyedObject { // Paper @Nullable public ScoreboardTeamBase aY() { diff --git a/Spigot-Server-Patches/0086-Don-t-teleport-dead-entities.patch b/Spigot-Server-Patches/0086-Don-t-teleport-dead-entities.patch index 797c20e6ef..4d9345f2c4 100644 --- a/Spigot-Server-Patches/0086-Don-t-teleport-dead-entities.patch +++ b/Spigot-Server-Patches/0086-Don-t-teleport-dead-entities.patch @@ -1,4 +1,4 @@ -From 9a662f1a253d481005f4318fd6db8deda65a553b Mon Sep 17 00:00:00 2001 +From 615a75652424409cc5f097ea1cb71ce13ec4fb86 Mon Sep 17 00:00:00 2001 From: Aikar Date: Tue, 22 Mar 2016 00:55:23 -0400 Subject: [PATCH] Don't teleport dead entities @@ -7,10 +7,10 @@ Had some issue with this in past, and this is the vanilla logic. Potentially an old CB change that's no longer needed. diff --git a/src/main/java/net/minecraft/server/Entity.java b/src/main/java/net/minecraft/server/Entity.java -index 843cb3a61..89ea217b9 100644 +index b3eea4337..13035574e 100644 --- a/src/main/java/net/minecraft/server/Entity.java +++ b/src/main/java/net/minecraft/server/Entity.java -@@ -2380,7 +2380,7 @@ public abstract class Entity implements ICommandListener, KeyedObject { // Paper +@@ -2385,7 +2385,7 @@ public abstract class Entity implements ICommandListener, KeyedObject { // Paper } public Entity teleportTo(Location exit, boolean portal) { diff --git a/Spigot-Server-Patches/0109-Option-to-use-vanilla-per-world-scoreboard-coloring-.patch b/Spigot-Server-Patches/0109-Option-to-use-vanilla-per-world-scoreboard-coloring-.patch index a8a28eb11c..15743d77de 100644 --- a/Spigot-Server-Patches/0109-Option-to-use-vanilla-per-world-scoreboard-coloring-.patch +++ b/Spigot-Server-Patches/0109-Option-to-use-vanilla-per-world-scoreboard-coloring-.patch @@ -1,4 +1,4 @@ -From e90027b47608f6153ad3d0321ec2799077d3b0b7 Mon Sep 17 00:00:00 2001 +From 6b6bfc5c1d44feb7485d3e330c02983211794352 Mon Sep 17 00:00:00 2001 From: Zach Brown Date: Wed, 6 Apr 2016 01:04:23 -0500 Subject: [PATCH] Option to use vanilla per-world scoreboard coloring on names @@ -19,10 +19,10 @@ index abc1aabdd..6ea608ba9 100644 + } } diff --git a/src/main/java/net/minecraft/server/Entity.java b/src/main/java/net/minecraft/server/Entity.java -index 89ea217b9..437ae2fa3 100644 +index 13035574e..8f47ffd47 100644 --- a/src/main/java/net/minecraft/server/Entity.java +++ b/src/main/java/net/minecraft/server/Entity.java -@@ -2103,6 +2103,7 @@ public abstract class Entity implements ICommandListener, KeyedObject { // Paper +@@ -2108,6 +2108,7 @@ public abstract class Entity implements ICommandListener, KeyedObject { // Paper return this.getFlag(5); } diff --git a/Spigot-Server-Patches/0122-Vehicle-Event-Cancellation-Changes.patch b/Spigot-Server-Patches/0122-Vehicle-Event-Cancellation-Changes.patch index 2bba1b8400..90f76c8b4c 100644 --- a/Spigot-Server-Patches/0122-Vehicle-Event-Cancellation-Changes.patch +++ b/Spigot-Server-Patches/0122-Vehicle-Event-Cancellation-Changes.patch @@ -1,11 +1,11 @@ -From 4b24d8aeee60f407bd9917d39f49188526338a26 Mon Sep 17 00:00:00 2001 +From 577bace6c1eef300fd2970de0a10a377afe6e1ac Mon Sep 17 00:00:00 2001 From: Zach Brown Date: Fri, 22 Apr 2016 18:20:05 -0500 Subject: [PATCH] Vehicle Event Cancellation Changes diff --git a/src/main/java/net/minecraft/server/Entity.java b/src/main/java/net/minecraft/server/Entity.java -index 437ae2fa3..17ec10c26 100644 +index 8f47ffd47..41fca4118 100644 --- a/src/main/java/net/minecraft/server/Entity.java +++ b/src/main/java/net/minecraft/server/Entity.java @@ -70,7 +70,7 @@ public abstract class Entity implements ICommandListener, KeyedObject { // Paper @@ -17,7 +17,7 @@ index 437ae2fa3..17ec10c26 100644 public boolean attachedToPlayer; public World world; public double lastX; -@@ -1985,6 +1985,7 @@ public abstract class Entity implements ICommandListener, KeyedObject { // Paper +@@ -1990,6 +1990,7 @@ public abstract class Entity implements ICommandListener, KeyedObject { // Paper throw new IllegalStateException("Use x.stopRiding(y), not y.removePassenger(x)"); } else { // CraftBukkit start @@ -25,7 +25,7 @@ index 437ae2fa3..17ec10c26 100644 CraftEntity craft = (CraftEntity) entity.getBukkitEntity().getVehicle(); Entity orig = craft == null ? null : craft.getHandle(); if (getBukkitEntity() instanceof Vehicle && entity.getBukkitEntity() instanceof LivingEntity) { -@@ -2000,7 +2001,13 @@ public abstract class Entity implements ICommandListener, KeyedObject { // Paper +@@ -2005,7 +2006,13 @@ public abstract class Entity implements ICommandListener, KeyedObject { // Paper } } // CraftBukkit end diff --git a/Spigot-Server-Patches/0136-Optional-TNT-doesn-t-move-in-water.patch b/Spigot-Server-Patches/0136-Optional-TNT-doesn-t-move-in-water.patch index 3f90303e3c..3ea9433a7f 100644 --- a/Spigot-Server-Patches/0136-Optional-TNT-doesn-t-move-in-water.patch +++ b/Spigot-Server-Patches/0136-Optional-TNT-doesn-t-move-in-water.patch @@ -1,4 +1,4 @@ -From 1975e598adb294c806ff4b0699ba67178cbce3ad Mon Sep 17 00:00:00 2001 +From 03dc46a921790b6f0fabdb28969547a4af7e7954 Mon Sep 17 00:00:00 2001 From: Zach Brown Date: Sun, 22 May 2016 20:20:55 -0500 Subject: [PATCH] Optional TNT doesn't move in water @@ -32,7 +32,7 @@ index 067cb233e..06acdaaf0 100644 + } } diff --git a/src/main/java/net/minecraft/server/Entity.java b/src/main/java/net/minecraft/server/Entity.java -index e860e9c6a..a52cd0728 100644 +index b6b4b581b..e77a3b2ab 100644 --- a/src/main/java/net/minecraft/server/Entity.java +++ b/src/main/java/net/minecraft/server/Entity.java @@ -1114,6 +1114,11 @@ public abstract class Entity implements ICommandListener, KeyedObject { // Paper @@ -47,7 +47,7 @@ index e860e9c6a..a52cd0728 100644 if (this.bJ() instanceof EntityBoat) { this.inWater = false; } else if (this.world.a(this.getBoundingBox().grow(0.0D, -0.4000000059604645D, 0.0D).shrink(0.001D), Material.WATER, this)) { -@@ -2568,6 +2573,11 @@ public abstract class Entity implements ICommandListener, KeyedObject { // Paper +@@ -2573,6 +2578,11 @@ public abstract class Entity implements ICommandListener, KeyedObject { // Paper } public boolean bo() { diff --git a/Spigot-Server-Patches/0188-Activation-Range-Improvements.patch b/Spigot-Server-Patches/0188-Activation-Range-Improvements.patch index 93898fb291..0615e4f2ee 100644 --- a/Spigot-Server-Patches/0188-Activation-Range-Improvements.patch +++ b/Spigot-Server-Patches/0188-Activation-Range-Improvements.patch @@ -1,4 +1,4 @@ -From 68fbc7785fd609e258aa6084639d6206a3cef286 Mon Sep 17 00:00:00 2001 +From 3da653ac5594ecd2407621dc2d303c63816df5a4 Mon Sep 17 00:00:00 2001 From: Aikar Date: Tue, 27 Dec 2016 22:38:06 -0500 Subject: [PATCH] Activation Range Improvements @@ -96,7 +96,7 @@ index e5b5e9887..e3781f3a8 100644 } } diff --git a/src/main/java/org/spigotmc/ActivationRange.java b/src/main/java/org/spigotmc/ActivationRange.java -index b79bf70f0..b1536e1c5 100644 +index b79bf70f0..33ae73890 100644 --- a/src/main/java/org/spigotmc/ActivationRange.java +++ b/src/main/java/org/spigotmc/ActivationRange.java @@ -20,6 +20,7 @@ import net.minecraft.server.EntityFireball; @@ -140,12 +140,26 @@ index b79bf70f0..b1536e1c5 100644 if ( entity instanceof EntityAnimal ) { EntityAnimal animal = (EntityAnimal) entity; -@@ -278,7 +290,7 @@ public class ActivationRange - int x = MathHelper.floor( entity.locX ); - int z = MathHelper.floor( entity.locZ ); +@@ -251,7 +263,7 @@ public class ActivationRange + { + // Never safe to skip fireworks or entities not yet added to chunk + // PAIL: inChunk - boolean under datawatchers +- if ( !entity.aa || entity instanceof EntityFireworks ) { ++ if ( !entity.isAddedToChunk() || entity instanceof EntityFireworks ) { // Paper (use obf helper) + return true; + } + +@@ -275,10 +287,10 @@ public class ActivationRange + { + isActive = false; + } +- int x = MathHelper.floor( entity.locX ); +- int z = MathHelper.floor( entity.locZ ); ++ //int x = MathHelper.floor( entity.locX ); // Paper ++ //int z = MathHelper.floor( entity.locZ ); // Paper // Make sure not on edge of unloaded chunk - Chunk chunk = entity.world.getChunkIfLoaded( x >> 4, z >> 4 ); -+ Chunk chunk = entity.getCurrentChunk(); // Paper ++ Chunk chunk = entity.getChunkAtLocation(); // Paper if ( isActive && !( chunk != null && chunk.areNeighborsLoaded( 1 ) ) ) { isActive = false; diff --git a/Spigot-Server-Patches/0195-Don-t-allow-entities-to-ride-themselves-572.patch b/Spigot-Server-Patches/0195-Don-t-allow-entities-to-ride-themselves-572.patch index e80fa5ea16..aa25bf0ecd 100644 --- a/Spigot-Server-Patches/0195-Don-t-allow-entities-to-ride-themselves-572.patch +++ b/Spigot-Server-Patches/0195-Don-t-allow-entities-to-ride-themselves-572.patch @@ -1,14 +1,14 @@ -From 3fa934b4f3d9456a4d9aa78bd013f5d0232dd929 Mon Sep 17 00:00:00 2001 +From 06dc5de21c577e7757f5e38cbc88062fb62158c9 Mon Sep 17 00:00:00 2001 From: Alfie Cleveland Date: Sun, 8 Jan 2017 04:31:36 +0000 Subject: [PATCH] Don't allow entities to ride themselves - #572 diff --git a/src/main/java/net/minecraft/server/Entity.java b/src/main/java/net/minecraft/server/Entity.java -index 64e566d3a..f75d57c30 100644 +index e4b45f2c7..8fbef57cc 100644 --- a/src/main/java/net/minecraft/server/Entity.java +++ b/src/main/java/net/minecraft/server/Entity.java -@@ -1962,6 +1962,7 @@ public abstract class Entity implements ICommandListener, KeyedObject { // Paper +@@ -1967,6 +1967,7 @@ public abstract class Entity implements ICommandListener, KeyedObject { // Paper } protected void o(Entity entity) { diff --git a/Spigot-Server-Patches/0307-Properly-remove-entities-on-dimension-teleport.patch b/Spigot-Server-Patches/0307-Properly-remove-entities-on-dimension-teleport.patch index db03fe1d4a..b0fadccf33 100644 --- a/Spigot-Server-Patches/0307-Properly-remove-entities-on-dimension-teleport.patch +++ b/Spigot-Server-Patches/0307-Properly-remove-entities-on-dimension-teleport.patch @@ -1,4 +1,4 @@ -From 24da81e684f7d7c01c3b5e6053899d60668157c1 Mon Sep 17 00:00:00 2001 +From 1fc278e5919f7644bd12ebb0eb81039c27faa37e Mon Sep 17 00:00:00 2001 From: Aikar Date: Sun, 10 Jun 2018 20:04:42 -0400 Subject: [PATCH] Properly remove entities on dimension teleport @@ -22,10 +22,10 @@ requirement, but plugins (such as my own) use this method to trigger a "reload" of the entity on the client. diff --git a/src/main/java/net/minecraft/server/Entity.java b/src/main/java/net/minecraft/server/Entity.java -index 9f2db9025..a96cdcbc6 100644 +index b61927c99..eff84f812 100644 --- a/src/main/java/net/minecraft/server/Entity.java +++ b/src/main/java/net/minecraft/server/Entity.java -@@ -2430,7 +2430,7 @@ public abstract class Entity implements ICommandListener, KeyedObject { // Paper +@@ -2435,7 +2435,7 @@ public abstract class Entity implements ICommandListener, KeyedObject { // Paper } // CraftBukkit end */ diff --git a/Spigot-Server-Patches/0326-Avoid-Chunk-Lookups-for-Entity-TileEntity-Current-Ch.patch b/Spigot-Server-Patches/0326-Avoid-Chunk-Lookups-for-Entity-TileEntity-Current-Ch.patch index 3b48db2a6b..1bf454c181 100644 --- a/Spigot-Server-Patches/0326-Avoid-Chunk-Lookups-for-Entity-TileEntity-Current-Ch.patch +++ b/Spigot-Server-Patches/0326-Avoid-Chunk-Lookups-for-Entity-TileEntity-Current-Ch.patch @@ -1,4 +1,4 @@ -From 2d1fee2dfb5ead97bc5af3ad7b86158993a65fdf Mon Sep 17 00:00:00 2001 +From 855c50b43725ac1167d2735d0d0b0b60de73499f Mon Sep 17 00:00:00 2001 From: Aikar Date: Wed, 4 Jul 2018 03:39:51 -0400 Subject: [PATCH] Avoid Chunk Lookups for Entity/TileEntity Current Chunk @@ -22,7 +22,7 @@ index 3e80825f7..4a94fd5a6 100644 this.a(entity, entity.ac); } diff --git a/src/main/java/net/minecraft/server/World.java b/src/main/java/net/minecraft/server/World.java -index c0816b9f8..33ac57e6b 100644 +index c0816b9f8..52adee880 100644 --- a/src/main/java/net/minecraft/server/World.java +++ b/src/main/java/net/minecraft/server/World.java @@ -1511,12 +1511,15 @@ public abstract class World implements IBlockAccess { @@ -37,7 +37,7 @@ index c0816b9f8..33ac57e6b 100644 this.getChunkAt(k, j).b(e); - } + }*/ -+ Chunk chunk = e.getCurrentChunk(); ++ Chunk chunk = e.isAddedToChunk() ? e.getCurrentChunk() : null; + if (chunk != null) chunk.removeEntity(e); } @@ -56,7 +56,7 @@ index c0816b9f8..33ac57e6b 100644 this.getChunkAt(j, l).b(entity); - } + }*/ -+ Chunk chunk = entity.getCurrentChunk(); ++ Chunk chunk = entity.isAddedToChunk() ? entity.getCurrentChunk() : null; + if (chunk != null) chunk.removeEntity(entity); + // Paper end @@ -86,5 +86,5 @@ index c0816b9f8..33ac57e6b 100644 } } -- -2.17.1 +2.18.0