Paper/patches/server/0673-Implement-getComputedBiome-API.patch

62 lines
3.0 KiB
Diff
Raw Normal View History

2022-03-15 19:38:36 +01:00
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Jason Penilla <11360596+jpenilla@users.noreply.github.com>
Date: Mon, 14 Mar 2022 22:46:05 -0700
Subject: [PATCH] Implement getComputedBiome API
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftRegionAccessor.java b/src/main/java/org/bukkit/craftbukkit/CraftRegionAccessor.java
2024-10-24 19:29:35 +02:00
index ca35e93239eea09b3d0dc6ef18f58743e633996b..a7748f4b7c5a1630937c702b3fd5fded93793d64 100644
2022-03-15 19:38:36 +01:00
--- a/src/main/java/org/bukkit/craftbukkit/CraftRegionAccessor.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftRegionAccessor.java
2024-06-14 03:30:23 +02:00
@@ -77,6 +77,13 @@ public abstract class CraftRegionAccessor implements RegionAccessor {
return CraftBiome.minecraftHolderToBukkit(this.getHandle().getNoiseBiome(x >> 2, y >> 2, z >> 2));
2022-03-15 19:38:36 +01:00
}
+ // Paper start
+ @Override
+ public Biome getComputedBiome(int x, int y, int z) {
+ return CraftBiome.minecraftHolderToBukkit(this.getHandle().getBiome(new BlockPos(x, y, z)));
2022-03-15 19:38:36 +01:00
+ }
+ // Paper end
+
@Override
public void setBiome(Location location, Biome biome) {
this.setBiome(location.getBlockX(), location.getBlockY(), location.getBlockZ(), biome);
diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java b/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java
2024-10-23 22:52:43 +02:00
index d5b495b5a3ca7f4411d1a700f7149042a16509f1..68fcec085334383808b2117a49220f4d8239220b 100644
2022-03-15 19:38:36 +01:00
--- a/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java
+++ b/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java
2023-12-06 17:00:26 +01:00
@@ -340,6 +340,13 @@ public class CraftBlock implements Block {
2022-03-15 19:38:36 +01:00
return this.getWorld().getBiome(this.getX(), this.getY(), this.getZ());
}
+ // Paper start
+ @Override
+ public Biome getComputedBiome() {
+ return this.getWorld().getComputedBiome(this.getX(), this.getY(), this.getZ());
+ }
+ // Paper end
+
@Override
public void setBiome(Biome bio) {
this.getWorld().setBiome(this.getX(), this.getY(), this.getZ(), bio);
diff --git a/src/main/java/org/bukkit/craftbukkit/generator/CraftLimitedRegion.java b/src/main/java/org/bukkit/craftbukkit/generator/CraftLimitedRegion.java
2024-10-23 22:52:43 +02:00
index 2c7b64bd7071cb803a042152d497982d753e0b5d..a23269e3bdb83f85a1d08d5f7b54742025223ada 100644
2022-03-15 19:38:36 +01:00
--- a/src/main/java/org/bukkit/craftbukkit/generator/CraftLimitedRegion.java
+++ b/src/main/java/org/bukkit/craftbukkit/generator/CraftLimitedRegion.java
2024-10-23 22:52:43 +02:00
@@ -166,6 +166,14 @@ public class CraftLimitedRegion extends CraftRegionAccessor implements LimitedRe
2022-03-15 19:38:36 +01:00
return super.getBiome(x, y, z);
}
+ // Paper start
+ @Override
+ public Biome getComputedBiome(int x, int y, int z) {
+ Preconditions.checkArgument(this.isInRegion(x, y, z), "Coordinates %s, %s, %s are not in the region", x, y, z);
+ return super.getComputedBiome(x, y, z);
+ }
+ // Paper end
+
@Override
public void setBiome(int x, int y, int z, Holder<net.minecraft.world.level.biome.Biome> biomeBase) {
Preconditions.checkArgument(this.isInRegion(x, y, z), "Coordinates %s, %s, %s are not in the region", x, y, z);