mirror of
https://github.com/GTMEGA/EndlessIDs.git
synced 2026-11-17 22:45:04 +00:00
The Big Rename (ebs, section -> subChunk)
This commit is contained in:
25 files changed
+168
-168
No files matched your search
@@ -3,7 +3,7 @@ package com.falsepattern.endlessids.managers;
|
||||
import com.falsepattern.chunk.api.ArrayUtil;
|
||||
import com.falsepattern.chunk.api.DataManager;
|
||||
import com.falsepattern.endlessids.Tags;
|
||||
import com.falsepattern.endlessids.mixin.helpers.IExtendedBlockStorageMixin;
|
||||
import com.falsepattern.endlessids.mixin.helpers.SubChunkBlockHook;
|
||||
import lombok.val;
|
||||
import lombok.var;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -34,35 +34,35 @@ public class BlockIDManager implements DataManager.PacketDataManager, DataManage
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToBuffer(Chunk chunk, int ebsMask, boolean forceUpdate, ByteBuffer data) {
|
||||
val ebsList = chunk.getBlockStorageArray();
|
||||
public void writeToBuffer(Chunk chunk, int subChunkMask, boolean forceUpdate, ByteBuffer data) {
|
||||
val subChunkList = chunk.getBlockStorageArray();
|
||||
int storageFlags = 0;
|
||||
val start = data.position() + 4;
|
||||
data.position(start);
|
||||
for (int i = 0; i < 16; i++) {
|
||||
if ((ebsMask & (1 << i)) == 0 || ebsList[i] == null) {
|
||||
if ((subChunkMask & (1 << i)) == 0 || subChunkList[i] == null) {
|
||||
continue;
|
||||
}
|
||||
val ebs = (IExtendedBlockStorageMixin) ebsList[i];
|
||||
val subChunk = (SubChunkBlockHook) subChunkList[i];
|
||||
|
||||
storageFlags |= ebs.getEBSMSBMask() << (i * 2);
|
||||
storageFlags |= subChunk.getBlockMask() << (i * 2);
|
||||
|
||||
val b1 = ebs.getB1();
|
||||
val b1 = subChunk.getB1();
|
||||
data.put(b1);
|
||||
|
||||
val b2Low = ebs.getB2Low();
|
||||
val b2Low = subChunk.getB2Low();
|
||||
if (b2Low == null) {
|
||||
continue;
|
||||
}
|
||||
data.put(b2Low.data);
|
||||
|
||||
val b2High = ebs.getB2High();
|
||||
val b2High = subChunk.getB2High();
|
||||
if (b2High == null) {
|
||||
continue;
|
||||
}
|
||||
data.put(b2High.data);
|
||||
|
||||
val b3 = ebs.getB3();
|
||||
val b3 = subChunk.getB3();
|
||||
if (b3 != null) {
|
||||
data.put(b3);
|
||||
}
|
||||
@@ -71,45 +71,45 @@ public class BlockIDManager implements DataManager.PacketDataManager, DataManage
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromBuffer(Chunk chunk, int ebsMask, boolean forceUpdate, ByteBuffer buffer) {
|
||||
val ebsList = chunk.getBlockStorageArray();
|
||||
public void readFromBuffer(Chunk chunk, int subChunkMask, boolean forceUpdate, ByteBuffer buffer) {
|
||||
val subChunkList = chunk.getBlockStorageArray();
|
||||
val storageFlags = buffer.getInt();
|
||||
for (int i = 0; i < 16; i++) {
|
||||
if ((ebsMask & (1 << i)) == 0 || ebsList[i] == null) {
|
||||
if ((subChunkMask & (1 << i)) == 0 || subChunkList[i] == null) {
|
||||
continue;
|
||||
}
|
||||
val ebs = (IExtendedBlockStorageMixin) ebsList[i];
|
||||
val subChunk = (SubChunkBlockHook) subChunkList[i];
|
||||
val storageFlag = (storageFlags >>> (i * 2)) & 3;
|
||||
val b1 = ebs.getB1();
|
||||
val b1 = subChunk.getB1();
|
||||
buffer.get(b1);
|
||||
if (storageFlag == 0b00) {
|
||||
ebs.setB2Low(null);
|
||||
ebs.setB2High(null);
|
||||
ebs.setB3(null);
|
||||
subChunk.setB2Low(null);
|
||||
subChunk.setB2High(null);
|
||||
subChunk.setB3(null);
|
||||
continue;
|
||||
}
|
||||
var b2Low = ebs.getB2Low();
|
||||
var b2Low = subChunk.getB2Low();
|
||||
if (b2Low == null) {
|
||||
b2Low = ebs.createB2Low();
|
||||
b2Low = subChunk.createB2Low();
|
||||
}
|
||||
buffer.get(b2Low.data);
|
||||
if (storageFlag == 0b01) {
|
||||
ebs.setB2High(null);
|
||||
ebs.setB3(null);
|
||||
subChunk.setB2High(null);
|
||||
subChunk.setB3(null);
|
||||
continue;
|
||||
}
|
||||
var b2High = ebs.getB2High();
|
||||
var b2High = subChunk.getB2High();
|
||||
if (b2High == null) {
|
||||
b2High = ebs.createB2High();
|
||||
b2High = subChunk.createB2High();
|
||||
}
|
||||
buffer.get(b2High.data);
|
||||
if (storageFlag == 0b10) {
|
||||
ebs.setB3(null);
|
||||
subChunk.setB3(null);
|
||||
continue;
|
||||
}
|
||||
var b3 = ebs.getB3();
|
||||
var b3 = subChunk.getB3();
|
||||
if (b3 == null) {
|
||||
b3 = ebs.createB3();
|
||||
b3 = subChunk.createB3();
|
||||
}
|
||||
buffer.get(b3);
|
||||
}
|
||||
@@ -122,27 +122,27 @@ public class BlockIDManager implements DataManager.PacketDataManager, DataManage
|
||||
|
||||
|
||||
@Override
|
||||
public void writeSubChunkToNBT(Chunk chunk, ExtendedBlockStorage ebsVanilla, NBTTagCompound section) {
|
||||
val ebs = (IExtendedBlockStorageMixin) ebsVanilla;
|
||||
val b1 = ebs.getB1();
|
||||
val b2Low = ebs.getB2Low();
|
||||
val b2High = ebs.getB2High();
|
||||
val b3 = ebs.getB3();
|
||||
section.setByteArray("Blocks", b1);
|
||||
public void writeSubChunkToNBT(Chunk chunk, ExtendedBlockStorage subChunkVanilla, NBTTagCompound nbt) {
|
||||
val subChunk = (SubChunkBlockHook) subChunkVanilla;
|
||||
val b1 = subChunk.getB1();
|
||||
val b2Low = subChunk.getB2Low();
|
||||
val b2High = subChunk.getB2High();
|
||||
val b3 = subChunk.getB3();
|
||||
nbt.setByteArray("Blocks", b1);
|
||||
if (b2Low != null) {
|
||||
section.setByteArray("Add", b2Low.data);
|
||||
nbt.setByteArray("Add", b2Low.data);
|
||||
}
|
||||
if (b2High != null) {
|
||||
section.setByteArray("BlocksB2Hi", b2High.data);
|
||||
nbt.setByteArray("BlocksB2Hi", b2High.data);
|
||||
}
|
||||
if (b3 != null) {
|
||||
section.setByteArray("BlocksB3", b3);
|
||||
nbt.setByteArray("BlocksB3", b3);
|
||||
}
|
||||
}
|
||||
|
||||
//NotEnoughIDs world compatibility
|
||||
public static void readSectionFromNBTNotEnoughIDsDFU(IExtendedBlockStorageMixin ebs, NBTTagCompound section) {
|
||||
val data = section.getByteArray("Blocks16");
|
||||
public static void readSectionFromNBTNotEnoughIDsDFU(SubChunkBlockHook subChunk, NBTTagCompound nbt) {
|
||||
val data = nbt.getByteArray("Blocks16");
|
||||
val dataShort = new short[data.length >>> 1];
|
||||
ByteBuffer.wrap(data).asShortBuffer().get(dataShort);
|
||||
val b1 = new byte[dataShort.length];
|
||||
@@ -156,34 +156,34 @@ public class BlockIDManager implements DataManager.PacketDataManager, DataManage
|
||||
b2L[nI] |= ((s & 0x0F00) >>> 8) << mI;
|
||||
b2H[nI] |= ((s & 0xF000) >>> 12) << mI;
|
||||
}
|
||||
ebs.setB1(b1);
|
||||
ebs.setB2Low(new NibbleArray(b2L, 4));
|
||||
ebs.setB2High(new NibbleArray(b2H, 4));
|
||||
subChunk.setB1(b1);
|
||||
subChunk.setB2Low(new NibbleArray(b2L, 4));
|
||||
subChunk.setB2High(new NibbleArray(b2H, 4));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readSubChunkFromNBT(Chunk chunk, ExtendedBlockStorage ebsVanilla, NBTTagCompound section) {
|
||||
val ebs = (IExtendedBlockStorageMixin) ebsVanilla;
|
||||
if (section.hasKey("Blocks16")) {
|
||||
readSectionFromNBTNotEnoughIDsDFU(ebs, section);
|
||||
public void readSubChunkFromNBT(Chunk chunk, ExtendedBlockStorage subChunkVanilla, NBTTagCompound nbt) {
|
||||
val subChunk = (SubChunkBlockHook) subChunkVanilla;
|
||||
if (nbt.hasKey("Blocks16")) {
|
||||
readSectionFromNBTNotEnoughIDsDFU(subChunk, nbt);
|
||||
return;
|
||||
}
|
||||
assert section.hasKey("Blocks");
|
||||
val b1 = section.getByteArray("Blocks");
|
||||
final byte[] b2Low = section.hasKey("Add") ? section.getByteArray("Add") : null;
|
||||
final byte[] b2High = section.hasKey("BlocksB2Hi") ? section.getByteArray("BlocksB2Hi") : null;
|
||||
final byte[] b3 = section.hasKey("BlocksB3") ? section.getByteArray("BlocksB3") : null;
|
||||
assert nbt.hasKey("Blocks");
|
||||
val b1 = nbt.getByteArray("Blocks");
|
||||
final byte[] b2Low = nbt.hasKey("Add") ? nbt.getByteArray("Add") : null;
|
||||
final byte[] b2High = nbt.hasKey("BlocksB2Hi") ? nbt.getByteArray("BlocksB2Hi") : null;
|
||||
final byte[] b3 = nbt.hasKey("BlocksB3") ? nbt.getByteArray("BlocksB3") : null;
|
||||
|
||||
ebs.setB1(b1);
|
||||
ebs.setB2Low(b2Low == null ? null : new NibbleArray(b2Low, 4));
|
||||
ebs.setB2High(b2High == null ? null : new NibbleArray(b2High, 4));
|
||||
ebs.setB3(b3);
|
||||
subChunk.setB1(b1);
|
||||
subChunk.setB2Low(b2Low == null ? null : new NibbleArray(b2Low, 4));
|
||||
subChunk.setB2High(b2High == null ? null : new NibbleArray(b2High, 4));
|
||||
subChunk.setB3(b3);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void cloneSubChunk(Chunk fromChunk, ExtendedBlockStorage fromVanilla, ExtendedBlockStorage toVanilla) {
|
||||
val from = (IExtendedBlockStorageMixin) fromVanilla;
|
||||
val to = (IExtendedBlockStorageMixin) toVanilla;
|
||||
val from = (SubChunkBlockHook) fromVanilla;
|
||||
val to = (SubChunkBlockHook) toVanilla;
|
||||
|
||||
to.setB1(ArrayUtil.copyArray(from.getB1(), to.getB1()));
|
||||
to.setB2Low(ArrayUtil.copyArray(from.getB2Low(), to.getB2Low()));
|
||||
|
||||
Reference in new issue
Block a user