diff --git a/paper-server/nms-patches/BiomeStorage.patch b/paper-server/nms-patches/BiomeStorage.patch index 278584550d..a45f20c3a1 100644 --- a/paper-server/nms-patches/BiomeStorage.patch +++ b/paper-server/nms-patches/BiomeStorage.patch @@ -1,5 +1,14 @@ --- a/net/minecraft/server/BiomeStorage.java +++ b/net/minecraft/server/BiomeStorage.java +@@ -12,7 +12,7 @@ + public static final int a = 1 << BiomeStorage.e + BiomeStorage.e + BiomeStorage.f; + public static final int b = (1 << BiomeStorage.e) - 1; + public static final int c = (1 << BiomeStorage.f) - 1; +- private final Registry g; ++ public final Registry g; // PAIL + private final BiomeBase[] h; + + public BiomeStorage(Registry registry, BiomeBase[] abiomebase) { @@ -87,4 +87,14 @@ return this.h[i1 << BiomeStorage.e + BiomeStorage.e | j1 << BiomeStorage.e | l]; diff --git a/paper-server/nms-patches/MinecraftServer.patch b/paper-server/nms-patches/MinecraftServer.patch index d04a9f7419..57728e1953 100644 --- a/paper-server/nms-patches/MinecraftServer.patch +++ b/paper-server/nms-patches/MinecraftServer.patch @@ -211,7 +211,7 @@ + + org.bukkit.generator.ChunkGenerator gen = this.server.getGenerator(name); + -+ IRegistryCustom.Dimension iregistrycustom_dimension = IRegistryCustom.b(); ++ IRegistryCustom.Dimension iregistrycustom_dimension = this.f; + + RegistryReadOps registryreadops = RegistryReadOps.a((DynamicOps) DynamicOpsNBT.a, this.dataPackResources.h(), iregistrycustom_dimension); + worlddata = (WorldDataServer) worldSession.a((DynamicOps) registryreadops, datapackconfiguration); diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/CraftChunkSnapshot.java b/paper-server/src/main/java/org/bukkit/craftbukkit/CraftChunkSnapshot.java index 4ec53a54e3..ff8ba54574 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/CraftChunkSnapshot.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/CraftChunkSnapshot.java @@ -3,11 +3,13 @@ package org.bukkit.craftbukkit; import com.google.common.base.Preconditions; import com.google.common.base.Predicates; import java.util.function.Predicate; +import net.minecraft.server.BiomeBase; import net.minecraft.server.BiomeStorage; import net.minecraft.server.BlockPosition; import net.minecraft.server.DataPaletteBlock; import net.minecraft.server.HeightMap; import net.minecraft.server.IBlockData; +import net.minecraft.server.IRegistry; import org.bukkit.ChunkSnapshot; import org.bukkit.Material; import org.bukkit.block.Biome; @@ -128,7 +130,7 @@ public class CraftChunkSnapshot implements ChunkSnapshot { Preconditions.checkState(biome != null, "ChunkSnapshot created without biome. Please call getSnapshot with includeBiome=true"); CraftChunk.validateChunkCoordinates(x, y, z); - return CraftBlock.biomeBaseToBiome(biome.getBiome(x >> 2, y >> 2, z >> 2)); + return CraftBlock.biomeBaseToBiome((IRegistry) biome.g, biome.getBiome(x >> 2, y >> 2, z >> 2)); } @Override diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/paper-server/src/main/java/org/bukkit/craftbukkit/CraftWorld.java index 0c4ac2e71f..eb189b5d99 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/CraftWorld.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/CraftWorld.java @@ -72,6 +72,7 @@ import net.minecraft.server.GameRules; import net.minecraft.server.GroupDataEntity; import net.minecraft.server.IBlockData; import net.minecraft.server.IChunkAccess; +import net.minecraft.server.IRegistry; import net.minecraft.server.MinecraftKey; import net.minecraft.server.MovingObjectPosition; import net.minecraft.server.PacketPlayOutCustomSoundEffect; @@ -88,9 +89,6 @@ import net.minecraft.server.Ticket; import net.minecraft.server.TicketType; import net.minecraft.server.Unit; import net.minecraft.server.Vec3D; -import net.minecraft.server.WorldGenFeatureConfigured; -import net.minecraft.server.WorldGenFeatureHugeFungiConfiguration; -import net.minecraft.server.WorldGenerator; import net.minecraft.server.WorldServer; import org.apache.commons.lang.Validate; import org.bukkit.BlockChangeDelegate; @@ -920,7 +918,7 @@ public class CraftWorld implements World { @Override public Biome getBiome(int x, int y, int z) { - return CraftBlock.biomeBaseToBiome(this.world.getBiome(x >> 2, y >> 2, z >> 2)); + return CraftBlock.biomeBaseToBiome(getHandle().r().b(IRegistry.ay), this.world.getBiome(x >> 2, y >> 2, z >> 2)); } @Override @@ -932,7 +930,7 @@ public class CraftWorld implements World { @Override public void setBiome(int x, int y, int z, Biome bio) { - BiomeBase bb = CraftBlock.biomeToBiomeBase(bio); + BiomeBase bb = CraftBlock.biomeToBiomeBase(getHandle().r().b(IRegistry.ay), bio); BlockPosition pos = new BlockPosition(x, 0, z); if (this.world.isLoaded(pos)) { net.minecraft.server.Chunk chunk = this.world.getChunkAtWorldCoords(pos); diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java b/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java index a8c1cab3e8..ac63b098f4 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java @@ -29,6 +29,7 @@ import org.bukkit.Chunk; import org.bukkit.FluidCollisionMode; import org.bukkit.Location; import org.bukkit.Material; +import org.bukkit.Registry; import org.bukkit.World; import org.bukkit.block.Biome; import org.bukkit.block.Block; @@ -42,6 +43,7 @@ import org.bukkit.craftbukkit.block.data.CraftBlockData; import org.bukkit.craftbukkit.entity.CraftEntity; import org.bukkit.craftbukkit.inventory.CraftItemStack; import org.bukkit.craftbukkit.util.CraftMagicNumbers; +import org.bukkit.craftbukkit.util.CraftNamespacedKey; import org.bukkit.craftbukkit.util.CraftRayTraceResult; import org.bukkit.entity.Entity; import org.bukkit.inventory.ItemStack; @@ -488,20 +490,20 @@ public class CraftBlock implements Block { getWorld().setBiome(getX(), getY(), getZ(), bio); } - public static Biome biomeBaseToBiome(BiomeBase base) { + public static Biome biomeBaseToBiome(IRegistry registry, BiomeBase base) { if (base == null) { return null; } - return Biome.valueOf(RegistryGeneration.WORLDGEN_BIOME.getKey(base).getKey().toUpperCase(java.util.Locale.ENGLISH)); + return Registry.BIOME.get(CraftNamespacedKey.fromMinecraft(registry.getKey(base))); } - public static BiomeBase biomeToBiomeBase(Biome bio) { + public static BiomeBase biomeToBiomeBase(IRegistry registry, Biome bio) { if (bio == null) { return null; } - return RegistryGeneration.WORLDGEN_BIOME.get(new MinecraftKey(bio.name().toLowerCase(java.util.Locale.ENGLISH))); + return registry.get(CraftNamespacedKey.toMinecraft(bio.getKey())); } @Override diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/generator/CustomChunkGenerator.java b/paper-server/src/main/java/org/bukkit/craftbukkit/generator/CustomChunkGenerator.java index 323beecc12..6d69454426 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/generator/CustomChunkGenerator.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/generator/CustomChunkGenerator.java @@ -67,12 +67,12 @@ public class CustomChunkGenerator extends InternalChunkGenerator { @Override public Biome getBiome(int x, int y, int z) { - return CraftBlock.biomeBaseToBiome(biome.getBiome(x >> 2, y >> 2, z >> 2)); + return CraftBlock.biomeBaseToBiome((IRegistry) biome.g, biome.getBiome(x >> 2, y >> 2, z >> 2)); } @Override public void setBiome(int x, int y, int z, Biome bio) { - biome.setBiome(x >> 2, y >> 2, z >> 2, CraftBlock.biomeToBiomeBase(bio)); + biome.setBiome(x >> 2, y >> 2, z >> 2, CraftBlock.biomeToBiomeBase((IRegistry) biome.g, bio)); } } diff --git a/paper-server/src/test/java/org/bukkit/BiomeTest.java b/paper-server/src/test/java/org/bukkit/BiomeTest.java index 04a11b6927..c971e0a1aa 100644 --- a/paper-server/src/test/java/org/bukkit/BiomeTest.java +++ b/paper-server/src/test/java/org/bukkit/BiomeTest.java @@ -13,14 +13,14 @@ public class BiomeTest extends AbstractTestingBase { @Test public void testBukkitToMinecraft() { for (Biome biome : Biome.values()) { - Assert.assertNotNull("No NMS mapping for " + biome, CraftBlock.biomeToBiomeBase(biome)); + Assert.assertNotNull("No NMS mapping for " + biome, CraftBlock.biomeToBiomeBase(RegistryGeneration.WORLDGEN_BIOME, biome)); } } @Test public void testMinecraftToBukkit() { for (Object biome : RegistryGeneration.WORLDGEN_BIOME) { - Assert.assertNotNull("No Bukkit mapping for " + biome, CraftBlock.biomeBaseToBiome((BiomeBase) biome)); + Assert.assertNotNull("No Bukkit mapping for " + biome, CraftBlock.biomeBaseToBiome(RegistryGeneration.WORLDGEN_BIOME, (BiomeBase) biome)); } } }