13
0
geforkt von Mirrors/Paper

SPIGOT-7214: Add CraftChunk and CraftChunkSnapshot contains biome method

By: md_5 <git@md-5.net>
Dieser Commit ist enthalten in:
CraftBukkit/Spigot 2023-01-28 11:49:46 +11:00
Ursprung 3b6d547a25
Commit cbc24baf79
2 geänderte Dateien mit 29 neuen und 0 gelöschten Zeilen

Datei anzeigen

@ -40,6 +40,7 @@ import net.minecraft.world.level.lighting.LightEngine;
import org.bukkit.Chunk; import org.bukkit.Chunk;
import org.bukkit.ChunkSnapshot; import org.bukkit.ChunkSnapshot;
import org.bukkit.World; import org.bukkit.World;
import org.bukkit.block.Biome;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import org.bukkit.block.BlockState; import org.bukkit.block.BlockState;
import org.bukkit.block.data.BlockData; import org.bukkit.block.data.BlockData;
@ -281,6 +282,20 @@ public class CraftChunk implements Chunk {
return false; return false;
} }
@Override
public boolean contains(Biome biome) {
Preconditions.checkArgument(biome != null, "Biome cannot be null");
Predicate<Holder<BiomeBase>> nms = Predicates.equalTo(CraftBlock.biomeToBiomeBase(getHandle().biomeRegistry, biome));
for (ChunkSection section : getHandle().getSections()) {
if (section != null && section.getBiomes().maybeHas(nms)) {
return true;
}
}
return false;
}
@Override @Override
public ChunkSnapshot getChunkSnapshot() { public ChunkSnapshot getChunkSnapshot() {
return getChunkSnapshot(true, false, false); return getChunkSnapshot(true, false, false);

Datei anzeigen

@ -81,6 +81,20 @@ public class CraftChunkSnapshot implements ChunkSnapshot {
return false; return false;
} }
@Override
public boolean contains(Biome biome) {
Preconditions.checkArgument(biome != null, "Biome cannot be null");
Predicate<Holder<BiomeBase>> nms = Predicates.equalTo(CraftBlock.biomeToBiomeBase(this.biomeRegistry, biome));
for (PalettedContainerRO<Holder<BiomeBase>> palette : this.biome) {
if (palette.maybeHas(nms)) {
return true;
}
}
return false;
}
@Override @Override
public Material getBlockType(int x, int y, int z) { public Material getBlockType(int x, int y, int z) {
validateChunkCoordinates(x, y, z); validateChunkCoordinates(x, y, z);