The Big Rename (ebs, section -> subChunk)

This commit is contained in:
FalsePattern committed 2023-12-28 21:30:10 +01:00
1 parent 83bfb89d8b
commit 3dd168fc8e
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,29 +34,29 @@ public class BlockMetaManager implements DataManager.PacketDataManager, DataMana
}
@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.getEBSMask() << (i * 2);
storageFlags |= subChunk.getMetadataMask() << (i * 2);
val m1Low = ebs.getM1Low();
val m1Low = subChunk.getM1Low();
data.put(m1Low.data);
val m1High = ebs.getM1High();
val m1High = subChunk.getM1High();
if (m1High == null) {
continue;
}
data.put(m1High.data);
val m2 = ebs.getM2();
val m2 = subChunk.getM2();
if (m2 != null) {
data.put(m2);
}
@@ -65,34 +65,34 @@ public class BlockMetaManager implements DataManager.PacketDataManager, DataMana
}
@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 m1Low = ebs.getM1Low();
val m1Low = subChunk.getM1Low();
buffer.get(m1Low.data);
if (storageFlag == 0b01) {
ebs.setM1High(null);
ebs.setM2(null);
subChunk.setM1High(null);
subChunk.setM2(null);
continue;
}
var m1High = ebs.getM1High();
var m1High = subChunk.getM1High();
if (m1High == null) {
m1High = ebs.createM1High();
m1High = subChunk.createM1High();
}
buffer.get(m1High.data);
if (storageFlag == 0b10) {
ebs.setM2(null);
subChunk.setM2(null);
continue;
}
var m2 = ebs.getM2();
var m2 = subChunk.getM2();
if (m2 == null) {
m2 = ebs.createM2();
m2 = subChunk.createM2();
}
buffer.get(m2);
}
@@ -104,37 +104,37 @@ public class BlockMetaManager implements DataManager.PacketDataManager, DataMana
}
@Override
public void writeSubChunkToNBT(Chunk chunk, ExtendedBlockStorage ebsVanilla, NBTTagCompound section) {
val ebs = (IExtendedBlockStorageMixin) ebsVanilla;
val m1Low = ebs.getM1Low();
val m1High = ebs.getM1High();
val m2 = ebs.getM2();
section.setByteArray("Data", m1Low.data);
public void writeSubChunkToNBT(Chunk chunk, ExtendedBlockStorage subChunkVanilla, NBTTagCompound nbt) {
val subChunk = (SubChunkBlockHook) subChunkVanilla;
val m1Low = subChunk.getM1Low();
val m1High = subChunk.getM1High();
val m2 = subChunk.getM2();
nbt.setByteArray("Data", m1Low.data);
if (m1High != null) {
section.setByteArray("Data1High", m1High.data);
nbt.setByteArray("Data1High", m1High.data);
}
if (m2 != null) {
section.setByteArray("Data2", m2);
nbt.setByteArray("Data2", m2);
}
}
@Override
public void readSubChunkFromNBT(Chunk chunk, ExtendedBlockStorage ebsVanilla, NBTTagCompound section) {
val ebs = (IExtendedBlockStorageMixin) ebsVanilla;
assert section.hasKey("Data");
val m1Low = section.getByteArray("Data");
final byte[] m1High = section.hasKey("Data1High") ? section.getByteArray("Data1High") : null;
final byte[] m2 = section.hasKey("Data2") ? section.getByteArray("Data2") : null;
public void readSubChunkFromNBT(Chunk chunk, ExtendedBlockStorage subChunkVanilla, NBTTagCompound nbt) {
val subChunk = (SubChunkBlockHook) subChunkVanilla;
assert nbt.hasKey("Data");
val m1Low = nbt.getByteArray("Data");
final byte[] m1High = nbt.hasKey("Data1High") ? nbt.getByteArray("Data1High") : null;
final byte[] m2 = nbt.hasKey("Data2") ? nbt.getByteArray("Data2") : null;
ebs.setM1Low(new NibbleArray(m1Low, 4));
ebs.setM1High(m1High == null ? null : new NibbleArray(m1High, 4));
ebs.setM2(m2);
subChunk.setM1Low(new NibbleArray(m1Low, 4));
subChunk.setM1High(m1High == null ? null : new NibbleArray(m1High, 4));
subChunk.setM2(m2);
}
@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.setM1Low(ArrayUtil.copyArray(from.getM1Low(), to.getM1Low()));
to.setM1High(ArrayUtil.copyArray(from.getM1High(), to.getM1High()));