Update to Minecraft 1.17

By: md_5 <git@md-5.net>
This commit is contained in:
CraftBukkit/Spigot
2021-06-11 15:00:00 +10:00
parent 75faba7fde
commit b3a8254758
619 changed files with 10708 additions and 8451 deletions

View File

@@ -24,6 +24,7 @@ import org.bukkit.craftbukkit.util.CraftMagicNumbers;
*/
public class CraftChunkSnapshot implements ChunkSnapshot {
private final int x, z;
private final int minHeight, maxHeight;
private final String worldname;
private final DataPaletteBlock<IBlockData>[] blockids;
private final byte[][] skylight;
@@ -33,9 +34,11 @@ public class CraftChunkSnapshot implements ChunkSnapshot {
private final long captureFulltime;
private final BiomeStorage biome;
CraftChunkSnapshot(int x, int z, String wname, long wtime, DataPaletteBlock<IBlockData>[] sectionBlockIDs, byte[][] sectionSkyLights, byte[][] sectionEmitLights, boolean[] sectionEmpty, HeightMap hmap, BiomeStorage biome) {
CraftChunkSnapshot(int x, int z, int minHeight, int maxHeight, String wname, long wtime, DataPaletteBlock<IBlockData>[] sectionBlockIDs, byte[][] sectionSkyLights, byte[][] sectionEmitLights, boolean[] sectionEmpty, HeightMap hmap, BiomeStorage biome) {
this.x = x;
this.z = z;
this.minHeight = minHeight;
this.maxHeight = maxHeight;
this.worldname = wname;
this.captureFulltime = wtime;
this.blockids = sectionBlockIDs;
@@ -77,45 +80,45 @@ public class CraftChunkSnapshot implements ChunkSnapshot {
@Override
public Material getBlockType(int x, int y, int z) {
CraftChunk.validateChunkCoordinates(x, y, z);
validateChunkCoordinates(x, y, z);
return CraftMagicNumbers.getMaterial(blockids[y >> 4].a(x, y & 0xF, z).getBlock());
return CraftMagicNumbers.getMaterial(blockids[getSectionIndex(y)].a(x, y & 0xF, z).getBlock());
}
@Override
public final BlockData getBlockData(int x, int y, int z) {
CraftChunk.validateChunkCoordinates(x, y, z);
validateChunkCoordinates(x, y, z);
return CraftBlockData.fromData(blockids[y >> 4].a(x, y & 0xF, z));
return CraftBlockData.fromData(blockids[getSectionIndex(y)].a(x, y & 0xF, z));
}
@Override
public final int getData(int x, int y, int z) {
CraftChunk.validateChunkCoordinates(x, y, z);
validateChunkCoordinates(x, y, z);
return CraftMagicNumbers.toLegacyData(blockids[y >> 4].a(x, y & 0xF, z));
return CraftMagicNumbers.toLegacyData(blockids[getSectionIndex(y)].a(x, y & 0xF, z));
}
@Override
public final int getBlockSkyLight(int x, int y, int z) {
CraftChunk.validateChunkCoordinates(x, y, z);
validateChunkCoordinates(x, y, z);
int off = ((y & 0xF) << 7) | (z << 3) | (x >> 1);
return (skylight[y >> 4][off] >> ((x & 1) << 2)) & 0xF;
return (skylight[getSectionIndex(y)][off] >> ((x & 1) << 2)) & 0xF;
}
@Override
public final int getBlockEmittedLight(int x, int y, int z) {
CraftChunk.validateChunkCoordinates(x, y, z);
validateChunkCoordinates(x, y, z);
int off = ((y & 0xF) << 7) | (z << 3) | (x >> 1);
return (emitlight[y >> 4][off] >> ((x & 1) << 2)) & 0xF;
return (emitlight[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");
CraftChunk.validateChunkCoordinates(x, 0, z);
validateChunkCoordinates(x, 0, z);
return hmap.a(x, z);
}
@@ -128,9 +131,9 @@ public class CraftChunkSnapshot implements ChunkSnapshot {
@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");
CraftChunk.validateChunkCoordinates(x, y, z);
validateChunkCoordinates(x, y, z);
return CraftBlock.biomeBaseToBiome((IRegistry<BiomeBase>) biome.registry, biome.getBiome(x >> 2, y >> 2, z >> 2));
return CraftBlock.biomeBaseToBiome((IRegistry<BiomeBase>) biome.biomeRegistry, biome.getBiome(x >> 2, y >> 2, z >> 2));
}
@Override
@@ -141,7 +144,7 @@ public class CraftChunkSnapshot implements ChunkSnapshot {
@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");
CraftChunk.validateChunkCoordinates(x, y, z);
validateChunkCoordinates(x, y, z);
return biome.getBiome(x >> 2, y >> 2, z >> 2).getAdjustedTemperature(new BlockPosition((this.x << 4) | x, y, (this.z << 4) | z));
}
@@ -155,4 +158,12 @@ public class CraftChunkSnapshot implements ChunkSnapshot {
public final boolean isSectionEmpty(int sy) {
return empty[sy];
}
private int getSectionIndex(int y) {
return (y - minHeight) >> 4;
}
private void validateChunkCoordinates(int x, int y, int z) {
CraftChunk.validateChunkCoordinates(minHeight, maxHeight, x, y, z);
}
}