Mirror von
https://github.com/PaperMC/Paper.git
synchronisiert 2024-11-15 12:30:06 +01:00
f6969b6374
Upstream has released updates that appear to apply and compile correctly. This update has not been tested by PaperMC and as with ANY update, please do your own testing Bukkit Changes: 09b1c123 PR-916: Add more lightning API c085f3de PR-859: Add Entity#getTrackedBy CraftBukkit Changes: 1bf30a4e9 SPIGOT-7495: Spawning bee entity in asynchronous BlockPopulator causes IllegalStateException - Accessing LegacyRandomSource from multiple threads 476c5bccd PR-1267: Add more lightning API 40d5e6c02 PR-1190: Add Entity#getTrackedBy 40d41acc1 SPIGOT-7491: Downgrade bundled SQLite to be updated next release 44b31da38 PR-1264: Load Bukkit class before creating Registry item dc45a6738 SPIGOT-7496: Failure to load datapacks with multiple identical predicates f508657d6 Fix decompile error affecting javac ef7a4743d PR-1265: Ensure UTF-8 used in new test resource Spigot Changes: 224dad51 Rebuild patches
47 Zeilen
1.9 KiB
Diff
47 Zeilen
1.9 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: Aikar <aikar@aikar.co>
|
|
Date: Sun, 10 Jun 2018 20:20:15 -0400
|
|
Subject: [PATCH] Fix CraftEntity hashCode
|
|
|
|
hashCodes are not allowed to change, however bukkit used a value
|
|
that does change, the entityId.
|
|
|
|
When an entity is teleported dimensions, the entity reference is
|
|
replaced with a new one with a new entity ID.
|
|
|
|
For hashCode, we can simply use the UUID's hashCode to keep
|
|
the hashCode from changing.
|
|
|
|
equals() is ok to use getEntityId() because equals() should only
|
|
be true if both the left and right are the same reference.
|
|
|
|
Since entity ids can not duplicate during runtime, this
|
|
check is essentially the same as this.getHandle() == other.getHandle()
|
|
|
|
However, replaced it too to make it clearer of intent.
|
|
|
|
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java
|
|
index 714a8fb1715751038c411ea7f2f0cf37ee41abd8..5e9642662716a0e60a700e6359539339f1cf5230 100644
|
|
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java
|
|
@@ -840,14 +840,15 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity {
|
|
return false;
|
|
}
|
|
final CraftEntity other = (CraftEntity) obj;
|
|
- return (this.getEntityId() == other.getEntityId());
|
|
+ return (this.getHandle() == other.getHandle()); // Paper - while logically the same, this is clearer
|
|
}
|
|
|
|
+ // Paper - Fix hashCode. entity ID's are not static.
|
|
+ // A CraftEntity can change reference to a new entity with a new ID, and hash codes should never change
|
|
@Override
|
|
public int hashCode() {
|
|
- int hash = 7;
|
|
- hash = 29 * hash + this.getEntityId();
|
|
- return hash;
|
|
+ return getUniqueId().hashCode();
|
|
+ // Paper end
|
|
}
|
|
|
|
@Override
|