Co-authored-by: Bjarne Koll <git@lynxplay.dev>
Co-authored-by: Jake Potrebic <jake.m.potrebic@gmail.com>
Co-authored-by: Lulu13022002 <41980282+Lulu13022002@users.noreply.github.com>
Co-authored-by: MiniDigger | Martin <admin@minidigger.dev>
Co-authored-by: Nassim Jahnke <nassim@njahnke.dev>
Co-authored-by: Noah van der Aa <ndvdaa@gmail.com>
Co-authored-by: Owen1212055 <23108066+Owen1212055@users.noreply.github.com>
Co-authored-by: Shane Freeder <theboyetronic@gmail.com>
Co-authored-by: Spottedleaf <Spottedleaf@users.noreply.github.com>
Co-authored-by: Tamion <70228790+notTamion@users.noreply.github.com>
Co-authored-by: Warrior <50800980+Warriorrrr@users.noreply.github.com>
This commit is contained in:
Nassim Jahnke
2025-04-12 17:26:44 +02:00
parent 0767902699
commit f00727c57e
2092 changed files with 50551 additions and 48729 deletions

View File

@@ -5,7 +5,6 @@ import com.google.common.base.Predicates;
import java.util.function.Predicate;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Holder;
import net.minecraft.core.Registry;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.chunk.PalettedContainer;
import net.minecraft.world.level.chunk.PalettedContainerRO;
@@ -15,7 +14,6 @@ import org.bukkit.Material;
import org.bukkit.block.Biome;
import org.bukkit.block.data.BlockData;
import org.bukkit.craftbukkit.block.CraftBiome;
import org.bukkit.craftbukkit.block.CraftBlockType;
import org.bukkit.craftbukkit.block.data.CraftBlockData;
import org.bukkit.craftbukkit.util.CraftMagicNumbers;
@@ -26,30 +24,28 @@ import org.bukkit.craftbukkit.util.CraftMagicNumbers;
public class CraftChunkSnapshot implements ChunkSnapshot {
private final int x, z;
private final int minHeight, maxHeight, seaLevel;
private final String worldname;
private final PalettedContainer<BlockState>[] blockids;
private final String worldName;
private final PalettedContainer<BlockState>[] blockIds;
private final byte[][] skylight;
private final byte[][] emitlight;
private final byte[][] emitLight;
private final boolean[] empty;
private final Heightmap hmap; // Height map
private final long captureFulltime;
private final Registry<net.minecraft.world.level.biome.Biome> biomeRegistry;
private final Heightmap heightmap; // Height map
private final long captureFullTime;
private final PalettedContainerRO<Holder<net.minecraft.world.level.biome.Biome>>[] biome;
CraftChunkSnapshot(int x, int z, int minHeight, int maxHeight, int seaLevel, String wname, long wtime, PalettedContainer<BlockState>[] sectionBlockIDs, byte[][] sectionSkyLights, byte[][] sectionEmitLights, boolean[] sectionEmpty, Heightmap hmap, Registry<net.minecraft.world.level.biome.Biome> biomeRegistry, PalettedContainerRO<Holder<net.minecraft.world.level.biome.Biome>>[] biome) {
CraftChunkSnapshot(int x, int z, int minHeight, int maxHeight, int seaLevel, String worldName, long fullTime, PalettedContainer<BlockState>[] sectionBlockIDs, byte[][] sectionSkyLights, byte[][] sectionEmitLights, boolean[] sectionEmpty, Heightmap heightmap, PalettedContainerRO<Holder<net.minecraft.world.level.biome.Biome>>[] biome) {
this.x = x;
this.z = z;
this.minHeight = minHeight;
this.maxHeight = maxHeight;
this.seaLevel = seaLevel;
this.worldname = wname;
this.captureFulltime = wtime;
this.blockids = sectionBlockIDs;
this.worldName = worldName;
this.captureFullTime = fullTime;
this.blockIds = sectionBlockIDs;
this.skylight = sectionSkyLights;
this.emitlight = sectionEmitLights;
this.emitLight = sectionEmitLights;
this.empty = sectionEmpty;
this.hmap = hmap;
this.biomeRegistry = biomeRegistry;
this.heightmap = heightmap;
this.biome = biome;
}
@@ -65,16 +61,16 @@ public class CraftChunkSnapshot implements ChunkSnapshot {
@Override
public String getWorldName() {
return this.worldname;
return this.worldName;
}
@Override
public boolean contains(BlockData block) {
Preconditions.checkArgument(block != null, "Block cannot be null");
Predicate<BlockState> nms = Predicates.equalTo(((CraftBlockData) block).getState());
for (PalettedContainer<BlockState> palette : this.blockids) {
if (palette.maybeHas(nms)) {
Predicate<BlockState> filter = Predicates.equalTo(((CraftBlockData) block).getState());
for (PalettedContainer<BlockState> palette : this.blockIds) {
if (palette.maybeHas(filter)) {
return true;
}
}
@@ -86,9 +82,9 @@ public class CraftChunkSnapshot implements ChunkSnapshot {
public boolean contains(Biome biome) {
Preconditions.checkArgument(biome != null, "Biome cannot be null");
Predicate<Holder<net.minecraft.world.level.biome.Biome>> nms = Predicates.equalTo(CraftBiome.bukkitToMinecraftHolder(biome));
Predicate<Holder<net.minecraft.world.level.biome.Biome>> filter = Predicates.equalTo(CraftBiome.bukkitToMinecraftHolder(biome));
for (PalettedContainerRO<Holder<net.minecraft.world.level.biome.Biome>> palette : this.biome) {
if (palette.maybeHas(nms)) {
if (palette.maybeHas(filter)) {
return true;
}
}
@@ -100,21 +96,21 @@ public class CraftChunkSnapshot implements ChunkSnapshot {
public Material getBlockType(int x, int y, int z) {
this.validateChunkCoordinates(x, y, z);
return this.blockids[this.getSectionIndex(y)].get(x, y & 0xF, z).getBukkitMaterial(); // Paper - optimise getType calls
return this.blockIds[this.getSectionIndex(y)].get(x, y & 0xF, z).getBukkitMaterial(); // Paper - optimise get calls
}
@Override
public final BlockData getBlockData(int x, int y, int z) {
this.validateChunkCoordinates(x, y, z);
return CraftBlockData.fromData(this.blockids[this.getSectionIndex(y)].get(x, y & 0xF, z));
return CraftBlockData.fromData(this.blockIds[this.getSectionIndex(y)].get(x, y & 0xF, z));
}
@Override
public final int getData(int x, int y, int z) {
this.validateChunkCoordinates(x, y, z);
return CraftMagicNumbers.toLegacyData(this.blockids[this.getSectionIndex(y)].get(x, y & 0xF, z));
return CraftMagicNumbers.toLegacyData(this.blockIds[this.getSectionIndex(y)].get(x, y & 0xF, z));
}
@Override
@@ -128,19 +124,19 @@ public class CraftChunkSnapshot implements ChunkSnapshot {
@Override
public final int getBlockEmittedLight(int x, int y, int z) {
Preconditions.checkState(this.emitlight != null, "ChunkSnapshot created without light data. Please call getSnapshot with includeLightData=true"); // Paper - Add getChunkSnapshot includeLightData parameter
Preconditions.checkState(this.emitLight != null, "ChunkSnapshot created without light data. Please call getSnapshot with includeLightData=true"); // Paper - Add getChunkSnapshot includeLightData parameter
this.validateChunkCoordinates(x, y, z);
int off = ((y & 0xF) << 7) | (z << 3) | (x >> 1);
return (this.emitlight[this.getSectionIndex(y)][off] >> ((x & 1) << 2)) & 0xF;
return (this.emitLight[this.getSectionIndex(y)][off] >> ((x & 1) << 2)) & 0xF;
}
@Override
public final int getHighestBlockYAt(int x, int z) {
Preconditions.checkState(this.hmap != null, "ChunkSnapshot created without height map. Please call getSnapshot with includeMaxblocky=true");
Preconditions.checkState(this.heightmap != null, "ChunkSnapshot created without height map. Please call getSnapshot with includeMaxblocky=true");
this.validateChunkCoordinates(x, 0, z);
return this.hmap.getHighestTaken(x, z);
return this.heightmap.getHighestTaken(x, z);
}
@Override
@@ -173,7 +169,7 @@ public class CraftChunkSnapshot implements ChunkSnapshot {
@Override
public final long getCaptureFullTime() {
return this.captureFulltime;
return this.captureFullTime;
}
@Override