mirror of
https://github.com/PaperMC/Paper.git
synced 2025-01-05 02:22:12 +01:00
SPIGOT-6064: world.getBiome() null Error
This commit is contained in:
parent
9f12e29b71
commit
2ee7318ae1
7 changed files with 26 additions and 15 deletions
|
@ -1,5 +1,14 @@
|
||||||
--- a/net/minecraft/server/BiomeStorage.java
|
--- a/net/minecraft/server/BiomeStorage.java
|
||||||
+++ b/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<BiomeBase> g;
|
||||||
|
+ public final Registry<BiomeBase> g; // PAIL
|
||||||
|
private final BiomeBase[] h;
|
||||||
|
|
||||||
|
public BiomeStorage(Registry<BiomeBase> registry, BiomeBase[] abiomebase) {
|
||||||
@@ -87,4 +87,14 @@
|
@@ -87,4 +87,14 @@
|
||||||
|
|
||||||
return this.h[i1 << BiomeStorage.e + BiomeStorage.e | j1 << BiomeStorage.e | l];
|
return this.h[i1 << BiomeStorage.e + BiomeStorage.e | j1 << BiomeStorage.e | l];
|
||||||
|
|
|
@ -211,7 +211,7 @@
|
||||||
+
|
+
|
||||||
+ org.bukkit.generator.ChunkGenerator gen = this.server.getGenerator(name);
|
+ org.bukkit.generator.ChunkGenerator gen = this.server.getGenerator(name);
|
||||||
+
|
+
|
||||||
+ IRegistryCustom.Dimension iregistrycustom_dimension = IRegistryCustom.b();
|
+ IRegistryCustom.Dimension iregistrycustom_dimension = this.f;
|
||||||
+
|
+
|
||||||
+ RegistryReadOps<NBTBase> registryreadops = RegistryReadOps.a((DynamicOps) DynamicOpsNBT.a, this.dataPackResources.h(), iregistrycustom_dimension);
|
+ RegistryReadOps<NBTBase> registryreadops = RegistryReadOps.a((DynamicOps) DynamicOpsNBT.a, this.dataPackResources.h(), iregistrycustom_dimension);
|
||||||
+ worlddata = (WorldDataServer) worldSession.a((DynamicOps) registryreadops, datapackconfiguration);
|
+ worlddata = (WorldDataServer) worldSession.a((DynamicOps) registryreadops, datapackconfiguration);
|
||||||
|
|
|
@ -3,11 +3,13 @@ package org.bukkit.craftbukkit;
|
||||||
import com.google.common.base.Preconditions;
|
import com.google.common.base.Preconditions;
|
||||||
import com.google.common.base.Predicates;
|
import com.google.common.base.Predicates;
|
||||||
import java.util.function.Predicate;
|
import java.util.function.Predicate;
|
||||||
|
import net.minecraft.server.BiomeBase;
|
||||||
import net.minecraft.server.BiomeStorage;
|
import net.minecraft.server.BiomeStorage;
|
||||||
import net.minecraft.server.BlockPosition;
|
import net.minecraft.server.BlockPosition;
|
||||||
import net.minecraft.server.DataPaletteBlock;
|
import net.minecraft.server.DataPaletteBlock;
|
||||||
import net.minecraft.server.HeightMap;
|
import net.minecraft.server.HeightMap;
|
||||||
import net.minecraft.server.IBlockData;
|
import net.minecraft.server.IBlockData;
|
||||||
|
import net.minecraft.server.IRegistry;
|
||||||
import org.bukkit.ChunkSnapshot;
|
import org.bukkit.ChunkSnapshot;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.block.Biome;
|
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");
|
Preconditions.checkState(biome != null, "ChunkSnapshot created without biome. Please call getSnapshot with includeBiome=true");
|
||||||
CraftChunk.validateChunkCoordinates(x, y, z);
|
CraftChunk.validateChunkCoordinates(x, y, z);
|
||||||
|
|
||||||
return CraftBlock.biomeBaseToBiome(biome.getBiome(x >> 2, y >> 2, z >> 2));
|
return CraftBlock.biomeBaseToBiome((IRegistry<BiomeBase>) biome.g, biome.getBiome(x >> 2, y >> 2, z >> 2));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -72,6 +72,7 @@ import net.minecraft.server.GameRules;
|
||||||
import net.minecraft.server.GroupDataEntity;
|
import net.minecraft.server.GroupDataEntity;
|
||||||
import net.minecraft.server.IBlockData;
|
import net.minecraft.server.IBlockData;
|
||||||
import net.minecraft.server.IChunkAccess;
|
import net.minecraft.server.IChunkAccess;
|
||||||
|
import net.minecraft.server.IRegistry;
|
||||||
import net.minecraft.server.MinecraftKey;
|
import net.minecraft.server.MinecraftKey;
|
||||||
import net.minecraft.server.MovingObjectPosition;
|
import net.minecraft.server.MovingObjectPosition;
|
||||||
import net.minecraft.server.PacketPlayOutCustomSoundEffect;
|
import net.minecraft.server.PacketPlayOutCustomSoundEffect;
|
||||||
|
@ -88,9 +89,6 @@ import net.minecraft.server.Ticket;
|
||||||
import net.minecraft.server.TicketType;
|
import net.minecraft.server.TicketType;
|
||||||
import net.minecraft.server.Unit;
|
import net.minecraft.server.Unit;
|
||||||
import net.minecraft.server.Vec3D;
|
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 net.minecraft.server.WorldServer;
|
||||||
import org.apache.commons.lang.Validate;
|
import org.apache.commons.lang.Validate;
|
||||||
import org.bukkit.BlockChangeDelegate;
|
import org.bukkit.BlockChangeDelegate;
|
||||||
|
@ -920,7 +918,7 @@ public class CraftWorld implements World {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Biome getBiome(int x, int y, int z) {
|
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
|
@Override
|
||||||
|
@ -932,7 +930,7 @@ public class CraftWorld implements World {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setBiome(int x, int y, int z, Biome bio) {
|
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);
|
BlockPosition pos = new BlockPosition(x, 0, z);
|
||||||
if (this.world.isLoaded(pos)) {
|
if (this.world.isLoaded(pos)) {
|
||||||
net.minecraft.server.Chunk chunk = this.world.getChunkAtWorldCoords(pos);
|
net.minecraft.server.Chunk chunk = this.world.getChunkAtWorldCoords(pos);
|
||||||
|
|
|
@ -29,6 +29,7 @@ import org.bukkit.Chunk;
|
||||||
import org.bukkit.FluidCollisionMode;
|
import org.bukkit.FluidCollisionMode;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.Registry;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.bukkit.block.Biome;
|
import org.bukkit.block.Biome;
|
||||||
import org.bukkit.block.Block;
|
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.entity.CraftEntity;
|
||||||
import org.bukkit.craftbukkit.inventory.CraftItemStack;
|
import org.bukkit.craftbukkit.inventory.CraftItemStack;
|
||||||
import org.bukkit.craftbukkit.util.CraftMagicNumbers;
|
import org.bukkit.craftbukkit.util.CraftMagicNumbers;
|
||||||
|
import org.bukkit.craftbukkit.util.CraftNamespacedKey;
|
||||||
import org.bukkit.craftbukkit.util.CraftRayTraceResult;
|
import org.bukkit.craftbukkit.util.CraftRayTraceResult;
|
||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
@ -488,20 +490,20 @@ public class CraftBlock implements Block {
|
||||||
getWorld().setBiome(getX(), getY(), getZ(), bio);
|
getWorld().setBiome(getX(), getY(), getZ(), bio);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Biome biomeBaseToBiome(BiomeBase base) {
|
public static Biome biomeBaseToBiome(IRegistry<BiomeBase> registry, BiomeBase base) {
|
||||||
if (base == null) {
|
if (base == null) {
|
||||||
return 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<BiomeBase> registry, Biome bio) {
|
||||||
if (bio == null) {
|
if (bio == null) {
|
||||||
return 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
|
@Override
|
||||||
|
|
|
@ -67,12 +67,12 @@ public class CustomChunkGenerator extends InternalChunkGenerator {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Biome getBiome(int x, int y, int z) {
|
public Biome getBiome(int x, int y, int z) {
|
||||||
return CraftBlock.biomeBaseToBiome(biome.getBiome(x >> 2, y >> 2, z >> 2));
|
return CraftBlock.biomeBaseToBiome((IRegistry<BiomeBase>) biome.g, biome.getBiome(x >> 2, y >> 2, z >> 2));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setBiome(int x, int y, int z, Biome bio) {
|
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<BiomeBase>) biome.g, bio));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -13,14 +13,14 @@ public class BiomeTest extends AbstractTestingBase {
|
||||||
@Test
|
@Test
|
||||||
public void testBukkitToMinecraft() {
|
public void testBukkitToMinecraft() {
|
||||||
for (Biome biome : Biome.values()) {
|
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
|
@Test
|
||||||
public void testMinecraftToBukkit() {
|
public void testMinecraftToBukkit() {
|
||||||
for (Object biome : RegistryGeneration.WORLDGEN_BIOME) {
|
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));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue