From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: Jake Potrebic Date: Fri, 25 Feb 2022 07:14:48 -0800 Subject: [PATCH] CB fixes * Missing Level -> LevelStem generic in StructureCheck Need to use the right for injectDatafixingContext (Spottedleaf) * Removed incorrect parent perm for `minecraft.debugstick.always` (Machine_Maker) * Fixed method signature of Marker#addPassenger (Machine_Maker) * Removed unneeded UOE in CustomWorldChunkManager (extends BiomeSource) (Machine_Maker) * Honor Server#getLootTable method contract (Machine_Maker) Co-authored-by: Spottedleaf diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java index 64522a15ecb73087222b33ffb13e29ac048b62a7..82c9886222d49bd03b642c0d9c07d82d1d27896b 100644 --- a/src/main/java/net/minecraft/server/level/ServerLevel.java +++ b/src/main/java/net/minecraft/server/level/ServerLevel.java @@ -294,7 +294,7 @@ public class ServerLevel extends Level implements WorldGenLevel { long l = minecraftserver.getWorldData().worldGenOptions().seed(); - this.structureCheck = new StructureCheck(this.chunkSource.chunkScanner(), this.registryAccess(), minecraftserver.getStructureManager(), resourcekey, chunkgenerator, this.chunkSource.randomState(), this, chunkgenerator.getBiomeSource(), l, datafixer); + this.structureCheck = new StructureCheck(this.chunkSource.chunkScanner(), this.registryAccess(), minecraftserver.getStructureManager(), this.getTypeKey(), chunkgenerator, this.chunkSource.randomState(), this, chunkgenerator.getBiomeSource(), l, datafixer); // Paper - Fix missing CB diff this.structureManager = new StructureManager(this, this.serverLevelData.worldGenOptions(), this.structureCheck); // CraftBukkit if ((this.dimension() == Level.END && this.dimensionTypeRegistration().is(BuiltinDimensionTypes.END)) || env == org.bukkit.World.Environment.THE_END) { // CraftBukkit - Allow to create EnderDragonBattle in default and custom END this.dragonFight = new EndDragonFight(this, this.serverLevelData.worldGenOptions().seed(), this.serverLevelData.endDragonFightData()); // CraftBukkit diff --git a/src/main/java/net/minecraft/world/entity/animal/camel/Camel.java b/src/main/java/net/minecraft/world/entity/animal/camel/Camel.java index 869f60e9407ed1c5bee536ef91a21f4d11f8f964..3aa98f7c282cb4884589cb83b1546b924e66f096 100644 --- a/src/main/java/net/minecraft/world/entity/animal/camel/Camel.java +++ b/src/main/java/net/minecraft/world/entity/animal/camel/Camel.java @@ -445,9 +445,9 @@ public class Camel extends AbstractHorse implements PlayerRideableJumping, Saddl } @Override - protected void actuallyHurt(DamageSource source, float amount) { + protected boolean damageEntity0(DamageSource source, float amount) { // Paper - fix CB method rename issue this.standUpInstantly(); - super.actuallyHurt(source, amount); + return super.damageEntity0(source, amount); // Paper - fix CB method rename issue } @Override diff --git a/src/main/java/net/minecraft/world/level/levelgen/structure/StructureCheck.java b/src/main/java/net/minecraft/world/level/levelgen/structure/StructureCheck.java index 161ad6ab1443b2ce33a2d7d91d189c855db0453b..15a9736a870055d639d03063c7cf67fd769fff36 100644 --- a/src/main/java/net/minecraft/world/level/levelgen/structure/StructureCheck.java +++ b/src/main/java/net/minecraft/world/level/levelgen/structure/StructureCheck.java @@ -43,7 +43,7 @@ public class StructureCheck { private final Registry biomes; private final Registry structureConfigs; private final StructureTemplateManager structureTemplateManager; - private final ResourceKey dimension; + private final ResourceKey dimension; // Paper - fix missing CB diff private final ChunkGenerator chunkGenerator; private final RandomState randomState; private final LevelHeightAccessor heightAccessor; @@ -53,7 +53,7 @@ public class StructureCheck { private final Long2ObjectMap> loadedChunks = new Long2ObjectOpenHashMap<>(); private final Map featureChecks = new HashMap<>(); - public StructureCheck(ChunkScanAccess chunkIoWorker, RegistryAccess registryManager, StructureTemplateManager structureTemplateManager, ResourceKey worldKey, ChunkGenerator chunkGenerator, RandomState noiseConfig, LevelHeightAccessor world, BiomeSource biomeSource, long seed, DataFixer dataFixer) { + public StructureCheck(ChunkScanAccess chunkIoWorker, RegistryAccess registryManager, StructureTemplateManager structureTemplateManager, ResourceKey worldKey, ChunkGenerator chunkGenerator, RandomState noiseConfig, LevelHeightAccessor world, BiomeSource biomeSource, long seed, DataFixer dataFixer) { // Paper - fix missing CB diff this.storageAccess = chunkIoWorker; this.registryAccess = registryManager; 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 index 79f9e87a2f0b517b762b3843fcd2bc119ed57b8a..b7d5b46fa3af1420a402addb73d6ed95f2456375 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java @@ -2422,7 +2422,13 @@ public final class CraftServer implements Server { Preconditions.checkArgument(key != null, "NamespacedKey key cannot be null"); LootDataManager registry = this.getServer().getLootData(); - return new CraftLootTable(key, registry.getLootTable(CraftNamespacedKey.toMinecraft(key))); + // Paper start - honor method contract + final ResourceLocation lootTableKey = CraftNamespacedKey.toMinecraft(key); + if (registry.getLootTable(lootTableKey) == net.minecraft.world.level.storage.loot.LootTable.EMPTY) { + return null; + } + return new CraftLootTable(key, registry.getLootTable(lootTableKey)); + // Paper end } @Override diff --git a/src/main/java/org/bukkit/craftbukkit/Main.java b/src/main/java/org/bukkit/craftbukkit/Main.java index 3523f8851472890c97e628e22df883b91ba603fe..b1a1caef59f3ea0fa68ca47040ad6fff9820cc5a 100644 --- a/src/main/java/org/bukkit/craftbukkit/Main.java +++ b/src/main/java/org/bukkit/craftbukkit/Main.java @@ -122,6 +122,7 @@ public class Main { this.acceptsAll(Main.asList("forceUpgrade"), "Whether to force a world upgrade"); this.acceptsAll(Main.asList("eraseCache"), "Whether to force cache erase during world upgrade"); + this.accepts("safeMode", "Loads level with vanilla datapack only"); // Paper this.acceptsAll(Main.asList("nogui"), "Disables the graphical console"); this.acceptsAll(Main.asList("nojline"), "Disables jline and emulates the vanilla console"); diff --git a/src/main/java/org/bukkit/craftbukkit/util/permissions/CraftDefaultPermissions.java b/src/main/java/org/bukkit/craftbukkit/util/permissions/CraftDefaultPermissions.java index 5ac25dab93fd4c9e9533c80d1ca3d93446d7a365..245ad120a36b6defca7e6889faae1ca5fc33d0c7 100644 --- a/src/main/java/org/bukkit/craftbukkit/util/permissions/CraftDefaultPermissions.java +++ b/src/main/java/org/bukkit/craftbukkit/util/permissions/CraftDefaultPermissions.java @@ -15,7 +15,7 @@ public final class CraftDefaultPermissions { DefaultPermissions.registerPermission(CraftDefaultPermissions.ROOT + ".nbt.place", "Gives the user the ability to place restricted blocks with NBT in creative", org.bukkit.permissions.PermissionDefault.OP, parent); DefaultPermissions.registerPermission(CraftDefaultPermissions.ROOT + ".nbt.copy", "Gives the user the ability to copy NBT in creative", org.bukkit.permissions.PermissionDefault.TRUE, parent); DefaultPermissions.registerPermission(CraftDefaultPermissions.ROOT + ".debugstick", "Gives the user the ability to use the debug stick in creative", org.bukkit.permissions.PermissionDefault.OP, parent); - DefaultPermissions.registerPermission(CraftDefaultPermissions.ROOT + ".debugstick.always", "Gives the user the ability to use the debug stick in all game modes", org.bukkit.permissions.PermissionDefault.FALSE, parent); + DefaultPermissions.registerPermission(CraftDefaultPermissions.ROOT + ".debugstick.always", "Gives the user the ability to use the debug stick in all game modes", org.bukkit.permissions.PermissionDefault.FALSE/* , parent */); // Paper - should not have this parent, as it's not a "vanilla" utility // Spigot end parent.recalculatePermissibles(); }