aboutsummaryrefslogtreecommitdiffhomepage
path: root/Spigot-Server-Patches/0714-More-World-API.patch
blob: 88a8d987c6720bb7cde002088e5b40f37a473d34 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Jake Potrebic <jake.m.potrebic@gmail.com>
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 bea183ba796f2acf5465ad91e4e7fe3e73c9da74..47fbb8df04b2b77e10314666e87eaef621cffb3b 100644
--- a/src/main/java/net/minecraft/server/level/WorldServer.java
+++ b/src/main/java/net/minecraft/server/level/WorldServer.java
@@ -1870,6 +1870,7 @@ 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) -> {
@@ -1892,6 +1893,7 @@ 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 72bc1a1e1c2153550313e93cf7df901a514a9bef..be6d63bcf15027e02a0bfbee0792c24f2300b27e 100644
--- a/src/main/java/net/minecraft/world/level/dimension/DimensionManager.java
+++ b/src/main/java/net/minecraft/world/level/dimension/DimensionManager.java
@@ -142,10 +142,10 @@ public class DimensionManager {
     public static IRegistryCustom.Dimension a(IRegistryCustom.Dimension iregistrycustom_dimension) {
         IRegistryWritable<DimensionManager> 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;
     }
 
@@ -164,10 +164,10 @@ public class DimensionManager {
     public static RegistryMaterials<WorldDimension> a(IRegistry<DimensionManager> iregistry, IRegistry<BiomeBase> iregistry1, IRegistry<GeneratorSettingBase> iregistry2, long i) {
         RegistryMaterials<WorldDimension> 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;
@@ -256,6 +256,7 @@ public class DimensionManager {
         return this.E[i];
     }
 
+    public Tag<Block> getInfiniburnTag() { return o(); } // Paper - OBFHELPER
     public Tag<Block> o() {
         Tag<Block> 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 6c2a4607028c61e4a01ff200d301878e2d63b456..80de9f687d9acd7425e7c8a453c2759450869497 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
@@ -2533,6 +2533,75 @@ 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<org.bukkit.Material> 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");