Remap CraftBukkit to Mojang+Yarn Mappings

By: Initial Source <noreply+automated@papermc.io>
This commit is contained in:
CraftBukkit/Spigot
2024-12-11 22:26:55 +01:00
parent a265d64138
commit 30e4583dbe
1780 changed files with 44628 additions and 41274 deletions

View File

@@ -3,14 +3,13 @@ package org.bukkit.craftbukkit;
import com.google.common.base.Preconditions;
import com.google.common.base.Predicates;
import java.util.function.Predicate;
import net.minecraft.core.BlockPosition;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Holder;
import net.minecraft.core.IRegistry;
import net.minecraft.world.level.biome.BiomeBase;
import net.minecraft.world.level.block.state.IBlockData;
import net.minecraft.world.level.chunk.DataPaletteBlock;
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;
import net.minecraft.world.level.levelgen.HeightMap;
import net.minecraft.world.level.levelgen.Heightmap;
import org.bukkit.ChunkSnapshot;
import org.bukkit.Material;
import org.bukkit.block.Biome;
@@ -28,16 +27,16 @@ public class CraftChunkSnapshot implements ChunkSnapshot {
private final int x, z;
private final int minHeight, maxHeight, seaLevel;
private final String worldname;
private final DataPaletteBlock<IBlockData>[] blockids;
private final PalettedContainer<BlockState>[] blockids;
private final byte[][] skylight;
private final byte[][] emitlight;
private final boolean[] empty;
private final HeightMap hmap; // Height map
private final Heightmap hmap; // Height map
private final long captureFulltime;
private final IRegistry<BiomeBase> biomeRegistry;
private final PalettedContainerRO<Holder<BiomeBase>>[] biome;
private final Registry<net.minecraft.world.level.biome.Biome> biomeRegistry;
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, DataPaletteBlock<IBlockData>[] sectionBlockIDs, byte[][] sectionSkyLights, byte[][] sectionEmitLights, boolean[] sectionEmpty, HeightMap hmap, IRegistry<BiomeBase> biomeRegistry, PalettedContainerRO<Holder<BiomeBase>>[] 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) {
this.x = x;
this.z = z;
this.minHeight = minHeight;
@@ -56,25 +55,25 @@ public class CraftChunkSnapshot implements ChunkSnapshot {
@Override
public int getX() {
return x;
return this.x;
}
@Override
public int getZ() {
return z;
return this.z;
}
@Override
public String getWorldName() {
return worldname;
return this.worldname;
}
@Override
public boolean contains(BlockData block) {
Preconditions.checkArgument(block != null, "Block cannot be null");
Predicate<IBlockData> nms = Predicates.equalTo(((CraftBlockData) block).getState());
for (DataPaletteBlock<IBlockData> palette : blockids) {
Predicate<BlockState> nms = Predicates.equalTo(((CraftBlockData) block).getState());
for (PalettedContainer<BlockState> palette : this.blockids) {
if (palette.maybeHas(nms)) {
return true;
}
@@ -87,8 +86,8 @@ public class CraftChunkSnapshot implements ChunkSnapshot {
public boolean contains(Biome biome) {
Preconditions.checkArgument(biome != null, "Biome cannot be null");
Predicate<Holder<BiomeBase>> nms = Predicates.equalTo(CraftBiome.bukkitToMinecraftHolder(biome));
for (PalettedContainerRO<Holder<BiomeBase>> palette : this.biome) {
Predicate<Holder<net.minecraft.world.level.biome.Biome>> nms = Predicates.equalTo(CraftBiome.bukkitToMinecraftHolder(biome));
for (PalettedContainerRO<Holder<net.minecraft.world.level.biome.Biome>> palette : this.biome) {
if (palette.maybeHas(nms)) {
return true;
}
@@ -99,92 +98,92 @@ public class CraftChunkSnapshot implements ChunkSnapshot {
@Override
public Material getBlockType(int x, int y, int z) {
validateChunkCoordinates(x, y, z);
this.validateChunkCoordinates(x, y, z);
return CraftBlockType.minecraftToBukkit(blockids[getSectionIndex(y)].get(x, y & 0xF, z).getBlock());
return CraftBlockType.minecraftToBukkit(this.blockids[this.getSectionIndex(y)].get(x, y & 0xF, z).getBlock());
}
@Override
public final BlockData getBlockData(int x, int y, int z) {
validateChunkCoordinates(x, y, z);
this.validateChunkCoordinates(x, y, z);
return CraftBlockData.fromData(blockids[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) {
validateChunkCoordinates(x, y, z);
this.validateChunkCoordinates(x, y, z);
return CraftMagicNumbers.toLegacyData(blockids[getSectionIndex(y)].get(x, y & 0xF, z));
return CraftMagicNumbers.toLegacyData(this.blockids[this.getSectionIndex(y)].get(x, y & 0xF, z));
}
@Override
public final int getBlockSkyLight(int x, int y, int z) {
validateChunkCoordinates(x, y, z);
this.validateChunkCoordinates(x, y, z);
int off = ((y & 0xF) << 7) | (z << 3) | (x >> 1);
return (skylight[getSectionIndex(y)][off] >> ((x & 1) << 2)) & 0xF;
return (this.skylight[this.getSectionIndex(y)][off] >> ((x & 1) << 2)) & 0xF;
}
@Override
public final int getBlockEmittedLight(int x, int y, int z) {
validateChunkCoordinates(x, y, z);
this.validateChunkCoordinates(x, y, z);
int off = ((y & 0xF) << 7) | (z << 3) | (x >> 1);
return (emitlight[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(hmap != null, "ChunkSnapshot created without height map. Please call getSnapshot with includeMaxblocky=true");
validateChunkCoordinates(x, 0, z);
Preconditions.checkState(this.hmap != null, "ChunkSnapshot created without height map. Please call getSnapshot with includeMaxblocky=true");
this.validateChunkCoordinates(x, 0, z);
return hmap.getHighestTaken(x, z);
return this.hmap.getHighestTaken(x, z);
}
@Override
public final Biome getBiome(int x, int z) {
return getBiome(x, 0, z);
return this.getBiome(x, 0, z);
}
@Override
public final Biome getBiome(int x, int y, int z) {
Preconditions.checkState(biome != null, "ChunkSnapshot created without biome. Please call getSnapshot with includeBiome=true");
validateChunkCoordinates(x, y, z);
Preconditions.checkState(this.biome != null, "ChunkSnapshot created without biome. Please call getSnapshot with includeBiome=true");
this.validateChunkCoordinates(x, y, z);
PalettedContainerRO<Holder<BiomeBase>> biome = this.biome[getSectionIndex(y)]; // SPIGOT-7188: Don't need to convert y to biome coordinate scale since it is bound to the block chunk section
PalettedContainerRO<Holder<net.minecraft.world.level.biome.Biome>> biome = this.biome[this.getSectionIndex(y)]; // SPIGOT-7188: Don't need to convert y to biome coordinate scale since it is bound to the block chunk section
return CraftBiome.minecraftHolderToBukkit(biome.get(x >> 2, (y & 0xF) >> 2, z >> 2));
}
@Override
public final double getRawBiomeTemperature(int x, int z) {
return getRawBiomeTemperature(x, 0, z);
return this.getRawBiomeTemperature(x, 0, z);
}
@Override
public final double getRawBiomeTemperature(int x, int y, int z) {
Preconditions.checkState(biome != null, "ChunkSnapshot created without biome. Please call getSnapshot with includeBiome=true");
validateChunkCoordinates(x, y, z);
Preconditions.checkState(this.biome != null, "ChunkSnapshot created without biome. Please call getSnapshot with includeBiome=true");
this.validateChunkCoordinates(x, y, z);
PalettedContainerRO<Holder<BiomeBase>> biome = this.biome[getSectionIndex(y)]; // SPIGOT-7188: Don't need to convert y to biome coordinate scale since it is bound to the block chunk section
return biome.get(x >> 2, (y & 0xF) >> 2, z >> 2).value().getTemperature(new BlockPosition((this.x << 4) | x, y, (this.z << 4) | z), seaLevel);
PalettedContainerRO<Holder<net.minecraft.world.level.biome.Biome>> biome = this.biome[this.getSectionIndex(y)]; // SPIGOT-7188: Don't need to convert y to biome coordinate scale since it is bound to the block chunk section
return biome.get(x >> 2, (y & 0xF) >> 2, z >> 2).value().getTemperature(new BlockPos((this.x << 4) | x, y, (this.z << 4) | z), this.seaLevel);
}
@Override
public final long getCaptureFullTime() {
return captureFulltime;
return this.captureFulltime;
}
@Override
public final boolean isSectionEmpty(int sy) {
return empty[sy];
return this.empty[sy];
}
private int getSectionIndex(int y) {
return (y - minHeight) >> 4;
return (y - this.minHeight) >> 4;
}
private void validateChunkCoordinates(int x, int y, int z) {
CraftChunk.validateChunkCoordinates(minHeight, maxHeight, x, y, z);
CraftChunk.validateChunkCoordinates(this.minHeight, this.maxHeight, x, y, z);
}
}