mirror of
https://github.com/GTMEGA/EndlessIDs.git
synced 2026-11-12 01:27:32 +00:00
ChunkAPI 0.5 port
This commit is contained in:
7 files changed
+68
-80
No files matched your search
+2
-1
@@ -23,7 +23,8 @@ dependencies {
|
||||
|
||||
implementation("com.falsepattern:falsepatternlib-mc1.7.10:1.0.0:dev")
|
||||
|
||||
implementation("com.falsepattern:chunkapi-mc1.7.10:0.4.0-hotfix1:dev")
|
||||
compileOnly("com.falsepattern:chunkapi-mc1.7.10:0.5.0:api")
|
||||
runtimeOnly("com.falsepattern:chunkapi-mc1.7.10:0.5.0:dev")
|
||||
|
||||
compileOnly("org.jetbrains:annotations:24.0.1")
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.falsepattern.endlessids;
|
||||
|
||||
import com.falsepattern.chunk.api.ChunkDataRegistry;
|
||||
import com.falsepattern.chunk.api.DataRegistry;
|
||||
import com.falsepattern.endlessids.config.GeneralConfig;
|
||||
import com.falsepattern.endlessids.managers.BiomeManager;
|
||||
import com.falsepattern.endlessids.managers.BlockIDManager;
|
||||
@@ -20,7 +20,7 @@ import cpw.mods.fml.common.event.FMLPreInitializationEvent;
|
||||
version = Tags.VERSION,
|
||||
name = Tags.MODNAME,
|
||||
acceptedMinecraftVersions = "[1.7.10]",
|
||||
dependencies = "required-after:chunkapi@[0.4.0,0.5.0);" +
|
||||
dependencies = "required-after:chunkapi@[0.5.0,0.6.0);" +
|
||||
"required-after:falsepatternlib@[1.0.0,);" +
|
||||
"after:antiidconflict")
|
||||
public class EndlessIDs {
|
||||
@@ -76,11 +76,11 @@ public class EndlessIDs {
|
||||
public void init(FMLInitializationEvent e) {
|
||||
patchManager.init();
|
||||
if (GeneralConfig.extendBiome) {
|
||||
ChunkDataRegistry.registerDataManager(new BiomeManager());
|
||||
DataRegistry.registerDataManager(new BiomeManager());
|
||||
}
|
||||
if (GeneralConfig.extendBlockItem) {
|
||||
ChunkDataRegistry.registerDataManager(new BlockIDManager());
|
||||
ChunkDataRegistry.registerDataManager(new BlockMetaManager());
|
||||
DataRegistry.registerDataManager(new BlockIDManager());
|
||||
DataRegistry.registerDataManager(new BlockMetaManager());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -88,11 +88,11 @@ public class EndlessIDs {
|
||||
public void postInit(FMLPostInitializationEvent e) {
|
||||
patchManager.postInit();
|
||||
if (GeneralConfig.extendBiome) {
|
||||
ChunkDataRegistry.disableDataManager("minecraft", "biome");
|
||||
DataRegistry.disableDataManager("minecraft", "biome");
|
||||
}
|
||||
if (GeneralConfig.extendBlockItem) {
|
||||
ChunkDataRegistry.disableDataManager("minecraft", "blockid");
|
||||
ChunkDataRegistry.disableDataManager("minecraft", "metadata");
|
||||
DataRegistry.disableDataManager("minecraft", "blockid");
|
||||
DataRegistry.disableDataManager("minecraft", "metadata");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,9 +1,11 @@
|
||||
package com.falsepattern.endlessids.managers;
|
||||
|
||||
import com.falsepattern.chunk.api.ChunkDataManager;
|
||||
import com.falsepattern.chunk.api.ArrayUtil;
|
||||
import com.falsepattern.chunk.api.DataManager;
|
||||
import com.falsepattern.endlessids.Hooks;
|
||||
import com.falsepattern.endlessids.Tags;
|
||||
import com.falsepattern.endlessids.mixin.helpers.IChunkMixin;
|
||||
import lombok.val;
|
||||
import lombok.var;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
@@ -13,7 +15,7 @@ import net.minecraft.world.chunk.Chunk;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
public class BiomeManager implements ChunkDataManager, ChunkDataManager.PacketDataManager, ChunkDataManager.ChunkNBTDataManager {
|
||||
public class BiomeManager implements DataManager.PacketDataManager, DataManager.ChunkDataManager {
|
||||
|
||||
@Override
|
||||
public String domain() {
|
||||
@@ -75,6 +77,14 @@ public class BiomeManager implements ChunkDataManager, ChunkDataManager.PacketDa
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void cloneChunk(Chunk fromVanilla, Chunk toVanilla) {
|
||||
val from = (IChunkMixin) fromVanilla;
|
||||
val to = (IChunkMixin) toVanilla;
|
||||
|
||||
to.setBiomeShortArray(ArrayUtil.copyArray(from.getBiomeShortArray(), to.getBiomeShortArray()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull String version() {
|
||||
return Tags.MODID;
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.falsepattern.endlessids.managers;
|
||||
|
||||
import com.falsepattern.chunk.api.ChunkDataManager;
|
||||
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 lombok.val;
|
||||
@@ -15,7 +16,7 @@ import net.minecraft.world.chunk.storage.ExtendedBlockStorage;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
public class BlockIDManager implements ChunkDataManager, ChunkDataManager.PacketDataManager, ChunkDataManager.SectionNBTDataManager {
|
||||
public class BlockIDManager implements DataManager.PacketDataManager, DataManager.SubChunkDataManager {
|
||||
|
||||
@Override
|
||||
public String domain() {
|
||||
@@ -82,9 +83,9 @@ public class BlockIDManager implements ChunkDataManager, ChunkDataManager.Packet
|
||||
val b1 = ebs.getB1();
|
||||
buffer.get(b1);
|
||||
if (storageFlag == 0b00) {
|
||||
ebs.clearB2Low();
|
||||
ebs.clearB2High();
|
||||
ebs.clearB3();
|
||||
ebs.setB2Low(null);
|
||||
ebs.setB2High(null);
|
||||
ebs.setB3(null);
|
||||
continue;
|
||||
}
|
||||
var b2Low = ebs.getB2Low();
|
||||
@@ -93,8 +94,8 @@ public class BlockIDManager implements ChunkDataManager, ChunkDataManager.Packet
|
||||
}
|
||||
buffer.get(b2Low.data);
|
||||
if (storageFlag == 0b01) {
|
||||
ebs.clearB2High();
|
||||
ebs.clearB3();
|
||||
ebs.setB2High(null);
|
||||
ebs.setB3(null);
|
||||
continue;
|
||||
}
|
||||
var b2High = ebs.getB2High();
|
||||
@@ -103,7 +104,7 @@ public class BlockIDManager implements ChunkDataManager, ChunkDataManager.Packet
|
||||
}
|
||||
buffer.get(b2High.data);
|
||||
if (storageFlag == 0b10) {
|
||||
ebs.clearB3();
|
||||
ebs.setB3(null);
|
||||
continue;
|
||||
}
|
||||
var b3 = ebs.getB3();
|
||||
@@ -115,12 +116,13 @@ public class BlockIDManager implements ChunkDataManager, ChunkDataManager.Packet
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean sectionPrivilegedAccess() {
|
||||
public boolean subChunkPrivilegedAccess() {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void writeSectionToNBT(Chunk chunk, ExtendedBlockStorage ebsVanilla, NBTTagCompound section) {
|
||||
public void writeSubChunkToNBT(Chunk chunk, ExtendedBlockStorage ebsVanilla, NBTTagCompound section) {
|
||||
val ebs = (IExtendedBlockStorageMixin) ebsVanilla;
|
||||
val b1 = ebs.getB1();
|
||||
val b2Low = ebs.getB2Low();
|
||||
@@ -160,7 +162,7 @@ public class BlockIDManager implements ChunkDataManager, ChunkDataManager.Packet
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readSectionFromNBT(Chunk chunk, ExtendedBlockStorage ebsVanilla, NBTTagCompound section) {
|
||||
public void readSubChunkFromNBT(Chunk chunk, ExtendedBlockStorage ebsVanilla, NBTTagCompound section) {
|
||||
val ebs = (IExtendedBlockStorageMixin) ebsVanilla;
|
||||
if (section.hasKey("Blocks16")) {
|
||||
readSectionFromNBTNotEnoughIDsDFU(ebs, section);
|
||||
@@ -173,19 +175,22 @@ public class BlockIDManager implements ChunkDataManager, ChunkDataManager.Packet
|
||||
final byte[] b3 = section.hasKey("BlocksB3") ? section.getByteArray("BlocksB3") : null;
|
||||
|
||||
ebs.setB1(b1);
|
||||
if (b2Low == null) {
|
||||
ebs.clearB2Low();
|
||||
} else {
|
||||
ebs.setB2Low(new NibbleArray(b2Low, 4));
|
||||
}
|
||||
if (b2High == null) {
|
||||
ebs.clearB2High();
|
||||
} else {
|
||||
ebs.setB2High(new NibbleArray(b2High, 4));
|
||||
}
|
||||
ebs.setB2Low(b2Low == null ? null : new NibbleArray(b2Low, 4));
|
||||
ebs.setB2High(b2High == null ? null : new NibbleArray(b2High, 4));
|
||||
ebs.setB3(b3);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void cloneSubChunk(Chunk fromChunk, ExtendedBlockStorage fromVanilla, ExtendedBlockStorage toVanilla) {
|
||||
val from = (IExtendedBlockStorageMixin) fromVanilla;
|
||||
val to = (IExtendedBlockStorageMixin) toVanilla;
|
||||
|
||||
to.setB1(ArrayUtil.copyArray(from.getB1(), to.getB1()));
|
||||
to.setB2Low(ArrayUtil.copyArray(from.getB2Low(), to.getB2Low()));
|
||||
to.setB2High(ArrayUtil.copyArray(from.getB2High(), to.getB2High()));
|
||||
to.setB3(ArrayUtil.copyArray(from.getB3(), to.getB3()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull String version() {
|
||||
return Tags.VERSION;
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.falsepattern.endlessids.managers;
|
||||
|
||||
import com.falsepattern.chunk.api.ChunkDataManager;
|
||||
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 lombok.val;
|
||||
@@ -15,7 +16,7 @@ import net.minecraft.world.chunk.storage.ExtendedBlockStorage;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
public class BlockMetaManager implements ChunkDataManager, ChunkDataManager.PacketDataManager, ChunkDataManager.SectionNBTDataManager {
|
||||
public class BlockMetaManager implements DataManager.PacketDataManager, DataManager.SubChunkDataManager {
|
||||
|
||||
@Override
|
||||
public String domain() {
|
||||
@@ -76,8 +77,8 @@ public class BlockMetaManager implements ChunkDataManager, ChunkDataManager.Pack
|
||||
val m1Low = ebs.getM1Low();
|
||||
buffer.get(m1Low.data);
|
||||
if (storageFlag == 0b01) {
|
||||
ebs.clearM1High();
|
||||
ebs.clearM2();
|
||||
ebs.setM1High(null);
|
||||
ebs.setM2(null);
|
||||
continue;
|
||||
}
|
||||
var m1High = ebs.getM1High();
|
||||
@@ -86,7 +87,7 @@ public class BlockMetaManager implements ChunkDataManager, ChunkDataManager.Pack
|
||||
}
|
||||
buffer.get(m1High.data);
|
||||
if (storageFlag == 0b10) {
|
||||
ebs.clearM2();
|
||||
ebs.setM2(null);
|
||||
continue;
|
||||
}
|
||||
var m2 = ebs.getM2();
|
||||
@@ -98,12 +99,12 @@ public class BlockMetaManager implements ChunkDataManager, ChunkDataManager.Pack
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean sectionPrivilegedAccess() {
|
||||
public boolean subChunkPrivilegedAccess() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeSectionToNBT(Chunk chunk, ExtendedBlockStorage ebsVanilla, NBTTagCompound section) {
|
||||
public void writeSubChunkToNBT(Chunk chunk, ExtendedBlockStorage ebsVanilla, NBTTagCompound section) {
|
||||
val ebs = (IExtendedBlockStorageMixin) ebsVanilla;
|
||||
val m1Low = ebs.getM1Low();
|
||||
val m1High = ebs.getM1High();
|
||||
@@ -118,7 +119,7 @@ public class BlockMetaManager implements ChunkDataManager, ChunkDataManager.Pack
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readSectionFromNBT(Chunk chunk, ExtendedBlockStorage ebsVanilla, NBTTagCompound section) {
|
||||
public void readSubChunkFromNBT(Chunk chunk, ExtendedBlockStorage ebsVanilla, NBTTagCompound section) {
|
||||
val ebs = (IExtendedBlockStorageMixin) ebsVanilla;
|
||||
assert section.hasKey("Data");
|
||||
val m1Low = section.getByteArray("Data");
|
||||
@@ -126,14 +127,20 @@ public class BlockMetaManager implements ChunkDataManager, ChunkDataManager.Pack
|
||||
final byte[] m2 = section.hasKey("Data2") ? section.getByteArray("Data2") : null;
|
||||
|
||||
ebs.setM1Low(new NibbleArray(m1Low, 4));
|
||||
if (m1High == null) {
|
||||
ebs.clearM1High();
|
||||
} else {
|
||||
ebs.setM1High(new NibbleArray(m1High, 4));
|
||||
}
|
||||
ebs.setM1High(m1High == null ? null : new NibbleArray(m1High, 4));
|
||||
ebs.setM2(m2);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void cloneSubChunk(Chunk fromChunk, ExtendedBlockStorage fromVanilla, ExtendedBlockStorage toVanilla) {
|
||||
val from = (IExtendedBlockStorageMixin) fromVanilla;
|
||||
val to = (IExtendedBlockStorageMixin) toVanilla;
|
||||
|
||||
to.setM1Low(ArrayUtil.copyArray(from.getM1Low(), to.getM1Low()));
|
||||
to.setM1High(ArrayUtil.copyArray(from.getM1High(), to.getM1High()));
|
||||
to.setM2(ArrayUtil.copyArray(from.getM2(), to.getM2()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull String version() {
|
||||
return Tags.VERSION;
|
||||
|
||||
-10
@@ -11,24 +11,18 @@ public interface IExtendedBlockStorageMixin {
|
||||
|
||||
void setB2Low(NibbleArray data);
|
||||
|
||||
void clearB2Low();
|
||||
|
||||
NibbleArray createB2Low();
|
||||
|
||||
NibbleArray getB2High();
|
||||
|
||||
void setB2High(NibbleArray data);
|
||||
|
||||
void clearB2High();
|
||||
|
||||
NibbleArray createB2High();
|
||||
|
||||
byte[] getB3();
|
||||
|
||||
void setB3(byte[] data);
|
||||
|
||||
void clearB3();
|
||||
|
||||
byte[] createB3();
|
||||
|
||||
int getEBSMask();
|
||||
@@ -45,15 +39,11 @@ public interface IExtendedBlockStorageMixin {
|
||||
|
||||
void setM1High(NibbleArray m1High);
|
||||
|
||||
void clearM1High();
|
||||
|
||||
NibbleArray createM1High();
|
||||
|
||||
byte[] getM2();
|
||||
|
||||
void setM2(byte[] m2);
|
||||
|
||||
void clearM2();
|
||||
|
||||
byte[] createM2();
|
||||
}
|
||||
-25
@@ -196,11 +196,6 @@ public abstract class ExtendedBlockStorageMixin implements IExtendedBlockStorage
|
||||
blockMSBArray = data;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clearB2Low() {
|
||||
blockMSBArray = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NibbleArray createB2Low() {
|
||||
return (blockMSBArray = new NibbleArray(blockLSBArray.length, 4));
|
||||
@@ -216,11 +211,6 @@ public abstract class ExtendedBlockStorageMixin implements IExtendedBlockStorage
|
||||
b2High = data;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clearB2High() {
|
||||
b2High = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NibbleArray createB2High() {
|
||||
return (b2High = new NibbleArray(blockLSBArray.length, 4));
|
||||
@@ -236,11 +226,6 @@ public abstract class ExtendedBlockStorageMixin implements IExtendedBlockStorage
|
||||
b3 = data;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clearB3() {
|
||||
b3 = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte[] createB3() {
|
||||
return b3 = new byte[blockLSBArray.length];
|
||||
@@ -266,11 +251,6 @@ public abstract class ExtendedBlockStorageMixin implements IExtendedBlockStorage
|
||||
this.m1High = m1High;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clearM1High() {
|
||||
m1High = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NibbleArray createM1High() {
|
||||
return (m1High = new NibbleArray(blockLSBArray.length, 4));
|
||||
@@ -286,11 +266,6 @@ public abstract class ExtendedBlockStorageMixin implements IExtendedBlockStorage
|
||||
this.m2 = m2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clearM2() {
|
||||
m2 = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte[] createM2() {
|
||||
return (m2 = new byte[blockLSBArray.length]);
|
||||
|
||||
Reference in new issue
Block a user