Paper/patches/server/0698-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-04-24 22:05:42 +02:00
index 4932ba59a6b70b405f7dd05358f6bb00b629d34c..d1c265733941874002f6dfc7543917af88600659 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
@@ -76,6 +76,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
2023-12-06 17:00:26 +01:00
index 068b3735b6c50a7a2053c7dc39856f728fb7218a..6d10396347b69d9243ab902ecc68ede93fa17b7d 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-04-26 03:51:28 +02:00
index 7d6ee60b1d3e023e1eabc59eb591c3ae3d8ac043..eaa9ba70b0b80d86eb376a0641420093a7c9dfdb 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
@@ -165,6 +165,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);