mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2025-07-18 18:23:06 +00:00
Merge remote-tracking branch 'upstream/master' into DecreeCommands
This commit is contained in:
commit
22b77411ec
@ -32,7 +32,7 @@ plugins {
|
|||||||
}
|
}
|
||||||
|
|
||||||
group 'com.volmit.iris'
|
group 'com.volmit.iris'
|
||||||
version '1.7.8-Dumpy'
|
version '1.7.9'
|
||||||
def apiVersion = '1.17'
|
def apiVersion = '1.17'
|
||||||
def name = getRootProject().getName() // See settings.gradle
|
def name = getRootProject().getName() // See settings.gradle
|
||||||
def main = 'com.volmit.iris.Iris'
|
def main = 'com.volmit.iris.Iris'
|
||||||
|
@ -48,38 +48,30 @@ import com.volmit.iris.util.io.InstanceState;
|
|||||||
import com.volmit.iris.util.io.JarScanner;
|
import com.volmit.iris.util.io.JarScanner;
|
||||||
import com.volmit.iris.util.math.M;
|
import com.volmit.iris.util.math.M;
|
||||||
import com.volmit.iris.util.math.RNG;
|
import com.volmit.iris.util.math.RNG;
|
||||||
import com.volmit.iris.util.nbt.mca.*;
|
|
||||||
import com.volmit.iris.util.parallel.MultiBurst;
|
import com.volmit.iris.util.parallel.MultiBurst;
|
||||||
import com.volmit.iris.util.plugin.*;
|
import com.volmit.iris.util.plugin.*;
|
||||||
import com.volmit.iris.util.reflect.ShadeFix;
|
import com.volmit.iris.util.reflect.ShadeFix;
|
||||||
import com.volmit.iris.util.scheduling.J;
|
import com.volmit.iris.util.scheduling.J;
|
||||||
import com.volmit.iris.util.scheduling.Looper;
|
|
||||||
import com.volmit.iris.util.scheduling.Queue;
|
import com.volmit.iris.util.scheduling.Queue;
|
||||||
import com.volmit.iris.util.scheduling.ShurikenQueue;
|
import com.volmit.iris.util.scheduling.ShurikenQueue;
|
||||||
import io.papermc.lib.PaperLib;
|
import io.papermc.lib.PaperLib;
|
||||||
import net.kyori.adventure.platform.bukkit.BukkitAudiences;
|
import net.kyori.adventure.platform.bukkit.BukkitAudiences;
|
||||||
import net.kyori.adventure.text.serializer.ComponentSerializer;
|
import net.kyori.adventure.text.serializer.ComponentSerializer;
|
||||||
import net.minecraft.world.level.chunk.storage.RegionFile;
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Material;
|
|
||||||
import org.bukkit.block.data.BlockData;
|
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.Event;
|
import org.bukkit.event.Event;
|
||||||
import org.bukkit.event.HandlerList;
|
import org.bukkit.event.HandlerList;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
import org.bukkit.event.block.BlockDamageEvent;
|
|
||||||
import org.bukkit.generator.ChunkGenerator;
|
import org.bukkit.generator.ChunkGenerator;
|
||||||
import org.bukkit.plugin.Plugin;
|
import org.bukkit.plugin.Plugin;
|
||||||
import org.checkerframework.checker.units.qual.K;
|
|
||||||
|
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
import java.lang.annotation.Annotation;
|
import java.lang.annotation.Annotation;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
@SuppressWarnings("CanBeFinal")
|
@SuppressWarnings("CanBeFinal")
|
||||||
public class Iris extends VolmitPlugin implements Listener {
|
public class Iris extends VolmitPlugin implements Listener {
|
||||||
@ -116,139 +108,8 @@ public class Iris extends VolmitPlugin implements Listener {
|
|||||||
IO.delete(new File("iris"));
|
IO.delete(new File("iris"));
|
||||||
installDataPacks();
|
installDataPacks();
|
||||||
fixShading();
|
fixShading();
|
||||||
(new Looper() {
|
|
||||||
protected long loop() {
|
|
||||||
File ff = Iris.instance.getDataFolderNoCreate("dump");
|
|
||||||
if (ff.exists() && ff.isDirectory() && ff.listFiles().length == 0)
|
|
||||||
Iris.dump();
|
|
||||||
return 10000L;
|
|
||||||
}
|
|
||||||
}).start();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void testmca() {
|
|
||||||
try
|
|
||||||
{
|
|
||||||
int forceBits = 5;
|
|
||||||
int possibilities = (int) (Math.pow(2, forceBits) - 1);
|
|
||||||
KList<BlockData> bp = new KList<>();
|
|
||||||
Set<BlockData> bf = new KSet<>();
|
|
||||||
|
|
||||||
while(bp.size() < possibilities)
|
|
||||||
{
|
|
||||||
BlockData b = null;
|
|
||||||
|
|
||||||
while(b == null)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
b = Material.values()[RNG.r.i(Material.values().length-1)].createBlockData();
|
|
||||||
}
|
|
||||||
|
|
||||||
catch(Throwable e)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
bp.addIfMissing(b);
|
|
||||||
}
|
|
||||||
|
|
||||||
MCAFile file = new MCAFile(0, 0);
|
|
||||||
for(int cx = 0; cx < 32; cx++)
|
|
||||||
{
|
|
||||||
for(int cz = 0; cz < 32; cz++)
|
|
||||||
{
|
|
||||||
Chunk c = Chunk.newChunk();
|
|
||||||
|
|
||||||
for(int i = 0; i < 16; i++)
|
|
||||||
{
|
|
||||||
for(int j = 0; j < 16; j++)
|
|
||||||
{
|
|
||||||
for(int k = 0; k < 16; k++)
|
|
||||||
{
|
|
||||||
BlockData b = bp.getRandom();
|
|
||||||
c.setBlockStateAt(i,j,k, NBTWorld.getCompound(b), false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
file.setChunk(cx, cz, c);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
File f = new File("r.0.0.mca");
|
|
||||||
Iris.info("Write " + MCAUtil.write(file, f) + " chunks");
|
|
||||||
file = MCAUtil.read(f);
|
|
||||||
|
|
||||||
for(int i = 0; i < 1024; i++) {
|
|
||||||
Chunk c = file.getChunks().get(i);
|
|
||||||
|
|
||||||
if (c == null) {
|
|
||||||
Iris.error("Missing Chunk: " + i);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
Section s = c.getSection(0);
|
|
||||||
|
|
||||||
if (s == null)
|
|
||||||
{
|
|
||||||
Iris.error("Missing section 0 in chunk: " + i);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
for(int a = 0; a < 16; a++)
|
|
||||||
{
|
|
||||||
for(int b = 0; b < 16; b++)
|
|
||||||
{
|
|
||||||
for(int ca = 0; ca < 16; ca++)
|
|
||||||
{
|
|
||||||
BlockData data = NBTWorld.getBlockData(s.getBlockStateAt(a, b, ca));
|
|
||||||
bf.add(data);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Iris.info("Read .. OK?");
|
|
||||||
|
|
||||||
Iris.info("Possibilities: " + bp.size());
|
|
||||||
Iris.info("Read Possibss: " + bf.size());
|
|
||||||
int match = 0;
|
|
||||||
for(BlockData i : bp)
|
|
||||||
{
|
|
||||||
if(bf.contains(i))
|
|
||||||
{
|
|
||||||
match++;
|
|
||||||
}
|
|
||||||
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Iris.warn("Couldn't find preset " + i.getAsString(true) + " in any section");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for(BlockData i : bf)
|
|
||||||
{
|
|
||||||
if(!bp.contains(i))
|
|
||||||
{
|
|
||||||
Iris.warn("Forign block data " + i.getAsString(true) + "! (ignore leaves, they are modded by us)");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Iris.info("Matched: " + match);
|
|
||||||
} catch (IOException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
catch(Throwable ee)
|
|
||||||
{
|
|
||||||
ee.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
private void enable() {
|
private void enable() {
|
||||||
audiences = BukkitAudiences.create(this);
|
audiences = BukkitAudiences.create(this);
|
||||||
sender = new VolmitSender(Bukkit.getConsoleSender());
|
sender = new VolmitSender(Bukkit.getConsoleSender());
|
||||||
@ -261,7 +122,6 @@ public class Iris extends VolmitPlugin implements Listener {
|
|||||||
configWatcher = new FileWatcher(getDataFile("settings.json"));
|
configWatcher = new FileWatcher(getDataFile("settings.json"));
|
||||||
services.values().forEach(IrisService::onEnable);
|
services.values().forEach(IrisService::onEnable);
|
||||||
services.values().forEach(this::registerListener);
|
services.values().forEach(this::registerListener);
|
||||||
J.s(this::testmca, 20);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void postShutdown(Runnable r) {
|
public void postShutdown(Runnable r) {
|
||||||
|
@ -121,7 +121,6 @@ public class DecIris implements DecreeExecutor {
|
|||||||
case ">>" -> v = value1 >> value2;
|
case ">>" -> v = value1 >> value2;
|
||||||
case "<<" -> v = value1 << value2;
|
case "<<" -> v = value1 << value2;
|
||||||
}
|
}
|
||||||
;
|
|
||||||
if (v == null) {
|
if (v == null) {
|
||||||
sender().sendMessage(C.RED + "The operator you entered: (" + operator + ") is invalid!");
|
sender().sendMessage(C.RED + "The operator you entered: (" + operator + ") is invalid!");
|
||||||
return;
|
return;
|
||||||
|
@ -18,6 +18,7 @@
|
|||||||
|
|
||||||
package com.volmit.iris.core.nms;
|
package com.volmit.iris.core.nms;
|
||||||
|
|
||||||
|
import com.volmit.iris.util.nbt.mca.palette.BiomeContainer;
|
||||||
import com.volmit.iris.util.nbt.mca.palette.PaletteAccess;
|
import com.volmit.iris.util.nbt.mca.palette.PaletteAccess;
|
||||||
import com.volmit.iris.util.nbt.tag.CompoundTag;
|
import com.volmit.iris.util.nbt.tag.CompoundTag;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
@ -64,6 +65,10 @@ public interface INMSBinding {
|
|||||||
|
|
||||||
int getBiomeId(Biome biome);
|
int getBiomeId(Biome biome);
|
||||||
|
|
||||||
|
BiomeContainer newBiomeContainer(int min, int max, int[] data);
|
||||||
|
|
||||||
|
BiomeContainer newBiomeContainer(int min, int max);
|
||||||
|
|
||||||
default World createWorld(WorldCreator c) {
|
default World createWorld(WorldCreator c) {
|
||||||
return c.createWorld();
|
return c.createWorld();
|
||||||
}
|
}
|
||||||
|
@ -56,11 +56,13 @@ import org.bukkit.craftbukkit.v1_17_R1.block.data.CraftBlockData;
|
|||||||
import org.bukkit.craftbukkit.v1_17_R1.entity.CraftEntity;
|
import org.bukkit.craftbukkit.v1_17_R1.entity.CraftEntity;
|
||||||
import org.bukkit.entity.EntityType;
|
import org.bukkit.entity.EntityType;
|
||||||
import org.bukkit.generator.ChunkGenerator;
|
import org.bukkit.generator.ChunkGenerator;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
import java.util.IdentityHashMap;
|
import java.util.IdentityHashMap;
|
||||||
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.concurrent.atomic.AtomicInteger;
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
|
|
||||||
@ -69,6 +71,7 @@ public class NMSBinding17_1 implements INMSBinding {
|
|||||||
private final KMap<Biome, Object> baseBiomeCache = new KMap<>();
|
private final KMap<Biome, Object> baseBiomeCache = new KMap<>();
|
||||||
private final AtomicCache<IdMapper<IBlockData>> registryCache = new AtomicCache<>();
|
private final AtomicCache<IdMapper<IBlockData>> registryCache = new AtomicCache<>();
|
||||||
private final AtomicCache<Palette<IBlockData>> globalCache = new AtomicCache<>();
|
private final AtomicCache<Palette<IBlockData>> globalCache = new AtomicCache<>();
|
||||||
|
private final AtomicCache<IdMap<BiomeBase>> biomeMapCache = new AtomicCache<>();
|
||||||
private Field biomeStorageCache = null;
|
private Field biomeStorageCache = null;
|
||||||
|
|
||||||
public boolean supportsDataPacks() {
|
public boolean supportsDataPacks() {
|
||||||
@ -90,14 +93,14 @@ public class NMSBinding17_1 implements INMSBinding {
|
|||||||
List<IBlockData> d = (List<IBlockData>) df.get(blockData);
|
List<IBlockData> d = (List<IBlockData>) df.get(blockData);
|
||||||
return new IdMapper<>(c, d, b);
|
return new IdMapper<>(c, d, b);
|
||||||
});
|
});
|
||||||
Palette<IBlockData> global = globalCache.aquireNasty(() -> new GlobalPalette<>(registry, ((CraftBlockData)AIR).getState()));
|
Palette<IBlockData> global = globalCache.aquireNasty(() -> new GlobalPalette<>(registry, ((CraftBlockData) AIR).getState()));
|
||||||
PalettedContainer<IBlockData> container = new PalettedContainer<>(global, registry,
|
PalettedContainer<IBlockData> container = new PalettedContainer<>(global, registry,
|
||||||
i -> ((CraftBlockData)NBTWorld.getBlockData(i)).getState(),
|
i -> ((CraftBlockData) NBTWorld.getBlockData(i)).getState(),
|
||||||
i -> NBTWorld.getCompound(CraftBlockData.fromData(i)),
|
i -> NBTWorld.getCompound(CraftBlockData.fromData(i)),
|
||||||
((CraftBlockData) AIR).getState());
|
((CraftBlockData) AIR).getState());
|
||||||
return new WrappedPalettedContainer<>(container,
|
return new WrappedPalettedContainer<>(container,
|
||||||
i -> NBTWorld.getCompound(CraftBlockData.fromData(i)),
|
i -> NBTWorld.getCompound(CraftBlockData.fromData(i)),
|
||||||
i -> ((CraftBlockData)NBTWorld.getBlockData(i)).getState());
|
i -> ((CraftBlockData) NBTWorld.getBlockData(i)).getState());
|
||||||
}
|
}
|
||||||
|
|
||||||
private Object getBiomeStorage(ChunkGenerator.BiomeGrid g) {
|
private Object getBiomeStorage(ChunkGenerator.BiomeGrid g) {
|
||||||
@ -383,6 +386,58 @@ public class NMSBinding17_1 implements INMSBinding {
|
|||||||
return biome.ordinal();
|
return biome.ordinal();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private IdMap<BiomeBase> getBiomeMapping() {
|
||||||
|
return biomeMapCache.aquire(() -> new IdMap<>() {
|
||||||
|
@NotNull
|
||||||
|
@Override
|
||||||
|
public Iterator<BiomeBase> iterator() {
|
||||||
|
return getCustomBiomeRegistry().iterator();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getId(BiomeBase paramT) {
|
||||||
|
return getCustomBiomeRegistry().getId(paramT);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BiomeBase byId(int paramInt) {
|
||||||
|
return getCustomBiomeRegistry().fromId(paramInt);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BiomeContainer newBiomeContainer(int min, int max) {
|
||||||
|
ChunkBiomeContainer<BiomeBase> base = new ChunkBiomeContainer<>(getBiomeMapping(), min, max);
|
||||||
|
return getBiomeContainerInterface(getBiomeMapping(), base);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BiomeContainer newBiomeContainer(int min, int max, int[] data) {
|
||||||
|
ChunkBiomeContainer<BiomeBase> base = new ChunkBiomeContainer<>(getBiomeMapping(), min, max, data);
|
||||||
|
return getBiomeContainerInterface(getBiomeMapping(), base);
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
private BiomeContainer getBiomeContainerInterface(IdMap<BiomeBase> biomeMapping, ChunkBiomeContainer<BiomeBase> base) {
|
||||||
|
return new BiomeContainer() {
|
||||||
|
@Override
|
||||||
|
public int[] getData() {
|
||||||
|
return base.writeBiomes();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setBiome(int x, int y, int z, int id) {
|
||||||
|
base.setBiome(x, y, z, biomeMapping.byId(id));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getBiome(int x, int y, int z) {
|
||||||
|
return biomeMapping.getId(base.getBiome(x, y, z));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int countCustomBiomes() {
|
public int countCustomBiomes() {
|
||||||
AtomicInteger a = new AtomicInteger(0);
|
AtomicInteger a = new AtomicInteger(0);
|
||||||
|
@ -20,6 +20,7 @@ package com.volmit.iris.core.nms.v1X;
|
|||||||
|
|
||||||
import com.volmit.iris.Iris;
|
import com.volmit.iris.Iris;
|
||||||
import com.volmit.iris.core.nms.INMSBinding;
|
import com.volmit.iris.core.nms.INMSBinding;
|
||||||
|
import com.volmit.iris.util.nbt.mca.palette.BiomeContainer;
|
||||||
import com.volmit.iris.util.nbt.mca.palette.PaletteAccess;
|
import com.volmit.iris.util.nbt.mca.palette.PaletteAccess;
|
||||||
import com.volmit.iris.util.nbt.tag.CompoundTag;
|
import com.volmit.iris.util.nbt.tag.CompoundTag;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
@ -135,6 +136,20 @@ public class NMSBinding1X implements INMSBinding {
|
|||||||
return biome.ordinal();
|
return biome.ordinal();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BiomeContainer newBiomeContainer(int min, int max) {
|
||||||
|
Iris.error("Cannot use the custom biome data! Iris is incapable of using MCA generation on this version of minecraft!");
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BiomeContainer newBiomeContainer(int min, int max, int[] v) {
|
||||||
|
Iris.error("Cannot use the custom biome data! Iris is incapable of using MCA generation on this version of minecraft!");
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int countCustomBiomes() {
|
public int countCustomBiomes() {
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -113,7 +113,7 @@ public class AsyncPregenMethod implements PregeneratorMethod {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void generateChunk(int x, int z, PregenListener listener) {
|
public void generateChunk(int x, int z, PregenListener listener) {
|
||||||
if (future.size() > IrisSettings.getThreadCount((int) IrisSettings.get().getConcurrency().getParallelism())) { // TODO: FIX
|
if (future.size() > IrisSettings.getThreadCount(IrisSettings.get().getConcurrency().getParallelism())) { // TODO: FIX
|
||||||
waitForChunks();
|
waitForChunks();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -95,7 +95,7 @@ public class MedievalPregenMethod implements PregeneratorMethod {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void generateChunk(int x, int z, PregenListener listener) {
|
public void generateChunk(int x, int z, PregenListener listener) {
|
||||||
if (futures.size() > IrisSettings.getThreadCount((int) IrisSettings.get().getConcurrency().getParallelism())) {
|
if (futures.size() > IrisSettings.getThreadCount(IrisSettings.get().getConcurrency().getParallelism())) {
|
||||||
waitForChunks();
|
waitForChunks();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -337,7 +337,7 @@ public class IrisData {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
String ff = g.toString().substring(1).split("\\Q.\\E")[0];
|
String ff = g.substring(1).split("\\Q.\\E")[0];
|
||||||
return ff;
|
return ff;
|
||||||
} else {
|
} else {
|
||||||
Iris.error("Forign file from loader " + f.getPath() + " (loader realm: " + getDataFolder().getPath() + ")");
|
Iris.error("Forign file from loader " + f.getPath() + " (loader realm: " + getDataFolder().getPath() + ")");
|
||||||
|
@ -29,8 +29,8 @@ import com.volmit.iris.util.scheduling.Looper;
|
|||||||
import java.util.concurrent.ExecutorService;
|
import java.util.concurrent.ExecutorService;
|
||||||
|
|
||||||
public class PreservationSVC implements IrisService {
|
public class PreservationSVC implements IrisService {
|
||||||
private KList<Thread> threads = new KList<>();
|
private final KList<Thread> threads = new KList<>();
|
||||||
private KList<ExecutorService> services = new KList<>();
|
private final KList<ExecutorService> services = new KList<>();
|
||||||
private Looper dereferencer;
|
private Looper dereferencer;
|
||||||
|
|
||||||
public void register(Thread t) {
|
public void register(Thread t) {
|
||||||
|
@ -129,7 +129,7 @@ public class IrisToolbelt {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return pregenerate(task, new HybridPregenMethod(gen.getEngine().getWorld().realWorld(),
|
return pregenerate(task, new HybridPregenMethod(gen.getEngine().getWorld().realWorld(),
|
||||||
IrisSettings.getThreadCount((int) IrisSettings.get().getConcurrency().getParallelism())));
|
IrisSettings.getThreadCount(IrisSettings.get().getConcurrency().getParallelism())));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -145,7 +145,7 @@ public class IrisToolbelt {
|
|||||||
return pregenerate(task, access(world));
|
return pregenerate(task, access(world));
|
||||||
}
|
}
|
||||||
|
|
||||||
return pregenerate(task, new HybridPregenMethod(world, IrisSettings.getThreadCount((int) IrisSettings.get().getConcurrency().getParallelism())));
|
return pregenerate(task, new HybridPregenMethod(world, IrisSettings.getThreadCount(IrisSettings.get().getConcurrency().getParallelism())));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -397,19 +397,17 @@ public class IrisEngine implements Engine {
|
|||||||
context.touch();
|
context.touch();
|
||||||
getEngineData().getStatistics().generatedChunk();
|
getEngineData().getStatistics().generatedChunk();
|
||||||
try {
|
try {
|
||||||
|
|
||||||
PrecisionStopwatch p = PrecisionStopwatch.start();
|
PrecisionStopwatch p = PrecisionStopwatch.start();
|
||||||
Hunk<BlockData> blocks = vblocks.listen((xx, y, zz, t) -> catchBlockUpdates(x + xx, y + getMinHeight(), z + zz, t));
|
Hunk<BlockData> blocks = vblocks.listen((xx, y, zz, t) -> catchBlockUpdates(x + xx, y + getMinHeight(), z + zz, t));
|
||||||
|
|
||||||
if (multicore) {
|
if (getDimension().isDebugChunkCrossSections() && ((x >> 4) % getDimension().getDebugCrossSectionsMod() == 0 || (z >> 4) % getDimension().getDebugCrossSectionsMod() == 0)) {
|
||||||
for (int i = 0; i < 16; i++) {
|
for (int i = 0; i < 16; i++) {
|
||||||
for (int j = 0; j < 16; j++) {
|
for (int j = 0; j < 16; j++) {
|
||||||
blocks.set(i, 0, j, Material.RED_GLAZED_TERRACOTTA.createBlockData());
|
blocks.set(i, 0, j, Material.CRYING_OBSIDIAN.createBlockData());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
getMantle().generateMatter(x >> 4, z >> 4, multicore);
|
getMantle().generateMatter(x >> 4, z >> 4, true);
|
||||||
|
|
||||||
burst().burst(multicore,
|
burst().burst(multicore,
|
||||||
() -> getTerrainActuator().actuate(x, z, vblocks, multicore),
|
() -> getTerrainActuator().actuate(x, z, vblocks, multicore),
|
||||||
() -> getBiomeActuator().actuate(x, z, vbiomes, multicore)
|
() -> getBiomeActuator().actuate(x, z, vbiomes, multicore)
|
||||||
@ -419,16 +417,12 @@ public class IrisEngine implements Engine {
|
|||||||
() -> getDecorantActuator().actuate(x, z, blocks, multicore),
|
() -> getDecorantActuator().actuate(x, z, blocks, multicore),
|
||||||
() -> getRavineModifier().modify(x, z, vblocks, multicore)
|
() -> getRavineModifier().modify(x, z, vblocks, multicore)
|
||||||
);
|
);
|
||||||
|
|
||||||
getPostModifier().modify(x, z, vblocks, multicore);
|
getPostModifier().modify(x, z, vblocks, multicore);
|
||||||
|
|
||||||
burst().burst(multicore,
|
burst().burst(multicore,
|
||||||
() -> getMantle().insertMatter(x >> 4, z >> 4, BlockData.class, blocks, multicore),
|
() -> getMantle().insertMatter(x >> 4, z >> 4, BlockData.class, blocks, true),
|
||||||
() -> getDepositModifier().modify(x, z, vblocks, multicore)
|
() -> getDepositModifier().modify(x, z, vblocks, multicore)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
getMetrics().getTotal().put(p.getMilliseconds());
|
getMetrics().getTotal().put(p.getMilliseconds());
|
||||||
generated.incrementAndGet();
|
generated.incrementAndGet();
|
||||||
recycle();
|
recycle();
|
||||||
|
@ -136,7 +136,7 @@ public class IrisTerrainNormalActuator extends EngineAssignedActuator<BlockData>
|
|||||||
if (i <= he) {
|
if (i <= he) {
|
||||||
depth = he - i;
|
depth = he - i;
|
||||||
if (blocks == null) {
|
if (blocks == null) {
|
||||||
blocks = biome.generateLayers(realX, realZ, rng,
|
blocks = biome.generateLayers(getDimension(), realX, realZ, rng,
|
||||||
he,
|
he,
|
||||||
he,
|
he,
|
||||||
getData(),
|
getData(),
|
||||||
|
@ -51,16 +51,11 @@ public class AtomicCache<T> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public T aquireNasty(NastySupplier<T> t)
|
public T aquireNasty(NastySupplier<T> t) {
|
||||||
{
|
|
||||||
return aquire(() -> {
|
return aquire(() -> {
|
||||||
try
|
try {
|
||||||
{
|
|
||||||
return t.get();
|
return t.get();
|
||||||
}
|
} catch (Throwable e) {
|
||||||
|
|
||||||
catch(Throwable e)
|
|
||||||
{
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -81,8 +81,8 @@ public class IrisCaveModifier extends EngineAssignedModifier<BlockData> {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
KList<BlockData> floor = cave.generateLayers(x + finalI, z + j, rng, cl.getFloor(), cl.getFloor(), getData(), getComplex());
|
KList<BlockData> floor = cave.generateLayers(getDimension(), x + finalI, z + j, rng, cl.getFloor(), cl.getFloor(), getData(), getComplex());
|
||||||
KList<BlockData> ceiling = cave.generateLayers(x + finalI + 656, z + j - 656, rng,
|
KList<BlockData> ceiling = cave.generateLayers(getDimension(), x + finalI + 656, z + j - 656, rng,
|
||||||
he - cl.getCeiling(),
|
he - cl.getCeiling(),
|
||||||
he - cl.getCeiling(), getData(), getComplex());
|
he - cl.getCeiling(), getData(), getComplex());
|
||||||
|
|
||||||
|
@ -30,6 +30,7 @@ import com.volmit.iris.engine.object.block.IrisBlockDrops;
|
|||||||
import com.volmit.iris.engine.object.common.IRare;
|
import com.volmit.iris.engine.object.common.IRare;
|
||||||
import com.volmit.iris.engine.object.decoration.IrisDecorator;
|
import com.volmit.iris.engine.object.decoration.IrisDecorator;
|
||||||
import com.volmit.iris.engine.object.deposits.IrisDepositGenerator;
|
import com.volmit.iris.engine.object.deposits.IrisDepositGenerator;
|
||||||
|
import com.volmit.iris.engine.object.dimensional.IrisDimension;
|
||||||
import com.volmit.iris.engine.object.feature.IrisFeaturePotential;
|
import com.volmit.iris.engine.object.feature.IrisFeaturePotential;
|
||||||
import com.volmit.iris.engine.object.jigsaw.IrisJigsawStructurePlacement;
|
import com.volmit.iris.engine.object.jigsaw.IrisJigsawStructurePlacement;
|
||||||
import com.volmit.iris.engine.object.loot.IrisLootReference;
|
import com.volmit.iris.engine.object.loot.IrisLootReference;
|
||||||
@ -56,6 +57,7 @@ import lombok.Data;
|
|||||||
import lombok.EqualsAndHashCode;
|
import lombok.EqualsAndHashCode;
|
||||||
import lombok.NoArgsConstructor;
|
import lombok.NoArgsConstructor;
|
||||||
import lombok.experimental.Accessors;
|
import lombok.experimental.Accessors;
|
||||||
|
import org.bukkit.Material;
|
||||||
import org.bukkit.block.Biome;
|
import org.bukkit.block.Biome;
|
||||||
import org.bukkit.block.data.BlockData;
|
import org.bukkit.block.data.BlockData;
|
||||||
|
|
||||||
@ -65,7 +67,6 @@ import java.awt.*;
|
|||||||
@Accessors(chain = true)
|
@Accessors(chain = true)
|
||||||
@NoArgsConstructor
|
@NoArgsConstructor
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
|
|
||||||
@Desc("Represents a biome in iris. Biomes are placed inside of regions and hold objects.\nA biome consists of layers (block palletes), decorations, objects & generators.")
|
@Desc("Represents a biome in iris. Biomes are placed inside of regions and hold objects.\nA biome consists of layers (block palletes), decorations, objects & generators.")
|
||||||
@Data
|
@Data
|
||||||
@EqualsAndHashCode(callSuper = false)
|
@EqualsAndHashCode(callSuper = false)
|
||||||
@ -88,7 +89,6 @@ public class IrisBiome extends IrisRegistrant implements IRare {
|
|||||||
@ArrayType(min = 1, type = IrisFeaturePotential.class)
|
@ArrayType(min = 1, type = IrisFeaturePotential.class)
|
||||||
private KList<IrisFeaturePotential> features = new KList<>();
|
private KList<IrisFeaturePotential> features = new KList<>();
|
||||||
|
|
||||||
|
|
||||||
@ArrayType(min = 1, type = IrisEffect.class)
|
@ArrayType(min = 1, type = IrisEffect.class)
|
||||||
@Desc("Effects are ambient effects such as potion effects, random sounds, or even particles around each player. All of these effects are played via packets so two players won't see/hear each others effects.\nDue to performance reasons, effects will play around the player even if where the effect was played is no longer in the biome the player is in.")
|
@Desc("Effects are ambient effects such as potion effects, random sounds, or even particles around each player. All of these effects are played via packets so two players won't see/hear each others effects.\nDue to performance reasons, effects will play around the player even if where the effect was played is no longer in the biome the player is in.")
|
||||||
private KList<IrisEffect> effects = new KList<>();
|
private KList<IrisEffect> effects = new KList<>();
|
||||||
@ -194,6 +194,7 @@ public class IrisBiome extends IrisRegistrant implements IRare {
|
|||||||
|
|
||||||
private transient InferredType inferredType;
|
private transient InferredType inferredType;
|
||||||
|
|
||||||
|
private static final BlockData BARRIER = Material.BARRIER.createBlockData();
|
||||||
private final transient AtomicCache<KMap<String, IrisBiomeGeneratorLink>> genCache = new AtomicCache<>();
|
private final transient AtomicCache<KMap<String, IrisBiomeGeneratorLink>> genCache = new AtomicCache<>();
|
||||||
private final transient AtomicCache<KMap<String, Integer>> genCacheMax = new AtomicCache<>();
|
private final transient AtomicCache<KMap<String, Integer>> genCacheMax = new AtomicCache<>();
|
||||||
private final transient AtomicCache<KMap<String, Integer>> genCacheMin = new AtomicCache<>();
|
private final transient AtomicCache<KMap<String, Integer>> genCacheMin = new AtomicCache<>();
|
||||||
@ -326,7 +327,7 @@ public class IrisBiome extends IrisRegistrant implements IRare {
|
|||||||
return childrenCell.aquire(() -> getChildStyle().create(random.nextParallelRNG(sig * 2137), getLoader()).bake().scale(scale).bake());
|
return childrenCell.aquire(() -> getChildStyle().create(random.nextParallelRNG(sig * 2137), getLoader()).bake().scale(scale).bake());
|
||||||
}
|
}
|
||||||
|
|
||||||
public KList<BlockData> generateLayers(double wx, double wz, RNG random, int maxDepth, int height, IrisData rdata, IrisComplex complex) {
|
public KList<BlockData> generateLayers(IrisDimension dim, double wx, double wz, RNG random, int maxDepth, int height, IrisData rdata, IrisComplex complex) {
|
||||||
if (isLockLayers()) {
|
if (isLockLayers()) {
|
||||||
return generateLockedLayers(wx, wz, random, maxDepth, height, rdata, complex);
|
return generateLockedLayers(wx, wz, random, maxDepth, height, rdata, complex);
|
||||||
}
|
}
|
||||||
@ -369,6 +370,16 @@ public class IrisBiome extends IrisRegistrant implements IRare {
|
|||||||
if (data.size() >= maxDepth) {
|
if (data.size() >= maxDepth) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (dim.isExplodeBiomePalettes()) {
|
||||||
|
for (int j = 0; j < dim.getExplodeBiomePaletteSize(); j++) {
|
||||||
|
data.add(BARRIER);
|
||||||
|
|
||||||
|
if (data.size() >= maxDepth) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return data;
|
return data;
|
||||||
|
@ -86,6 +86,22 @@ public class IrisDimension extends IrisRegistrant {
|
|||||||
@Desc("If defined, Iris will place the given jigsaw structure where minecraft should place the overworld stronghold.")
|
@Desc("If defined, Iris will place the given jigsaw structure where minecraft should place the overworld stronghold.")
|
||||||
private String stronghold;
|
private String stronghold;
|
||||||
|
|
||||||
|
@Desc("If set to true, Iris will remove chunks to allow visualizing cross sections of chunks easily")
|
||||||
|
private boolean debugChunkCrossSections = false;
|
||||||
|
|
||||||
|
@Desc("Vertically split up the biome palettes with 3 air blocks in between to visualize them")
|
||||||
|
private boolean explodeBiomePalettes = false;
|
||||||
|
|
||||||
|
@MinNumber(1)
|
||||||
|
@MaxNumber(16)
|
||||||
|
@Desc("Customize the palette height explosion")
|
||||||
|
private int explodeBiomePaletteSize = 3;
|
||||||
|
|
||||||
|
@MinNumber(2)
|
||||||
|
@MaxNumber(16)
|
||||||
|
@Desc("Every X/Z % debugCrossSectionsMod == 0 cuts the chunk")
|
||||||
|
private int debugCrossSectionsMod = 3;
|
||||||
|
|
||||||
@Desc("The average distance between strongholds")
|
@Desc("The average distance between strongholds")
|
||||||
private int strongholdJumpDistance = 1280;
|
private int strongholdJumpDistance = 1280;
|
||||||
|
|
||||||
|
@ -26,7 +26,6 @@ import org.bukkit.craftbukkit.libs.org.apache.commons.lang3.math.NumberUtils;
|
|||||||
|
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import java.util.function.Consumer;
|
|
||||||
import java.util.function.IntPredicate;
|
import java.util.function.IntPredicate;
|
||||||
|
|
||||||
public class MathHelper {
|
public class MathHelper {
|
||||||
@ -44,7 +43,7 @@ public class MathHelper {
|
|||||||
public static final float f = 1.0E-5F;
|
public static final float f = 1.0E-5F;
|
||||||
public static final float g = c(2.0F);
|
public static final float g = c(2.0F);
|
||||||
private static final float n = 10430.378F;
|
private static final float n = 10430.378F;
|
||||||
private static final float[] o = (float[]) SystemUtils.a(new float[65536], (var0x) -> {
|
private static final float[] o = SystemUtils.a(new float[65536], (var0x) -> {
|
||||||
for (int var1 = 0; var1 < var0x.length; ++var1) {
|
for (int var1 = 0; var1 < var0x.length; ++var1) {
|
||||||
var0x[var1] = (float) Math.sin((double) var1 * 3.141592653589793D * 2.0D / 65536.0D);
|
var0x[var1] = (float) Math.sin((double) var1 * 3.141592653589793D * 2.0D / 65536.0D);
|
||||||
}
|
}
|
||||||
@ -71,7 +70,7 @@ public class MathHelper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static float c(float var0) {
|
public static float c(float var0) {
|
||||||
return (float) Math.sqrt((double) var0);
|
return (float) Math.sqrt(var0);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int d(float var0) {
|
public static int d(float var0) {
|
||||||
@ -607,7 +606,7 @@ public class MathHelper {
|
|||||||
|
|
||||||
int var2;
|
int var2;
|
||||||
for (var2 = 0; var2 < var0.length; ++var2) {
|
for (var2 = 0; var2 < var0.length; ++var2) {
|
||||||
var0[var2] /= (double) var1;
|
var0[var2] /= var1;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (var2 = 0; var2 < var0.length; ++var2) {
|
for (var2 = 0; var2 < var0.length; ++var2) {
|
||||||
@ -658,7 +657,7 @@ public class MathHelper {
|
|||||||
int var7 = 0;
|
int var7 = 0;
|
||||||
|
|
||||||
for (int var8 = var4; var8 <= var5; ++var8) {
|
for (int var8 = var4; var8 <= var5; ++var8) {
|
||||||
var6[var7] = Math.max(var0 * StrictMath.log((double) var8) + var2, 0.0D);
|
var6[var7] = Math.max(var0 * StrictMath.log(var8) + var2, 0.0D);
|
||||||
++var7;
|
++var7;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -773,7 +772,7 @@ public class MathHelper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static double n(double var0) {
|
public static double n(double var0) {
|
||||||
return var0 + (2.0D * (new Random((long) floor(var0 * 3000.0D))).nextDouble() - 1.0D) * 1.0E-7D / 2.0D;
|
return var0 + (2.0D * (new Random(floor(var0 * 3000.0D))).nextDouble() - 1.0D) * 1.0E-7D / 2.0D;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int d(int var0, int var1) {
|
public static int d(int var0, int var1) {
|
||||||
|
@ -19,16 +19,15 @@
|
|||||||
package com.volmit.iris.util.nbt.mca;
|
package com.volmit.iris.util.nbt.mca;
|
||||||
|
|
||||||
import com.volmit.iris.Iris;
|
import com.volmit.iris.Iris;
|
||||||
import com.volmit.iris.util.io.IO;
|
import com.volmit.iris.core.nms.INMS;
|
||||||
import com.volmit.iris.util.nbt.io.NBTDeserializer;
|
import com.volmit.iris.util.nbt.io.NBTDeserializer;
|
||||||
import com.volmit.iris.util.nbt.io.NBTSerializer;
|
import com.volmit.iris.util.nbt.io.NBTSerializer;
|
||||||
import com.volmit.iris.util.nbt.io.NamedTag;
|
import com.volmit.iris.util.nbt.io.NamedTag;
|
||||||
|
import com.volmit.iris.util.nbt.mca.palette.BiomeContainer;
|
||||||
import com.volmit.iris.util.nbt.tag.CompoundTag;
|
import com.volmit.iris.util.nbt.tag.CompoundTag;
|
||||||
import com.volmit.iris.util.nbt.tag.ListTag;
|
import com.volmit.iris.util.nbt.tag.ListTag;
|
||||||
import com.volmit.iris.util.nbt.tag.Tag;
|
|
||||||
|
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.concurrent.atomic.AtomicReferenceArray;
|
import java.util.concurrent.atomic.AtomicReferenceArray;
|
||||||
|
|
||||||
import static com.volmit.iris.util.nbt.mca.LoadFlags.*;
|
import static com.volmit.iris.util.nbt.mca.LoadFlags.*;
|
||||||
@ -41,7 +40,7 @@ public class Chunk {
|
|||||||
private int dataVersion;
|
private int dataVersion;
|
||||||
private long lastUpdate;
|
private long lastUpdate;
|
||||||
private long inhabitedTime;
|
private long inhabitedTime;
|
||||||
private int[] biomes;
|
private BiomeContainer biomes;
|
||||||
private CompoundTag heightMaps;
|
private CompoundTag heightMaps;
|
||||||
private CompoundTag carvingMasks;
|
private CompoundTag carvingMasks;
|
||||||
private final AtomicReferenceArray<Section> sections = new AtomicReferenceArray<>(16);
|
private final AtomicReferenceArray<Section> sections = new AtomicReferenceArray<>(16);
|
||||||
@ -83,7 +82,7 @@ public class Chunk {
|
|||||||
inhabitedTime = level.getLong("InhabitedTime");
|
inhabitedTime = level.getLong("InhabitedTime");
|
||||||
lastUpdate = level.getLong("LastUpdate");
|
lastUpdate = level.getLong("LastUpdate");
|
||||||
if ((loadFlags & BIOMES) != 0) {
|
if ((loadFlags & BIOMES) != 0) {
|
||||||
biomes = level.getIntArray("Biomes");
|
biomes = INMS.get().newBiomeContainer(0, 256, level.getIntArray("Biomes"));
|
||||||
}
|
}
|
||||||
if ((loadFlags & HEIGHTMAPS) != 0) {
|
if ((loadFlags & HEIGHTMAPS) != 0) {
|
||||||
heightMaps = level.getCompoundTag("Heightmaps");
|
heightMaps = level.getCompoundTag("Heightmaps");
|
||||||
@ -201,21 +200,6 @@ public class Chunk {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @deprecated Use {@link #getBiomeAt(int, int, int)} instead
|
|
||||||
*/
|
|
||||||
@Deprecated
|
|
||||||
public int getBiomeAt(int blockX, int blockZ) {
|
|
||||||
if (dataVersion < 2202) {
|
|
||||||
if (biomes == null || biomes.length != 256) {
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
return biomes[getBlockIndex(blockX, blockZ)];
|
|
||||||
} else {
|
|
||||||
throw new IllegalStateException("cannot get biome using Chunk#getBiomeAt(int,int) from biome data with DataVersion of 2202 or higher, use Chunk#getBiomeAt(int,int,int) instead");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fetches a biome id at a specific block in this chunk.
|
* Fetches a biome id at a specific block in this chunk.
|
||||||
* The coordinates can be absolute coordinates or relative to the region or chunk.
|
* The coordinates can be absolute coordinates or relative to the region or chunk.
|
||||||
@ -226,44 +210,7 @@ public class Chunk {
|
|||||||
* @return The biome id or -1 if the biomes are not correctly initialized.
|
* @return The biome id or -1 if the biomes are not correctly initialized.
|
||||||
*/
|
*/
|
||||||
public synchronized int getBiomeAt(int blockX, int blockY, int blockZ) {
|
public synchronized int getBiomeAt(int blockX, int blockY, int blockZ) {
|
||||||
if (dataVersion < 2202) {
|
return biomes.getBiome(blockX, blockY, blockZ);
|
||||||
if (biomes == null || biomes.length != 256) {
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
return biomes[getBlockIndex(blockX, blockZ)];
|
|
||||||
} else {
|
|
||||||
if (biomes == null || biomes.length != 1024) {
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
int biomeX = (blockX & 0xF) >> 2;
|
|
||||||
int biomeY = (blockY & 0xF) >> 2;
|
|
||||||
int biomeZ = (blockZ & 0xF) >> 2;
|
|
||||||
|
|
||||||
return biomes[getBiomeIndex(biomeX, biomeY, biomeZ)];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Deprecated
|
|
||||||
public synchronized void setBiomeAt(int blockX, int blockZ, int biomeID) {
|
|
||||||
if (dataVersion < 2202) {
|
|
||||||
if (biomes == null || biomes.length != 256) {
|
|
||||||
biomes = new int[256];
|
|
||||||
Arrays.fill(biomes, -1);
|
|
||||||
}
|
|
||||||
biomes[getBlockIndex(blockX, blockZ)] = biomeID;
|
|
||||||
} else {
|
|
||||||
if (biomes == null || biomes.length != 1024) {
|
|
||||||
biomes = new int[1024];
|
|
||||||
Arrays.fill(biomes, -1);
|
|
||||||
}
|
|
||||||
|
|
||||||
int biomeX = (blockX & 0xF) >> 2;
|
|
||||||
int biomeZ = (blockZ & 0xF) >> 2;
|
|
||||||
|
|
||||||
for (int y = 0; y < 64; y++) {
|
|
||||||
biomes[getBiomeIndex(biomeX, y, biomeZ)] = biomeID;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -276,23 +223,7 @@ public class Chunk {
|
|||||||
* When set to a negative number, Minecraft will replace it with the block column's default biome.
|
* When set to a negative number, Minecraft will replace it with the block column's default biome.
|
||||||
*/
|
*/
|
||||||
public synchronized void setBiomeAt(int blockX, int blockY, int blockZ, int biomeID) {
|
public synchronized void setBiomeAt(int blockX, int blockY, int blockZ, int biomeID) {
|
||||||
if (dataVersion < 2202) {
|
biomes.setBiome(blockX, blockY, blockZ, biomeID);
|
||||||
if (biomes == null || biomes.length != 256) {
|
|
||||||
biomes = new int[256];
|
|
||||||
Arrays.fill(biomes, -1);
|
|
||||||
}
|
|
||||||
biomes[getBlockIndex(blockX, blockZ)] = biomeID;
|
|
||||||
} else {
|
|
||||||
if (biomes == null || biomes.length != 1024) {
|
|
||||||
biomes = new int[1024];
|
|
||||||
Arrays.fill(biomes, -1);
|
|
||||||
}
|
|
||||||
|
|
||||||
int biomeX = (blockX & 0xF) >> 2;
|
|
||||||
int biomeZ = (blockZ & 0xF) >> 2;
|
|
||||||
|
|
||||||
biomes[getBiomeIndex(biomeX, blockY, biomeZ)] = biomeID;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int getBiomeIndex(int biomeX, int biomeY, int biomeZ) {
|
int getBiomeIndex(int biomeX, int biomeY, int biomeZ) {
|
||||||
@ -430,29 +361,6 @@ public class Chunk {
|
|||||||
this.inhabitedTime = inhabitedTime;
|
this.inhabitedTime = inhabitedTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return A matrix of biome IDs for all block columns in this chunk.
|
|
||||||
*/
|
|
||||||
public int[] getBiomes() {
|
|
||||||
return biomes;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets the biome IDs for this chunk.
|
|
||||||
*
|
|
||||||
* @param biomes The biome ID matrix of this chunk. Must have a length of <code>256</code>.
|
|
||||||
* @throws IllegalArgumentException When the biome matrix does not have a length of <code>256</code>
|
|
||||||
* or is <code>null</code>
|
|
||||||
*/
|
|
||||||
public void setBiomes(int[] biomes) {
|
|
||||||
if (biomes != null) {
|
|
||||||
if (dataVersion < 2202 && biomes.length != 256 || dataVersion >= 2202 && biomes.length != 1024) {
|
|
||||||
throw new IllegalArgumentException("biomes array must have a length of " + (dataVersion < 2202 ? "256" : "1024"));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
this.biomes = biomes;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return The height maps of this chunk.
|
* @return The height maps of this chunk.
|
||||||
*/
|
*/
|
||||||
@ -646,6 +554,7 @@ public class Chunk {
|
|||||||
Chunk c = new Chunk(0);
|
Chunk c = new Chunk(0);
|
||||||
c.dataVersion = DEFAULT_DATA_VERSION;
|
c.dataVersion = DEFAULT_DATA_VERSION;
|
||||||
c.data = new CompoundTag();
|
c.data = new CompoundTag();
|
||||||
|
c.biomes = INMS.get().newBiomeContainer(0, 256);
|
||||||
c.data.put("Level", defaultLevel());
|
c.data.put("Level", defaultLevel());
|
||||||
c.status = "full";
|
c.status = "full";
|
||||||
return c;
|
return c;
|
||||||
@ -665,7 +574,7 @@ public class Chunk {
|
|||||||
level.putInt("zPos", zPos);
|
level.putInt("zPos", zPos);
|
||||||
level.putLong("LastUpdate", lastUpdate);
|
level.putLong("LastUpdate", lastUpdate);
|
||||||
level.putLong("InhabitedTime", inhabitedTime);
|
level.putLong("InhabitedTime", inhabitedTime);
|
||||||
if (biomes != null && biomes.length == 1024) level.putIntArray("Biomes", biomes);
|
level.putIntArray("Biomes", biomes.getData());
|
||||||
if (heightMaps != null) level.put("Heightmaps", heightMaps);
|
if (heightMaps != null) level.put("Heightmaps", heightMaps);
|
||||||
if (carvingMasks != null) level.put("CarvingMasks", carvingMasks);
|
if (carvingMasks != null) level.put("CarvingMasks", carvingMasks);
|
||||||
if (entities != null) level.put("Entities", entities);
|
if (entities != null) level.put("Entities", entities);
|
||||||
|
@ -18,7 +18,6 @@
|
|||||||
|
|
||||||
package com.volmit.iris.util.nbt.mca;
|
package com.volmit.iris.util.nbt.mca;
|
||||||
|
|
||||||
import com.volmit.iris.Iris;
|
|
||||||
import com.volmit.iris.util.collection.KList;
|
import com.volmit.iris.util.collection.KList;
|
||||||
import com.volmit.iris.util.math.Position2;
|
import com.volmit.iris.util.math.Position2;
|
||||||
import com.volmit.iris.util.nbt.tag.CompoundTag;
|
import com.volmit.iris.util.nbt.tag.CompoundTag;
|
||||||
@ -275,31 +274,10 @@ public class MCAFile {
|
|||||||
return chunk;
|
return chunk;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @deprecated Use {@link #setBiomeAt(int, int, int, int)} instead
|
|
||||||
*/
|
|
||||||
@Deprecated
|
|
||||||
public void setBiomeAt(int blockX, int blockZ, int biomeID) {
|
|
||||||
createChunkIfMissing(blockX, blockZ).setBiomeAt(blockX, blockZ, biomeID);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setBiomeAt(int blockX, int blockY, int blockZ, int biomeID) {
|
public void setBiomeAt(int blockX, int blockY, int blockZ, int biomeID) {
|
||||||
createChunkIfMissing(blockX, blockZ).setBiomeAt(blockX, blockY, blockZ, biomeID);
|
createChunkIfMissing(blockX, blockZ).setBiomeAt(blockX, blockY, blockZ, biomeID);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @deprecated Use {@link #getBiomeAt(int, int, int)} instead
|
|
||||||
*/
|
|
||||||
@Deprecated
|
|
||||||
public int getBiomeAt(int blockX, int blockZ) {
|
|
||||||
int chunkX = MCAUtil.blockToChunk(blockX), chunkZ = MCAUtil.blockToChunk(blockZ);
|
|
||||||
Chunk chunk = getChunk(getChunkIndex(chunkX, chunkZ));
|
|
||||||
if (chunk == null) {
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
return chunk.getBiomeAt(blockX, blockZ);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fetches the biome id at a specific block.
|
* Fetches the biome id at a specific block.
|
||||||
*
|
*
|
||||||
|
@ -73,24 +73,22 @@ public class Section {
|
|||||||
* @return The block state data of this block.
|
* @return The block state data of this block.
|
||||||
*/
|
*/
|
||||||
public synchronized CompoundTag getBlockStateAt(int blockX, int blockY, int blockZ) {
|
public synchronized CompoundTag getBlockStateAt(int blockX, int blockY, int blockZ) {
|
||||||
synchronized (palette)
|
synchronized (palette) {
|
||||||
{
|
return palette.getBlock(blockX & 15, blockY & 15, blockZ & 15);
|
||||||
return palette.getBlock(blockX&15, blockY&15, blockZ&15);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Attempts to add a block state for a specific block location in this Section.
|
* Attempts to add a block state for a specific block location in this Section.
|
||||||
*
|
*
|
||||||
* @param blockX The x-coordinate of the block in this Section
|
* @param blockX The x-coordinate of the block in this Section
|
||||||
* @param blockY The y-coordinate of the block in this Section
|
* @param blockY The y-coordinate of the block in this Section
|
||||||
* @param blockZ The z-coordinate of the block in this Section
|
* @param blockZ The z-coordinate of the block in this Section
|
||||||
* @param state The block state to be set
|
* @param state The block state to be set
|
||||||
*/
|
*/
|
||||||
public synchronized void setBlockStateAt(int blockX, int blockY, int blockZ, CompoundTag state, boolean cleanup) {
|
public synchronized void setBlockStateAt(int blockX, int blockY, int blockZ, CompoundTag state, boolean cleanup) {
|
||||||
synchronized (palette)
|
synchronized (palette) {
|
||||||
{
|
palette.setBlock(blockX & 15, blockY & 15, blockZ & 15, state);
|
||||||
palette.setBlock(blockX&15, blockY&15, blockZ&15, state);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -167,8 +165,7 @@ public class Section {
|
|||||||
data.putByte("Y", (byte) y);
|
data.putByte("Y", (byte) y);
|
||||||
|
|
||||||
if (palette != null) {
|
if (palette != null) {
|
||||||
synchronized (palette)
|
synchronized (palette) {
|
||||||
{
|
|
||||||
palette.writeToSection(data);
|
palette.writeToSection(data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,27 @@
|
|||||||
|
/*
|
||||||
|
* Iris is a World Generator for Minecraft Bukkit Servers
|
||||||
|
* Copyright (c) 2021 Arcane Arts (Volmit Software)
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.volmit.iris.util.nbt.mca.palette;
|
||||||
|
|
||||||
|
public interface BiomeContainer {
|
||||||
|
int[] getData();
|
||||||
|
|
||||||
|
void setBiome(int x, int y, int z, int id);
|
||||||
|
|
||||||
|
int getBiome(int x, int y, int z);
|
||||||
|
}
|
@ -23,123 +23,123 @@ import org.apache.commons.lang3.Validate;
|
|||||||
import java.util.function.IntConsumer;
|
import java.util.function.IntConsumer;
|
||||||
|
|
||||||
public class BitStorage {
|
public class BitStorage {
|
||||||
private static final int[] MAGIC = new int[] {
|
private static final int[] MAGIC = new int[]{
|
||||||
-1, -1, 0, Integer.MIN_VALUE, 0, 0, 1431655765, 1431655765, 0, Integer.MIN_VALUE,
|
-1, -1, 0, Integer.MIN_VALUE, 0, 0, 1431655765, 1431655765, 0, Integer.MIN_VALUE,
|
||||||
0, 1, 858993459, 858993459, 0, 715827882, 715827882, 0, 613566756, 613566756,
|
0, 1, 858993459, 858993459, 0, 715827882, 715827882, 0, 613566756, 613566756,
|
||||||
0, Integer.MIN_VALUE, 0, 2, 477218588, 477218588, 0, 429496729, 429496729, 0,
|
0, Integer.MIN_VALUE, 0, 2, 477218588, 477218588, 0, 429496729, 429496729, 0,
|
||||||
390451572, 390451572, 0, 357913941, 357913941, 0, 330382099, 330382099, 0, 306783378,
|
390451572, 390451572, 0, 357913941, 357913941, 0, 330382099, 330382099, 0, 306783378,
|
||||||
306783378, 0, 286331153, 286331153, 0, Integer.MIN_VALUE, 0, 3, 252645135, 252645135,
|
306783378, 0, 286331153, 286331153, 0, Integer.MIN_VALUE, 0, 3, 252645135, 252645135,
|
||||||
0, 238609294, 238609294, 0, 226050910, 226050910, 0, 214748364, 214748364, 0,
|
0, 238609294, 238609294, 0, 226050910, 226050910, 0, 214748364, 214748364, 0,
|
||||||
204522252, 204522252, 0, 195225786, 195225786, 0, 186737708, 186737708, 0, 178956970,
|
204522252, 204522252, 0, 195225786, 195225786, 0, 186737708, 186737708, 0, 178956970,
|
||||||
178956970, 0, 171798691, 171798691, 0, 165191049, 165191049, 0, 159072862, 159072862,
|
178956970, 0, 171798691, 171798691, 0, 165191049, 165191049, 0, 159072862, 159072862,
|
||||||
0, 153391689, 153391689, 0, 148102320, 148102320, 0, 143165576, 143165576, 0,
|
0, 153391689, 153391689, 0, 148102320, 148102320, 0, 143165576, 143165576, 0,
|
||||||
138547332, 138547332, 0, Integer.MIN_VALUE, 0, 4, 130150524, 130150524, 0, 126322567,
|
138547332, 138547332, 0, Integer.MIN_VALUE, 0, 4, 130150524, 130150524, 0, 126322567,
|
||||||
126322567, 0, 122713351, 122713351, 0, 119304647, 119304647, 0, 116080197, 116080197,
|
126322567, 0, 122713351, 122713351, 0, 119304647, 119304647, 0, 116080197, 116080197,
|
||||||
0, 113025455, 113025455, 0, 110127366, 110127366, 0, 107374182, 107374182, 0,
|
0, 113025455, 113025455, 0, 110127366, 110127366, 0, 107374182, 107374182, 0,
|
||||||
104755299, 104755299, 0, 102261126, 102261126, 0, 99882960, 99882960, 0, 97612893,
|
104755299, 104755299, 0, 102261126, 102261126, 0, 99882960, 99882960, 0, 97612893,
|
||||||
97612893, 0, 95443717, 95443717, 0, 93368854, 93368854, 0, 91382282, 91382282,
|
97612893, 0, 95443717, 95443717, 0, 93368854, 93368854, 0, 91382282, 91382282,
|
||||||
0, 89478485, 89478485, 0, 87652393, 87652393, 0, 85899345, 85899345, 0,
|
0, 89478485, 89478485, 0, 87652393, 87652393, 0, 85899345, 85899345, 0,
|
||||||
84215045, 84215045, 0, 82595524, 82595524, 0, 81037118, 81037118, 0, 79536431,
|
84215045, 84215045, 0, 82595524, 82595524, 0, 81037118, 81037118, 0, 79536431,
|
||||||
79536431, 0, 78090314, 78090314, 0, 76695844, 76695844, 0, 75350303, 75350303,
|
79536431, 0, 78090314, 78090314, 0, 76695844, 76695844, 0, 75350303, 75350303,
|
||||||
0, 74051160, 74051160, 0, 72796055, 72796055, 0, 71582788, 71582788, 0,
|
0, 74051160, 74051160, 0, 72796055, 72796055, 0, 71582788, 71582788, 0,
|
||||||
70409299, 70409299, 0, 69273666, 69273666, 0, 68174084, 68174084, 0, Integer.MIN_VALUE,
|
70409299, 70409299, 0, 69273666, 69273666, 0, 68174084, 68174084, 0, Integer.MIN_VALUE,
|
||||||
0, 5 };
|
0, 5};
|
||||||
|
|
||||||
private final long[] data;
|
private final long[] data;
|
||||||
|
|
||||||
private final int bits;
|
private final int bits;
|
||||||
|
|
||||||
private final long mask;
|
private final long mask;
|
||||||
|
|
||||||
private final int size;
|
private final int size;
|
||||||
|
|
||||||
private final int valuesPerLong;
|
private final int valuesPerLong;
|
||||||
|
|
||||||
private final int divideMul;
|
private final int divideMul;
|
||||||
|
|
||||||
private final int divideAdd;
|
private final int divideAdd;
|
||||||
|
|
||||||
private final int divideShift;
|
private final int divideShift;
|
||||||
|
|
||||||
public BitStorage(int var0, int var1) {
|
public BitStorage(int var0, int var1) {
|
||||||
this(var0, var1, null);
|
this(var0, var1, null);
|
||||||
}
|
|
||||||
|
|
||||||
public BitStorage(int var0, int var1, long[] var2) {
|
|
||||||
Validate.inclusiveBetween(1L, 32L, var0);
|
|
||||||
this.size = var1;
|
|
||||||
this.bits = var0;
|
|
||||||
this.mask = (1L << var0) - 1L;
|
|
||||||
this.valuesPerLong = (char)(64 / var0);
|
|
||||||
int var3 = 3 * (this.valuesPerLong - 1);
|
|
||||||
this.divideMul = MAGIC[var3 + 0];
|
|
||||||
this.divideAdd = MAGIC[var3 + 1];
|
|
||||||
this.divideShift = MAGIC[var3 + 2];
|
|
||||||
int var4 = (var1 + this.valuesPerLong - 1) / this.valuesPerLong;
|
|
||||||
if (var2 != null) {
|
|
||||||
if (var2.length != var4)
|
|
||||||
throw new RuntimeException("NO!");
|
|
||||||
this.data = var2;
|
|
||||||
} else {
|
|
||||||
this.data = new long[var4];
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
private int cellIndex(int var0) {
|
public BitStorage(int var0, int var1, long[] var2) {
|
||||||
long var1 = Integer.toUnsignedLong(this.divideMul);
|
Validate.inclusiveBetween(1L, 32L, var0);
|
||||||
long var3 = Integer.toUnsignedLong(this.divideAdd);
|
this.size = var1;
|
||||||
return (int)(var0 * var1 + var3 >> 32L >> this.divideShift);
|
this.bits = var0;
|
||||||
}
|
this.mask = (1L << var0) - 1L;
|
||||||
|
this.valuesPerLong = (char) (64 / var0);
|
||||||
public int getAndSet(int var0, int var1) {
|
int var3 = 3 * (this.valuesPerLong - 1);
|
||||||
Validate.inclusiveBetween(0L, (this.size - 1), var0);
|
this.divideMul = MAGIC[var3 + 0];
|
||||||
Validate.inclusiveBetween(0L, this.mask, var1);
|
this.divideAdd = MAGIC[var3 + 1];
|
||||||
int var2 = cellIndex(var0);
|
this.divideShift = MAGIC[var3 + 2];
|
||||||
long var3 = this.data[var2];
|
int var4 = (var1 + this.valuesPerLong - 1) / this.valuesPerLong;
|
||||||
int var5 = (var0 - var2 * this.valuesPerLong) * this.bits;
|
if (var2 != null) {
|
||||||
int var6 = (int)(var3 >> var5 & this.mask);
|
if (var2.length != var4)
|
||||||
this.data[var2] = var3 & (this.mask << var5 ^ 0xFFFFFFFFFFFFFFFFL) | (var1 & this.mask) << var5;
|
throw new RuntimeException("NO!");
|
||||||
return var6;
|
this.data = var2;
|
||||||
}
|
} else {
|
||||||
|
this.data = new long[var4];
|
||||||
public void set(int var0, int var1) {
|
}
|
||||||
Validate.inclusiveBetween(0L, (this.size - 1), var0);
|
}
|
||||||
Validate.inclusiveBetween(0L, this.mask, var1);
|
|
||||||
int var2 = cellIndex(var0);
|
private int cellIndex(int var0) {
|
||||||
long var3 = this.data[var2];
|
long var1 = Integer.toUnsignedLong(this.divideMul);
|
||||||
int var5 = (var0 - var2 * this.valuesPerLong) * this.bits;
|
long var3 = Integer.toUnsignedLong(this.divideAdd);
|
||||||
this.data[var2] = var3 & (this.mask << var5 ^ 0xFFFFFFFFFFFFFFFFL) | (var1 & this.mask) << var5;
|
return (int) (var0 * var1 + var3 >> 32L >> this.divideShift);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int get(int var0) {
|
public int getAndSet(int var0, int var1) {
|
||||||
Validate.inclusiveBetween(0L, (this.size - 1), var0);
|
Validate.inclusiveBetween(0L, (this.size - 1), var0);
|
||||||
int var1 = cellIndex(var0);
|
Validate.inclusiveBetween(0L, this.mask, var1);
|
||||||
long var2 = this.data[var1];
|
int var2 = cellIndex(var0);
|
||||||
int var4 = (var0 - var1 * this.valuesPerLong) * this.bits;
|
long var3 = this.data[var2];
|
||||||
return (int)(var2 >> var4 & this.mask);
|
int var5 = (var0 - var2 * this.valuesPerLong) * this.bits;
|
||||||
}
|
int var6 = (int) (var3 >> var5 & this.mask);
|
||||||
|
this.data[var2] = var3 & (this.mask << var5 ^ 0xFFFFFFFFFFFFFFFFL) | (var1 & this.mask) << var5;
|
||||||
public long[] getRaw() {
|
return var6;
|
||||||
return this.data;
|
}
|
||||||
}
|
|
||||||
|
public void set(int var0, int var1) {
|
||||||
public int getSize() {
|
Validate.inclusiveBetween(0L, (this.size - 1), var0);
|
||||||
return this.size;
|
Validate.inclusiveBetween(0L, this.mask, var1);
|
||||||
}
|
int var2 = cellIndex(var0);
|
||||||
|
long var3 = this.data[var2];
|
||||||
public int getBits() {
|
int var5 = (var0 - var2 * this.valuesPerLong) * this.bits;
|
||||||
return this.bits;
|
this.data[var2] = var3 & (this.mask << var5 ^ 0xFFFFFFFFFFFFFFFFL) | (var1 & this.mask) << var5;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void getAll(IntConsumer var0) {
|
public int get(int var0) {
|
||||||
int var1 = 0;
|
Validate.inclusiveBetween(0L, (this.size - 1), var0);
|
||||||
for (long var5 : this.data) {
|
int var1 = cellIndex(var0);
|
||||||
for (int var7 = 0; var7 < this.valuesPerLong; var7++) {
|
long var2 = this.data[var1];
|
||||||
var0.accept((int)(var5 & this.mask));
|
int var4 = (var0 - var1 * this.valuesPerLong) * this.bits;
|
||||||
var5 >>= this.bits;
|
return (int) (var2 >> var4 & this.mask);
|
||||||
if (++var1 >= this.size)
|
}
|
||||||
return;
|
|
||||||
}
|
public long[] getRaw() {
|
||||||
|
return this.data;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getSize() {
|
||||||
|
return this.size;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getBits() {
|
||||||
|
return this.bits;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void getAll(IntConsumer var0) {
|
||||||
|
int var1 = 0;
|
||||||
|
for (long var5 : this.data) {
|
||||||
|
for (int var7 = 0; var7 < this.valuesPerLong; var7++) {
|
||||||
|
var0.accept((int) (var5 & this.mask));
|
||||||
|
var5 >>= this.bits;
|
||||||
|
if (++var1 >= this.size)
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -18,79 +18,79 @@
|
|||||||
|
|
||||||
package com.volmit.iris.util.nbt.mca.palette;
|
package com.volmit.iris.util.nbt.mca.palette;
|
||||||
|
|
||||||
import net.minecraft.world.level.LevelHeightAccessor;
|
|
||||||
import net.minecraft.world.level.biome.BiomeBase;
|
|
||||||
import net.minecraft.world.level.biome.BiomeManager;
|
|
||||||
import org.apache.logging.log4j.LogManager;
|
import org.apache.logging.log4j.LogManager;
|
||||||
import org.apache.logging.log4j.Logger;
|
import org.apache.logging.log4j.Logger;
|
||||||
import org.bukkit.block.Biome;
|
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
|
||||||
public class ChunkBiomeContainer<T> {
|
public class ChunkBiomeContainer<T> {
|
||||||
private static final Logger LOGGER = LogManager.getLogger();
|
private static final Logger LOGGER = LogManager.getLogger();
|
||||||
private static final int WIDTH_BITS = Mth.ceillog2(16) - 2;
|
private static final int WIDTH_BITS = Mth.ceillog2(16) - 2;
|
||||||
private static final int HORIZONTAL_MASK = (1 << WIDTH_BITS) - 1;
|
private static final int HORIZONTAL_MASK = (1 << WIDTH_BITS) - 1;
|
||||||
private static final int PACKED_X_LENGTH = 1 + Mth.log2(Mth.smallestEncompassingPowerOfTwo(30000000));
|
private static final int PACKED_X_LENGTH = 1 + Mth.log2(Mth.smallestEncompassingPowerOfTwo(30000000));
|
||||||
private static final int PACKED_Z_LENGTH = PACKED_X_LENGTH;
|
private static final int PACKED_Z_LENGTH = PACKED_X_LENGTH;
|
||||||
public static final int PACKED_Y_LENGTH = 64 - PACKED_X_LENGTH - PACKED_Z_LENGTH;
|
public static final int PACKED_Y_LENGTH = 64 - PACKED_X_LENGTH - PACKED_Z_LENGTH;
|
||||||
public static final int MAX_SIZE = 1 << WIDTH_BITS + WIDTH_BITS + PACKED_Y_LENGTH - 2;
|
public static final int MAX_SIZE = 1 << WIDTH_BITS + WIDTH_BITS + PACKED_Y_LENGTH - 2;
|
||||||
|
|
||||||
public final IdMap<T> biomeRegistry;
|
public final IdMap<T> biomeRegistry;
|
||||||
|
|
||||||
private final T[] biomes;
|
private final T[] biomes;
|
||||||
|
|
||||||
private final int quartMinY;
|
private final int quartMinY;
|
||||||
|
|
||||||
private final int quartHeight;
|
private final int quartHeight;
|
||||||
|
|
||||||
protected ChunkBiomeContainer(IdMap<T> registry, int minHeight, int maxHeight, T[] abiomebase) {
|
protected ChunkBiomeContainer(IdMap<T> registry, int minHeight, int maxHeight, T[] abiomebase) {
|
||||||
this.biomeRegistry = registry;
|
this.biomeRegistry = registry;
|
||||||
this.biomes = abiomebase;
|
this.biomes = abiomebase;
|
||||||
this.quartMinY = QuartPos.fromBlock(minHeight);
|
this.quartMinY = QuartPos.fromBlock(minHeight);
|
||||||
this.quartHeight = QuartPos.fromBlock(maxHeight) - 1;
|
this.quartHeight = QuartPos.fromBlock(maxHeight) - 1;
|
||||||
}
|
|
||||||
|
|
||||||
public ChunkBiomeContainer(IdMap<T> registry, int minHeight, int maxHeight, int[] aint) {
|
|
||||||
this(registry, minHeight, maxHeight, (T[])new Object[aint.length]);
|
|
||||||
int i = -1;
|
|
||||||
for (int j = 0; j < this.biomes.length; j++) {
|
|
||||||
int k = aint[j];
|
|
||||||
T biomebase = registry.byId(k);
|
|
||||||
if (biomebase == null) {
|
|
||||||
if (i == -1)
|
|
||||||
i = j;
|
|
||||||
this.biomes[j] = (T)registry.byId(0);
|
|
||||||
} else {
|
|
||||||
this.biomes[j] = biomebase;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (i != -1)
|
|
||||||
LOGGER.warn("Invalid biome data received, starting from {}: {}", Integer.valueOf(i), Arrays.toString(aint));
|
|
||||||
}
|
|
||||||
|
|
||||||
private static int ceilDiv(int i, int j) {
|
public ChunkBiomeContainer(IdMap<T> registry, int min, int max) {
|
||||||
return (i + j - 1) / j;
|
this(registry, min, max, new int[(1 << WIDTH_BITS + WIDTH_BITS) * ceilDiv(max - min, 4)]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int[] writeBiomes() {
|
public ChunkBiomeContainer(IdMap<T> registry, int minHeight, int maxHeight, int[] aint) {
|
||||||
int[] aint = new int[this.biomes.length];
|
this(registry, minHeight, maxHeight, (T[]) new Object[aint.length]);
|
||||||
for (int i = 0; i < this.biomes.length; i++)
|
int i = -1;
|
||||||
aint[i] = this.biomeRegistry.getId(this.biomes[i]);
|
for (int j = 0; j < this.biomes.length; j++) {
|
||||||
return aint;
|
int k = aint[j];
|
||||||
}
|
T biomebase = registry.byId(k);
|
||||||
|
if (biomebase == null) {
|
||||||
|
if (i == -1)
|
||||||
|
i = j;
|
||||||
|
this.biomes[j] = registry.byId(0);
|
||||||
|
} else {
|
||||||
|
this.biomes[j] = biomebase;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (i != -1)
|
||||||
|
LOGGER.warn("Invalid biome data received, starting from {}: {}", Integer.valueOf(i), Arrays.toString(aint));
|
||||||
|
}
|
||||||
|
|
||||||
public T getBiome(int i, int j, int k) {
|
private static int ceilDiv(int i, int j) {
|
||||||
int l = i & HORIZONTAL_MASK;
|
return (i + j - 1) / j;
|
||||||
int i1 = Mth.clamp(j - this.quartMinY, 0, this.quartHeight);
|
}
|
||||||
int j1 = k & HORIZONTAL_MASK;
|
|
||||||
return this.biomes[i1 << WIDTH_BITS + WIDTH_BITS | j1 << WIDTH_BITS | l];
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setBiome(int i, int j, int k, T biome) {
|
public int[] writeBiomes() {
|
||||||
int l = i & HORIZONTAL_MASK;
|
int[] aint = new int[this.biomes.length];
|
||||||
int i1 = Mth.clamp(j - this.quartMinY, 0, this.quartHeight);
|
for (int i = 0; i < this.biomes.length; i++)
|
||||||
int j1 = k & HORIZONTAL_MASK;
|
aint[i] = this.biomeRegistry.getId(this.biomes[i]);
|
||||||
this.biomes[i1 << WIDTH_BITS + WIDTH_BITS | j1 << WIDTH_BITS | l] = biome;
|
return aint;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public T getBiome(int i, int j, int k) {
|
||||||
|
int l = i & HORIZONTAL_MASK;
|
||||||
|
int i1 = Mth.clamp(j - this.quartMinY, 0, this.quartHeight);
|
||||||
|
int j1 = k & HORIZONTAL_MASK;
|
||||||
|
return this.biomes[i1 << WIDTH_BITS + WIDTH_BITS | j1 << WIDTH_BITS | l];
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setBiome(int i, int j, int k, T biome) {
|
||||||
|
int l = i & HORIZONTAL_MASK;
|
||||||
|
int i1 = Mth.clamp(j - this.quartMinY, 0, this.quartHeight);
|
||||||
|
int j1 = k & HORIZONTAL_MASK;
|
||||||
|
this.biomes[i1 << WIDTH_BITS + WIDTH_BITS | j1 << WIDTH_BITS | l] = biome;
|
||||||
|
}
|
||||||
}
|
}
|
@ -20,5 +20,5 @@ package com.volmit.iris.util.nbt.mca.palette;
|
|||||||
|
|
||||||
@FunctionalInterface
|
@FunctionalInterface
|
||||||
public interface CountConsumer<T> {
|
public interface CountConsumer<T> {
|
||||||
void accept(T paramT, int paramInt);
|
void accept(T paramT, int paramInt);
|
||||||
}
|
}
|
||||||
|
@ -25,143 +25,143 @@ import java.util.Arrays;
|
|||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
|
|
||||||
public class CrudeIncrementalIntIdentityHashBiMap<K> implements IdMap<K> {
|
public class CrudeIncrementalIntIdentityHashBiMap<K> implements IdMap<K> {
|
||||||
public static final int NOT_FOUND = -1;
|
public static final int NOT_FOUND = -1;
|
||||||
|
|
||||||
private static final Object EMPTY_SLOT = null;
|
private static final Object EMPTY_SLOT = null;
|
||||||
|
|
||||||
private static final float LOADFACTOR = 0.8F;
|
private static final float LOADFACTOR = 0.8F;
|
||||||
|
|
||||||
private K[] keys;
|
private K[] keys;
|
||||||
|
|
||||||
private int[] values;
|
private int[] values;
|
||||||
|
|
||||||
private K[] byId;
|
private K[] byId;
|
||||||
|
|
||||||
private int nextId;
|
private int nextId;
|
||||||
|
|
||||||
private int size;
|
private int size;
|
||||||
|
|
||||||
public CrudeIncrementalIntIdentityHashBiMap(int var0) {
|
public CrudeIncrementalIntIdentityHashBiMap(int var0) {
|
||||||
var0 = (int)(var0 / 0.8F);
|
var0 = (int) (var0 / 0.8F);
|
||||||
this.keys = (K[])new Object[var0];
|
this.keys = (K[]) new Object[var0];
|
||||||
this.values = new int[var0];
|
this.values = new int[var0];
|
||||||
this.byId = (K[])new Object[var0];
|
this.byId = (K[]) new Object[var0];
|
||||||
}
|
|
||||||
|
|
||||||
public int getId(K var0) {
|
|
||||||
return getValue(indexOf(var0, hash(var0)));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public K byId(int var0) {
|
|
||||||
if (var0 < 0 || var0 >= this.byId.length)
|
|
||||||
return null;
|
|
||||||
return this.byId[var0];
|
|
||||||
}
|
|
||||||
|
|
||||||
private int getValue(int var0) {
|
|
||||||
if (var0 == -1)
|
|
||||||
return -1;
|
|
||||||
return this.values[var0];
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean contains(K var0) {
|
|
||||||
return (getId(var0) != -1);
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean contains(int var0) {
|
|
||||||
return (byId(var0) != null);
|
|
||||||
}
|
|
||||||
|
|
||||||
public int add(K var0) {
|
|
||||||
int var1 = nextId();
|
|
||||||
addMapping(var0, var1);
|
|
||||||
return var1;
|
|
||||||
}
|
|
||||||
|
|
||||||
private int nextId() {
|
|
||||||
while (this.nextId < this.byId.length && this.byId[this.nextId] != null)
|
|
||||||
this.nextId++;
|
|
||||||
return this.nextId;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void grow(int var0) {
|
|
||||||
K[] var1 = this.keys;
|
|
||||||
int[] var2 = this.values;
|
|
||||||
this.keys = (K[])new Object[var0];
|
|
||||||
this.values = new int[var0];
|
|
||||||
this.byId = (K[])new Object[var0];
|
|
||||||
this.nextId = 0;
|
|
||||||
this.size = 0;
|
|
||||||
for (int var3 = 0; var3 < var1.length; var3++) {
|
|
||||||
if (var1[var3] != null)
|
|
||||||
addMapping(var1[var3], var2[var3]);
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public void addMapping(K var0, int var1) {
|
public int getId(K var0) {
|
||||||
int var2 = Math.max(var1, this.size + 1);
|
return getValue(indexOf(var0, hash(var0)));
|
||||||
if (var2 >= this.keys.length * 0.8F) {
|
|
||||||
int i = this.keys.length << 1;
|
|
||||||
while (i < var1)
|
|
||||||
i <<= 1;
|
|
||||||
grow(i);
|
|
||||||
}
|
}
|
||||||
int var3 = findEmpty(hash(var0));
|
|
||||||
this.keys[var3] = var0;
|
|
||||||
this.values[var3] = var1;
|
|
||||||
this.byId[var1] = var0;
|
|
||||||
this.size++;
|
|
||||||
if (var1 == this.nextId)
|
|
||||||
this.nextId++;
|
|
||||||
}
|
|
||||||
|
|
||||||
private int hash( K var0) {
|
|
||||||
return (Mth.murmurHash3Mixer(System.identityHashCode(var0)) & Integer.MAX_VALUE) % this.keys.length;
|
|
||||||
}
|
|
||||||
|
|
||||||
private int indexOf( K var0, int var1) {
|
public K byId(int var0) {
|
||||||
int var2;
|
if (var0 < 0 || var0 >= this.byId.length)
|
||||||
for (var2 = var1; var2 < this.keys.length; var2++) {
|
return null;
|
||||||
if (this.keys[var2] == var0)
|
return this.byId[var0];
|
||||||
return var2;
|
|
||||||
if (this.keys[var2] == EMPTY_SLOT)
|
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
for (var2 = 0; var2 < var1; var2++) {
|
|
||||||
if (this.keys[var2] == var0)
|
|
||||||
return var2;
|
|
||||||
if (this.keys[var2] == EMPTY_SLOT)
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
private int findEmpty(int var0) {
|
private int getValue(int var0) {
|
||||||
int var1;
|
if (var0 == -1)
|
||||||
for (var1 = var0; var1 < this.keys.length; var1++) {
|
return -1;
|
||||||
if (this.keys[var1] == EMPTY_SLOT)
|
return this.values[var0];
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean contains(K var0) {
|
||||||
|
return (getId(var0) != -1);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean contains(int var0) {
|
||||||
|
return (byId(var0) != null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public int add(K var0) {
|
||||||
|
int var1 = nextId();
|
||||||
|
addMapping(var0, var1);
|
||||||
return var1;
|
return var1;
|
||||||
}
|
}
|
||||||
for (var1 = 0; var1 < var0; var1++) {
|
|
||||||
if (this.keys[var1] == EMPTY_SLOT)
|
private int nextId() {
|
||||||
return var1;
|
while (this.nextId < this.byId.length && this.byId[this.nextId] != null)
|
||||||
|
this.nextId++;
|
||||||
|
return this.nextId;
|
||||||
}
|
}
|
||||||
throw new RuntimeException("Overflowed :(");
|
|
||||||
}
|
|
||||||
|
|
||||||
public Iterator<K> iterator() {
|
private void grow(int var0) {
|
||||||
return (Iterator<K>) Iterators.filter((Iterator)Iterators.forArray((Object[])this.byId), Predicates.notNull());
|
K[] var1 = this.keys;
|
||||||
}
|
int[] var2 = this.values;
|
||||||
|
this.keys = (K[]) new Object[var0];
|
||||||
|
this.values = new int[var0];
|
||||||
|
this.byId = (K[]) new Object[var0];
|
||||||
|
this.nextId = 0;
|
||||||
|
this.size = 0;
|
||||||
|
for (int var3 = 0; var3 < var1.length; var3++) {
|
||||||
|
if (var1[var3] != null)
|
||||||
|
addMapping(var1[var3], var2[var3]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void clear() {
|
public void addMapping(K var0, int var1) {
|
||||||
Arrays.fill((Object[])this.keys, (Object)null);
|
int var2 = Math.max(var1, this.size + 1);
|
||||||
Arrays.fill((Object[])this.byId, (Object)null);
|
if (var2 >= this.keys.length * 0.8F) {
|
||||||
this.nextId = 0;
|
int i = this.keys.length << 1;
|
||||||
this.size = 0;
|
while (i < var1)
|
||||||
}
|
i <<= 1;
|
||||||
|
grow(i);
|
||||||
|
}
|
||||||
|
int var3 = findEmpty(hash(var0));
|
||||||
|
this.keys[var3] = var0;
|
||||||
|
this.values[var3] = var1;
|
||||||
|
this.byId[var1] = var0;
|
||||||
|
this.size++;
|
||||||
|
if (var1 == this.nextId)
|
||||||
|
this.nextId++;
|
||||||
|
}
|
||||||
|
|
||||||
public int size() {
|
private int hash(K var0) {
|
||||||
return this.size;
|
return (Mth.murmurHash3Mixer(System.identityHashCode(var0)) & Integer.MAX_VALUE) % this.keys.length;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private int indexOf(K var0, int var1) {
|
||||||
|
int var2;
|
||||||
|
for (var2 = var1; var2 < this.keys.length; var2++) {
|
||||||
|
if (this.keys[var2] == var0)
|
||||||
|
return var2;
|
||||||
|
if (this.keys[var2] == EMPTY_SLOT)
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
for (var2 = 0; var2 < var1; var2++) {
|
||||||
|
if (this.keys[var2] == var0)
|
||||||
|
return var2;
|
||||||
|
if (this.keys[var2] == EMPTY_SLOT)
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
private int findEmpty(int var0) {
|
||||||
|
int var1;
|
||||||
|
for (var1 = var0; var1 < this.keys.length; var1++) {
|
||||||
|
if (this.keys[var1] == EMPTY_SLOT)
|
||||||
|
return var1;
|
||||||
|
}
|
||||||
|
for (var1 = 0; var1 < var0; var1++) {
|
||||||
|
if (this.keys[var1] == EMPTY_SLOT)
|
||||||
|
return var1;
|
||||||
|
}
|
||||||
|
throw new RuntimeException("Overflowed :(");
|
||||||
|
}
|
||||||
|
|
||||||
|
public Iterator<K> iterator() {
|
||||||
|
return (Iterator<K>) Iterators.filter(Iterators.forArray((Object[]) this.byId), Predicates.notNull());
|
||||||
|
}
|
||||||
|
|
||||||
|
public void clear() {
|
||||||
|
Arrays.fill(this.keys, null);
|
||||||
|
Arrays.fill(this.byId, null);
|
||||||
|
this.nextId = 0;
|
||||||
|
this.size = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int size() {
|
||||||
|
return this.size;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -23,32 +23,33 @@ import com.volmit.iris.util.nbt.tag.ListTag;
|
|||||||
import java.util.function.Predicate;
|
import java.util.function.Predicate;
|
||||||
|
|
||||||
public class GlobalPalette<T> implements Palette<T> {
|
public class GlobalPalette<T> implements Palette<T> {
|
||||||
private final IdMapper<T> registry;
|
private final IdMapper<T> registry;
|
||||||
|
|
||||||
private final T defaultValue;
|
private final T defaultValue;
|
||||||
|
|
||||||
public GlobalPalette(IdMapper<T> var0, T var1) {
|
public GlobalPalette(IdMapper<T> var0, T var1) {
|
||||||
this.registry = var0;
|
this.registry = var0;
|
||||||
this.defaultValue = var1;
|
this.defaultValue = var1;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int idFor(T var0) {
|
public int idFor(T var0) {
|
||||||
int var1 = this.registry.getId(var0);
|
int var1 = this.registry.getId(var0);
|
||||||
return (var1 == -1) ? 0 : var1;
|
return (var1 == -1) ? 0 : var1;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean maybeHas(Predicate<T> var0) {
|
public boolean maybeHas(Predicate<T> var0) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public T valueFor(int var0) {
|
public T valueFor(int var0) {
|
||||||
T var1 = (T)this.registry.byId(var0);
|
T var1 = this.registry.byId(var0);
|
||||||
return (var1 == null) ? this.defaultValue : var1;
|
return (var1 == null) ? this.defaultValue : var1;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getSize() {
|
public int getSize() {
|
||||||
return this.registry.size();
|
return this.registry.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void read(ListTag var0) {}
|
public void read(ListTag var0) {
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -25,61 +25,61 @@ import java.util.function.Function;
|
|||||||
import java.util.function.Predicate;
|
import java.util.function.Predicate;
|
||||||
|
|
||||||
public class HashMapPalette<T> implements Palette<T> {
|
public class HashMapPalette<T> implements Palette<T> {
|
||||||
private final IdMapper<T> registry;
|
private final IdMapper<T> registry;
|
||||||
|
|
||||||
private final CrudeIncrementalIntIdentityHashBiMap<T> values;
|
private final CrudeIncrementalIntIdentityHashBiMap<T> values;
|
||||||
|
|
||||||
private final PaletteResize<T> resizeHandler;
|
private final PaletteResize<T> resizeHandler;
|
||||||
|
|
||||||
private final Function<CompoundTag, T> reader;
|
private final Function<CompoundTag, T> reader;
|
||||||
|
|
||||||
private final Function<T, CompoundTag> writer;
|
private final Function<T, CompoundTag> writer;
|
||||||
|
|
||||||
private final int bits;
|
private final int bits;
|
||||||
|
|
||||||
public HashMapPalette(IdMapper<T> var0, int var1, PaletteResize<T> var2, Function<CompoundTag, T> var3, Function<T, CompoundTag> var4) {
|
public HashMapPalette(IdMapper<T> var0, int var1, PaletteResize<T> var2, Function<CompoundTag, T> var3, Function<T, CompoundTag> var4) {
|
||||||
this.registry = var0;
|
this.registry = var0;
|
||||||
this.bits = var1;
|
this.bits = var1;
|
||||||
this.resizeHandler = var2;
|
this.resizeHandler = var2;
|
||||||
this.reader = var3;
|
this.reader = var3;
|
||||||
this.writer = var4;
|
this.writer = var4;
|
||||||
this.values = new CrudeIncrementalIntIdentityHashBiMap(1 << var1);
|
this.values = new CrudeIncrementalIntIdentityHashBiMap(1 << var1);
|
||||||
}
|
|
||||||
|
|
||||||
public int idFor(T var0) {
|
|
||||||
int var1 = this.values.getId(var0);
|
|
||||||
if (var1 == -1) {
|
|
||||||
var1 = this.values.add(var0);
|
|
||||||
if (var1 >= 1 << this.bits)
|
|
||||||
var1 = this.resizeHandler.onResize(this.bits + 1, var0);
|
|
||||||
}
|
}
|
||||||
return var1;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean maybeHas(Predicate<T> var0) {
|
public int idFor(T var0) {
|
||||||
for (int var1 = 0; var1 < getSize(); var1++) {
|
int var1 = this.values.getId(var0);
|
||||||
if (var0.test((T)this.values.byId(var1)))
|
if (var1 == -1) {
|
||||||
return true;
|
var1 = this.values.add(var0);
|
||||||
|
if (var1 >= 1 << this.bits)
|
||||||
|
var1 = this.resizeHandler.onResize(this.bits + 1, var0);
|
||||||
|
}
|
||||||
|
return var1;
|
||||||
}
|
}
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public T valueFor(int var0) {
|
public boolean maybeHas(Predicate<T> var0) {
|
||||||
return (T)this.values.byId(var0);
|
for (int var1 = 0; var1 < getSize(); var1++) {
|
||||||
}
|
if (var0.test(this.values.byId(var1)))
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
public int getSize() {
|
public T valueFor(int var0) {
|
||||||
return this.values.size();
|
return this.values.byId(var0);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void read(ListTag var0) {
|
public int getSize() {
|
||||||
this.values.clear();
|
return this.values.size();
|
||||||
for (int var1 = 0; var1 < var0.size(); var1++)
|
}
|
||||||
this.values.add(this.reader.apply((CompoundTag) var0.get(var1)));
|
|
||||||
}
|
|
||||||
|
|
||||||
public void write(ListTag var0) {
|
public void read(ListTag var0) {
|
||||||
for (int var1 = 0; var1 < getSize(); var1++)
|
this.values.clear();
|
||||||
var0.add(this.writer.apply((T)this.values.byId(var1)));
|
for (int var1 = 0; var1 < var0.size(); var1++)
|
||||||
}
|
this.values.add(this.reader.apply((CompoundTag) var0.get(var1)));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void write(ListTag var0) {
|
||||||
|
for (int var1 = 0; var1 < getSize(); var1++)
|
||||||
|
var0.add(this.writer.apply(this.values.byId(var1)));
|
||||||
|
}
|
||||||
}
|
}
|
@ -19,7 +19,7 @@
|
|||||||
package com.volmit.iris.util.nbt.mca.palette;
|
package com.volmit.iris.util.nbt.mca.palette;
|
||||||
|
|
||||||
public interface IdMap<T> extends Iterable<T> {
|
public interface IdMap<T> extends Iterable<T> {
|
||||||
int getId(T paramT);
|
int getId(T paramT);
|
||||||
|
|
||||||
T byId(int paramInt);
|
T byId(int paramInt);
|
||||||
}
|
}
|
||||||
|
@ -27,62 +27,62 @@ import java.util.Iterator;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class IdMapper<T> implements IdMap<T> {
|
public class IdMapper<T> implements IdMap<T> {
|
||||||
public static final int DEFAULT = -1;
|
public static final int DEFAULT = -1;
|
||||||
|
|
||||||
private int nextId;
|
private int nextId;
|
||||||
|
|
||||||
private final IdentityHashMap<T, Integer> tToId;
|
private final IdentityHashMap<T, Integer> tToId;
|
||||||
|
|
||||||
private final List<T> idToT;
|
private final List<T> idToT;
|
||||||
|
|
||||||
public IdMapper(IdentityHashMap<T, Integer> tToId, List<T> idToT, int nextId) {
|
public IdMapper(IdentityHashMap<T, Integer> tToId, List<T> idToT, int nextId) {
|
||||||
this.tToId = tToId;
|
this.tToId = tToId;
|
||||||
this.idToT = idToT;
|
this.idToT = idToT;
|
||||||
this.nextId = nextId;
|
this.nextId = nextId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public IdMapper() {
|
public IdMapper() {
|
||||||
this(512);
|
this(512);
|
||||||
}
|
}
|
||||||
|
|
||||||
public IdMapper(int var0) {
|
public IdMapper(int var0) {
|
||||||
this.idToT = Lists.newArrayListWithExpectedSize(var0);
|
this.idToT = Lists.newArrayListWithExpectedSize(var0);
|
||||||
this.tToId = new IdentityHashMap<>(var0);
|
this.tToId = new IdentityHashMap<>(var0);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addMapping(T var0, int var1) {
|
public void addMapping(T var0, int var1) {
|
||||||
this.tToId.put(var0, Integer.valueOf(var1));
|
this.tToId.put(var0, Integer.valueOf(var1));
|
||||||
while (this.idToT.size() <= var1)
|
while (this.idToT.size() <= var1)
|
||||||
this.idToT.add(null);
|
this.idToT.add(null);
|
||||||
this.idToT.set(var1, var0);
|
this.idToT.set(var1, var0);
|
||||||
if (this.nextId <= var1)
|
if (this.nextId <= var1)
|
||||||
this.nextId = var1 + 1;
|
this.nextId = var1 + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void add(T var0) {
|
public void add(T var0) {
|
||||||
addMapping(var0, this.nextId);
|
addMapping(var0, this.nextId);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getId(T var0) {
|
public int getId(T var0) {
|
||||||
Integer var1 = this.tToId.get(var0);
|
Integer var1 = this.tToId.get(var0);
|
||||||
return (var1 == null) ? -1 : var1.intValue();
|
return (var1 == null) ? -1 : var1.intValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
public final T byId(int var0) {
|
public final T byId(int var0) {
|
||||||
if (var0 >= 0 && var0 < this.idToT.size())
|
if (var0 >= 0 && var0 < this.idToT.size())
|
||||||
return this.idToT.get(var0);
|
return this.idToT.get(var0);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Iterator<T> iterator() {
|
public Iterator<T> iterator() {
|
||||||
return (Iterator<T>) Iterators.filter(this.idToT.iterator(), Predicates.notNull());
|
return Iterators.filter(this.idToT.iterator(), Predicates.notNull());
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean contains(int var0) {
|
public boolean contains(int var0) {
|
||||||
return (byId(var0) != null);
|
return (byId(var0) != null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int size() {
|
public int size() {
|
||||||
return this.tToId.size();
|
return this.tToId.size();
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -25,62 +25,62 @@ import java.util.function.Function;
|
|||||||
import java.util.function.Predicate;
|
import java.util.function.Predicate;
|
||||||
|
|
||||||
public class LinearPalette<T> implements Palette<T> {
|
public class LinearPalette<T> implements Palette<T> {
|
||||||
private final IdMapper<T> registry;
|
private final IdMapper<T> registry;
|
||||||
|
|
||||||
private final T[] values;
|
private final T[] values;
|
||||||
|
|
||||||
private final PaletteResize<T> resizeHandler;
|
private final PaletteResize<T> resizeHandler;
|
||||||
|
|
||||||
private final Function<CompoundTag, T> reader;
|
private final Function<CompoundTag, T> reader;
|
||||||
|
|
||||||
private final int bits;
|
private final int bits;
|
||||||
|
|
||||||
private int size;
|
private int size;
|
||||||
|
|
||||||
public LinearPalette(IdMapper<T> var0, int var1, PaletteResize<T> var2, Function<CompoundTag, T> var3) {
|
public LinearPalette(IdMapper<T> var0, int var1, PaletteResize<T> var2, Function<CompoundTag, T> var3) {
|
||||||
this.registry = var0;
|
this.registry = var0;
|
||||||
this.values = (T[])new Object[1 << var1];
|
this.values = (T[]) new Object[1 << var1];
|
||||||
this.bits = var1;
|
this.bits = var1;
|
||||||
this.resizeHandler = var2;
|
this.resizeHandler = var2;
|
||||||
this.reader = var3;
|
this.reader = var3;
|
||||||
}
|
|
||||||
|
|
||||||
public int idFor(T var0) {
|
|
||||||
int var1;
|
|
||||||
for (var1 = 0; var1 < this.size; var1++) {
|
|
||||||
if (this.values[var1] == var0)
|
|
||||||
return var1;
|
|
||||||
}
|
}
|
||||||
var1 = this.size;
|
|
||||||
if (var1 < this.values.length) {
|
public int idFor(T var0) {
|
||||||
this.values[var1] = var0;
|
int var1;
|
||||||
this.size++;
|
for (var1 = 0; var1 < this.size; var1++) {
|
||||||
return var1;
|
if (this.values[var1] == var0)
|
||||||
|
return var1;
|
||||||
|
}
|
||||||
|
var1 = this.size;
|
||||||
|
if (var1 < this.values.length) {
|
||||||
|
this.values[var1] = var0;
|
||||||
|
this.size++;
|
||||||
|
return var1;
|
||||||
|
}
|
||||||
|
return this.resizeHandler.onResize(this.bits + 1, var0);
|
||||||
}
|
}
|
||||||
return this.resizeHandler.onResize(this.bits + 1, var0);
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean maybeHas(Predicate<T> var0) {
|
public boolean maybeHas(Predicate<T> var0) {
|
||||||
for (int var1 = 0; var1 < this.size; var1++) {
|
for (int var1 = 0; var1 < this.size; var1++) {
|
||||||
if (var0.test(this.values[var1]))
|
if (var0.test(this.values[var1]))
|
||||||
return true;
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public T valueFor(int var0) {
|
public T valueFor(int var0) {
|
||||||
if (var0 >= 0 && var0 < this.size)
|
if (var0 >= 0 && var0 < this.size)
|
||||||
return this.values[var0];
|
return this.values[var0];
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getSize() {
|
public int getSize() {
|
||||||
return this.size;
|
return this.size;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void read(ListTag var0) {
|
public void read(ListTag var0) {
|
||||||
for (int var1 = 0; var1 < var0.size(); var1++)
|
for (int var1 = 0; var1 < var0.size(); var1++)
|
||||||
this.values[var1] = this.reader.apply((CompoundTag) var0.get(var1));
|
this.values[var1] = this.reader.apply((CompoundTag) var0.get(var1));
|
||||||
this.size = var0.size();
|
this.size = var0.size();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -23,13 +23,13 @@ import com.volmit.iris.util.nbt.tag.ListTag;
|
|||||||
import java.util.function.Predicate;
|
import java.util.function.Predicate;
|
||||||
|
|
||||||
public interface Palette<T> {
|
public interface Palette<T> {
|
||||||
int idFor(T paramT);
|
int idFor(T paramT);
|
||||||
|
|
||||||
boolean maybeHas(Predicate<T> paramPredicate);
|
boolean maybeHas(Predicate<T> paramPredicate);
|
||||||
|
|
||||||
T valueFor(int paramInt);
|
T valueFor(int paramInt);
|
||||||
|
|
||||||
int getSize();
|
int getSize();
|
||||||
|
|
||||||
void read(ListTag paramListTag);
|
void read(ListTag paramListTag);
|
||||||
}
|
}
|
||||||
|
@ -21,11 +21,11 @@ package com.volmit.iris.util.nbt.mca.palette;
|
|||||||
import com.volmit.iris.util.nbt.tag.CompoundTag;
|
import com.volmit.iris.util.nbt.tag.CompoundTag;
|
||||||
|
|
||||||
public interface PaletteAccess {
|
public interface PaletteAccess {
|
||||||
public void setBlock(int x, int y, int z, CompoundTag data);
|
void setBlock(int x, int y, int z, CompoundTag data);
|
||||||
|
|
||||||
public CompoundTag getBlock(int x, int y, int z);
|
CompoundTag getBlock(int x, int y, int z);
|
||||||
|
|
||||||
public void writeToSection(CompoundTag tag);
|
void writeToSection(CompoundTag tag);
|
||||||
|
|
||||||
public void readFromSection(CompoundTag tag);
|
void readFromSection(CompoundTag tag);
|
||||||
}
|
}
|
||||||
|
@ -19,5 +19,5 @@
|
|||||||
package com.volmit.iris.util.nbt.mca.palette;
|
package com.volmit.iris.util.nbt.mca.palette;
|
||||||
|
|
||||||
interface PaletteResize<T> {
|
interface PaletteResize<T> {
|
||||||
int onResize(int paramInt, T paramT);
|
int onResize(int paramInt, T paramT);
|
||||||
}
|
}
|
||||||
|
@ -26,158 +26,157 @@ import java.util.function.Function;
|
|||||||
import java.util.function.Predicate;
|
import java.util.function.Predicate;
|
||||||
|
|
||||||
public class PalettedContainer<T> implements PaletteResize<T> {
|
public class PalettedContainer<T> implements PaletteResize<T> {
|
||||||
private static final int SIZE = 4096;
|
private static final int SIZE = 4096;
|
||||||
|
|
||||||
public static final int GLOBAL_PALETTE_BITS = 9;
|
public static final int GLOBAL_PALETTE_BITS = 9;
|
||||||
|
|
||||||
public static final int MIN_PALETTE_SIZE = 4;
|
public static final int MIN_PALETTE_SIZE = 4;
|
||||||
|
|
||||||
private final Palette<T> globalPalette;
|
private final Palette<T> globalPalette;
|
||||||
|
|
||||||
private final PaletteResize<T> dummyPaletteResize = (var0, var1) -> 0;
|
private final PaletteResize<T> dummyPaletteResize = (var0, var1) -> 0;
|
||||||
|
|
||||||
private final IdMapper<T> registry;
|
private final IdMapper<T> registry;
|
||||||
|
|
||||||
private final Function<CompoundTag, T> reader;
|
private final Function<CompoundTag, T> reader;
|
||||||
|
|
||||||
private final Function<T, CompoundTag> writer;
|
private final Function<T, CompoundTag> writer;
|
||||||
|
|
||||||
private final T defaultValue;
|
private final T defaultValue;
|
||||||
|
|
||||||
protected BitStorage storage;
|
protected BitStorage storage;
|
||||||
|
|
||||||
private Palette<T> palette;
|
private Palette<T> palette;
|
||||||
|
|
||||||
private int bits;
|
private int bits;
|
||||||
|
|
||||||
public PalettedContainer(Palette<T> var0, IdMapper<T> var1, Function<CompoundTag, T> var2, Function<T, CompoundTag> var3, T var4) {
|
public PalettedContainer(Palette<T> var0, IdMapper<T> var1, Function<CompoundTag, T> var2, Function<T, CompoundTag> var3, T var4) {
|
||||||
this.globalPalette = var0;
|
this.globalPalette = var0;
|
||||||
this.registry = var1;
|
this.registry = var1;
|
||||||
this.reader = var2;
|
this.reader = var2;
|
||||||
this.writer = var3;
|
this.writer = var3;
|
||||||
this.defaultValue = var4;
|
this.defaultValue = var4;
|
||||||
setBits(4);
|
setBits(4);
|
||||||
}
|
|
||||||
|
|
||||||
private static int getIndex(int var0, int var1, int var2) {
|
|
||||||
return var1 << 8 | var2 << 4 | var0;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void setBits(int var0) {
|
|
||||||
if (var0 == this.bits)
|
|
||||||
return;
|
|
||||||
this.bits = var0;
|
|
||||||
if (this.bits <= 4) {
|
|
||||||
this.bits = 4;
|
|
||||||
this.palette = new LinearPalette<>(this.registry, this.bits, this, this.reader);
|
|
||||||
} else if (this.bits < 9) {
|
|
||||||
this.palette = new HashMapPalette<>(this.registry, this.bits, this, this.reader, this.writer);
|
|
||||||
} else {
|
|
||||||
this.palette = this.globalPalette;
|
|
||||||
this.bits = Mth.ceillog2(this.registry.size());
|
|
||||||
}
|
}
|
||||||
this.palette.idFor(this.defaultValue);
|
|
||||||
this.storage = new BitStorage(this.bits, 4096);
|
|
||||||
}
|
|
||||||
|
|
||||||
public int onResize(int var0, T var1) {
|
private static int getIndex(int var0, int var1, int var2) {
|
||||||
BitStorage var2 = this.storage;
|
return var1 << 8 | var2 << 4 | var0;
|
||||||
Palette<T> var3 = this.palette;
|
|
||||||
setBits(var0);
|
|
||||||
for (int var4 = 0; var4 < var2.getSize(); var4++) {
|
|
||||||
T var5 = var3.valueFor(var2.get(var4));
|
|
||||||
if (var5 != null)
|
|
||||||
set(var4, var5);
|
|
||||||
}
|
}
|
||||||
return this.palette.idFor(var1);
|
|
||||||
}
|
|
||||||
|
|
||||||
public T getAndSet(int var0, int var1, int var2, T var3) {
|
private void setBits(int var0) {
|
||||||
return getAndSet(getIndex(var0, var1, var2), var3);
|
if (var0 == this.bits)
|
||||||
}
|
return;
|
||||||
|
this.bits = var0;
|
||||||
public T getAndSetUnchecked(int var0, int var1, int var2, T var3) {
|
if (this.bits <= 4) {
|
||||||
return getAndSet(getIndex(var0, var1, var2), var3);
|
this.bits = 4;
|
||||||
}
|
this.palette = new LinearPalette<>(this.registry, this.bits, this, this.reader);
|
||||||
|
} else if (this.bits < 9) {
|
||||||
private T getAndSet(int var0, T var1) {
|
this.palette = new HashMapPalette<>(this.registry, this.bits, this, this.reader, this.writer);
|
||||||
int var2 = this.palette.idFor(var1);
|
} else {
|
||||||
int var3 = this.storage.getAndSet(var0, var2);
|
this.palette = this.globalPalette;
|
||||||
T var4 = this.palette.valueFor(var3);
|
this.bits = Mth.ceillog2(this.registry.size());
|
||||||
return (var4 == null) ? this.defaultValue : var4;
|
}
|
||||||
}
|
this.palette.idFor(this.defaultValue);
|
||||||
|
this.storage = new BitStorage(this.bits, 4096);
|
||||||
public void set(int var0, int var1, int var2, T var3) {
|
|
||||||
set(getIndex(var0, var1, var2), var3);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void set(int var0, T var1) {
|
|
||||||
int var2 = this.palette.idFor(var1);
|
|
||||||
this.storage.set(var0, var2);
|
|
||||||
}
|
|
||||||
|
|
||||||
public T get(int var0, int var1, int var2) {
|
|
||||||
return get(getIndex(var0, var1, var2));
|
|
||||||
}
|
|
||||||
|
|
||||||
protected T get(int var0) {
|
|
||||||
T var1 = this.palette.valueFor(this.storage.get(var0));
|
|
||||||
return (var1 == null) ? this.defaultValue : var1;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void read(ListTag var0, long[] var1) {
|
|
||||||
int var2 = Math.max(4, Mth.ceillog2(var0.size()));
|
|
||||||
if (var2 != this.bits)
|
|
||||||
setBits(var2);
|
|
||||||
this.palette.read(var0);
|
|
||||||
int var3 = var1.length * 64 / 4096;
|
|
||||||
if (this.palette == this.globalPalette) {
|
|
||||||
Palette<T> var4 = new HashMapPalette<>(this.registry, var2, this.dummyPaletteResize, this.reader, this.writer);
|
|
||||||
var4.read(var0);
|
|
||||||
BitStorage var5 = new BitStorage(var2, 4096, var1);
|
|
||||||
for (int var6 = 0; var6 < 4096; var6++)
|
|
||||||
this.storage.set(var6, this.globalPalette.idFor(var4.valueFor(var5.get(var6))));
|
|
||||||
} else if (var3 == this.bits) {
|
|
||||||
System.arraycopy(var1, 0, this.storage.getRaw(), 0, var1.length);
|
|
||||||
} else {
|
|
||||||
BitStorage var4 = new BitStorage(var3, 4096, var1);
|
|
||||||
for (int var5 = 0; var5 < 4096; var5++)
|
|
||||||
this.storage.set(var5, var4.get(var5));
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public void write(CompoundTag var0, String var1, String var2) {
|
public int onResize(int var0, T var1) {
|
||||||
HashMapPalette<T> var3 = new HashMapPalette<>(this.registry, this.bits, this.dummyPaletteResize, this.reader, this.writer);
|
BitStorage var2 = this.storage;
|
||||||
T var4 = this.defaultValue;
|
Palette<T> var3 = this.palette;
|
||||||
int var5 = var3.idFor(this.defaultValue);
|
setBits(var0);
|
||||||
int[] var6 = new int[4096];
|
for (int var4 = 0; var4 < var2.getSize(); var4++) {
|
||||||
for (int i = 0; i < 4096; i++) {
|
T var5 = var3.valueFor(var2.get(var4));
|
||||||
T t = get(i);
|
if (var5 != null)
|
||||||
if (t != var4) {
|
set(var4, var5);
|
||||||
var4 = t;
|
}
|
||||||
var5 = var3.idFor(t);
|
return this.palette.idFor(var1);
|
||||||
}
|
|
||||||
var6[i] = var5;
|
|
||||||
}
|
}
|
||||||
ListTag<CompoundTag> paletteList = (ListTag<CompoundTag>) ListTag.createUnchecked(CompoundTag.class);
|
|
||||||
var3.write(paletteList);
|
public T getAndSet(int var0, int var1, int var2, T var3) {
|
||||||
var0.put(var1, paletteList);
|
return getAndSet(getIndex(var0, var1, var2), var3);
|
||||||
int var8 = Math.max(4, Mth.ceillog2(paletteList.size()));
|
|
||||||
BitStorage var9 = new BitStorage(var8, 4096);
|
|
||||||
for (int var10 = 0; var10 < var6.length; var10++)
|
|
||||||
{
|
|
||||||
var9.set(var10, var6[var10]);
|
|
||||||
}
|
}
|
||||||
var0.putLongArray(var2, var9.getRaw());
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean maybeHas(Predicate<T> var0) {
|
public T getAndSetUnchecked(int var0, int var1, int var2, T var3) {
|
||||||
return this.palette.maybeHas(var0);
|
return getAndSet(getIndex(var0, var1, var2), var3);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void count(CountConsumer<T> var0) {
|
private T getAndSet(int var0, T var1) {
|
||||||
Int2IntOpenHashMap int2IntOpenHashMap = new Int2IntOpenHashMap();
|
int var2 = this.palette.idFor(var1);
|
||||||
this.storage.getAll(var1 -> int2IntOpenHashMap.put(var1, int2IntOpenHashMap.get(var1) + 1));
|
int var3 = this.storage.getAndSet(var0, var2);
|
||||||
int2IntOpenHashMap.int2IntEntrySet().forEach(var1 -> var0.accept(this.palette.valueFor(var1.getIntKey()), var1.getIntValue()));
|
T var4 = this.palette.valueFor(var3);
|
||||||
}
|
return (var4 == null) ? this.defaultValue : var4;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void set(int var0, int var1, int var2, T var3) {
|
||||||
|
set(getIndex(var0, var1, var2), var3);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void set(int var0, T var1) {
|
||||||
|
int var2 = this.palette.idFor(var1);
|
||||||
|
this.storage.set(var0, var2);
|
||||||
|
}
|
||||||
|
|
||||||
|
public T get(int var0, int var1, int var2) {
|
||||||
|
return get(getIndex(var0, var1, var2));
|
||||||
|
}
|
||||||
|
|
||||||
|
protected T get(int var0) {
|
||||||
|
T var1 = this.palette.valueFor(this.storage.get(var0));
|
||||||
|
return (var1 == null) ? this.defaultValue : var1;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void read(ListTag var0, long[] var1) {
|
||||||
|
int var2 = Math.max(4, Mth.ceillog2(var0.size()));
|
||||||
|
if (var2 != this.bits)
|
||||||
|
setBits(var2);
|
||||||
|
this.palette.read(var0);
|
||||||
|
int var3 = var1.length * 64 / 4096;
|
||||||
|
if (this.palette == this.globalPalette) {
|
||||||
|
Palette<T> var4 = new HashMapPalette<>(this.registry, var2, this.dummyPaletteResize, this.reader, this.writer);
|
||||||
|
var4.read(var0);
|
||||||
|
BitStorage var5 = new BitStorage(var2, 4096, var1);
|
||||||
|
for (int var6 = 0; var6 < 4096; var6++)
|
||||||
|
this.storage.set(var6, this.globalPalette.idFor(var4.valueFor(var5.get(var6))));
|
||||||
|
} else if (var3 == this.bits) {
|
||||||
|
System.arraycopy(var1, 0, this.storage.getRaw(), 0, var1.length);
|
||||||
|
} else {
|
||||||
|
BitStorage var4 = new BitStorage(var3, 4096, var1);
|
||||||
|
for (int var5 = 0; var5 < 4096; var5++)
|
||||||
|
this.storage.set(var5, var4.get(var5));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void write(CompoundTag var0, String var1, String var2) {
|
||||||
|
HashMapPalette<T> var3 = new HashMapPalette<>(this.registry, this.bits, this.dummyPaletteResize, this.reader, this.writer);
|
||||||
|
T var4 = this.defaultValue;
|
||||||
|
int var5 = var3.idFor(this.defaultValue);
|
||||||
|
int[] var6 = new int[4096];
|
||||||
|
for (int i = 0; i < 4096; i++) {
|
||||||
|
T t = get(i);
|
||||||
|
if (t != var4) {
|
||||||
|
var4 = t;
|
||||||
|
var5 = var3.idFor(t);
|
||||||
|
}
|
||||||
|
var6[i] = var5;
|
||||||
|
}
|
||||||
|
ListTag<CompoundTag> paletteList = (ListTag<CompoundTag>) ListTag.createUnchecked(CompoundTag.class);
|
||||||
|
var3.write(paletteList);
|
||||||
|
var0.put(var1, paletteList);
|
||||||
|
int var8 = Math.max(4, Mth.ceillog2(paletteList.size()));
|
||||||
|
BitStorage var9 = new BitStorage(var8, 4096);
|
||||||
|
for (int var10 = 0; var10 < var6.length; var10++) {
|
||||||
|
var9.set(var10, var6[var10]);
|
||||||
|
}
|
||||||
|
var0.putLongArray(var2, var9.getRaw());
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean maybeHas(Predicate<T> var0) {
|
||||||
|
return this.palette.maybeHas(var0);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void count(CountConsumer<T> var0) {
|
||||||
|
Int2IntOpenHashMap int2IntOpenHashMap = new Int2IntOpenHashMap();
|
||||||
|
this.storage.getAll(var1 -> int2IntOpenHashMap.put(var1, int2IntOpenHashMap.get(var1) + 1));
|
||||||
|
int2IntOpenHashMap.int2IntEntrySet().forEach(var1 -> var0.accept(this.palette.valueFor(var1.getIntKey()), var1.getIntValue()));
|
||||||
|
}
|
||||||
}
|
}
|
@ -19,25 +19,25 @@
|
|||||||
package com.volmit.iris.util.nbt.mca.palette;
|
package com.volmit.iris.util.nbt.mca.palette;
|
||||||
|
|
||||||
public final class QuartPos {
|
public final class QuartPos {
|
||||||
public static final int BITS = 2;
|
public static final int BITS = 2;
|
||||||
|
|
||||||
public static final int SIZE = 4;
|
public static final int SIZE = 4;
|
||||||
|
|
||||||
private static final int SECTION_TO_QUARTS_BITS = 2;
|
private static final int SECTION_TO_QUARTS_BITS = 2;
|
||||||
|
|
||||||
public static int fromBlock(int var0) {
|
public static int fromBlock(int var0) {
|
||||||
return var0 >> 2;
|
return var0 >> 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int toBlock(int var0) {
|
public static int toBlock(int var0) {
|
||||||
return var0 << 2;
|
return var0 << 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int fromSection(int var0) {
|
public static int fromSection(int var0) {
|
||||||
return var0 << 2;
|
return var0 << 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int toSection(int var0) {
|
public static int toSection(int var0) {
|
||||||
return var0 >> 2;
|
return var0 >> 2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -29,23 +29,19 @@ public class WrappedPalettedContainer<T> implements PaletteAccess {
|
|||||||
private final Function<T, CompoundTag> reader;
|
private final Function<T, CompoundTag> reader;
|
||||||
private final Function<CompoundTag, T> writer;
|
private final Function<CompoundTag, T> writer;
|
||||||
|
|
||||||
public void setBlock(int x, int y, int z, CompoundTag data)
|
public void setBlock(int x, int y, int z, CompoundTag data) {
|
||||||
{
|
container.set(x, y, z, writer.apply(data));
|
||||||
container.set(x,y,z,writer.apply(data));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public CompoundTag getBlock(int x, int y, int z)
|
public CompoundTag getBlock(int x, int y, int z) {
|
||||||
{
|
return reader.apply(container.get(x, y, z));
|
||||||
return reader.apply(container.get(x,y,z));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void writeToSection(CompoundTag tag)
|
public void writeToSection(CompoundTag tag) {
|
||||||
{
|
|
||||||
container.write(tag, "Palette", "BlockStates");
|
container.write(tag, "Palette", "BlockStates");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void readFromSection(CompoundTag tag)
|
public void readFromSection(CompoundTag tag) {
|
||||||
{
|
|
||||||
container.read(tag.getListTag("Palette"), tag.getLongArrayTag("BlockStates").getValue());
|
container.read(tag.getListTag("Palette"), tag.getLongArrayTag("BlockStates").getValue());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -127,13 +127,9 @@ public class J {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static <T> T attemptResult(NastySupplier<T> r) {
|
public static <T> T attemptResult(NastySupplier<T> r) {
|
||||||
try
|
try {
|
||||||
{
|
|
||||||
return r.get();
|
return r.get();
|
||||||
}
|
} catch (Throwable e) {
|
||||||
|
|
||||||
catch(Throwable e)
|
|
||||||
{
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -25,7 +25,7 @@ import java.util.concurrent.atomic.AtomicInteger;
|
|||||||
public abstract class QueueJob<T> implements Job {
|
public abstract class QueueJob<T> implements Job {
|
||||||
final KList<T> queue;
|
final KList<T> queue;
|
||||||
protected int totalWork;
|
protected int totalWork;
|
||||||
private AtomicInteger completed;
|
private final AtomicInteger completed;
|
||||||
|
|
||||||
public QueueJob() {
|
public QueueJob() {
|
||||||
totalWork = 0;
|
totalWork = 0;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user