mirror of
https://github.com/PaperMC/Paper.git
synced 2024-08-21 11:52:55 +02: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:
parent
fa8406dab4
commit
82bcd1408a
|
@ -1,4 +1,4 @@
|
|||
From 95dfc2d6b2593ea2603bc30932824b855b8bb672 Mon Sep 17 00:00:00 2001
|
||||
From 077011a996a7c44bb7ec934b0e46aaf16725f121 Mon Sep 17 00:00:00 2001
|
||||
From: Aikar <aikar@aikar.co>
|
||||
Date: Tue, 22 Mar 2016 00:33:47 -0400
|
||||
Subject: [PATCH] Use a Shared Random for Entities
|
||||
|
@ -6,18 +6,31 @@ 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.
|
||||
|
||||
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
|
||||
+++ b/src/main/java/net/minecraft/server/Entity.java
|
||||
@@ -46,6 +46,7 @@ public abstract class Entity implements ICommandListener, KeyedObject { // Paper
|
||||
@@ -46,6 +46,20 @@ public abstract class Entity implements ICommandListener, KeyedObject { // Paper
|
||||
|
||||
// CraftBukkit start
|
||||
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) {
|
||||
return tag.hasKey("Bukkit.updateLevel") && tag.getInt("Bukkit.updateLevel") >= level;
|
||||
}
|
||||
@@ -171,7 +172,7 @@ public abstract class Entity implements ICommandListener, KeyedObject { // Paper
|
||||
@@ -171,7 +185,7 @@ public abstract class Entity implements ICommandListener, KeyedObject { // Paper
|
||||
this.length = 1.8F;
|
||||
this.ax = 1;
|
||||
this.ay = 1.0F;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
From d24cf71aec74d0f22ad259e435ccbce611139fed Mon Sep 17 00:00:00 2001
|
||||
From 3faa48aebbc50348a1c69b43c8f4be1f0d8d78e8 Mon Sep 17 00:00:00 2001
|
||||
From: Aikar <aikar@aikar.co>
|
||||
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 eb07d4233..e2202ed0c 100644
|
||||
index daf97bce3..87b82f908 100644
|
||||
--- a/src/main/java/net/minecraft/server/Entity.java
|
||||
+++ b/src/main/java/net/minecraft/server/Entity.java
|
||||
@@ -2399,7 +2399,7 @@ public abstract class Entity implements ICommandListener, KeyedObject { // Paper
|
||||
@@ -2412,7 +2412,7 @@ public abstract class Entity implements ICommandListener, KeyedObject { // Paper
|
||||
}
|
||||
|
||||
public Entity teleportTo(Location exit, boolean portal) {
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
From 90ca9d579f3d73834d58123205d8db9cfe179b56 Mon Sep 17 00:00:00 2001
|
||||
From 0f917b2215537ad0e4c08b4c4add7ad3bdec07c7 Mon Sep 17 00:00:00 2001
|
||||
From: Zach Brown <zach.brown@destroystokyo.com>
|
||||
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 e2202ed0c..88faa4601 100644
|
||||
index 87b82f908..fa9319aff 100644
|
||||
--- a/src/main/java/net/minecraft/server/Entity.java
|
||||
+++ b/src/main/java/net/minecraft/server/Entity.java
|
||||
@@ -2122,6 +2122,7 @@ public abstract class Entity implements ICommandListener, KeyedObject { // Paper
|
||||
@@ -2135,6 +2135,7 @@ public abstract class Entity implements ICommandListener, KeyedObject { // Paper
|
||||
return this.getFlag(5);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,14 +1,14 @@
|
|||
From eb11e43a94909435f4ce4020d2eded1eb0b8cdb1 Mon Sep 17 00:00:00 2001
|
||||
From 59d26d28500f04c9cced47dc4c99d71fc7efb7e5 Mon Sep 17 00:00:00 2001
|
||||
From: Zach Brown <zach.brown@destroystokyo.com>
|
||||
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 88faa4601..aece54d26 100644
|
||||
index fa9319aff..a3e9ee052 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
|
||||
@@ -83,7 +83,7 @@ public abstract class Entity implements ICommandListener, KeyedObject { // Paper
|
||||
public boolean i;
|
||||
public final List<Entity> passengers;
|
||||
protected int j;
|
||||
|
@ -17,7 +17,7 @@ index 88faa4601..aece54d26 100644
|
|||
public boolean attachedToPlayer;
|
||||
public World world;
|
||||
public double lastX;
|
||||
@@ -2004,6 +2004,7 @@ public abstract class Entity implements ICommandListener, KeyedObject { // Paper
|
||||
@@ -2017,6 +2017,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 88faa4601..aece54d26 100644
|
|||
CraftEntity craft = (CraftEntity) entity.getBukkitEntity().getVehicle();
|
||||
Entity orig = craft == null ? null : craft.getHandle();
|
||||
if (getBukkitEntity() instanceof Vehicle && entity.getBukkitEntity() instanceof LivingEntity) {
|
||||
@@ -2019,7 +2020,13 @@ public abstract class Entity implements ICommandListener, KeyedObject { // Paper
|
||||
@@ -2032,7 +2033,13 @@ public abstract class Entity implements ICommandListener, KeyedObject { // Paper
|
||||
}
|
||||
}
|
||||
// CraftBukkit end
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
From 2c29fda252395dc3caf19e77deea3ef876473ace Mon Sep 17 00:00:00 2001
|
||||
From 76366b2e02fbcffccddaec97bd494277c0d92d55 Mon Sep 17 00:00:00 2001
|
||||
From: Aikar <aikar@aikar.co>
|
||||
Date: Mon, 17 Jun 2013 01:24:00 -0400
|
||||
Subject: [PATCH] Entity Tracking Improvements
|
||||
|
@ -7,10 +7,10 @@ If any part of a Vehicle/Passenger relationship is visible to a player,
|
|||
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
|
||||
index d1f07bbbd..945f06c93 100644
|
||||
index a3e9ee052..9b01c23e0 100644
|
||||
--- a/src/main/java/net/minecraft/server/Entity.java
|
||||
+++ b/src/main/java/net/minecraft/server/Entity.java
|
||||
@@ -53,6 +53,7 @@ public abstract class Entity implements ICommandListener, KeyedObject { // Paper
|
||||
@@ -66,6 +66,7 @@ public abstract class Entity implements ICommandListener, KeyedObject { // Paper
|
||||
|
||||
protected CraftEntity bukkitEntity;
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
From d45df5fa649ad40f1cb1057bc29f5f23aed74c96 Mon Sep 17 00:00:00 2001
|
||||
From 036e57626907e289a1c0a842460a9bac8da4e5d3 Mon Sep 17 00:00:00 2001
|
||||
From: Zach Brown <zach.brown@destroystokyo.com>
|
||||
Date: Sun, 22 May 2016 20:20:55 -0500
|
||||
Subject: [PATCH] Optional TNT doesn't move in water
|
||||
|
@ -32,10 +32,10 @@ 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 c105dd9b0..334441ed7 100644
|
||||
index 9b01c23e0..0a62ebf4a 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
|
||||
@@ -1127,6 +1127,11 @@ public abstract class Entity implements ICommandListener, KeyedObject { // Paper
|
||||
}
|
||||
|
||||
public boolean aq() {
|
||||
|
@ -47,7 +47,7 @@ index c105dd9b0..334441ed7 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)) {
|
||||
@@ -2587,6 +2592,11 @@ public abstract class Entity implements ICommandListener, KeyedObject { // Paper
|
||||
@@ -2600,6 +2605,11 @@ public abstract class Entity implements ICommandListener, KeyedObject { // Paper
|
||||
}
|
||||
|
||||
public boolean bo() {
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
From b882250f89918c9a9e256def49d0d5b92d7e8916 Mon Sep 17 00:00:00 2001
|
||||
From 85cc2d8515551c826977868bf3c68b1d78cccead Mon Sep 17 00:00:00 2001
|
||||
From: Techcable <Techcable@outlook.com>
|
||||
Date: Sat, 18 Jun 2016 01:01:37 -0500
|
||||
Subject: [PATCH] Make entities look for hoppers
|
||||
|
@ -133,10 +133,10 @@ index 008ed206d..b3c1f550c 100644
|
|||
this.b = i;
|
||||
this.c = j;
|
||||
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
|
||||
+++ b/src/main/java/net/minecraft/server/Entity.java
|
||||
@@ -80,6 +80,19 @@ public abstract class Entity implements ICommandListener, KeyedObject { // Paper
|
||||
@@ -93,6 +93,19 @@ public abstract class Entity implements ICommandListener, KeyedObject { // Paper
|
||||
public double locX;
|
||||
public double locY;
|
||||
public double locZ;
|
||||
|
|
|
@ -1,14 +1,14 @@
|
|||
From 5f57f26f976b45cda5fcda4dffebc4981d748109 Mon Sep 17 00:00:00 2001
|
||||
From e04b0035798d951d1068d1625eda2fb758a34404 Mon Sep 17 00:00:00 2001
|
||||
From: Zach Brown <zach.brown@destroystokyo.com>
|
||||
Date: Fri, 16 Dec 2016 16:03:19 -0600
|
||||
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
|
||||
index c675a6e16..f71528b5f 100644
|
||||
index 0950c315f..d79844a98 100644
|
||||
--- a/src/main/java/net/minecraft/server/Entity.java
|
||||
+++ b/src/main/java/net/minecraft/server/Entity.java
|
||||
@@ -144,7 +144,7 @@ public abstract class Entity implements ICommandListener, KeyedObject { // Paper
|
||||
@@ -157,7 +157,7 @@ public abstract class Entity implements ICommandListener, KeyedObject { // Paper
|
||||
public boolean ah;
|
||||
public boolean impulse;
|
||||
public int portalCooldown;
|
||||
|
|
|
@ -1,14 +1,14 @@
|
|||
From 570c45e9491173c215cae1bd4ff5ff9b9b8b1fa0 Mon Sep 17 00:00:00 2001
|
||||
From 6c9aa29b50e035dc386794e866d64ec07c4c9c19 Mon Sep 17 00:00:00 2001
|
||||
From: Zach Brown <zach.brown@destroystokyo.com>
|
||||
Date: Fri, 16 Dec 2016 22:10:35 -0600
|
||||
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
|
||||
index f71528b5f..b13830e87 100644
|
||||
index d79844a98..6d1e61e23 100644
|
||||
--- a/src/main/java/net/minecraft/server/Entity.java
|
||||
+++ b/src/main/java/net/minecraft/server/Entity.java
|
||||
@@ -68,7 +68,7 @@ public abstract class Entity implements ICommandListener, KeyedObject { // Paper
|
||||
@@ -81,7 +81,7 @@ public abstract class Entity implements ICommandListener, KeyedObject { // Paper
|
||||
private static double f = 1.0D;
|
||||
private static int entityCount;
|
||||
private int id;
|
||||
|
|
|
@ -1,14 +1,14 @@
|
|||
From 977e13e598af25e22f19ad88220a047723a12193 Mon Sep 17 00:00:00 2001
|
||||
From 512e2cf16911c2f07c0c5b763d4b56b1788344fb Mon Sep 17 00:00:00 2001
|
||||
From: Alfie Cleveland <alfeh@me.com>
|
||||
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 b6711dcfa..e7f63c927 100644
|
||||
index 6d1e61e23..92b2bcb86 100644
|
||||
--- a/src/main/java/net/minecraft/server/Entity.java
|
||||
+++ b/src/main/java/net/minecraft/server/Entity.java
|
||||
@@ -1981,6 +1981,7 @@ public abstract class Entity implements ICommandListener, KeyedObject { // Paper
|
||||
@@ -1994,6 +1994,7 @@ public abstract class Entity implements ICommandListener, KeyedObject { // Paper
|
||||
}
|
||||
|
||||
protected void o(Entity entity) {
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
From a30098615015d5b407960dfe74033d7545d7eb12 Mon Sep 17 00:00:00 2001
|
||||
From 1ffe7e986e130686ef5b48ac41b63296f77b4e9c Mon Sep 17 00:00:00 2001
|
||||
From: Aikar <aikar@aikar.co>
|
||||
Date: Sun, 22 Jan 2017 18:07:56 -0500
|
||||
Subject: [PATCH] Cap Entity Collisions
|
||||
|
@ -27,10 +27,10 @@ index 5f06d4e5e..29b4bdb47 100644
|
|||
+ }
|
||||
}
|
||||
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
|
||||
+++ b/src/main/java/net/minecraft/server/Entity.java
|
||||
@@ -170,6 +170,7 @@ public abstract class Entity implements ICommandListener, KeyedObject { // Paper
|
||||
@@ -183,6 +183,7 @@ public abstract class Entity implements ICommandListener, KeyedObject { // Paper
|
||||
public final boolean defaultActivationState;
|
||||
public long activatedTick = Integer.MIN_VALUE;
|
||||
public boolean fromMobSpawner;
|
||||
|
|
|
@ -1,14 +1,14 @@
|
|||
From 57ed55129a54deecee7292fd00036b45ac0bd6ed Mon Sep 17 00:00:00 2001
|
||||
From 69193e9240f2c55715208ca6341f085a2b1cabca Mon Sep 17 00:00:00 2001
|
||||
From: BillyGalbreath <Blake.Galbreath@GMail.com>
|
||||
Date: Sun, 18 Jun 2017 18:17:05 -0500
|
||||
Subject: [PATCH] Entity#fromMobSpawner()
|
||||
|
||||
|
||||
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
|
||||
+++ b/src/main/java/net/minecraft/server/Entity.java
|
||||
@@ -170,6 +170,7 @@ public abstract class Entity implements ICommandListener, KeyedObject { // Paper
|
||||
@@ -183,6 +183,7 @@ public abstract class Entity implements ICommandListener, KeyedObject { // Paper
|
||||
public final boolean defaultActivationState;
|
||||
public long activatedTick = Integer.MIN_VALUE;
|
||||
public boolean fromMobSpawner;
|
||||
|
@ -16,7 +16,7 @@ index b4233df5f..00791faf2 100644
|
|||
protected int numCollisions = 0; // Paper
|
||||
public void inactiveTick() { }
|
||||
// Spigot end
|
||||
@@ -1590,6 +1591,10 @@ public abstract class Entity implements ICommandListener, KeyedObject { // Paper
|
||||
@@ -1603,6 +1604,10 @@ public abstract class Entity implements ICommandListener, KeyedObject { // Paper
|
||||
if (origin != null) {
|
||||
nbttagcompound.set("Paper.Origin", this.createList(origin.getX(), origin.getY(), origin.getZ()));
|
||||
}
|
||||
|
@ -27,7 +27,7 @@ index b4233df5f..00791faf2 100644
|
|||
// Paper end
|
||||
return nbttagcompound;
|
||||
} catch (Throwable throwable) {
|
||||
@@ -1739,6 +1744,8 @@ public abstract class Entity implements ICommandListener, KeyedObject { // Paper
|
||||
@@ -1752,6 +1757,8 @@ public abstract class Entity implements ICommandListener, KeyedObject { // Paper
|
||||
if (!originTag.isEmpty()) {
|
||||
origin = new Location(world.getWorld(), originTag.getDoubleAt(0), originTag.getDoubleAt(1), originTag.getDoubleAt(2));
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
From b770be1d1eb24d049cd7ca1af1a96bb87aed62e3 Mon Sep 17 00:00:00 2001
|
||||
From 11c4b454e2dca08dc7d8823bf7d533e20d67c7ef Mon Sep 17 00:00:00 2001
|
||||
From: Aikar <aikar@aikar.co>
|
||||
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 7b17c32bb..d03e7c24f 100644
|
||||
index 2dbb88f2d..80ecdb282 100644
|
||||
--- a/src/main/java/net/minecraft/server/Entity.java
|
||||
+++ b/src/main/java/net/minecraft/server/Entity.java
|
||||
@@ -2449,7 +2449,7 @@ public abstract class Entity implements ICommandListener, KeyedObject { // Paper
|
||||
@@ -2462,7 +2462,7 @@ public abstract class Entity implements ICommandListener, KeyedObject { // Paper
|
||||
}
|
||||
// CraftBukkit end */
|
||||
|
||||
|
@ -35,14 +35,14 @@ index 7b17c32bb..d03e7c24f 100644
|
|||
this.world.methodProfiler.a("reposition");
|
||||
/* 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
|
||||
index 49019d54d..9fe5c4406 100644
|
||||
index 49019d54d..bba2e164f 100644
|
||||
--- a/src/main/java/net/minecraft/server/WorldServer.java
|
||||
+++ b/src/main/java/net/minecraft/server/WorldServer.java
|
||||
@@ -1205,6 +1205,7 @@ public class WorldServer extends World implements IAsyncTaskHandler {
|
||||
}
|
||||
|
||||
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);
|
||||
this.entitiesById.d(entity.getId());
|
||||
this.entitiesByUUID.remove(entity.getUniqueID());
|
||||
|
|
Loading…
Reference in New Issue
Block a user