mirror of
https://github.com/LegacyModdingMC/ChunkAPI.git
synced 2026-11-18 19:29:12 +00:00
The Great Naming Scheme Cleanup. Breaking change.
- Replaced "EBS" with "subchunk" - Replaced "section" with "subchunk" - Removed the Chunk* prefix from most classes - Data manager names much more descriptive and less verbose Yes, this contradicts the backwards compatibility requirements set forth in the FalsePatternLib StableAPI interface, however, we're still in beta, and only our mods use this library as far as I'm aware, so it's fine to make changes like this for now.
This commit is contained in:
19 files changed
+250
-265
No files matched your search
@@ -7,7 +7,7 @@
|
||||
|
||||
package com.falsepattern.chunk.internal;
|
||||
|
||||
import com.falsepattern.chunk.api.ChunkDataRegistry;
|
||||
import com.falsepattern.chunk.api.DataRegistry;
|
||||
import com.falsepattern.chunk.internal.vanilla.BiomeManager;
|
||||
import com.falsepattern.chunk.internal.vanilla.BlockIDManager;
|
||||
import com.falsepattern.chunk.internal.vanilla.BlocklightManager;
|
||||
@@ -27,11 +27,11 @@ public class ChunkAPI {
|
||||
|
||||
@Mod.EventHandler
|
||||
public void init(FMLInitializationEvent event) {
|
||||
ChunkDataRegistry.registerDataManager(new BlockIDManager());
|
||||
ChunkDataRegistry.registerDataManager(new MetadataManager());
|
||||
ChunkDataRegistry.registerDataManager(new LightingManager());
|
||||
ChunkDataRegistry.registerDataManager(new BlocklightManager());
|
||||
ChunkDataRegistry.registerDataManager(new SkylightManager());
|
||||
ChunkDataRegistry.registerDataManager(new BiomeManager());
|
||||
DataRegistry.registerDataManager(new BlockIDManager());
|
||||
DataRegistry.registerDataManager(new MetadataManager());
|
||||
DataRegistry.registerDataManager(new LightingManager());
|
||||
DataRegistry.registerDataManager(new BlocklightManager());
|
||||
DataRegistry.registerDataManager(new SkylightManager());
|
||||
DataRegistry.registerDataManager(new BiomeManager());
|
||||
}
|
||||
}
|
||||
@@ -16,6 +16,6 @@ import org.apache.logging.log4j.Logger;
|
||||
public class Common {
|
||||
public static final Logger LOG = LogManager.getLogger(Tags.MODID);
|
||||
|
||||
public static final int EBS_PER_CHUNK = 16;
|
||||
public static final int BLOCKS_PER_EBS = 16 * 16 * 16;
|
||||
public static final int SUBCHUNKS_PER_CHUNK = 16;
|
||||
public static final int BLOCKS_PER_SUBCHUNK = 16 * 16 * 16;
|
||||
}
|
||||
+34
-34
@@ -7,7 +7,7 @@
|
||||
|
||||
package com.falsepattern.chunk.internal;
|
||||
|
||||
import com.falsepattern.chunk.api.ChunkDataManager;
|
||||
import com.falsepattern.chunk.api.DataManager;
|
||||
import lombok.Data;
|
||||
import lombok.val;
|
||||
import lombok.var;
|
||||
@@ -33,22 +33,22 @@ import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class ChunkDataRegistryImpl {
|
||||
public class DataRegistryImpl {
|
||||
private static final Set<String> managers = new HashSet<>();
|
||||
private static final Map<String, PacketManagerInfo> packetManagers = new HashMap<>();
|
||||
private static final Map<String, ChunkDataManager.NBTDataManager> NBTManagers = new HashMap<>();
|
||||
private static final Map<String, ChunkDataManager.ChunkNBTDataManager> chunkNBTManagers = new HashMap<>();
|
||||
private static final Map<String, ChunkDataManager.SectionNBTDataManager> sectionNBTManagers = 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 Set<String> disabledManagers = new HashSet<>();
|
||||
private static int maxPacketSize = 4;
|
||||
|
||||
@Data
|
||||
private static class PacketManagerInfo {
|
||||
public final int maxPacketSize;
|
||||
public final ChunkDataManager.PacketDataManager manager;
|
||||
public final DataManager.PacketDataManager manager;
|
||||
}
|
||||
|
||||
public static void registerDataManager(ChunkDataManager manager)
|
||||
public static void registerDataManager(DataManager manager)
|
||||
throws IllegalStateException, IllegalArgumentException {
|
||||
if (Loader.instance().getLoaderState() != LoaderState.INITIALIZATION) {
|
||||
throw new IllegalStateException("ChunkDataManager registration is not allowed at this time! " +
|
||||
@@ -65,19 +65,19 @@ public class ChunkDataRegistryImpl {
|
||||
}
|
||||
|
||||
managers.add(id);
|
||||
if (manager instanceof ChunkDataManager.PacketDataManager) {
|
||||
val packetManager = (ChunkDataManager.PacketDataManager) manager;
|
||||
if (manager instanceof DataManager.PacketDataManager) {
|
||||
val packetManager = (DataManager.PacketDataManager) manager;
|
||||
val maxSize = packetManager.maxPacketSize();
|
||||
maxPacketSize += 4 + id.getBytes(StandardCharsets.UTF_8).length + 4 + maxSize;
|
||||
packetManagers.put(id, new PacketManagerInfo(maxSize, packetManager));
|
||||
}
|
||||
if (manager instanceof ChunkDataManager.NBTDataManager) {
|
||||
NBTManagers.put(id, (ChunkDataManager.NBTDataManager) manager);
|
||||
if (manager instanceof ChunkDataManager.ChunkNBTDataManager) {
|
||||
chunkNBTManagers.put(id, (ChunkDataManager.ChunkNBTDataManager) manager);
|
||||
if (manager instanceof DataManager.StorageDataManager) {
|
||||
NBTManagers.put(id, (DataManager.StorageDataManager) manager);
|
||||
if (manager instanceof DataManager.ChunkDataManager) {
|
||||
chunkNBTManagers.put(id, (DataManager.ChunkDataManager) manager);
|
||||
}
|
||||
if (manager instanceof ChunkDataManager.SectionNBTDataManager) {
|
||||
sectionNBTManagers.put(id, (ChunkDataManager.SectionNBTDataManager) manager);
|
||||
if (manager instanceof DataManager.SubchunkDataManager) {
|
||||
subchunkNBTManagers.put(id, (DataManager.SubchunkDataManager) manager);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -98,7 +98,7 @@ public class ChunkDataRegistryImpl {
|
||||
maxPacketSize -= 4 + id.getBytes(StandardCharsets.UTF_8).length + 4 + removed.maxPacketSize;
|
||||
}
|
||||
chunkNBTManagers.remove(manager);
|
||||
sectionNBTManagers.remove(manager);
|
||||
subchunkNBTManagers.remove(manager);
|
||||
NBTManagers.remove(manager);
|
||||
}
|
||||
|
||||
@@ -123,7 +123,7 @@ public class ChunkDataRegistryImpl {
|
||||
return new String(bytes);
|
||||
}
|
||||
|
||||
public static void readFromBuffer(Chunk chunk, int ebsMask, 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 ChunkDataRegistryImpl {
|
||||
}
|
||||
int start = buf.position();
|
||||
val slice = createSlice(buf, start, length);
|
||||
managerInfo.manager.readFromBuffer(chunk, ebsMask, forceUpdate, slice);
|
||||
managerInfo.manager.readFromBuffer(chunk, subchunkMask, forceUpdate, slice);
|
||||
buf.position(start + length);
|
||||
}
|
||||
}
|
||||
|
||||
public static int writeToBuffer(Chunk chunk, int ebsMask, 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 ChunkDataRegistryImpl {
|
||||
writeString(buf, id);
|
||||
int start = buf.position() + 4;
|
||||
val slice = createSlice(buf, start, managerInfo.maxPacketSize);
|
||||
managerInfo.manager.writeToBuffer(chunk, ebsMask, forceUpdate, slice);
|
||||
managerInfo.manager.writeToBuffer(chunk, subchunkMask, forceUpdate, slice);
|
||||
int length = slice.position();
|
||||
buf.putInt(length);
|
||||
buf.position(start + length);
|
||||
@@ -175,7 +175,7 @@ public class ChunkDataRegistryImpl {
|
||||
return slice;
|
||||
}
|
||||
|
||||
private static NBTTagCompound createManagerNBT(boolean privileged, NBTTagCompound root, ChunkDataManager manager) {
|
||||
private static NBTTagCompound createManagerNBT(boolean privileged, NBTTagCompound root, DataManager manager) {
|
||||
if (privileged) {
|
||||
return root;
|
||||
}
|
||||
@@ -197,7 +197,7 @@ public class ChunkDataRegistryImpl {
|
||||
}
|
||||
}
|
||||
|
||||
private static NBTTagCompound getManagerNBT(boolean privileged, NBTTagCompound root, ChunkDataManager manager) {
|
||||
private static NBTTagCompound getManagerNBT(boolean privileged, NBTTagCompound root, DataManager manager) {
|
||||
if (privileged) {
|
||||
return root;
|
||||
}
|
||||
@@ -212,17 +212,17 @@ public class ChunkDataRegistryImpl {
|
||||
return domainNBT.getCompoundTag(manager.id());
|
||||
}
|
||||
|
||||
public static void writeSectionToNBT(Chunk chunk, ExtendedBlockStorage ebs, NBTTagCompound sectionNBT) {
|
||||
for (val manager : sectionNBTManagers.values()) {
|
||||
manager.writeSectionToNBT(chunk, ebs,
|
||||
createManagerNBT(manager.sectionPrivilegedAccess(), sectionNBT, 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 readSectionFromNBT(Chunk chunk, ExtendedBlockStorage ebs, NBTTagCompound sectionNBT) {
|
||||
for (val manager : sectionNBTManagers.values()) {
|
||||
manager.readSectionFromNBT(chunk, ebs,
|
||||
getManagerNBT(manager.sectionPrivilegedAccess(), sectionNBT, 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 ChunkDataRegistryImpl {
|
||||
}
|
||||
}
|
||||
|
||||
public static void cloneSection(Chunk fromChunk, ExtendedBlockStorage from, ExtendedBlockStorage to) {
|
||||
for (val manager: sectionNBTManagers.values()) {
|
||||
manager.cloneSection(fromChunk, from, to);
|
||||
public static void cloneSubchunk(Chunk fromChunk, ExtendedBlockStorage from, ExtendedBlockStorage to) {
|
||||
for (val manager: subchunkNBTManagers.values()) {
|
||||
manager.cloneSubchunk(fromChunk, from, to);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -414,7 +414,7 @@ public class ChunkDataRegistryImpl {
|
||||
}
|
||||
}
|
||||
|
||||
public static SaveManagerInfo fromManager(ChunkDataManager.NBTDataManager manager) {
|
||||
public static SaveManagerInfo fromManager(DataManager.StorageDataManager manager) {
|
||||
return new SaveManagerInfo(manager.version(), manager.uninstallMessage());
|
||||
}
|
||||
}
|
||||
@@ -1,26 +1,21 @@
|
||||
package com.falsepattern.chunk.internal.core;
|
||||
|
||||
import com.falsepattern.chunk.internal.ChunkDataRegistryImpl;
|
||||
import com.falsepattern.chunk.internal.DataRegistryImpl;
|
||||
import com.falsepattern.chunk.internal.Tags;
|
||||
import com.google.common.eventbus.EventBus;
|
||||
import lombok.Data;
|
||||
import lombok.val;
|
||||
|
||||
import net.minecraft.nbt.NBTBase;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.world.storage.SaveHandler;
|
||||
import net.minecraft.world.storage.WorldInfo;
|
||||
import net.minecraftforge.common.util.Constants;
|
||||
import cpw.mods.fml.common.DummyModContainer;
|
||||
import cpw.mods.fml.common.LoadController;
|
||||
import cpw.mods.fml.common.ModMetadata;
|
||||
import cpw.mods.fml.common.StartupQuery;
|
||||
import cpw.mods.fml.common.WorldAccessContainer;
|
||||
import cpw.mods.fml.common.versioning.DefaultArtifactVersion;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
public class ChunkAPICoreModContainer extends DummyModContainer implements WorldAccessContainer {
|
||||
public ChunkAPICoreModContainer() {
|
||||
@@ -45,12 +40,12 @@ public class ChunkAPICoreModContainer extends DummyModContainer implements World
|
||||
@Override
|
||||
public NBTTagCompound getDataForWriting(SaveHandler handler, WorldInfo info) {
|
||||
val tag = new NBTTagCompound();
|
||||
ChunkDataRegistryImpl.writeLevelDat(tag);
|
||||
DataRegistryImpl.writeLevelDat(tag);
|
||||
return tag;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readData(SaveHandler handler, WorldInfo info, Map<String, NBTBase> propertyMap, NBTTagCompound tag) {
|
||||
ChunkDataRegistryImpl.readLevelDat(tag);
|
||||
DataRegistryImpl.readLevelDat(tag);
|
||||
}
|
||||
}
|
||||
+5
-5
@@ -7,7 +7,7 @@
|
||||
|
||||
package com.falsepattern.chunk.internal.mixin.mixins.client.vanilla;
|
||||
|
||||
import com.falsepattern.chunk.internal.ChunkDataRegistryImpl;
|
||||
import com.falsepattern.chunk.internal.DataRegistryImpl;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Overwrite;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
@@ -53,7 +53,7 @@ public abstract class ChunkMixin {
|
||||
*/
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Overwrite
|
||||
public void fillChunk(byte[] data, int ebsMask, int ebsMSBMask, 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 ((ebsMask & (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 {
|
||||
}
|
||||
}
|
||||
|
||||
ChunkDataRegistryImpl.readFromBuffer((Chunk) (Object) this, ebsMask, forceUpdate, data);
|
||||
DataRegistryImpl.readFromBuffer((Chunk) (Object) this, subchunkMask, forceUpdate, data);
|
||||
|
||||
for (int i = 0; i < storageArrays.length; ++i) {
|
||||
if ((storageArrays[i] != null) && ((ebsMask & (1 << i)) != 0)) {
|
||||
if ((storageArrays[i] != null) && ((subchunkMask & (1 << i)) != 0)) {
|
||||
storageArrays[i].removeInvalidBlocks();
|
||||
}
|
||||
}
|
||||
|
||||
+27
-27
@@ -7,7 +7,7 @@
|
||||
|
||||
package com.falsepattern.chunk.internal.mixin.mixins.common.vanilla;
|
||||
|
||||
import com.falsepattern.chunk.internal.ChunkDataRegistryImpl;
|
||||
import com.falsepattern.chunk.internal.DataRegistryImpl;
|
||||
import lombok.val;
|
||||
import org.apache.logging.log4j.Level;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
@@ -44,7 +44,7 @@ public abstract class AnvilChunkLoaderMixin {
|
||||
nbt.setLong("LastUpdate", world.getTotalWorldTime());
|
||||
nbt.setBoolean("TerrainPopulated", chunk.isTerrainPopulated);
|
||||
nbt.setLong("InhabitedTime", chunk.inhabitedTime);
|
||||
writeSections(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");
|
||||
readSections(chunk, nbt);
|
||||
readSubchunks(chunk, nbt);
|
||||
readCustomData(chunk, nbt);
|
||||
|
||||
// End this method here and split off entity loading to another method
|
||||
@@ -71,46 +71,46 @@ public abstract class AnvilChunkLoaderMixin {
|
||||
}
|
||||
|
||||
private void readCustomData(Chunk chunk, NBTTagCompound nbt) {
|
||||
ChunkDataRegistryImpl.readChunkFromNBT(chunk, nbt);
|
||||
DataRegistryImpl.readChunkFromNBT(chunk, nbt);
|
||||
}
|
||||
|
||||
private void readSections(Chunk chunk, NBTTagCompound nbt) {
|
||||
NBTTagList sections = nbt.getTagList("Sections", 10);
|
||||
private void readSubchunks(Chunk chunk, NBTTagCompound nbt) {
|
||||
NBTTagList subchunksNBT = nbt.getTagList("Sections", 10);
|
||||
byte segments = 16;
|
||||
ExtendedBlockStorage[] ebsList = new ExtendedBlockStorage[segments];
|
||||
ExtendedBlockStorage[] subchunkList = new ExtendedBlockStorage[segments];
|
||||
|
||||
for (int k = 0; k < sections.tagCount(); ++k) {
|
||||
NBTTagCompound section = sections.getCompoundTagAt(k);
|
||||
byte yLevel = section.getByte("Y");
|
||||
ExtendedBlockStorage ebs = new ExtendedBlockStorage(yLevel << 4, !chunk.worldObj.provider.hasNoSky);
|
||||
ChunkDataRegistryImpl.readSectionFromNBT(chunk, ebs, section);
|
||||
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);
|
||||
|
||||
ebs.removeInvalidBlocks();
|
||||
ebsList[yLevel] = ebs;
|
||||
subchunk.removeInvalidBlocks();
|
||||
subchunkList[yLevel] = subchunk;
|
||||
}
|
||||
|
||||
chunk.setStorageArrays(ebsList);
|
||||
chunk.setStorageArrays(subchunkList);
|
||||
}
|
||||
|
||||
private void writeCustomData(Chunk chunk, NBTTagCompound nbt) {
|
||||
ChunkDataRegistryImpl.writeChunkToNBT(chunk, nbt);
|
||||
DataRegistryImpl.writeChunkToNBT(chunk, nbt);
|
||||
}
|
||||
|
||||
private void writeSections(Chunk chunk, NBTTagCompound nbt) {
|
||||
ExtendedBlockStorage[] ebsList = chunk.getBlockStorageArray();
|
||||
NBTTagList sections = new NBTTagList();
|
||||
NBTTagCompound section;
|
||||
private void writeSubchunks(Chunk chunk, NBTTagCompound nbt) {
|
||||
ExtendedBlockStorage[] subchunks = chunk.getBlockStorageArray();
|
||||
NBTTagList subchunksNBT = new NBTTagList();
|
||||
NBTTagCompound subchunkNBT;
|
||||
|
||||
for (ExtendedBlockStorage ebs : ebsList) {
|
||||
if (ebs != null) {
|
||||
section = new NBTTagCompound();
|
||||
section.setByte("Y", (byte) (ebs.getYLocation() >> 4 & 255));
|
||||
ChunkDataRegistryImpl.writeSectionToNBT(chunk, ebs, section);
|
||||
sections.appendTag(section);
|
||||
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", sections);
|
||||
nbt.setTag("Sections", subchunksNBT);
|
||||
}
|
||||
|
||||
private void writeEntities(Chunk chunk, World world, NBTTagCompound nbt) {
|
||||
|
||||
+12
-12
@@ -7,7 +7,7 @@
|
||||
|
||||
package com.falsepattern.chunk.internal.mixin.mixins.common.vanilla;
|
||||
|
||||
import com.falsepattern.chunk.internal.ChunkDataRegistryImpl;
|
||||
import com.falsepattern.chunk.internal.DataRegistryImpl;
|
||||
import lombok.val;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Overwrite;
|
||||
@@ -37,7 +37,7 @@ public abstract class S21PacketChunkDataMixin {
|
||||
@Shadow(aliases = "field_149282_b")
|
||||
private int zPosition;
|
||||
@Shadow(aliases = "field_149283_c")
|
||||
private int ebsMask;
|
||||
private int subchunkMask;
|
||||
@Shadow(aliases = "field_149281_e")
|
||||
private byte[] deflatedData;
|
||||
@Shadow(aliases = "field_149278_f")
|
||||
@@ -51,7 +51,7 @@ public abstract class S21PacketChunkDataMixin {
|
||||
constant = @Constant(intValue = 196864),
|
||||
require = 1)
|
||||
private static int increasePacketSize(int constant) {
|
||||
return ChunkDataRegistryImpl.maxPacketSize();
|
||||
return DataRegistryImpl.maxPacketSize();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -59,25 +59,25 @@ public abstract class S21PacketChunkDataMixin {
|
||||
* @reason Replace functionality
|
||||
*/
|
||||
@Overwrite
|
||||
public static S21PacketChunkData.Extracted func_149269_a(Chunk chunk, boolean forceUpdate, int ebsMask) {
|
||||
ExtendedBlockStorage[] ebs = 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 < ChunkDataRegistryImpl.maxPacketSize()) {
|
||||
buffer = new byte[ChunkDataRegistryImpl.maxPacketSize()];
|
||||
if (buffer.length < DataRegistryImpl.maxPacketSize()) {
|
||||
buffer = new byte[DataRegistryImpl.maxPacketSize()];
|
||||
}
|
||||
|
||||
if (forceUpdate) {
|
||||
chunk.sendUpdates = true;
|
||||
}
|
||||
|
||||
for (int i = 0; i < ebs.length; ++i) {
|
||||
if (ebs[i] != null && (!forceUpdate || !ebs[i].isEmpty()) && (ebsMask & 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;
|
||||
}
|
||||
}
|
||||
|
||||
int length = ChunkDataRegistryImpl.writeToBuffer(chunk, extracted.field_150280_b, forceUpdate, buffer);
|
||||
int length = DataRegistryImpl.writeToBuffer(chunk, extracted.field_150280_b, forceUpdate, buffer);
|
||||
|
||||
extracted.field_150282_a = new byte[length];
|
||||
System.arraycopy(buffer, 0, extracted.field_150282_a, 0, length);
|
||||
@@ -106,7 +106,7 @@ public abstract class S21PacketChunkDataMixin {
|
||||
data.writeInt(xPosition);
|
||||
data.writeInt(zPosition);
|
||||
data.writeBoolean(forceUpdate);
|
||||
data.writeShort((short) (ebsMask & 0xFFFF));
|
||||
data.writeShort((short) (subchunkMask & 0xFFFF));
|
||||
data.writeInt(this.data.length);
|
||||
data.writeInt(deflatedSize);
|
||||
data.writeBytes(deflatedData, 0, deflatedSize);
|
||||
@@ -121,7 +121,7 @@ public abstract class S21PacketChunkDataMixin {
|
||||
xPosition = data.readInt();
|
||||
zPosition = data.readInt();
|
||||
forceUpdate = data.readBoolean();
|
||||
ebsMask = 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[] ebsMasks;
|
||||
private int[] subchunkMasks;
|
||||
@Shadow(aliases = "field_149262_d")
|
||||
private int[] ebsMSBMasks;
|
||||
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];
|
||||
ebsMasks = new int[chunkCount];
|
||||
ebsMSBMasks = 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();
|
||||
ebsMasks[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) (ebsMasks[i] & 65535));
|
||||
data.writeShort((short) (subchunkMasks[i] & 65535));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -7,7 +7,7 @@
|
||||
|
||||
package com.falsepattern.chunk.internal.vanilla;
|
||||
|
||||
import com.falsepattern.chunk.api.ChunkDataManager;
|
||||
import com.falsepattern.chunk.api.DataManager;
|
||||
import com.falsepattern.chunk.api.ArrayUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
@@ -17,7 +17,7 @@ import net.minecraft.world.chunk.Chunk;
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
public class BiomeManager extends VanillaManager
|
||||
implements ChunkDataManager.PacketDataManager, ChunkDataManager.ChunkNBTDataManager {
|
||||
implements DataManager.PacketDataManager, DataManager.ChunkDataManager {
|
||||
public static final int BYTES_PER_CHUNK = 256;
|
||||
|
||||
@Override
|
||||
@@ -31,14 +31,14 @@ public class BiomeManager extends VanillaManager
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToBuffer(@NotNull Chunk chunk, int ebsMask, 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 ebsMask, boolean forceUpdate, @NotNull ByteBuffer buffer) {
|
||||
public void readFromBuffer(@NotNull Chunk chunk, int subchunkMask, boolean forceUpdate, @NotNull ByteBuffer buffer) {
|
||||
if (forceUpdate) {
|
||||
buffer.get(chunk.getBiomeArray());
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
|
||||
package com.falsepattern.chunk.internal.vanilla;
|
||||
|
||||
import com.falsepattern.chunk.api.ChunkDataManager;
|
||||
import com.falsepattern.chunk.api.DataManager;
|
||||
import com.falsepattern.chunk.api.ArrayUtil;
|
||||
import lombok.val;
|
||||
|
||||
@@ -18,13 +18,13 @@ import net.minecraft.world.chunk.storage.ExtendedBlockStorage;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
import static com.falsepattern.chunk.internal.Common.BLOCKS_PER_EBS;
|
||||
import static com.falsepattern.chunk.internal.Common.EBS_PER_CHUNK;
|
||||
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 ChunkDataManager.PacketDataManager, ChunkDataManager.SectionNBTDataManager {
|
||||
private static final int LSB_BYTES_PER_EBS = BLOCKS_PER_EBS;
|
||||
private static final int MSB_BYTES_PER_EBS = BLOCKS_PER_EBS / 2;
|
||||
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;
|
||||
|
||||
@Override
|
||||
@@ -34,20 +34,20 @@ public class BlockIDManager extends VanillaManager
|
||||
|
||||
@Override
|
||||
public int maxPacketSize() {
|
||||
return HEADER_SIZE + EBS_PER_CHUNK * (LSB_BYTES_PER_EBS + MSB_BYTES_PER_EBS);
|
||||
return HEADER_SIZE + SUBCHUNKS_PER_CHUNK * (LSB_BYTES_PER_SUBCHUNK + MSB_BYTES_PER_SUBCHUNK);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToBuffer(Chunk chunk, int ebsMask, boolean forceUpdate, ByteBuffer data) {
|
||||
val ebsArray = 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 < ebsArray.length; i++) {
|
||||
if ((ebsMask & (1 << i)) != 0) {
|
||||
val ebs = ebsArray[i];
|
||||
val lsb = ebs.getBlockLSBArray();
|
||||
val msb = ebs.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 ebsMask, boolean forceUpdate, ByteBuffer buffer) {
|
||||
val ebsArray = 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 < ebsArray.length; i++) {
|
||||
val ebs = ebsArray[i];
|
||||
if ((ebsMask & (1 << i)) != 0 && ebs != null) {
|
||||
buffer.get(ebs.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 = ebs.getBlockMSBArray();
|
||||
val msb = subchunk.getBlockMSBArray();
|
||||
if (msb == null) {
|
||||
ebs.createBlockMSBArray();
|
||||
subchunk.createBlockMSBArray();
|
||||
}
|
||||
buffer.get(ebs.getBlockMSBArray().data);
|
||||
buffer.get(subchunk.getBlockMSBArray().data);
|
||||
} else {
|
||||
ebs.setBlockMSBArray(null);
|
||||
subchunk.setBlockMSBArray(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean sectionPrivilegedAccess() {
|
||||
public boolean subchunkPrivilegedAccess() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeSectionToNBT(Chunk chunk, ExtendedBlockStorage ebs, NBTTagCompound section) {
|
||||
section.setByteArray("Blocks", ebs.getBlockLSBArray());
|
||||
public void writeSubchunkToNBT(Chunk chunk, ExtendedBlockStorage subchunk, NBTTagCompound nbt) {
|
||||
nbt.setByteArray("Blocks", subchunk.getBlockLSBArray());
|
||||
|
||||
if (ebs.getBlockMSBArray() != null) {
|
||||
section.setByteArray("Add", ebs.getBlockMSBArray().data);
|
||||
if (subchunk.getBlockMSBArray() != null) {
|
||||
nbt.setByteArray("Add", subchunk.getBlockMSBArray().data);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readSectionFromNBT(Chunk chunk, ExtendedBlockStorage ebs, NBTTagCompound section) {
|
||||
ebs.setBlockLSBArray(section.getByteArray("Blocks"));
|
||||
public void readSubchunkFromNBT(Chunk chunk, ExtendedBlockStorage subchunk, NBTTagCompound nbt) {
|
||||
subchunk.setBlockLSBArray(nbt.getByteArray("Blocks"));
|
||||
|
||||
if (section.hasKey("Add", 7)) {
|
||||
ebs.setBlockMSBArray(new NibbleArray(section.getByteArray("Add"), 4));
|
||||
if (nbt.hasKey("Add", 7)) {
|
||||
subchunk.setBlockMSBArray(new NibbleArray(nbt.getByteArray("Add"), 4));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void cloneSection(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()));
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
|
||||
package com.falsepattern.chunk.internal.vanilla;
|
||||
|
||||
import com.falsepattern.chunk.api.ChunkDataManager;
|
||||
import com.falsepattern.chunk.api.DataManager;
|
||||
import com.falsepattern.chunk.api.ArrayUtil;
|
||||
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
@@ -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 ChunkDataManager.SectionNBTDataManager {
|
||||
public class BlocklightManager extends NibbleManager implements DataManager.SubchunkDataManager {
|
||||
@Override
|
||||
protected NibbleArray getNibbleArray(ExtendedBlockStorage ebs) {
|
||||
return ebs.getBlocklightArray();
|
||||
protected NibbleArray getNibbleArray(ExtendedBlockStorage subchunk) {
|
||||
return subchunk.getBlocklightArray();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -27,22 +27,22 @@ public class BlocklightManager extends NibbleManager implements ChunkDataManager
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean sectionPrivilegedAccess() {
|
||||
public boolean subchunkPrivilegedAccess() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeSectionToNBT(Chunk chunk, ExtendedBlockStorage ebs, NBTTagCompound section) {
|
||||
section.setByteArray("BlockLight", ebs.getBlocklightArray().data);
|
||||
public void writeSubchunkToNBT(Chunk chunk, ExtendedBlockStorage subchunk, NBTTagCompound nbt) {
|
||||
nbt.setByteArray("BlockLight", subchunk.getBlocklightArray().data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readSectionFromNBT(Chunk chunk, ExtendedBlockStorage ebs, NBTTagCompound section) {
|
||||
ebs.setBlocklightArray(new NibbleArray(section.getByteArray("BlockLight"), 4));
|
||||
public void readSubchunkFromNBT(Chunk chunk, ExtendedBlockStorage subchunk, NBTTagCompound nbt) {
|
||||
subchunk.setBlocklightArray(new NibbleArray(nbt.getByteArray("BlockLight"), 4));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void cloneSection(Chunk fromChunk, ExtendedBlockStorage from, ExtendedBlockStorage to) {
|
||||
public void cloneSubchunk(Chunk fromChunk, ExtendedBlockStorage from, ExtendedBlockStorage to) {
|
||||
from.setBlocklightArray(ArrayUtil.copyArray(from.getBlocklightArray(), to.getBlocklightArray()));
|
||||
}
|
||||
}
|
||||
@@ -7,13 +7,13 @@
|
||||
|
||||
package com.falsepattern.chunk.internal.vanilla;
|
||||
|
||||
import com.falsepattern.chunk.api.ChunkDataManager;
|
||||
import com.falsepattern.chunk.api.DataManager;
|
||||
import com.falsepattern.chunk.api.ArrayUtil;
|
||||
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.world.chunk.Chunk;
|
||||
|
||||
public class LightingManager extends VanillaManager implements ChunkDataManager.ChunkNBTDataManager {
|
||||
public class LightingManager extends VanillaManager implements DataManager.ChunkDataManager {
|
||||
@Override
|
||||
public String id() {
|
||||
return "lighting";
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
|
||||
package com.falsepattern.chunk.internal.vanilla;
|
||||
|
||||
import com.falsepattern.chunk.api.ChunkDataManager;
|
||||
import com.falsepattern.chunk.api.DataManager;
|
||||
import com.falsepattern.chunk.api.ArrayUtil;
|
||||
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
@@ -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 ChunkDataManager.SectionNBTDataManager {
|
||||
public class MetadataManager extends NibbleManager implements DataManager.SubchunkDataManager {
|
||||
@Override
|
||||
protected NibbleArray getNibbleArray(ExtendedBlockStorage ebs) {
|
||||
return ebs.getMetadataArray();
|
||||
protected NibbleArray getNibbleArray(ExtendedBlockStorage subchunk) {
|
||||
return subchunk.getMetadataArray();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -27,22 +27,22 @@ public class MetadataManager extends NibbleManager implements ChunkDataManager.S
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean sectionPrivilegedAccess() {
|
||||
public boolean subchunkPrivilegedAccess() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeSectionToNBT(Chunk chunk, ExtendedBlockStorage ebs, NBTTagCompound section) {
|
||||
section.setByteArray("Data", ebs.getMetadataArray().data);
|
||||
public void writeSubchunkToNBT(Chunk chunk, ExtendedBlockStorage subchunk, NBTTagCompound nbt) {
|
||||
nbt.setByteArray("Data", subchunk.getMetadataArray().data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readSectionFromNBT(Chunk chunk, ExtendedBlockStorage ebs, NBTTagCompound section) {
|
||||
ebs.setBlockMetadataArray(new NibbleArray(section.getByteArray("Data"), 4));
|
||||
public void readSubchunkFromNBT(Chunk chunk, ExtendedBlockStorage subchunk, NBTTagCompound nbt) {
|
||||
subchunk.setBlockMetadataArray(new NibbleArray(nbt.getByteArray("Data"), 4));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void cloneSection(Chunk fromChunk, ExtendedBlockStorage from, ExtendedBlockStorage to) {
|
||||
public void cloneSubchunk(Chunk fromChunk, ExtendedBlockStorage from, ExtendedBlockStorage to) {
|
||||
to.setBlockMetadataArray(ArrayUtil.copyArray(from.getMetadataArray(), to.getMetadataArray()));
|
||||
}
|
||||
}
|
||||
@@ -7,7 +7,7 @@
|
||||
|
||||
package com.falsepattern.chunk.internal.vanilla;
|
||||
|
||||
import com.falsepattern.chunk.api.ChunkDataManager;
|
||||
import com.falsepattern.chunk.api.DataManager;
|
||||
import com.falsepattern.chunk.internal.Common;
|
||||
import lombok.val;
|
||||
|
||||
@@ -17,37 +17,37 @@ import net.minecraft.world.chunk.storage.ExtendedBlockStorage;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
public abstract class NibbleManager extends VanillaManager implements ChunkDataManager.PacketDataManager {
|
||||
public static final int BYTES_PER_EBS = Common.BLOCKS_PER_EBS / 2;
|
||||
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 ebs);
|
||||
protected abstract NibbleArray getNibbleArray(ExtendedBlockStorage subchunk);
|
||||
|
||||
@Override
|
||||
public int maxPacketSize() {
|
||||
return Common.EBS_PER_CHUNK * BYTES_PER_EBS;
|
||||
return Common.SUBCHUNKS_PER_CHUNK * BYTES_PER_SUBCHUNK;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToBuffer(Chunk chunk, int ebsMask, boolean forceUpdate, ByteBuffer data) {
|
||||
val ebsArray = chunk.getBlockStorageArray();
|
||||
for (int i = 0; i < ebsArray.length; i++) {
|
||||
if ((ebsMask & (1 << i)) != 0) {
|
||||
val ebs = ebsArray[i];
|
||||
if (ebs != null) {
|
||||
data.put(getNibbleArray(ebs).data, 0, BYTES_PER_EBS);
|
||||
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 ebsMask, boolean forceUpdate, ByteBuffer buffer) {
|
||||
val ebsArray = chunk.getBlockStorageArray();
|
||||
for (int i = 0; i < ebsArray.length; i++) {
|
||||
if ((ebsMask & (1 << i)) != 0) {
|
||||
val ebs = ebsArray[i];
|
||||
if (ebs != null) {
|
||||
buffer.get(getNibbleArray(ebs).data, 0, BYTES_PER_EBS);
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
|
||||
package com.falsepattern.chunk.internal.vanilla;
|
||||
|
||||
import com.falsepattern.chunk.api.ChunkDataManager;
|
||||
import com.falsepattern.chunk.api.DataManager;
|
||||
import com.falsepattern.chunk.api.ArrayUtil;
|
||||
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
@@ -17,54 +17,54 @@ import net.minecraft.world.chunk.storage.ExtendedBlockStorage;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
public class SkylightManager extends NibbleManager implements ChunkDataManager.SectionNBTDataManager {
|
||||
public class SkylightManager extends NibbleManager implements DataManager.SubchunkDataManager {
|
||||
@Override
|
||||
public String id() {
|
||||
return "skylight";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected NibbleArray getNibbleArray(ExtendedBlockStorage ebs) {
|
||||
return ebs.getSkylightArray();
|
||||
protected NibbleArray getNibbleArray(ExtendedBlockStorage subchunk) {
|
||||
return subchunk.getSkylightArray();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToBuffer(Chunk chunk, int ebsMask, boolean forceUpdate, ByteBuffer data) {
|
||||
public void writeToBuffer(Chunk chunk, int subchunkMask, boolean forceUpdate, ByteBuffer data) {
|
||||
if (!chunk.worldObj.provider.hasNoSky) {
|
||||
super.writeToBuffer(chunk, ebsMask, forceUpdate, data);
|
||||
super.writeToBuffer(chunk, subchunkMask, forceUpdate, data);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromBuffer(Chunk chunk, int ebsMask, boolean forceUpdate, ByteBuffer buffer) {
|
||||
public void readFromBuffer(Chunk chunk, int subchunkMask, boolean forceUpdate, ByteBuffer buffer) {
|
||||
if (!chunk.worldObj.provider.hasNoSky) {
|
||||
super.readFromBuffer(chunk, ebsMask, forceUpdate, buffer);
|
||||
super.readFromBuffer(chunk, subchunkMask, forceUpdate, buffer);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean sectionPrivilegedAccess() {
|
||||
public boolean subchunkPrivilegedAccess() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeSectionToNBT(Chunk chunk, ExtendedBlockStorage ebs, NBTTagCompound section) {
|
||||
public void writeSubchunkToNBT(Chunk chunk, ExtendedBlockStorage subchunk, NBTTagCompound nbt) {
|
||||
if (!chunk.worldObj.provider.hasNoSky) {
|
||||
section.setByteArray("SkyLight", ebs.getSkylightArray().data);
|
||||
nbt.setByteArray("SkyLight", subchunk.getSkylightArray().data);
|
||||
} else {
|
||||
section.setByteArray("SkyLight", new byte[ebs.getBlocklightArray().data.length]);
|
||||
nbt.setByteArray("SkyLight", new byte[subchunk.getBlocklightArray().data.length]);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readSectionFromNBT(Chunk chunk, ExtendedBlockStorage ebs, NBTTagCompound section) {
|
||||
public void readSubchunkFromNBT(Chunk chunk, ExtendedBlockStorage subchunk, NBTTagCompound nbt) {
|
||||
if (!chunk.worldObj.provider.hasNoSky) {
|
||||
ebs.setSkylightArray(new NibbleArray(section.getByteArray("SkyLight"), 4));
|
||||
subchunk.setSkylightArray(new NibbleArray(nbt.getByteArray("SkyLight"), 4));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void cloneSection(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 {
|
||||
|
||||
@@ -7,11 +7,11 @@
|
||||
|
||||
package com.falsepattern.chunk.internal.vanilla;
|
||||
|
||||
import com.falsepattern.chunk.api.ChunkDataManager;
|
||||
import com.falsepattern.chunk.api.DataManager;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public abstract class VanillaManager implements ChunkDataManager {
|
||||
public abstract class VanillaManager implements DataManager {
|
||||
@Override
|
||||
public String domain() {
|
||||
return "minecraft";
|
||||
|
||||
Reference in new issue
Block a user