mirror of
https://github.com/LegacyModdingMC/ChunkAPI.git
synced 2026-11-16 10:35:00 +00:00
whoops
This commit is contained in:
13 files changed
+157
-157
No files matched your search
@@ -26,7 +26,7 @@ import java.nio.ByteBuffer;
|
||||
* @since 0.5.0
|
||||
* @see PacketDataManager
|
||||
* @see ChunkDataManager
|
||||
* @see SubchunkDataManager
|
||||
* @see SubChunkDataManager
|
||||
* @see DataRegistry
|
||||
* @author FalsePattern
|
||||
* @version 0.5.0
|
||||
@@ -74,7 +74,7 @@ public interface DataManager {
|
||||
*/
|
||||
@Contract(mutates = "param4")
|
||||
@StableAPI.Expose
|
||||
void writeToBuffer(Chunk chunk, int subchunkMask, boolean forceUpdate, ByteBuffer data);
|
||||
void writeToBuffer(Chunk chunk, int subChunkMask, boolean forceUpdate, ByteBuffer data);
|
||||
|
||||
/**
|
||||
* Deserializes your data from a packet.
|
||||
@@ -85,11 +85,11 @@ public interface DataManager {
|
||||
*/
|
||||
@Contract(mutates = "param1,param4")
|
||||
@StableAPI.Expose
|
||||
void readFromBuffer(Chunk chunk, int subchunkMask, boolean forceUpdate, ByteBuffer buffer);
|
||||
void readFromBuffer(Chunk chunk, int subChunkMask, boolean forceUpdate, ByteBuffer buffer);
|
||||
}
|
||||
|
||||
/**
|
||||
* The common superinterface for RootDataManager and SubchunkDataManager.
|
||||
* The common superinterface for RootDataManager and SubChunkDataManager.
|
||||
* Contains version information and messages for users attempting to upgrade/remove versions.
|
||||
* @since 0.5.0
|
||||
* @author FalsePattern
|
||||
@@ -185,7 +185,7 @@ public interface DataManager {
|
||||
}
|
||||
|
||||
/**
|
||||
* Implement this interface if you want to save your subchunk data to disk. This is called once per
|
||||
* Implement this interface if you want to save your subChunk data to disk. This is called once per
|
||||
* ExtendedBlockStorage per chunk. (16 times per chunk)
|
||||
*
|
||||
* @since 0.5.0
|
||||
@@ -193,7 +193,7 @@ public interface DataManager {
|
||||
* @version 0.5.0
|
||||
*/
|
||||
@StableAPI(since = "0.5.0")
|
||||
interface SubchunkDataManager extends StorageDataManager {
|
||||
interface SubChunkDataManager extends StorageDataManager {
|
||||
/**
|
||||
* If false, the given nbt compound will be a freshly created object that gets inserted into the actual
|
||||
* segment NBT tag under the `domain:id` name.
|
||||
@@ -204,7 +204,7 @@ public interface DataManager {
|
||||
*/
|
||||
@StableAPI.Expose
|
||||
@Contract(pure = true)
|
||||
default boolean subchunkPrivilegedAccess() {
|
||||
default boolean subChunkPrivilegedAccess() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -213,25 +213,25 @@ public interface DataManager {
|
||||
*/
|
||||
@Contract(mutates = "param3")
|
||||
@StableAPI.Expose
|
||||
void writeSubchunkToNBT(Chunk chunk, ExtendedBlockStorage subchunk, NBTTagCompound nbt);
|
||||
void writeSubChunkToNBT(Chunk chunk, ExtendedBlockStorage subChunk, NBTTagCompound nbt);
|
||||
|
||||
/**
|
||||
* Deserializes your data from an NBT tag. This is used when loading the chunk from disk.
|
||||
* The NBT *may* be null if the chunk was saved before this manager was registered
|
||||
* (e.g., loading save before the mod was added), and the manager is not {@link #subchunkPrivilegedAccess() privileged}.
|
||||
* (e.g., loading save before the mod was added), and the manager is not {@link #subChunkPrivilegedAccess() privileged}.
|
||||
* In this case, you should initialize the data to a sane default.
|
||||
*/
|
||||
@Contract(mutates = "param2")
|
||||
@StableAPI.Expose
|
||||
void readSubchunkFromNBT(Chunk chunk, ExtendedBlockStorage subchunk, NBTTagCompound nbt);
|
||||
void readSubChunkFromNBT(Chunk chunk, ExtendedBlockStorage subChunk, NBTTagCompound nbt);
|
||||
|
||||
/**
|
||||
* Directly copies data from one subchunk to another.
|
||||
* @param fromChunk The owner of the subchunk to copy data from.
|
||||
* @param from The subchunk to copy data from.
|
||||
* @param to The subchunk to copy data to.
|
||||
* Directly copies data from one subChunk to another.
|
||||
* @param fromChunk The owner of the subChunk to copy data from.
|
||||
* @param from The subChunk to copy data from.
|
||||
* @param to The subChunk to copy data to.
|
||||
*/
|
||||
@Contract(mutates = "param3")
|
||||
void cloneSubchunk(Chunk fromChunk, ExtendedBlockStorage from, ExtendedBlockStorage to);
|
||||
void cloneSubChunk(Chunk fromChunk, ExtendedBlockStorage from, ExtendedBlockStorage to);
|
||||
}
|
||||
}
|
||||
@@ -76,14 +76,14 @@ public class DataRegistry {
|
||||
}
|
||||
|
||||
/**
|
||||
* Copies data from a source subchunk to a target subchunk.
|
||||
* @param fromChunk The chunk that owns the *from* subchunk. Used by data managers for getting metadata about the world (skylight presence, etc.)
|
||||
* @param from The subchunk to read the data from
|
||||
* @param to The subchunk to write the data to
|
||||
* Copies data from a source subChunk to a target subChunk.
|
||||
* @param fromChunk The chunk that owns the *from* subChunk. Used by data managers for getting metadata about the world (skylight presence, etc.)
|
||||
* @param from The subChunk to read the data from
|
||||
* @param to The subChunk to write the data to
|
||||
*/
|
||||
@Contract(mutates = "param3")
|
||||
@StableAPI.Expose(since = "0.5.0")
|
||||
public static void cloneSubchunk(Chunk fromChunk, ExtendedBlockStorage from, ExtendedBlockStorage to) {
|
||||
DataRegistryImpl.cloneSubchunk(fromChunk, from, to);
|
||||
public static void cloneSubChunk(Chunk fromChunk, ExtendedBlockStorage from, ExtendedBlockStorage to) {
|
||||
DataRegistryImpl.cloneSubChunk(fromChunk, from, to);
|
||||
}
|
||||
}
|
||||
@@ -38,7 +38,7 @@ public class DataRegistryImpl {
|
||||
private static final Map<String, PacketManagerInfo> packetManagers = new HashMap<>();
|
||||
private static final Map<String, DataManager.StorageDataManager> NBTManagers = new HashMap<>();
|
||||
private static final Map<String, DataManager.ChunkDataManager> chunkNBTManagers = new HashMap<>();
|
||||
private static final Map<String, DataManager.SubchunkDataManager> subchunkNBTManagers = new HashMap<>();
|
||||
private static final Map<String, DataManager.SubChunkDataManager> subChunkNBTManagers = new HashMap<>();
|
||||
private static final Set<String> disabledManagers = new HashSet<>();
|
||||
private static int maxPacketSize = 4;
|
||||
|
||||
@@ -76,8 +76,8 @@ public class DataRegistryImpl {
|
||||
if (manager instanceof DataManager.ChunkDataManager) {
|
||||
chunkNBTManagers.put(id, (DataManager.ChunkDataManager) manager);
|
||||
}
|
||||
if (manager instanceof DataManager.SubchunkDataManager) {
|
||||
subchunkNBTManagers.put(id, (DataManager.SubchunkDataManager) manager);
|
||||
if (manager instanceof DataManager.SubChunkDataManager) {
|
||||
subChunkNBTManagers.put(id, (DataManager.SubChunkDataManager) manager);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -98,7 +98,7 @@ public class DataRegistryImpl {
|
||||
maxPacketSize -= 4 + id.getBytes(StandardCharsets.UTF_8).length + 4 + removed.maxPacketSize;
|
||||
}
|
||||
chunkNBTManagers.remove(manager);
|
||||
subchunkNBTManagers.remove(manager);
|
||||
subChunkNBTManagers.remove(manager);
|
||||
NBTManagers.remove(manager);
|
||||
}
|
||||
|
||||
@@ -123,7 +123,7 @@ public class DataRegistryImpl {
|
||||
return new String(bytes);
|
||||
}
|
||||
|
||||
public static void readFromBuffer(Chunk chunk, int subchunkMask, boolean forceUpdate, byte[] data) {
|
||||
public static void readFromBuffer(Chunk chunk, int subChunkMask, boolean forceUpdate, byte[] data) {
|
||||
val buf = ByteBuffer.wrap(data);
|
||||
buf.order(ByteOrder.LITTLE_ENDIAN);
|
||||
int count = buf.getInt();
|
||||
@@ -141,12 +141,12 @@ public class DataRegistryImpl {
|
||||
}
|
||||
int start = buf.position();
|
||||
val slice = createSlice(buf, start, length);
|
||||
managerInfo.manager.readFromBuffer(chunk, subchunkMask, forceUpdate, slice);
|
||||
managerInfo.manager.readFromBuffer(chunk, subChunkMask, forceUpdate, slice);
|
||||
buf.position(start + length);
|
||||
}
|
||||
}
|
||||
|
||||
public static int writeToBuffer(Chunk chunk, int subchunkMask, boolean forceUpdate, byte[] data) {
|
||||
public static int writeToBuffer(Chunk chunk, int subChunkMask, boolean forceUpdate, byte[] data) {
|
||||
val buf = ByteBuffer.wrap(data);
|
||||
buf.order(ByteOrder.LITTLE_ENDIAN);
|
||||
buf.putInt(packetManagers.size());
|
||||
@@ -156,7 +156,7 @@ public class DataRegistryImpl {
|
||||
writeString(buf, id);
|
||||
int start = buf.position() + 4;
|
||||
val slice = createSlice(buf, start, managerInfo.maxPacketSize);
|
||||
managerInfo.manager.writeToBuffer(chunk, subchunkMask, forceUpdate, slice);
|
||||
managerInfo.manager.writeToBuffer(chunk, subChunkMask, forceUpdate, slice);
|
||||
int length = slice.position();
|
||||
buf.putInt(length);
|
||||
buf.position(start + length);
|
||||
@@ -212,17 +212,17 @@ public class DataRegistryImpl {
|
||||
return domainNBT.getCompoundTag(manager.id());
|
||||
}
|
||||
|
||||
public static void writeSubchunkToNBT(Chunk chunk, ExtendedBlockStorage subchunk, NBTTagCompound nbt) {
|
||||
for (val manager : subchunkNBTManagers.values()) {
|
||||
manager.writeSubchunkToNBT(chunk, subchunk,
|
||||
createManagerNBT(manager.subchunkPrivilegedAccess(), nbt, manager));
|
||||
public static void writeSubChunkToNBT(Chunk chunk, ExtendedBlockStorage subChunk, NBTTagCompound nbt) {
|
||||
for (val manager : subChunkNBTManagers.values()) {
|
||||
manager.writeSubChunkToNBT(chunk, subChunk,
|
||||
createManagerNBT(manager.subChunkPrivilegedAccess(), nbt, manager));
|
||||
}
|
||||
}
|
||||
|
||||
public static void readSubchunkFromNBT(Chunk chunk, ExtendedBlockStorage subchunk, NBTTagCompound nbt) {
|
||||
for (val manager : subchunkNBTManagers.values()) {
|
||||
manager.readSubchunkFromNBT(chunk, subchunk,
|
||||
getManagerNBT(manager.subchunkPrivilegedAccess(), nbt, manager));
|
||||
public static void readSubChunkFromNBT(Chunk chunk, ExtendedBlockStorage subChunk, NBTTagCompound nbt) {
|
||||
for (val manager : subChunkNBTManagers.values()) {
|
||||
manager.readSubChunkFromNBT(chunk, subChunk,
|
||||
getManagerNBT(manager.subChunkPrivilegedAccess(), nbt, manager));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -244,9 +244,9 @@ public class DataRegistryImpl {
|
||||
}
|
||||
}
|
||||
|
||||
public static void cloneSubchunk(Chunk fromChunk, ExtendedBlockStorage from, ExtendedBlockStorage to) {
|
||||
for (val manager: subchunkNBTManagers.values()) {
|
||||
manager.cloneSubchunk(fromChunk, from, to);
|
||||
public static void cloneSubChunk(Chunk fromChunk, ExtendedBlockStorage from, ExtendedBlockStorage to) {
|
||||
for (val manager: subChunkNBTManagers.values()) {
|
||||
manager.cloneSubChunk(fromChunk, from, to);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+4
-4
@@ -53,7 +53,7 @@ public abstract class ChunkMixin {
|
||||
*/
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Overwrite
|
||||
public void fillChunk(byte[] data, int subchunkMask, int subchunkMSBMask, boolean forceUpdate) {
|
||||
public void fillChunk(byte[] data, int subChunkMask, int subChunkMSBMask, boolean forceUpdate) {
|
||||
for (Object o : chunkTileEntityMap.values()) {
|
||||
TileEntity tileEntity = (TileEntity) o;
|
||||
tileEntity.updateContainingBlockInfo();
|
||||
@@ -64,7 +64,7 @@ public abstract class ChunkMixin {
|
||||
boolean hasSky = !this.worldObj.provider.hasNoSky;
|
||||
|
||||
for (int i = 0; i < storageArrays.length; i++) {
|
||||
if ((subchunkMask & (1 << i)) != 0) {
|
||||
if ((subChunkMask & (1 << i)) != 0) {
|
||||
if (storageArrays[i] == null) {
|
||||
storageArrays[i] = new ExtendedBlockStorage(i << 4, hasSky);
|
||||
}
|
||||
@@ -73,10 +73,10 @@ public abstract class ChunkMixin {
|
||||
}
|
||||
}
|
||||
|
||||
DataRegistryImpl.readFromBuffer((Chunk) (Object) this, subchunkMask, forceUpdate, data);
|
||||
DataRegistryImpl.readFromBuffer((Chunk) (Object) this, subChunkMask, forceUpdate, data);
|
||||
|
||||
for (int i = 0; i < storageArrays.length; ++i) {
|
||||
if ((storageArrays[i] != null) && ((subchunkMask & (1 << i)) != 0)) {
|
||||
if ((storageArrays[i] != null) && ((subChunkMask & (1 << i)) != 0)) {
|
||||
storageArrays[i].removeInvalidBlocks();
|
||||
}
|
||||
}
|
||||
|
||||
+24
-24
@@ -44,7 +44,7 @@ public abstract class AnvilChunkLoaderMixin {
|
||||
nbt.setLong("LastUpdate", world.getTotalWorldTime());
|
||||
nbt.setBoolean("TerrainPopulated", chunk.isTerrainPopulated);
|
||||
nbt.setLong("InhabitedTime", chunk.inhabitedTime);
|
||||
writeSubchunks(chunk, nbt);
|
||||
writeSubChunks(chunk, nbt);
|
||||
writeCustomData(chunk, nbt);
|
||||
writeEntities(chunk, world, nbt);
|
||||
}
|
||||
@@ -63,7 +63,7 @@ public abstract class AnvilChunkLoaderMixin {
|
||||
Chunk chunk = new Chunk(world, x, z);
|
||||
chunk.isTerrainPopulated = nbt.getBoolean("TerrainPopulated");
|
||||
chunk.inhabitedTime = nbt.getLong("InhabitedTime");
|
||||
readSubchunks(chunk, nbt);
|
||||
readSubChunks(chunk, nbt);
|
||||
readCustomData(chunk, nbt);
|
||||
|
||||
// End this method here and split off entity loading to another method
|
||||
@@ -74,43 +74,43 @@ public abstract class AnvilChunkLoaderMixin {
|
||||
DataRegistryImpl.readChunkFromNBT(chunk, nbt);
|
||||
}
|
||||
|
||||
private void readSubchunks(Chunk chunk, NBTTagCompound nbt) {
|
||||
NBTTagList subchunksNBT = nbt.getTagList("Sections", 10);
|
||||
private void readSubChunks(Chunk chunk, NBTTagCompound nbt) {
|
||||
NBTTagList subChunksNBT = nbt.getTagList("Sections", 10);
|
||||
byte segments = 16;
|
||||
ExtendedBlockStorage[] subchunkList = new ExtendedBlockStorage[segments];
|
||||
ExtendedBlockStorage[] subChunkList = new ExtendedBlockStorage[segments];
|
||||
|
||||
for (int k = 0; k < subchunksNBT.tagCount(); ++k) {
|
||||
NBTTagCompound subchunkNBT = subchunksNBT.getCompoundTagAt(k);
|
||||
byte yLevel = subchunkNBT.getByte("Y");
|
||||
ExtendedBlockStorage subchunk = new ExtendedBlockStorage(yLevel << 4, !chunk.worldObj.provider.hasNoSky);
|
||||
DataRegistryImpl.readSubchunkFromNBT(chunk, subchunk, subchunkNBT);
|
||||
for (int k = 0; k < subChunksNBT.tagCount(); ++k) {
|
||||
NBTTagCompound subChunkNBT = subChunksNBT.getCompoundTagAt(k);
|
||||
byte yLevel = subChunkNBT.getByte("Y");
|
||||
ExtendedBlockStorage subChunk = new ExtendedBlockStorage(yLevel << 4, !chunk.worldObj.provider.hasNoSky);
|
||||
DataRegistryImpl.readSubChunkFromNBT(chunk, subChunk, subChunkNBT);
|
||||
|
||||
subchunk.removeInvalidBlocks();
|
||||
subchunkList[yLevel] = subchunk;
|
||||
subChunk.removeInvalidBlocks();
|
||||
subChunkList[yLevel] = subChunk;
|
||||
}
|
||||
|
||||
chunk.setStorageArrays(subchunkList);
|
||||
chunk.setStorageArrays(subChunkList);
|
||||
}
|
||||
|
||||
private void writeCustomData(Chunk chunk, NBTTagCompound nbt) {
|
||||
DataRegistryImpl.writeChunkToNBT(chunk, nbt);
|
||||
}
|
||||
|
||||
private void writeSubchunks(Chunk chunk, NBTTagCompound nbt) {
|
||||
ExtendedBlockStorage[] subchunks = chunk.getBlockStorageArray();
|
||||
NBTTagList subchunksNBT = new NBTTagList();
|
||||
NBTTagCompound subchunkNBT;
|
||||
private void writeSubChunks(Chunk chunk, NBTTagCompound nbt) {
|
||||
ExtendedBlockStorage[] subChunks = chunk.getBlockStorageArray();
|
||||
NBTTagList subChunksNBT = new NBTTagList();
|
||||
NBTTagCompound subChunkNBT;
|
||||
|
||||
for (ExtendedBlockStorage subchunk : subchunks) {
|
||||
if (subchunk != null) {
|
||||
subchunkNBT = new NBTTagCompound();
|
||||
subchunkNBT.setByte("Y", (byte) (subchunk.getYLocation() >> 4 & 255));
|
||||
DataRegistryImpl.writeSubchunkToNBT(chunk, subchunk, subchunkNBT);
|
||||
subchunksNBT.appendTag(subchunkNBT);
|
||||
for (ExtendedBlockStorage subChunk : subChunks) {
|
||||
if (subChunk != null) {
|
||||
subChunkNBT = new NBTTagCompound();
|
||||
subChunkNBT.setByte("Y", (byte) (subChunk.getYLocation() >> 4 & 255));
|
||||
DataRegistryImpl.writeSubChunkToNBT(chunk, subChunk, subChunkNBT);
|
||||
subChunksNBT.appendTag(subChunkNBT);
|
||||
}
|
||||
}
|
||||
|
||||
nbt.setTag("Sections", subchunksNBT);
|
||||
nbt.setTag("Sections", subChunksNBT);
|
||||
}
|
||||
|
||||
private void writeEntities(Chunk chunk, World world, NBTTagCompound nbt) {
|
||||
|
||||
+7
-7
@@ -37,7 +37,7 @@ public abstract class S21PacketChunkDataMixin {
|
||||
@Shadow(aliases = "field_149282_b")
|
||||
private int zPosition;
|
||||
@Shadow(aliases = "field_149283_c")
|
||||
private int subchunkMask;
|
||||
private int subChunkMask;
|
||||
@Shadow(aliases = "field_149281_e")
|
||||
private byte[] deflatedData;
|
||||
@Shadow(aliases = "field_149278_f")
|
||||
@@ -62,8 +62,8 @@ public abstract class S21PacketChunkDataMixin {
|
||||
* @reason Replace functionality
|
||||
*/
|
||||
@Overwrite
|
||||
public static S21PacketChunkData.Extracted func_149269_a(Chunk chunk, boolean forceUpdate, int subchunkMask) {
|
||||
ExtendedBlockStorage[] subchunks = chunk.getBlockStorageArray();
|
||||
public static S21PacketChunkData.Extracted func_149269_a(Chunk chunk, boolean forceUpdate, int subChunkMask) {
|
||||
ExtendedBlockStorage[] subChunks = chunk.getBlockStorageArray();
|
||||
S21PacketChunkData.Extracted extracted = new S21PacketChunkData.Extracted();
|
||||
|
||||
if (buffer.length < DataRegistryImpl.maxPacketSize()) {
|
||||
@@ -74,8 +74,8 @@ public abstract class S21PacketChunkDataMixin {
|
||||
chunk.sendUpdates = true;
|
||||
}
|
||||
|
||||
for (int i = 0; i < subchunks.length; ++i) {
|
||||
if (subchunks[i] != null && (!forceUpdate || !subchunks[i].isEmpty()) && (subchunkMask & 1 << i) != 0) {
|
||||
for (int i = 0; i < subChunks.length; ++i) {
|
||||
if (subChunks[i] != null && (!forceUpdate || !subChunks[i].isEmpty()) && (subChunkMask & 1 << i) != 0) {
|
||||
extracted.field_150280_b |= 1 << i;
|
||||
}
|
||||
}
|
||||
@@ -109,7 +109,7 @@ public abstract class S21PacketChunkDataMixin {
|
||||
data.writeInt(xPosition);
|
||||
data.writeInt(zPosition);
|
||||
data.writeBoolean(forceUpdate);
|
||||
data.writeShort((short) (subchunkMask & 0xFFFF));
|
||||
data.writeShort((short) (subChunkMask & 0xFFFF));
|
||||
data.writeInt(this.data.length);
|
||||
data.writeInt(deflatedSize);
|
||||
data.writeBytes(deflatedData, 0, deflatedSize);
|
||||
@@ -124,7 +124,7 @@ public abstract class S21PacketChunkDataMixin {
|
||||
xPosition = data.readInt();
|
||||
zPosition = data.readInt();
|
||||
forceUpdate = data.readBoolean();
|
||||
subchunkMask = data.readShort() & 0xFFFF;
|
||||
subChunkMask = data.readShort() & 0xFFFF;
|
||||
this.data = new byte[data.readInt()];
|
||||
deflatedSize = data.readInt();
|
||||
if (buffer.length < deflatedSize) {
|
||||
|
||||
+6
-6
@@ -34,9 +34,9 @@ public abstract class S26PacketMapChunkBulkMixin {
|
||||
@Shadow(aliases = "field_149264_b")
|
||||
private int[] zPositions;
|
||||
@Shadow(aliases = "field_149265_c")
|
||||
private int[] subchunkMasks;
|
||||
private int[] subChunkMasks;
|
||||
@Shadow(aliases = "field_149262_d")
|
||||
private int[] subchunkMSBMasks;
|
||||
private int[] subChunkMSBMasks;
|
||||
@Shadow(aliases = "field_149261_g")
|
||||
private int deflatedSize;
|
||||
@Shadow(aliases = "field_149267_h")
|
||||
@@ -62,8 +62,8 @@ public abstract class S26PacketMapChunkBulkMixin {
|
||||
skylight = data.readBoolean();
|
||||
xPositions = new int[chunkCount];
|
||||
zPositions = new int[chunkCount];
|
||||
subchunkMasks = new int[chunkCount];
|
||||
subchunkMSBMasks = new int[chunkCount];
|
||||
subChunkMasks = new int[chunkCount];
|
||||
subChunkMSBMasks = new int[chunkCount];
|
||||
datas = new byte[chunkCount][];
|
||||
|
||||
if (inflaterBuffer.length < deflatedSize) {
|
||||
@@ -89,7 +89,7 @@ public abstract class S26PacketMapChunkBulkMixin {
|
||||
val size = sizes[i];
|
||||
xPositions[i] = data.readInt();
|
||||
zPositions[i] = data.readInt();
|
||||
subchunkMasks[i] = data.readUnsignedShort();
|
||||
subChunkMasks[i] = data.readUnsignedShort();
|
||||
|
||||
datas[i] = new byte[size];
|
||||
System.arraycopy(buf, pos, datas[i], 0, size);
|
||||
@@ -122,7 +122,7 @@ public abstract class S26PacketMapChunkBulkMixin {
|
||||
for (int i = 0; i < xPositions.length; ++i) {
|
||||
data.writeInt(xPositions[i]);
|
||||
data.writeInt(zPositions[i]);
|
||||
data.writeShort((short) (subchunkMasks[i] & 65535));
|
||||
data.writeShort((short) (subChunkMasks[i] & 65535));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -31,14 +31,14 @@ public class BiomeManager extends VanillaManager
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToBuffer(@NotNull Chunk chunk, int subchunkMask, boolean forceUpdate, @NotNull ByteBuffer data) {
|
||||
public void writeToBuffer(@NotNull Chunk chunk, int subChunkMask, boolean forceUpdate, @NotNull ByteBuffer data) {
|
||||
if (forceUpdate) {
|
||||
data.put(chunk.getBiomeArray());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromBuffer(@NotNull Chunk chunk, int subchunkMask, boolean forceUpdate, @NotNull ByteBuffer buffer) {
|
||||
public void readFromBuffer(@NotNull Chunk chunk, int subChunkMask, boolean forceUpdate, @NotNull ByteBuffer buffer) {
|
||||
if (forceUpdate) {
|
||||
buffer.get(chunk.getBiomeArray());
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@ import static com.falsepattern.chunk.internal.Common.BLOCKS_PER_SUBCHUNK;
|
||||
import static com.falsepattern.chunk.internal.Common.SUBCHUNKS_PER_CHUNK;
|
||||
|
||||
public class BlockIDManager extends VanillaManager
|
||||
implements DataManager.PacketDataManager, DataManager.SubchunkDataManager {
|
||||
implements DataManager.PacketDataManager, DataManager.SubChunkDataManager {
|
||||
private static final int LSB_BYTES_PER_SUBCHUNK = BLOCKS_PER_SUBCHUNK;
|
||||
private static final int MSB_BYTES_PER_SUBCHUNK = BLOCKS_PER_SUBCHUNK / 2;
|
||||
private static final int HEADER_SIZE = 2;
|
||||
@@ -38,16 +38,16 @@ public class BlockIDManager extends VanillaManager
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToBuffer(Chunk chunk, int subchunkMask, boolean forceUpdate, ByteBuffer data) {
|
||||
val subchunks = chunk.getBlockStorageArray();
|
||||
public void writeToBuffer(Chunk chunk, int subChunkMask, boolean forceUpdate, ByteBuffer data) {
|
||||
val subChunks = chunk.getBlockStorageArray();
|
||||
int currentPos = data.position();
|
||||
data.putShort((short) 0);
|
||||
int msbMask = 0;
|
||||
for (int i = 0; i < subchunks.length; i++) {
|
||||
if ((subchunkMask & (1 << i)) != 0) {
|
||||
val subchunk = subchunks[i];
|
||||
val lsb = subchunk.getBlockLSBArray();
|
||||
val msb = subchunk.getBlockMSBArray();
|
||||
for (int i = 0; i < subChunks.length; i++) {
|
||||
if ((subChunkMask & (1 << i)) != 0) {
|
||||
val subChunk = subChunks[i];
|
||||
val lsb = subChunk.getBlockLSBArray();
|
||||
val msb = subChunk.getBlockMSBArray();
|
||||
data.put(lsb);
|
||||
if (msb != null) {
|
||||
msbMask |= 1 << i;
|
||||
@@ -62,51 +62,51 @@ public class BlockIDManager extends VanillaManager
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromBuffer(Chunk chunk, int subchunkMask, boolean forceUpdate, ByteBuffer buffer) {
|
||||
val subchunks = chunk.getBlockStorageArray();
|
||||
public void readFromBuffer(Chunk chunk, int subChunkMask, boolean forceUpdate, ByteBuffer buffer) {
|
||||
val subChunks = chunk.getBlockStorageArray();
|
||||
val msbMask = buffer.getShort() & 0xFFFF;
|
||||
for (int i = 0; i < subchunks.length; i++) {
|
||||
val subchunk = subchunks[i];
|
||||
if ((subchunkMask & (1 << i)) != 0 && subchunk != null) {
|
||||
buffer.get(subchunk.getBlockLSBArray());
|
||||
for (int i = 0; i < subChunks.length; i++) {
|
||||
val subChunk = subChunks[i];
|
||||
if ((subChunkMask & (1 << i)) != 0 && subChunk != null) {
|
||||
buffer.get(subChunk.getBlockLSBArray());
|
||||
if ((msbMask & (1 << i)) != 0) {
|
||||
val msb = subchunk.getBlockMSBArray();
|
||||
val msb = subChunk.getBlockMSBArray();
|
||||
if (msb == null) {
|
||||
subchunk.createBlockMSBArray();
|
||||
subChunk.createBlockMSBArray();
|
||||
}
|
||||
buffer.get(subchunk.getBlockMSBArray().data);
|
||||
buffer.get(subChunk.getBlockMSBArray().data);
|
||||
} else {
|
||||
subchunk.setBlockMSBArray(null);
|
||||
subChunk.setBlockMSBArray(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean subchunkPrivilegedAccess() {
|
||||
public boolean subChunkPrivilegedAccess() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeSubchunkToNBT(Chunk chunk, ExtendedBlockStorage subchunk, NBTTagCompound nbt) {
|
||||
nbt.setByteArray("Blocks", subchunk.getBlockLSBArray());
|
||||
public void writeSubChunkToNBT(Chunk chunk, ExtendedBlockStorage subChunk, NBTTagCompound nbt) {
|
||||
nbt.setByteArray("Blocks", subChunk.getBlockLSBArray());
|
||||
|
||||
if (subchunk.getBlockMSBArray() != null) {
|
||||
nbt.setByteArray("Add", subchunk.getBlockMSBArray().data);
|
||||
if (subChunk.getBlockMSBArray() != null) {
|
||||
nbt.setByteArray("Add", subChunk.getBlockMSBArray().data);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readSubchunkFromNBT(Chunk chunk, ExtendedBlockStorage subchunk, NBTTagCompound nbt) {
|
||||
subchunk.setBlockLSBArray(nbt.getByteArray("Blocks"));
|
||||
public void readSubChunkFromNBT(Chunk chunk, ExtendedBlockStorage subChunk, NBTTagCompound nbt) {
|
||||
subChunk.setBlockLSBArray(nbt.getByteArray("Blocks"));
|
||||
|
||||
if (nbt.hasKey("Add", 7)) {
|
||||
subchunk.setBlockMSBArray(new NibbleArray(nbt.getByteArray("Add"), 4));
|
||||
subChunk.setBlockMSBArray(new NibbleArray(nbt.getByteArray("Add"), 4));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void cloneSubchunk(Chunk fromChunk, ExtendedBlockStorage from, ExtendedBlockStorage to) {
|
||||
public void cloneSubChunk(Chunk fromChunk, ExtendedBlockStorage from, ExtendedBlockStorage to) {
|
||||
to.setBlockLSBArray(ArrayUtil.copyArray(from.getBlockLSBArray(), to.getBlockLSBArray()));
|
||||
to.setBlockMSBArray(ArrayUtil.copyArray(from.getBlockMSBArray(), to.getBlockMSBArray()));
|
||||
}
|
||||
|
||||
@@ -15,10 +15,10 @@ import net.minecraft.world.chunk.Chunk;
|
||||
import net.minecraft.world.chunk.NibbleArray;
|
||||
import net.minecraft.world.chunk.storage.ExtendedBlockStorage;
|
||||
|
||||
public class BlocklightManager extends NibbleManager implements DataManager.SubchunkDataManager {
|
||||
public class BlocklightManager extends NibbleManager implements DataManager.SubChunkDataManager {
|
||||
@Override
|
||||
protected NibbleArray getNibbleArray(ExtendedBlockStorage subchunk) {
|
||||
return subchunk.getBlocklightArray();
|
||||
protected NibbleArray getNibbleArray(ExtendedBlockStorage subChunk) {
|
||||
return subChunk.getBlocklightArray();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -27,22 +27,22 @@ public class BlocklightManager extends NibbleManager implements DataManager.Subc
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean subchunkPrivilegedAccess() {
|
||||
public boolean subChunkPrivilegedAccess() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeSubchunkToNBT(Chunk chunk, ExtendedBlockStorage subchunk, NBTTagCompound nbt) {
|
||||
nbt.setByteArray("BlockLight", subchunk.getBlocklightArray().data);
|
||||
public void writeSubChunkToNBT(Chunk chunk, ExtendedBlockStorage subChunk, NBTTagCompound nbt) {
|
||||
nbt.setByteArray("BlockLight", subChunk.getBlocklightArray().data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readSubchunkFromNBT(Chunk chunk, ExtendedBlockStorage subchunk, NBTTagCompound nbt) {
|
||||
subchunk.setBlocklightArray(new NibbleArray(nbt.getByteArray("BlockLight"), 4));
|
||||
public void readSubChunkFromNBT(Chunk chunk, ExtendedBlockStorage subChunk, NBTTagCompound nbt) {
|
||||
subChunk.setBlocklightArray(new NibbleArray(nbt.getByteArray("BlockLight"), 4));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void cloneSubchunk(Chunk fromChunk, ExtendedBlockStorage from, ExtendedBlockStorage to) {
|
||||
public void cloneSubChunk(Chunk fromChunk, ExtendedBlockStorage from, ExtendedBlockStorage to) {
|
||||
from.setBlocklightArray(ArrayUtil.copyArray(from.getBlocklightArray(), to.getBlocklightArray()));
|
||||
}
|
||||
}
|
||||
@@ -15,10 +15,10 @@ import net.minecraft.world.chunk.Chunk;
|
||||
import net.minecraft.world.chunk.NibbleArray;
|
||||
import net.minecraft.world.chunk.storage.ExtendedBlockStorage;
|
||||
|
||||
public class MetadataManager extends NibbleManager implements DataManager.SubchunkDataManager {
|
||||
public class MetadataManager extends NibbleManager implements DataManager.SubChunkDataManager {
|
||||
@Override
|
||||
protected NibbleArray getNibbleArray(ExtendedBlockStorage subchunk) {
|
||||
return subchunk.getMetadataArray();
|
||||
protected NibbleArray getNibbleArray(ExtendedBlockStorage subChunk) {
|
||||
return subChunk.getMetadataArray();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -27,22 +27,22 @@ public class MetadataManager extends NibbleManager implements DataManager.Subchu
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean subchunkPrivilegedAccess() {
|
||||
public boolean subChunkPrivilegedAccess() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeSubchunkToNBT(Chunk chunk, ExtendedBlockStorage subchunk, NBTTagCompound nbt) {
|
||||
nbt.setByteArray("Data", subchunk.getMetadataArray().data);
|
||||
public void writeSubChunkToNBT(Chunk chunk, ExtendedBlockStorage subChunk, NBTTagCompound nbt) {
|
||||
nbt.setByteArray("Data", subChunk.getMetadataArray().data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readSubchunkFromNBT(Chunk chunk, ExtendedBlockStorage subchunk, NBTTagCompound nbt) {
|
||||
subchunk.setBlockMetadataArray(new NibbleArray(nbt.getByteArray("Data"), 4));
|
||||
public void readSubChunkFromNBT(Chunk chunk, ExtendedBlockStorage subChunk, NBTTagCompound nbt) {
|
||||
subChunk.setBlockMetadataArray(new NibbleArray(nbt.getByteArray("Data"), 4));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void cloneSubchunk(Chunk fromChunk, ExtendedBlockStorage from, ExtendedBlockStorage to) {
|
||||
public void cloneSubChunk(Chunk fromChunk, ExtendedBlockStorage from, ExtendedBlockStorage to) {
|
||||
to.setBlockMetadataArray(ArrayUtil.copyArray(from.getMetadataArray(), to.getMetadataArray()));
|
||||
}
|
||||
}
|
||||
@@ -20,7 +20,7 @@ import java.nio.ByteBuffer;
|
||||
public abstract class NibbleManager extends VanillaManager implements DataManager.PacketDataManager {
|
||||
public static final int BYTES_PER_SUBCHUNK = Common.BLOCKS_PER_SUBCHUNK / 2;
|
||||
|
||||
protected abstract NibbleArray getNibbleArray(ExtendedBlockStorage subchunk);
|
||||
protected abstract NibbleArray getNibbleArray(ExtendedBlockStorage subChunk);
|
||||
|
||||
@Override
|
||||
public int maxPacketSize() {
|
||||
@@ -28,26 +28,26 @@ public abstract class NibbleManager extends VanillaManager implements DataManage
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToBuffer(Chunk chunk, int subchunkMask, boolean forceUpdate, ByteBuffer data) {
|
||||
val subchunks = chunk.getBlockStorageArray();
|
||||
for (int i = 0; i < subchunks.length; i++) {
|
||||
if ((subchunkMask & (1 << i)) != 0) {
|
||||
val subchunk = subchunks[i];
|
||||
if (subchunk != null) {
|
||||
data.put(getNibbleArray(subchunk).data, 0, BYTES_PER_SUBCHUNK);
|
||||
public void writeToBuffer(Chunk chunk, int subChunkMask, boolean forceUpdate, ByteBuffer data) {
|
||||
val subChunks = chunk.getBlockStorageArray();
|
||||
for (int i = 0; i < subChunks.length; i++) {
|
||||
if ((subChunkMask & (1 << i)) != 0) {
|
||||
val subChunk = subChunks[i];
|
||||
if (subChunk != null) {
|
||||
data.put(getNibbleArray(subChunk).data, 0, BYTES_PER_SUBCHUNK);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromBuffer(Chunk chunk, int subchunkMask, boolean forceUpdate, ByteBuffer buffer) {
|
||||
val subchunks = chunk.getBlockStorageArray();
|
||||
for (int i = 0; i < subchunks.length; i++) {
|
||||
if ((subchunkMask & (1 << i)) != 0) {
|
||||
val subchunk = subchunks[i];
|
||||
if (subchunk != null) {
|
||||
buffer.get(getNibbleArray(subchunk).data, 0, BYTES_PER_SUBCHUNK);
|
||||
public void readFromBuffer(Chunk chunk, int subChunkMask, boolean forceUpdate, ByteBuffer buffer) {
|
||||
val subChunks = chunk.getBlockStorageArray();
|
||||
for (int i = 0; i < subChunks.length; i++) {
|
||||
if ((subChunkMask & (1 << i)) != 0) {
|
||||
val subChunk = subChunks[i];
|
||||
if (subChunk != null) {
|
||||
buffer.get(getNibbleArray(subChunk).data, 0, BYTES_PER_SUBCHUNK);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,54 +17,54 @@ import net.minecraft.world.chunk.storage.ExtendedBlockStorage;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
public class SkylightManager extends NibbleManager implements DataManager.SubchunkDataManager {
|
||||
public class SkylightManager extends NibbleManager implements DataManager.SubChunkDataManager {
|
||||
@Override
|
||||
public String id() {
|
||||
return "skylight";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected NibbleArray getNibbleArray(ExtendedBlockStorage subchunk) {
|
||||
return subchunk.getSkylightArray();
|
||||
protected NibbleArray getNibbleArray(ExtendedBlockStorage subChunk) {
|
||||
return subChunk.getSkylightArray();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToBuffer(Chunk chunk, int subchunkMask, boolean forceUpdate, ByteBuffer data) {
|
||||
public void writeToBuffer(Chunk chunk, int subChunkMask, boolean forceUpdate, ByteBuffer data) {
|
||||
if (!chunk.worldObj.provider.hasNoSky) {
|
||||
super.writeToBuffer(chunk, subchunkMask, forceUpdate, data);
|
||||
super.writeToBuffer(chunk, subChunkMask, forceUpdate, data);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromBuffer(Chunk chunk, int subchunkMask, boolean forceUpdate, ByteBuffer buffer) {
|
||||
public void readFromBuffer(Chunk chunk, int subChunkMask, boolean forceUpdate, ByteBuffer buffer) {
|
||||
if (!chunk.worldObj.provider.hasNoSky) {
|
||||
super.readFromBuffer(chunk, subchunkMask, forceUpdate, buffer);
|
||||
super.readFromBuffer(chunk, subChunkMask, forceUpdate, buffer);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean subchunkPrivilegedAccess() {
|
||||
public boolean subChunkPrivilegedAccess() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeSubchunkToNBT(Chunk chunk, ExtendedBlockStorage subchunk, NBTTagCompound nbt) {
|
||||
public void writeSubChunkToNBT(Chunk chunk, ExtendedBlockStorage subChunk, NBTTagCompound nbt) {
|
||||
if (!chunk.worldObj.provider.hasNoSky) {
|
||||
nbt.setByteArray("SkyLight", subchunk.getSkylightArray().data);
|
||||
nbt.setByteArray("SkyLight", subChunk.getSkylightArray().data);
|
||||
} else {
|
||||
nbt.setByteArray("SkyLight", new byte[subchunk.getBlocklightArray().data.length]);
|
||||
nbt.setByteArray("SkyLight", new byte[subChunk.getBlocklightArray().data.length]);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readSubchunkFromNBT(Chunk chunk, ExtendedBlockStorage subchunk, NBTTagCompound nbt) {
|
||||
public void readSubChunkFromNBT(Chunk chunk, ExtendedBlockStorage subChunk, NBTTagCompound nbt) {
|
||||
if (!chunk.worldObj.provider.hasNoSky) {
|
||||
subchunk.setSkylightArray(new NibbleArray(nbt.getByteArray("SkyLight"), 4));
|
||||
subChunk.setSkylightArray(new NibbleArray(nbt.getByteArray("SkyLight"), 4));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void cloneSubchunk(Chunk fromChunk, ExtendedBlockStorage from, ExtendedBlockStorage to) {
|
||||
public void cloneSubChunk(Chunk fromChunk, ExtendedBlockStorage from, ExtendedBlockStorage to) {
|
||||
if (!fromChunk.worldObj.provider.hasNoSky) {
|
||||
to.setSkylightArray(ArrayUtil.copyArray(from.getSkylightArray(), to.getSkylightArray()));
|
||||
} else {
|
||||
|
||||
Reference in new issue
Block a user