1
0
Fork 0
mirror of https://github.com/PaperMC/Paper.git synced 2025-01-30 19:40:37 +01:00

Guard the Entity.SHARED_RANDOM from seed changes

I don't clearly see any, but as a protection for future changes.
This commit is contained in:
Aikar 2018-07-21 09:03:10 -04:00
parent 185b6b4c59
commit 33cf273156
13 changed files with 29 additions and 16 deletions

View file

@ -27,7 +27,7 @@ index 5f06d4e5e..29b4bdb47 100644
+ } + }
} }
diff --git a/src/main/java/net/minecraft/server/Entity.java b/src/main/java/net/minecraft/server/Entity.java diff --git a/src/main/java/net/minecraft/server/Entity.java b/src/main/java/net/minecraft/server/Entity.java
index 20324deeb..b4233df5f 100644 index 92b2bcb86..5a4de30fe 100644
--- a/src/main/java/net/minecraft/server/Entity.java --- a/src/main/java/net/minecraft/server/Entity.java
+++ b/src/main/java/net/minecraft/server/Entity.java +++ b/src/main/java/net/minecraft/server/Entity.java
@@ -0,0 +0,0 @@ public abstract class Entity implements ICommandListener, KeyedObject { // Paper @@ -0,0 +0,0 @@ public abstract class Entity implements ICommandListener, KeyedObject { // Paper

View file

@ -5,7 +5,7 @@ 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 diff --git a/src/main/java/net/minecraft/server/Entity.java b/src/main/java/net/minecraft/server/Entity.java
index b6711dcfa..e7f63c927 100644 index 6d1e61e23..92b2bcb86 100644
--- a/src/main/java/net/minecraft/server/Entity.java --- a/src/main/java/net/minecraft/server/Entity.java
+++ b/src/main/java/net/minecraft/server/Entity.java +++ b/src/main/java/net/minecraft/server/Entity.java
@@ -0,0 +0,0 @@ public abstract class Entity implements ICommandListener, KeyedObject { // Paper @@ -0,0 +0,0 @@ public abstract class Entity implements ICommandListener, KeyedObject { // Paper

View file

@ -5,7 +5,7 @@ Subject: [PATCH] Don't let fishinghooks use portals
diff --git a/src/main/java/net/minecraft/server/Entity.java b/src/main/java/net/minecraft/server/Entity.java diff --git a/src/main/java/net/minecraft/server/Entity.java b/src/main/java/net/minecraft/server/Entity.java
index c675a6e16..f71528b5f 100644 index 0950c315f..d79844a98 100644
--- a/src/main/java/net/minecraft/server/Entity.java --- a/src/main/java/net/minecraft/server/Entity.java
+++ b/src/main/java/net/minecraft/server/Entity.java +++ b/src/main/java/net/minecraft/server/Entity.java
@@ -0,0 +0,0 @@ public abstract class Entity implements ICommandListener, KeyedObject { // Paper @@ -0,0 +0,0 @@ public abstract class Entity implements ICommandListener, KeyedObject { // Paper

View file

@ -7,7 +7,7 @@ Had some issue with this in past, and this is the vanilla logic.
Potentially an old CB change that's no longer needed. 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 diff --git a/src/main/java/net/minecraft/server/Entity.java b/src/main/java/net/minecraft/server/Entity.java
index eb07d4233..e2202ed0c 100644 index daf97bce3..87b82f908 100644
--- a/src/main/java/net/minecraft/server/Entity.java --- a/src/main/java/net/minecraft/server/Entity.java
+++ b/src/main/java/net/minecraft/server/Entity.java +++ b/src/main/java/net/minecraft/server/Entity.java
@@ -0,0 +0,0 @@ public abstract class Entity implements ICommandListener, KeyedObject { // Paper @@ -0,0 +0,0 @@ public abstract class Entity implements ICommandListener, KeyedObject { // Paper

View file

@ -7,7 +7,7 @@ If any part of a Vehicle/Passenger relationship is visible to a player,
send all passenger/vehicles to the player in the chain. send all passenger/vehicles to the player in the chain.
diff --git a/src/main/java/net/minecraft/server/Entity.java b/src/main/java/net/minecraft/server/Entity.java diff --git a/src/main/java/net/minecraft/server/Entity.java b/src/main/java/net/minecraft/server/Entity.java
index d1f07bbbd..945f06c93 100644 index a3e9ee052..9b01c23e0 100644
--- a/src/main/java/net/minecraft/server/Entity.java --- a/src/main/java/net/minecraft/server/Entity.java
+++ b/src/main/java/net/minecraft/server/Entity.java +++ b/src/main/java/net/minecraft/server/Entity.java
@@ -0,0 +0,0 @@ public abstract class Entity implements ICommandListener, KeyedObject { // Paper @@ -0,0 +0,0 @@ public abstract class Entity implements ICommandListener, KeyedObject { // Paper

View file

@ -5,7 +5,7 @@ Subject: [PATCH] Entity#fromMobSpawner()
diff --git a/src/main/java/net/minecraft/server/Entity.java b/src/main/java/net/minecraft/server/Entity.java diff --git a/src/main/java/net/minecraft/server/Entity.java b/src/main/java/net/minecraft/server/Entity.java
index b4233df5f..00791faf2 100644 index 5a4de30fe..2dbb88f2d 100644
--- a/src/main/java/net/minecraft/server/Entity.java --- a/src/main/java/net/minecraft/server/Entity.java
+++ b/src/main/java/net/minecraft/server/Entity.java +++ b/src/main/java/net/minecraft/server/Entity.java
@@ -0,0 +0,0 @@ public abstract class Entity implements ICommandListener, KeyedObject { // Paper @@ -0,0 +0,0 @@ public abstract class Entity implements ICommandListener, KeyedObject { // Paper

View file

@ -133,7 +133,7 @@ index 008ed206d..b3c1f550c 100644
this.b = i; this.b = i;
this.c = j; this.c = j;
diff --git a/src/main/java/net/minecraft/server/Entity.java b/src/main/java/net/minecraft/server/Entity.java diff --git a/src/main/java/net/minecraft/server/Entity.java b/src/main/java/net/minecraft/server/Entity.java
index cb9ef622c..c675a6e16 100644 index 0a62ebf4a..0950c315f 100644
--- a/src/main/java/net/minecraft/server/Entity.java --- a/src/main/java/net/minecraft/server/Entity.java
+++ b/src/main/java/net/minecraft/server/Entity.java +++ b/src/main/java/net/minecraft/server/Entity.java
@@ -0,0 +0,0 @@ public abstract class Entity implements ICommandListener, KeyedObject { // Paper @@ -0,0 +0,0 @@ public abstract class Entity implements ICommandListener, KeyedObject { // Paper

View file

@ -19,7 +19,7 @@ index abc1aabdd..6ea608ba9 100644
+ } + }
} }
diff --git a/src/main/java/net/minecraft/server/Entity.java b/src/main/java/net/minecraft/server/Entity.java diff --git a/src/main/java/net/minecraft/server/Entity.java b/src/main/java/net/minecraft/server/Entity.java
index e2202ed0c..88faa4601 100644 index 87b82f908..fa9319aff 100644
--- a/src/main/java/net/minecraft/server/Entity.java --- a/src/main/java/net/minecraft/server/Entity.java
+++ b/src/main/java/net/minecraft/server/Entity.java +++ b/src/main/java/net/minecraft/server/Entity.java
@@ -0,0 +0,0 @@ public abstract class Entity implements ICommandListener, KeyedObject { // Paper @@ -0,0 +0,0 @@ public abstract class Entity implements ICommandListener, KeyedObject { // Paper

View file

@ -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 diff --git a/src/main/java/net/minecraft/server/Entity.java b/src/main/java/net/minecraft/server/Entity.java
index c105dd9b0..334441ed7 100644 index 9b01c23e0..0a62ebf4a 100644
--- a/src/main/java/net/minecraft/server/Entity.java --- a/src/main/java/net/minecraft/server/Entity.java
+++ b/src/main/java/net/minecraft/server/Entity.java +++ b/src/main/java/net/minecraft/server/Entity.java
@@ -0,0 +0,0 @@ public abstract class Entity implements ICommandListener, KeyedObject { // Paper @@ -0,0 +0,0 @@ public abstract class Entity implements ICommandListener, KeyedObject { // Paper

View file

@ -22,7 +22,7 @@ requirement, but plugins (such as my own) use this method to
trigger a "reload" of the entity on the client. 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 diff --git a/src/main/java/net/minecraft/server/Entity.java b/src/main/java/net/minecraft/server/Entity.java
index 7b17c32bb..d03e7c24f 100644 index 2dbb88f2d..80ecdb282 100644
--- a/src/main/java/net/minecraft/server/Entity.java --- a/src/main/java/net/minecraft/server/Entity.java
+++ b/src/main/java/net/minecraft/server/Entity.java +++ b/src/main/java/net/minecraft/server/Entity.java
@@ -0,0 +0,0 @@ public abstract class Entity implements ICommandListener, KeyedObject { // Paper @@ -0,0 +0,0 @@ public abstract class Entity implements ICommandListener, KeyedObject { // Paper
@ -35,14 +35,14 @@ index 7b17c32bb..d03e7c24f 100644
this.world.methodProfiler.a("reposition"); this.world.methodProfiler.a("reposition");
/* CraftBukkit start - Handled in calculateTarget /* CraftBukkit start - Handled in calculateTarget
diff --git a/src/main/java/net/minecraft/server/WorldServer.java b/src/main/java/net/minecraft/server/WorldServer.java diff --git a/src/main/java/net/minecraft/server/WorldServer.java b/src/main/java/net/minecraft/server/WorldServer.java
index 49019d54d..9fe5c4406 100644 index 49019d54d..bba2e164f 100644
--- a/src/main/java/net/minecraft/server/WorldServer.java --- a/src/main/java/net/minecraft/server/WorldServer.java
+++ b/src/main/java/net/minecraft/server/WorldServer.java +++ b/src/main/java/net/minecraft/server/WorldServer.java
@@ -0,0 +0,0 @@ public class WorldServer extends World implements IAsyncTaskHandler { @@ -0,0 +0,0 @@ public class WorldServer extends World implements IAsyncTaskHandler {
} }
protected void c(Entity entity) { protected void c(Entity entity) {
+ if (!entity.valid) return; // Paper - Already removed, dont fire twice - this looks like it can happen even without our changes + if (!this.entitiesByUUID.containsKey(entity.getUniqueID()) && !entity.valid) return; // Paper - Already removed, dont fire twice - this looks like it can happen even without our changes
super.c(entity); super.c(entity);
this.entitiesById.d(entity.getId()); this.entitiesById.d(entity.getId());
this.entitiesByUUID.remove(entity.getUniqueID()); this.entitiesByUUID.remove(entity.getUniqueID());

View file

@ -6,14 +6,27 @@ Subject: [PATCH] Use a Shared Random for Entities
Reduces memory usage and provides ensures more randomness, Especially since a lot of garbage entity objects get created. Reduces memory usage and provides ensures more randomness, Especially since a lot of garbage entity objects get created.
diff --git a/src/main/java/net/minecraft/server/Entity.java b/src/main/java/net/minecraft/server/Entity.java diff --git a/src/main/java/net/minecraft/server/Entity.java b/src/main/java/net/minecraft/server/Entity.java
index b4ad611fc..4a08db5ba 100644 index f547dbfd0..daf97bce3 100644
--- a/src/main/java/net/minecraft/server/Entity.java --- a/src/main/java/net/minecraft/server/Entity.java
+++ b/src/main/java/net/minecraft/server/Entity.java +++ b/src/main/java/net/minecraft/server/Entity.java
@@ -0,0 +0,0 @@ public abstract class Entity implements ICommandListener, KeyedObject { // Paper @@ -0,0 +0,0 @@ public abstract class Entity implements ICommandListener, KeyedObject { // Paper
// CraftBukkit start // CraftBukkit start
private static final int CURRENT_LEVEL = 2; private static final int CURRENT_LEVEL = 2;
+ public static Random SHARED_RANDOM = new Random(); // Paper + // Paper start
+ public static Random SHARED_RANDOM = new Random() {
+ private boolean locked = false;
+ @Override
+ public synchronized void setSeed(long seed) {
+ if (locked) {
+ LogManager.getLogger().error("Ignoring setSeed on Entity.SHARED_RANDOM", new Throwable());
+ } else {
+ super.setSeed(seed);
+ locked = true;
+ }
+ }
+ };
+ // Paper end
static boolean isLevelAtLeast(NBTTagCompound tag, int level) { static boolean isLevelAtLeast(NBTTagCompound tag, int level) {
return tag.hasKey("Bukkit.updateLevel") && tag.getInt("Bukkit.updateLevel") >= level; return tag.hasKey("Bukkit.updateLevel") && tag.getInt("Bukkit.updateLevel") >= level;
} }

View file

@ -5,7 +5,7 @@ Subject: [PATCH] Vanished players don't have rights
diff --git a/src/main/java/net/minecraft/server/Entity.java b/src/main/java/net/minecraft/server/Entity.java diff --git a/src/main/java/net/minecraft/server/Entity.java b/src/main/java/net/minecraft/server/Entity.java
index f71528b5f..b13830e87 100644 index d79844a98..6d1e61e23 100644
--- a/src/main/java/net/minecraft/server/Entity.java --- a/src/main/java/net/minecraft/server/Entity.java
+++ b/src/main/java/net/minecraft/server/Entity.java +++ b/src/main/java/net/minecraft/server/Entity.java
@@ -0,0 +0,0 @@ public abstract class Entity implements ICommandListener, KeyedObject { // Paper @@ -0,0 +0,0 @@ public abstract class Entity implements ICommandListener, KeyedObject { // Paper

View file

@ -5,7 +5,7 @@ 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 diff --git a/src/main/java/net/minecraft/server/Entity.java b/src/main/java/net/minecraft/server/Entity.java
index 88faa4601..aece54d26 100644 index fa9319aff..a3e9ee052 100644
--- a/src/main/java/net/minecraft/server/Entity.java --- a/src/main/java/net/minecraft/server/Entity.java
+++ b/src/main/java/net/minecraft/server/Entity.java +++ b/src/main/java/net/minecraft/server/Entity.java
@@ -0,0 +0,0 @@ public abstract class Entity implements ICommandListener, KeyedObject { // Paper @@ -0,0 +0,0 @@ public abstract class Entity implements ICommandListener, KeyedObject { // Paper