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() {
|
||||||
@ -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,8 +73,7 @@ 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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -88,8 +87,7 @@ public class 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);
|
||||||
|
}
|
@ -18,12 +18,8 @@
|
|||||||
|
|
||||||
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;
|
||||||
|
|
||||||
@ -51,6 +47,10 @@ public class ChunkBiomeContainer<T> {
|
|||||||
this.quartHeight = QuartPos.fromBlock(maxHeight) - 1;
|
this.quartHeight = QuartPos.fromBlock(maxHeight) - 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ChunkBiomeContainer(IdMap<T> registry, int min, int max) {
|
||||||
|
this(registry, min, max, new int[(1 << WIDTH_BITS + WIDTH_BITS) * ceilDiv(max - min, 4)]);
|
||||||
|
}
|
||||||
|
|
||||||
public ChunkBiomeContainer(IdMap<T> registry, int minHeight, int maxHeight, int[] aint) {
|
public ChunkBiomeContainer(IdMap<T> registry, int minHeight, int maxHeight, int[] aint) {
|
||||||
this(registry, minHeight, maxHeight, (T[]) new Object[aint.length]);
|
this(registry, minHeight, maxHeight, (T[]) new Object[aint.length]);
|
||||||
int i = -1;
|
int i = -1;
|
||||||
@ -60,7 +60,7 @@ public class ChunkBiomeContainer<T> {
|
|||||||
if (biomebase == null) {
|
if (biomebase == null) {
|
||||||
if (i == -1)
|
if (i == -1)
|
||||||
i = j;
|
i = j;
|
||||||
this.biomes[j] = (T)registry.byId(0);
|
this.biomes[j] = registry.byId(0);
|
||||||
} else {
|
} else {
|
||||||
this.biomes[j] = biomebase;
|
this.biomes[j] = biomebase;
|
||||||
}
|
}
|
||||||
|
@ -151,12 +151,12 @@ public class CrudeIncrementalIntIdentityHashBiMap<K> implements IdMap<K> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Iterator<K> iterator() {
|
public Iterator<K> iterator() {
|
||||||
return (Iterator<K>) Iterators.filter((Iterator)Iterators.forArray((Object[])this.byId), Predicates.notNull());
|
return (Iterator<K>) Iterators.filter(Iterators.forArray((Object[]) this.byId), Predicates.notNull());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void clear() {
|
public void clear() {
|
||||||
Arrays.fill((Object[])this.keys, (Object)null);
|
Arrays.fill(this.keys, null);
|
||||||
Arrays.fill((Object[])this.byId, (Object)null);
|
Arrays.fill(this.byId, null);
|
||||||
this.nextId = 0;
|
this.nextId = 0;
|
||||||
this.size = 0;
|
this.size = 0;
|
||||||
}
|
}
|
||||||
|
@ -42,7 +42,7 @@ public class GlobalPalette<T> implements Palette<T> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -50,5 +50,6 @@ public class GlobalPalette<T> implements Palette<T> {
|
|||||||
return this.registry.size();
|
return this.registry.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void read(ListTag var0) {}
|
public void read(ListTag var0) {
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -58,14 +58,14 @@ public class HashMapPalette<T> implements Palette<T> {
|
|||||||
|
|
||||||
public boolean maybeHas(Predicate<T> var0) {
|
public boolean maybeHas(Predicate<T> var0) {
|
||||||
for (int var1 = 0; var1 < getSize(); var1++) {
|
for (int var1 = 0; var1 < getSize(); var1++) {
|
||||||
if (var0.test((T)this.values.byId(var1)))
|
if (var0.test(this.values.byId(var1)))
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public T valueFor(int var0) {
|
public T valueFor(int var0) {
|
||||||
return (T)this.values.byId(var0);
|
return this.values.byId(var0);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getSize() {
|
public int getSize() {
|
||||||
@ -80,6 +80,6 @@ public class HashMapPalette<T> implements Palette<T> {
|
|||||||
|
|
||||||
public void write(ListTag var0) {
|
public void write(ListTag var0) {
|
||||||
for (int var1 = 0; var1 < getSize(); var1++)
|
for (int var1 = 0; var1 < getSize(); var1++)
|
||||||
var0.add(this.writer.apply((T)this.values.byId(var1)));
|
var0.add(this.writer.apply(this.values.byId(var1)));
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -75,7 +75,7 @@ public class IdMapper<T> implements IdMap<T> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
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) {
|
||||||
|
@ -55,7 +55,7 @@ public class Mth {
|
|||||||
private static final float[] SIN;
|
private static final float[] SIN;
|
||||||
|
|
||||||
static {
|
static {
|
||||||
SIN = (float[])make(new float[65536], var0 -> {
|
SIN = make(new float[65536], var0 -> {
|
||||||
for (int var1 = 0; var1 < var0.length; var1++)
|
for (int var1 = 0; var1 < var0.length; var1++)
|
||||||
var0[var1] = (float) Math.sin(var1 * Math.PI * 2.0D / 65536.0D);
|
var0[var1] = (float) Math.sin(var1 * Math.PI * 2.0D / 65536.0D);
|
||||||
});
|
});
|
||||||
|
@ -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);
|
||||||
}
|
}
|
||||||
|
@ -164,8 +164,7 @@ public class PalettedContainer<T> implements PaletteResize<T> {
|
|||||||
var0.put(var1, paletteList);
|
var0.put(var1, paletteList);
|
||||||
int var8 = Math.max(4, Mth.ceillog2(paletteList.size()));
|
int var8 = Math.max(4, Mth.ceillog2(paletteList.size()));
|
||||||
BitStorage var9 = new BitStorage(var8, 4096);
|
BitStorage var9 = new BitStorage(var8, 4096);
|
||||||
for (int var10 = 0; var10 < var6.length; var10++)
|
for (int var10 = 0; var10 < var6.length; var10++) {
|
||||||
{
|
|
||||||
var9.set(var10, var6[var10]);
|
var9.set(var10, var6[var10]);
|
||||||
}
|
}
|
||||||
var0.putLongArray(var2, var9.getRaw());
|
var0.putLongArray(var2, var9.getRaw());
|
||||||
|
@ -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