mirror of
https://github.com/LegacyModdingMC/ChunkAPI.git
synced 2026-11-18 19:29:12 +00:00
add data cloning API
This commit is contained in:
13 files changed
+241
-4
No files matched your search
@@ -22,7 +22,7 @@ import cpw.mods.fml.common.event.FMLInitializationEvent;
|
||||
version = Tags.VERSION,
|
||||
name = Tags.MODNAME,
|
||||
acceptedMinecraftVersions = "[1.7.10]",
|
||||
dependencies = "required-after:falsepatternlib@[0.11,);")
|
||||
dependencies = "required-after:falsepatternlib@[1.0.0,);")
|
||||
public class ChunkAPI {
|
||||
|
||||
@Mod.EventHandler
|
||||
|
||||
@@ -238,6 +238,18 @@ public class ChunkDataRegistryImpl {
|
||||
}
|
||||
}
|
||||
|
||||
public static void cloneChunk(Chunk from, Chunk to) {
|
||||
for (val manager: chunkNBTManagers.values()) {
|
||||
manager.cloneChunk(from, to);
|
||||
}
|
||||
}
|
||||
|
||||
public static void cloneSection(Chunk fromChunk, ExtendedBlockStorage from, ExtendedBlockStorage to) {
|
||||
for (val manager: sectionNBTManagers.values()) {
|
||||
manager.cloneSection(fromChunk, from, to);
|
||||
}
|
||||
}
|
||||
|
||||
public static Set<String> getRegisteredManagers() {
|
||||
return Collections.unmodifiableSet(managers);
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
package com.falsepattern.chunk.internal.vanilla;
|
||||
|
||||
import com.falsepattern.chunk.api.ChunkDataManager;
|
||||
import com.falsepattern.chunk.api.ArrayUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
@@ -60,4 +61,9 @@ public class BiomeManager extends VanillaManager
|
||||
chunk.setBiomeArray(nbt.getByteArray("Biomes"));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void cloneChunk(Chunk from, Chunk to) {
|
||||
to.setBiomeArray(ArrayUtil.copyArray(from.getBiomeArray(), to.getBiomeArray()));
|
||||
}
|
||||
}
|
||||
@@ -8,6 +8,7 @@
|
||||
package com.falsepattern.chunk.internal.vanilla;
|
||||
|
||||
import com.falsepattern.chunk.api.ChunkDataManager;
|
||||
import com.falsepattern.chunk.api.ArrayUtil;
|
||||
import lombok.val;
|
||||
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
@@ -103,4 +104,10 @@ public class BlockIDManager extends VanillaManager
|
||||
ebs.setBlockMSBArray(new NibbleArray(section.getByteArray("Add"), 4));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void cloneSection(Chunk fromChunk, ExtendedBlockStorage from, ExtendedBlockStorage to) {
|
||||
to.setBlockLSBArray(ArrayUtil.copyArray(from.getBlockLSBArray(), to.getBlockLSBArray()));
|
||||
to.setBlockMSBArray(ArrayUtil.copyArray(from.getBlockMSBArray(), to.getBlockMSBArray()));
|
||||
}
|
||||
}
|
||||
@@ -8,6 +8,7 @@
|
||||
package com.falsepattern.chunk.internal.vanilla;
|
||||
|
||||
import com.falsepattern.chunk.api.ChunkDataManager;
|
||||
import com.falsepattern.chunk.api.ArrayUtil;
|
||||
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.world.chunk.Chunk;
|
||||
@@ -39,4 +40,9 @@ public class BlocklightManager extends NibbleManager implements ChunkDataManager
|
||||
public void readSectionFromNBT(Chunk chunk, ExtendedBlockStorage ebs, NBTTagCompound section) {
|
||||
ebs.setBlocklightArray(new NibbleArray(section.getByteArray("BlockLight"), 4));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void cloneSection(Chunk fromChunk, ExtendedBlockStorage from, ExtendedBlockStorage to) {
|
||||
from.setBlocklightArray(ArrayUtil.copyArray(from.getBlocklightArray(), to.getBlocklightArray()));
|
||||
}
|
||||
}
|
||||
@@ -8,6 +8,7 @@
|
||||
package com.falsepattern.chunk.internal.vanilla;
|
||||
|
||||
import com.falsepattern.chunk.api.ChunkDataManager;
|
||||
import com.falsepattern.chunk.api.ArrayUtil;
|
||||
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.world.chunk.Chunk;
|
||||
@@ -34,4 +35,10 @@ public class LightingManager extends VanillaManager implements ChunkDataManager.
|
||||
public boolean chunkPrivilegedAccess() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void cloneChunk(Chunk from, Chunk to) {
|
||||
to.heightMap = ArrayUtil.copyArray(from.heightMap, to.heightMap);
|
||||
to.isLightPopulated = from.isLightPopulated;
|
||||
}
|
||||
}
|
||||
@@ -8,6 +8,7 @@
|
||||
package com.falsepattern.chunk.internal.vanilla;
|
||||
|
||||
import com.falsepattern.chunk.api.ChunkDataManager;
|
||||
import com.falsepattern.chunk.api.ArrayUtil;
|
||||
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.world.chunk.Chunk;
|
||||
@@ -39,4 +40,9 @@ public class MetadataManager extends NibbleManager implements ChunkDataManager.S
|
||||
public void readSectionFromNBT(Chunk chunk, ExtendedBlockStorage ebs, NBTTagCompound section) {
|
||||
ebs.setBlockMetadataArray(new NibbleArray(section.getByteArray("Data"), 4));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void cloneSection(Chunk fromChunk, ExtendedBlockStorage from, ExtendedBlockStorage to) {
|
||||
to.setBlockMetadataArray(ArrayUtil.copyArray(from.getMetadataArray(), to.getMetadataArray()));
|
||||
}
|
||||
}
|
||||
@@ -8,6 +8,7 @@
|
||||
package com.falsepattern.chunk.internal.vanilla;
|
||||
|
||||
import com.falsepattern.chunk.api.ChunkDataManager;
|
||||
import com.falsepattern.chunk.api.ArrayUtil;
|
||||
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.world.chunk.Chunk;
|
||||
@@ -61,4 +62,13 @@ public class SkylightManager extends NibbleManager implements ChunkDataManager.S
|
||||
ebs.setSkylightArray(new NibbleArray(section.getByteArray("SkyLight"), 4));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void cloneSection(Chunk fromChunk, ExtendedBlockStorage from, ExtendedBlockStorage to) {
|
||||
if (!fromChunk.worldObj.provider.hasNoSky) {
|
||||
to.setSkylightArray(ArrayUtil.copyArray(from.getSkylightArray(), to.getSkylightArray()));
|
||||
} else {
|
||||
to.setSkylightArray(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user