From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: Jake Potrebic Date: Tue, 7 Jul 2020 10:52:34 -0700 Subject: [PATCH] More World API diff --git a/src/main/java/net/minecraft/server/level/WorldServer.java b/src/main/java/net/minecraft/server/level/WorldServer.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/net/minecraft/server/level/WorldServer.java +++ b/src/main/java/net/minecraft/server/level/WorldServer.java @@ -0,0 +0,0 @@ public class WorldServer extends World implements GeneratorAccessSeed { return !this.worldDataServer.getGeneratorSettings().shouldGenerateMapFeatures() ? null : this.getChunkProvider().getChunkGenerator().findNearestMapFeature(this, structuregenerator, blockposition, i, flag); // CraftBukkit } + public BlockPosition getNearestBiome(BiomeBase biomeBase, BlockPosition blockPosition, int radius, int step) { return this.a(biomeBase, blockPosition, radius, step); } // Paper - OBFHELPER @Nullable public BlockPosition a(BiomeBase biomebase, BlockPosition blockposition, int i, int j) { return this.getChunkProvider().getChunkGenerator().getWorldChunkManager().a(blockposition.getX(), blockposition.getY(), blockposition.getZ(), i, j, (biomebase1) -> { @@ -0,0 +0,0 @@ public class WorldServer extends World implements GeneratorAccessSeed { return this.savingDisabled; } + public IRegistryCustom getWorldCustomRegistry() { return r(); } // Paper - OBFHELPER @Override public IRegistryCustom r() { return this.server.getCustomRegistry(); diff --git a/src/main/java/net/minecraft/world/level/dimension/DimensionManager.java b/src/main/java/net/minecraft/world/level/dimension/DimensionManager.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/net/minecraft/world/level/dimension/DimensionManager.java +++ b/src/main/java/net/minecraft/world/level/dimension/DimensionManager.java @@ -0,0 +0,0 @@ public class DimensionManager { public static IRegistryCustom.Dimension a(IRegistryCustom.Dimension iregistrycustom_dimension) { IRegistryWritable iregistrywritable = iregistrycustom_dimension.b(IRegistry.K); - iregistrywritable.a(DimensionManager.OVERWORLD, (Object) DimensionManager.OVERWORLD_IMPL, Lifecycle.stable()); - iregistrywritable.a(DimensionManager.l, (Object) DimensionManager.m, Lifecycle.stable()); - iregistrywritable.a(DimensionManager.THE_NETHER, (Object) DimensionManager.THE_NETHER_IMPL, Lifecycle.stable()); - iregistrywritable.a(DimensionManager.THE_END, (Object) DimensionManager.THE_END_IMPL, Lifecycle.stable()); + iregistrywritable.a(DimensionManager.OVERWORLD, DimensionManager.OVERWORLD_IMPL, Lifecycle.stable()); // Paper - decompile fix + iregistrywritable.a(DimensionManager.l, DimensionManager.m, Lifecycle.stable()); // Paper - decompile fix + iregistrywritable.a(DimensionManager.THE_NETHER, DimensionManager.THE_NETHER_IMPL, Lifecycle.stable()); // Paper - decompile fix + iregistrywritable.a(DimensionManager.THE_END, DimensionManager.THE_END_IMPL, Lifecycle.stable()); // Paper - decompile fix return iregistrycustom_dimension; } @@ -0,0 +0,0 @@ public class DimensionManager { public static RegistryMaterials a(IRegistry iregistry, IRegistry iregistry1, IRegistry iregistry2, long i) { RegistryMaterials registrymaterials = new RegistryMaterials<>(IRegistry.M, Lifecycle.experimental()); - registrymaterials.a(WorldDimension.THE_NETHER, (Object) (new WorldDimension(() -> { + registrymaterials.a(WorldDimension.THE_NETHER, (new WorldDimension(() -> { // Paper - decompile fix return (DimensionManager) iregistry.d(DimensionManager.THE_NETHER); }, b(iregistry1, iregistry2, i))), Lifecycle.stable()); - registrymaterials.a(WorldDimension.THE_END, (Object) (new WorldDimension(() -> { + registrymaterials.a(WorldDimension.THE_END, (new WorldDimension(() -> { // Paper - decompile fix return (DimensionManager) iregistry.d(DimensionManager.THE_END); }, a(iregistry1, iregistry2, i))), Lifecycle.stable()); return registrymaterials; @@ -0,0 +0,0 @@ public class DimensionManager { return this.E[i]; } + public Tag getInfiniburnTag() { return o(); } // Paper - OBFHELPER public Tag o() { Tag tag = TagsBlock.a().a(this.infiniburn); diff --git a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java @@ -0,0 +0,0 @@ public class CraftWorld implements World { return (nearest == null) ? null : new Location(this, nearest.getX(), nearest.getY(), nearest.getZ()); } + // Paper start + @Override + public Location locateNearestBiome(Location origin, Biome biome, int radius) { + return this.locateNearestBiome(origin, biome, radius, 8); + } + + @Override + public Location locateNearestBiome(Location origin, Biome biome, int radius, int step) { + BlockPosition originPos = new BlockPosition(origin.getX(), origin.getY(), origin.getZ()); + BlockPosition nearest = getHandle().getNearestBiome(CraftBlock.biomeToBiomeBase(getHandle().getWorldCustomRegistry().b(IRegistry.ay), biome), originPos, radius, step); + return (nearest == null) ? null : new Location(this, nearest.getX(), nearest.getY(), nearest.getZ()); + } + + @Override + public boolean isUltrawarm() { + return getHandle().getDimensionManager().isNether(); + } + + @Override + public boolean isNatural() { + return getHandle().getDimensionManager().isNatural(); + } + + @Override + public double getCoordinateScale() { + return getHandle().getDimensionManager().getCoordinateScale(); + } + + @Override + public boolean hasSkylight() { + return getHandle().getDimensionManager().hasSkyLight(); + } + + @Override + public boolean hasBedrockCeiling() { + return getHandle().getDimensionManager().hasSkyLight(); + } + + @Override + public boolean isPiglinSafe() { + return getHandle().getDimensionManager().isPiglinSafe(); + } + + @Override + public boolean doesBedWork() { + return getHandle().getDimensionManager().isBedWorks(); + } + + @Override + public boolean doesRespawnAnchorWork() { + return getHandle().getDimensionManager().isRespawnAnchorWorks(); + } + + @Override + public boolean hasRaids() { + return getHandle().getDimensionManager().hasRaids(); + } + + @Override + public boolean isFixedTime() { + return getHandle().getDimensionManager().isFixedTime(); + } + + @Override + public Collection getInfiniburn() { + return com.google.common.collect.Sets.newHashSet(com.google.common.collect.Iterators.transform(getHandle().getDimensionManager().getInfiniburnTag().getTagged().iterator(), CraftMagicNumbers::getMaterial)); + } + // Paper end + @Override public Raid locateNearestRaid(Location location, int radius) { Validate.notNull(location, "Location cannot be null");