Fixes for loot tables (#9818)

This commit is contained in:
Jake Potrebic 2023-10-10 10:35:49 -07:00 committed by GitHub
parent a2ba45239c
commit e87240b674
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 35 additions and 0 deletions

View file

@ -67,6 +67,22 @@ index 161ad6ab1443b2ce33a2d7d91d189c855db0453b..15a9736a870055d639d03063c7cf67fd
this.storageAccess = chunkIoWorker; this.storageAccess = chunkIoWorker;
this.registryAccess = registryManager; this.registryAccess = registryManager;
this.structureTemplateManager = structureTemplateManager; this.structureTemplateManager = structureTemplateManager;
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftLootTable.java b/src/main/java/org/bukkit/craftbukkit/CraftLootTable.java
index 6ab2fd523b7f4e5cacef4ebb95f6812f391985d1..85133c388eff009ea1ffa391824b6556f7bf2014 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftLootTable.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftLootTable.java
@@ -174,4 +174,11 @@ public class CraftLootTable implements org.bukkit.loot.LootTable {
org.bukkit.loot.LootTable table = (org.bukkit.loot.LootTable) obj;
return table.getKey().equals(this.getKey());
}
+
+ // Paper start - satisfy equals/hashCode contract
+ @Override
+ public int hashCode() {
+ return java.util.Objects.hash(key);
+ }
+ // Paper end
}
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
index 2d5627f5dc48c0d51464452907b50bbeb069e67c..f890e0e8ae52965f671fe82911b006a61a33a86b 100644 index 2d5627f5dc48c0d51464452907b50bbeb069e67c..f890e0e8ae52965f671fe82911b006a61a33a86b 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java --- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java

View file

@ -0,0 +1,19 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Jake Potrebic <jake.m.potrebic@gmail.com>
Date: Tue, 10 Oct 2023 10:17:43 -0700
Subject: [PATCH] Use correct variable for initializing CraftLootTable
diff --git a/src/main/java/net/minecraft/world/level/storage/loot/LootDataManager.java b/src/main/java/net/minecraft/world/level/storage/loot/LootDataManager.java
index ac4de8a082b495d945723d6062d9eacaa9add2bb..08f5239d5eea9133340ec9e1a3a7d8d5e792ced0 100644
--- a/src/main/java/net/minecraft/world/level/storage/loot/LootDataManager.java
+++ b/src/main/java/net/minecraft/world/level/storage/loot/LootDataManager.java
@@ -101,7 +101,7 @@ public class LootDataManager implements PreparableReloadListener, LootDataResolv
});
// CraftBukkit start
map1.forEach((key, lootTable) -> {
- if (object instanceof LootTable table) {
+ if (lootTable instanceof LootTable table) { // Paper - use correct variable
table.craftLootTable = new CraftLootTable(CraftNamespacedKey.fromMinecraft(key.location()), table);
}
});