mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-01 20:50:41 +01:00
SPIGOT-2726: Fix duplicate UUID check not always running
World.addEntity(Entity entity) calls addEntity(entity, SpawnReason.DEFAULT), which contains the code that was originally in addEntity (and some event code). However, WorldServer previously only had addEntity(Entity entity), so if addEntity(Entity entity, SpawnReason spawnreason) was called directly, the UUID check that's found in it (the call to 'i') is skipped. This happens, among other places, in ChunkRegionLoader.spawnEntity (which /summon uses). I fixed this by making WorldServer override the SpawnReason version, rather than the regular version. This is safe to do because the World version calls the SpawnReason version - it's not necessary to do the same thing in WorldServer.
This commit is contained in:
parent
b5fb9a1cd7
commit
e20928f7da
1 changed files with 50 additions and 33 deletions
|
@ -1,6 +1,6 @@
|
|||
--- a/net/minecraft/server/WorldServer.java
|
||||
+++ b/net/minecraft/server/WorldServer.java
|
||||
@@ -19,14 +19,25 @@
|
||||
@@ -19,14 +19,26 @@
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
|
@ -12,6 +12,7 @@
|
|||
+import org.bukkit.craftbukkit.util.HashTreeSet;
|
||||
+
|
||||
+import org.bukkit.event.block.BlockFormEvent;
|
||||
+import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason;
|
||||
+import org.bukkit.event.weather.LightningStrikeEvent;
|
||||
+// CraftBukkit end
|
||||
+
|
||||
|
@ -28,7 +29,7 @@
|
|||
private final Map<UUID, Entity> entitiesByUUID = Maps.newHashMap();
|
||||
public boolean savingDisabled;
|
||||
private boolean O;
|
||||
@@ -38,14 +49,22 @@
|
||||
@@ -38,14 +50,22 @@
|
||||
private int T;
|
||||
private final List<NextTickListEntry> U = Lists.newArrayList();
|
||||
|
||||
|
@ -54,7 +55,7 @@
|
|||
this.H();
|
||||
this.I();
|
||||
this.getWorldBorder().a(minecraftserver.aD());
|
||||
@@ -64,6 +83,7 @@
|
||||
@@ -64,6 +84,7 @@
|
||||
this.villages.a((World) this);
|
||||
}
|
||||
|
||||
|
@ -62,7 +63,7 @@
|
|||
this.scoreboard = new ScoreboardServer(this.server);
|
||||
PersistentScoreboard persistentscoreboard = (PersistentScoreboard) this.worldMaps.get(PersistentScoreboard.class, "scoreboard");
|
||||
|
||||
@@ -74,6 +94,11 @@
|
||||
@@ -74,6 +95,11 @@
|
||||
|
||||
persistentscoreboard.a(this.scoreboard);
|
||||
((ScoreboardServer) this.scoreboard).a((Runnable) (new RunnableSaveScoreboard(persistentscoreboard)));
|
||||
|
@ -74,7 +75,7 @@
|
|||
this.B = new LootTableRegistry(new File(new File(this.dataManager.getDirectory(), "data"), "loot_tables"));
|
||||
this.getWorldBorder().setCenter(this.worldData.B(), this.worldData.C());
|
||||
this.getWorldBorder().setDamageAmount(this.worldData.H());
|
||||
@@ -86,9 +111,98 @@
|
||||
@@ -86,9 +112,98 @@
|
||||
this.getWorldBorder().setSize(this.worldData.D());
|
||||
}
|
||||
|
||||
|
@ -173,7 +174,7 @@
|
|||
public void doTick() {
|
||||
super.doTick();
|
||||
if (this.getWorldData().isHardcore() && this.getDifficulty() != EnumDifficulty.HARD) {
|
||||
@@ -106,9 +220,11 @@
|
||||
@@ -106,9 +221,11 @@
|
||||
this.f();
|
||||
}
|
||||
|
||||
|
@ -188,7 +189,7 @@
|
|||
}
|
||||
|
||||
this.methodProfiler.c("chunkSource");
|
||||
@@ -137,6 +253,8 @@
|
||||
@@ -137,6 +254,8 @@
|
||||
this.portalTravelAgent.a(this.getTime());
|
||||
this.methodProfiler.b();
|
||||
this.ao();
|
||||
|
@ -197,7 +198,7 @@
|
|||
}
|
||||
|
||||
@Nullable
|
||||
@@ -164,7 +282,7 @@
|
||||
@@ -164,7 +283,7 @@
|
||||
|
||||
if (entityhuman.isSpectator()) {
|
||||
++i;
|
||||
|
@ -206,7 +207,7 @@
|
|||
++j;
|
||||
}
|
||||
}
|
||||
@@ -190,25 +308,46 @@
|
||||
@@ -190,25 +309,46 @@
|
||||
}
|
||||
|
||||
private void c() {
|
||||
|
@ -257,7 +258,7 @@
|
|||
|
||||
return false;
|
||||
} else {
|
||||
@@ -279,7 +418,7 @@
|
||||
@@ -279,7 +419,7 @@
|
||||
entityhorse.y(true);
|
||||
entityhorse.setAgeRaw(0);
|
||||
entityhorse.setPosition((double) blockposition.getX(), (double) blockposition.getY(), (double) blockposition.getZ());
|
||||
|
@ -266,7 +267,7 @@
|
|||
this.strikeLightning(new EntityLightning(this, (double) blockposition.getX(), (double) blockposition.getY(), (double) blockposition.getZ(), true));
|
||||
} else {
|
||||
this.strikeLightning(new EntityLightning(this, (double) blockposition.getX(), (double) blockposition.getY(), (double) blockposition.getZ(), false));
|
||||
@@ -295,11 +434,29 @@
|
||||
@@ -295,11 +435,29 @@
|
||||
BlockPosition blockposition1 = blockposition.down();
|
||||
|
||||
if (this.v(blockposition1)) {
|
||||
|
@ -298,7 +299,7 @@
|
|||
}
|
||||
|
||||
if (flag && this.getBiome(blockposition1).d()) {
|
||||
@@ -374,7 +531,7 @@
|
||||
@@ -374,7 +532,7 @@
|
||||
public boolean b(BlockPosition blockposition, Block block) {
|
||||
NextTickListEntry nextticklistentry = new NextTickListEntry(blockposition, block);
|
||||
|
||||
|
@ -307,7 +308,7 @@
|
|||
}
|
||||
|
||||
public void a(BlockPosition blockposition, Block block, int i) {
|
||||
@@ -413,8 +570,8 @@
|
||||
@@ -413,8 +571,8 @@
|
||||
nextticklistentry.a(j);
|
||||
}
|
||||
|
||||
|
@ -318,7 +319,7 @@
|
|||
this.nextTickList.add(nextticklistentry);
|
||||
}
|
||||
}
|
||||
@@ -436,15 +593,15 @@
|
||||
@@ -436,15 +594,15 @@
|
||||
nextticklistentry.a((long) i + this.worldData.getTime());
|
||||
}
|
||||
|
||||
|
@ -337,7 +338,7 @@
|
|||
if (this.emptyTime++ >= 300) {
|
||||
return;
|
||||
}
|
||||
@@ -514,11 +671,17 @@
|
||||
@@ -514,11 +672,17 @@
|
||||
} else {
|
||||
int i = this.nextTickList.size();
|
||||
|
||||
|
@ -357,7 +358,7 @@
|
|||
}
|
||||
|
||||
this.methodProfiler.a("cleaning");
|
||||
@@ -531,8 +694,9 @@
|
||||
@@ -531,8 +695,9 @@
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -368,7 +369,7 @@
|
|||
this.U.add(nextticklistentry);
|
||||
}
|
||||
|
||||
@@ -602,7 +766,7 @@
|
||||
@@ -602,7 +767,7 @@
|
||||
if (blockposition.getX() >= structureboundingbox.a && blockposition.getX() < structureboundingbox.d && blockposition.getZ() >= structureboundingbox.c && blockposition.getZ() < structureboundingbox.f) {
|
||||
if (flag) {
|
||||
if (i == 0) {
|
||||
|
@ -377,7 +378,7 @@
|
|||
}
|
||||
|
||||
iterator.remove();
|
||||
@@ -620,6 +784,7 @@
|
||||
@@ -620,6 +785,7 @@
|
||||
return arraylist;
|
||||
}
|
||||
|
||||
|
@ -385,7 +386,7 @@
|
|||
public void entityJoinedWorld(Entity entity, boolean flag) {
|
||||
if (!this.getSpawnAnimals() && (entity instanceof EntityAnimal || entity instanceof EntityWaterAnimal)) {
|
||||
entity.die();
|
||||
@@ -631,6 +796,7 @@
|
||||
@@ -631,6 +797,7 @@
|
||||
|
||||
super.entityJoinedWorld(entity, flag);
|
||||
}
|
||||
|
@ -393,7 +394,7 @@
|
|||
|
||||
private boolean getSpawnNPCs() {
|
||||
return this.server.getSpawnNPCs();
|
||||
@@ -643,7 +809,54 @@
|
||||
@@ -643,7 +810,54 @@
|
||||
protected IChunkProvider n() {
|
||||
IChunkLoader ichunkloader = this.dataManager.createChunkLoader(this.worldProvider);
|
||||
|
||||
|
@ -449,7 +450,7 @@
|
|||
}
|
||||
|
||||
public boolean a(EntityHuman entityhuman, BlockPosition blockposition) {
|
||||
@@ -705,6 +918,23 @@
|
||||
@@ -705,6 +919,23 @@
|
||||
int j = this.worldProvider.getSeaLevel();
|
||||
int k = 8;
|
||||
|
||||
|
@ -473,7 +474,7 @@
|
|||
if (blockposition != null) {
|
||||
i = blockposition.getX();
|
||||
k = blockposition.getZ();
|
||||
@@ -714,7 +944,7 @@
|
||||
@@ -714,7 +945,7 @@
|
||||
|
||||
int l = 0;
|
||||
|
||||
|
@ -482,7 +483,7 @@
|
|||
i += random.nextInt(64) - random.nextInt(64);
|
||||
k += random.nextInt(64) - random.nextInt(64);
|
||||
++l;
|
||||
@@ -755,6 +985,7 @@
|
||||
@@ -755,6 +986,7 @@
|
||||
ChunkProviderServer chunkproviderserver = this.getChunkProviderServer();
|
||||
|
||||
if (chunkproviderserver.e()) {
|
||||
|
@ -490,7 +491,7 @@
|
|||
if (iprogressupdate != null) {
|
||||
iprogressupdate.a("Saving level");
|
||||
}
|
||||
@@ -765,7 +996,8 @@
|
||||
@@ -765,7 +997,8 @@
|
||||
}
|
||||
|
||||
chunkproviderserver.a(flag);
|
||||
|
@ -500,7 +501,7 @@
|
|||
Iterator iterator = arraylist.iterator();
|
||||
|
||||
while (iterator.hasNext()) {
|
||||
@@ -800,6 +1032,12 @@
|
||||
@@ -800,6 +1033,12 @@
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -513,7 +514,23 @@
|
|||
this.worldData.a(this.getWorldBorder().getSize());
|
||||
this.worldData.d(this.getWorldBorder().getCenterX());
|
||||
this.worldData.c(this.getWorldBorder().getCenterZ());
|
||||
@@ -834,7 +1072,7 @@
|
||||
@@ -813,9 +1052,13 @@
|
||||
this.worldMaps.a();
|
||||
}
|
||||
|
||||
- public boolean addEntity(Entity entity) {
|
||||
- return this.i(entity) ? super.addEntity(entity) : false;
|
||||
+ // CraftBukkit start
|
||||
+ public boolean addEntity(Entity entity, SpawnReason spawnReason) { // Changed signature, added SpawnReason
|
||||
+ // World.addEntity(Entity) will call this, and we still want to perform
|
||||
+ // existing entity checking when it's called with a SpawnReason
|
||||
+ return this.i(entity) ? super.addEntity(entity, spawnReason) : false;
|
||||
}
|
||||
+ // CraftBukkit end
|
||||
|
||||
public void a(Collection<Entity> collection) {
|
||||
ArrayList arraylist = Lists.newArrayList(collection);
|
||||
@@ -834,7 +1077,7 @@
|
||||
|
||||
private boolean i(Entity entity) {
|
||||
if (entity.dead) {
|
||||
|
@ -522,7 +539,7 @@
|
|||
return false;
|
||||
} else {
|
||||
UUID uuid = entity.getUniqueID();
|
||||
@@ -846,7 +1084,7 @@
|
||||
@@ -846,7 +1089,7 @@
|
||||
this.f.remove(entity1);
|
||||
} else {
|
||||
if (!(entity instanceof EntityHuman)) {
|
||||
|
@ -531,7 +548,7 @@
|
|||
return false;
|
||||
}
|
||||
|
||||
@@ -899,8 +1137,16 @@
|
||||
@@ -899,8 +1142,16 @@
|
||||
}
|
||||
|
||||
public boolean strikeLightning(Entity entity) {
|
||||
|
@ -549,7 +566,7 @@
|
|||
return true;
|
||||
} else {
|
||||
return false;
|
||||
@@ -916,10 +1162,20 @@
|
||||
@@ -916,10 +1167,20 @@
|
||||
}
|
||||
|
||||
public Explosion createExplosion(@Nullable Entity entity, double d0, double d1, double d2, float f, boolean flag, boolean flag1) {
|
||||
|
@ -570,7 +587,7 @@
|
|||
if (!flag1) {
|
||||
explosion.clearBlocks();
|
||||
}
|
||||
@@ -965,7 +1221,8 @@
|
||||
@@ -965,7 +1226,8 @@
|
||||
BlockActionData blockactiondata = (BlockActionData) iterator.next();
|
||||
|
||||
if (this.a(blockactiondata)) {
|
||||
|
@ -580,7 +597,7 @@
|
|||
}
|
||||
}
|
||||
|
||||
@@ -988,6 +1245,7 @@
|
||||
@@ -988,6 +1250,7 @@
|
||||
boolean flag = this.W();
|
||||
|
||||
super.t();
|
||||
|
@ -588,7 +605,7 @@
|
|||
if (this.n != this.o) {
|
||||
this.server.getPlayerList().a((Packet) (new PacketPlayOutGameStateChange(7, this.o)), this.worldProvider.getDimensionManager().getDimensionID());
|
||||
}
|
||||
@@ -1006,6 +1264,21 @@
|
||||
@@ -1006,6 +1269,21 @@
|
||||
this.server.getPlayerList().sendAll(new PacketPlayOutGameStateChange(7, this.o));
|
||||
this.server.getPlayerList().sendAll(new PacketPlayOutGameStateChange(8, this.q));
|
||||
}
|
||||
|
@ -610,7 +627,7 @@
|
|||
|
||||
}
|
||||
|
||||
@@ -1035,10 +1308,20 @@
|
||||
@@ -1035,10 +1313,20 @@
|
||||
}
|
||||
|
||||
public void a(EnumParticle enumparticle, boolean flag, double d0, double d1, double d2, int i, double d3, double d4, double d5, double d6, int... aint) {
|
||||
|
|
Loading…
Reference in a new issue