9
0
mirror of https://github.com/VolmitSoftware/Iris.git synced 2025-12-26 18:49:06 +00:00

Merge remote-tracking branch 'origin/Development' into Development

This commit is contained in:
DanMB
2022-06-25 16:00:53 -04:00
73 changed files with 1573 additions and 287 deletions

View File

@@ -18,12 +18,16 @@
package com.volmit.iris;
import com.google.gson.JsonObject;
import com.google.gson.JsonParseException;
import com.google.gson.JsonParser;
import com.volmit.iris.core.IrisSettings;
import com.volmit.iris.core.ServerConfigurator;
import com.volmit.iris.core.link.*;
import com.volmit.iris.core.loader.IrisData;
import com.volmit.iris.core.nms.INMS;
import com.volmit.iris.core.service.StudioSVC;
import com.volmit.iris.core.tools.IrisToolbelt;
import com.volmit.iris.engine.EnginePanic;
import com.volmit.iris.engine.object.IrisCompat;
import com.volmit.iris.engine.object.IrisDimension;
@@ -56,6 +60,7 @@ import org.bukkit.GameMode;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.WorldCreator;
import org.bukkit.block.data.BlockData;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.configuration.file.FileConfiguration;
@@ -71,15 +76,12 @@ import org.bukkit.plugin.Plugin;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.io.BufferedInputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.PrintWriter;
import java.io.*;
import java.lang.annotation.Annotation;
import java.net.URL;
import java.util.Date;
import java.util.Map;
import java.util.Objects;
@SuppressWarnings("CanBeFinal")
public class Iris extends VolmitPlugin implements Listener {
@@ -243,12 +245,12 @@ public class Iris extends VolmitPlugin implements Listener {
return f;
}
public static void warn(String string) {
msg(C.YELLOW + string);
public static void warn(String format, Object... objs) {
msg(C.YELLOW + String.format(format, objs));
}
public static void error(String string) {
msg(C.RED + string);
public static void error(String format, Object... objs) {
msg(C.RED + String.format(format, objs));
}
public static void debug(String string) {
@@ -406,6 +408,8 @@ public class Iris extends VolmitPlugin implements Listener {
splash();
autoStartStudio();
checkForBukkitWorlds();
IrisToolbelt.retainMantleDataForSlice(String.class.getCanonicalName());
IrisToolbelt.retainMantleDataForSlice(BlockData.class.getCanonicalName());
});
}
@@ -675,17 +679,51 @@ public class Iris extends VolmitPlugin implements Listener {
String padd2 = Form.repeat(" ", 4);
String[] info = {"", "", "", "", "", padd2 + C.IRIS + " Iris", padd2 + C.GRAY + " by " + "<rainbow>Volmit Software", padd2 + C.GRAY + " v" + C.IRIS + getDescription().getVersion(),
};
String[] splash = {padd + C.GRAY + " @@@@@@@@@@@@@@" + C.DARK_GRAY + "@@@", padd + C.GRAY + " @@&&&&&&&&&" + C.DARK_GRAY + "&&&&&&" + C.IRIS + " .(((()))). ", padd + C.GRAY + "@@@&&&&&&&&" + C.DARK_GRAY + "&&&&&" + C.IRIS + " .((((((())))))). ", padd + C.GRAY + "@@@&&&&&" + C.DARK_GRAY + "&&&&&&&" + C.IRIS + " ((((((((())))))))) " + C.GRAY + " @", padd + C.GRAY + "@@@&&&&" + C.DARK_GRAY + "@@@@@&" + C.IRIS + " ((((((((-))))))))) " + C.GRAY + " @@", padd + C.GRAY + "@@@&&" + C.IRIS + " ((((((({ })))))))) " + C.GRAY + " &&@@@", padd + C.GRAY + "@@" + C.IRIS + " ((((((((-))))))))) " + C.DARK_GRAY + "&@@@@@" + C.GRAY + "&&&&@@@", padd + C.GRAY + "@" + C.IRIS + " ((((((((())))))))) " + C.DARK_GRAY + "&&&&&" + C.GRAY + "&&&&&&&@@@", padd + C.GRAY + "" + C.IRIS + " '((((((()))))))' " + C.DARK_GRAY + "&&&&&" + C.GRAY + "&&&&&&&&@@@", padd + C.GRAY + "" + C.IRIS + " '(((())))' " + C.DARK_GRAY + "&&&&&&&&" + C.GRAY + "&&&&&&&@@", padd + C.GRAY + " " + C.DARK_GRAY + "@@@" + C.GRAY + "@@@@@@@@@@@@@@"
String[] splash = {
padd + C.GRAY + " @@@@@@@@@@@@@@" + C.DARK_GRAY + "@@@",
padd + C.GRAY + " @@&&&&&&&&&" + C.DARK_GRAY + "&&&&&&" + C.IRIS + " .(((()))). ",
padd + C.GRAY + "@@@&&&&&&&&" + C.DARK_GRAY + "&&&&&" + C.IRIS + " .((((((())))))). ",
padd + C.GRAY + "@@@&&&&&" + C.DARK_GRAY + "&&&&&&&" + C.IRIS + " ((((((((())))))))) " + C.GRAY + " @",
padd + C.GRAY + "@@@&&&&" + C.DARK_GRAY + "@@@@@&" + C.IRIS + " ((((((((-))))))))) " + C.GRAY + " @@",
padd + C.GRAY + "@@@&&" + C.IRIS + " ((((((({ })))))))) " + C.GRAY + " &&@@@",
padd + C.GRAY + "@@" + C.IRIS + " ((((((((-))))))))) " + C.DARK_GRAY + "&@@@@@" + C.GRAY + "&&&&@@@",
padd + C.GRAY + "@" + C.IRIS + " ((((((((())))))))) " + C.DARK_GRAY + "&&&&&" + C.GRAY + "&&&&&&&@@@",
padd + C.GRAY + "" + C.IRIS + " '((((((()))))))' " + C.DARK_GRAY + "&&&&&" + C.GRAY + "&&&&&&&&@@@",
padd + C.GRAY + "" + C.IRIS + " '(((())))' " + C.DARK_GRAY + "&&&&&&&&" + C.GRAY + "&&&&&&&@@",
padd + C.GRAY + " " + C.DARK_GRAY + "@@@" + C.GRAY + "@@@@@@@@@@@@@@"
};
//@done
Iris.info("Server type & version: " + Bukkit.getVersion());
Iris.info("Bukkit version: " + Bukkit.getBukkitVersion());
Iris.info("Java version: " + getJavaVersion());
Iris.info("Custom Biomes: " + INMS.get().countCustomBiomes());
printPacks();
for(int i = 0; i < info.length; i++) {
splash[i] += info[i];
}
Iris.info("\n\n " + new KList<>(splash).toString("\n") + "\n");
}
private void printPacks() {
File packFolder = Iris.service(StudioSVC.class).getWorkspaceFolder();
File[] packs = packFolder.listFiles(File::isDirectory);
if(packs == null || packs.length == 0)
return;
Iris.info("Custom Dimensions: " + packs.length);
for(File f : packs)
printPack(f);
}
private void printPack(File pack) {
String dimName = pack.getName();
String version = "???";
try(FileReader r = new FileReader(new File(pack, "dimensions/" + dimName + ".json"))) {
JsonObject json = JsonParser.parseReader(r).getAsJsonObject();
if(json.has("version"))
version = json.get("version").getAsString();
} catch(IOException | JsonParseException ignored) { }
Iris.info(" " + dimName + " v" + version);
}
}

View File

@@ -74,6 +74,7 @@ public class IrisSettings {
public double targetSpawnEntitiesPerChunk = 0.95;
public boolean markerEntitySpawningSystem = true;
public boolean effectSystem = true;
public boolean worldEditWandCUI = true;
}
@Data

View File

@@ -55,7 +55,7 @@ public class ServerConfigurator {
}
private static void increaseKeepAliveSpigot() throws IOException, InvalidConfigurationException {
File spigotConfig = new File("spigot.yml");
File spigotConfig = new File("config/spigot.yml");
FileConfiguration f = new YamlConfiguration();
f.load(spigotConfig);
long tt = f.getLong("settings.timeout-time");
@@ -69,15 +69,15 @@ public class ServerConfigurator {
}
private static void increasePaperWatchdog() throws IOException, InvalidConfigurationException {
File spigotConfig = new File("paper.yml");
File spigotConfig = new File("config/paper-global.yml");
FileConfiguration f = new YamlConfiguration();
f.load(spigotConfig);
long tt = f.getLong("settings.watchdog.early-warning-delay");
long tt = f.getLong("watchdog.early-warning-delay");
if(tt < TimeUnit.MINUTES.toMillis(3)) {
Iris.warn("Updating paper.yml watchdog early-warning-delay: " + tt + " -> " + TimeUnit.MINUTES.toMillis(3) + " (3 minutes)");
Iris.warn("You can disable this change (autoconfigureServer) in Iris settings, then change back the value.");
f.set("settings.watchdog.early-warning-delay", TimeUnit.MINUTES.toMillis(3));
f.set("watchdog.early-warning-delay", TimeUnit.MINUTES.toMillis(3));
f.save(spigotConfig);
}
}

View File

@@ -76,7 +76,7 @@ public class CommandIris implements DecreeExecutor {
return;
}
sender().sendMessage(C.RED + "You should not be using this command to create new worlds. Instead, use /mvc " + name + " NORMAL -g Iris:" + type.getName());
sender().sendMessage(C.RED + "You should not be using this command to create new worlds. Instead, use the tutorial: https://docs.volmit.com/iris/getting-started");
try {
IrisToolbelt.createWorld()
@@ -163,7 +163,7 @@ public class CommandIris implements DecreeExecutor {
public void download(
@Param(name = "pack", description = "The pack to download", defaultValue = "overworld", aliases = "project")
String pack,
@Param(name = "branch", description = "The branch to download from", defaultValue = "master")
@Param(name = "branch", description = "The branch to download from", defaultValue = "main")
String branch,
@Param(name = "trim", description = "Whether or not to download a trimmed version (do not enable when editing)", defaultValue = "false")
boolean trim,

View File

@@ -19,6 +19,7 @@
package com.volmit.iris.core.commands;
import com.volmit.iris.Iris;
import com.volmit.iris.core.link.WorldEditLink;
import com.volmit.iris.core.loader.IrisData;
import com.volmit.iris.core.service.ObjectSVC;
import com.volmit.iris.core.service.StudioSVC;
@@ -41,12 +42,7 @@ import com.volmit.iris.util.format.C;
import com.volmit.iris.util.math.Direction;
import com.volmit.iris.util.math.RNG;
import com.volmit.iris.util.scheduling.Queue;
import org.bukkit.ChatColor;
import org.bukkit.HeightMap;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.World;
import org.bukkit.*;
import org.bukkit.block.Block;
import org.bukkit.block.BlockState;
import org.bukkit.block.TileState;
@@ -232,7 +228,7 @@ public class CommandObject implements DecreeExecutor {
}
Location[] b = WandSVC.getCuboid(player().getInventory().getItemInMainHand());
Location[] b = WandSVC.getCuboid(player());
Location a1 = b[0].clone();
Location a2 = b[1].clone();
Cuboid cursor = new Cuboid(a1, a2);
@@ -256,10 +252,8 @@ public class CommandObject implements DecreeExecutor {
return;
}
ItemStack wand = player().getInventory().getItemInMainHand();
if(WandSVC.isWand(wand)) {
Location[] g = WandSVC.getCuboid(wand);
if(WandSVC.isHoldingWand(player())) {
Location[] g = WandSVC.getCuboid(player());
if(!here) {
// TODO: WARNING HEIGHT
@@ -281,10 +275,8 @@ public class CommandObject implements DecreeExecutor {
return;
}
ItemStack wand = player().getInventory().getItemInMainHand();
if(WandSVC.isWand(wand)) {
Location[] g = WandSVC.getCuboid(wand);
if(WandSVC.isHoldingIrisWand(player())) {
Location[] g = WandSVC.getCuboid(player());
if(!here) {
// TODO: WARNING HEIGHT
@@ -367,7 +359,7 @@ public class CommandObject implements DecreeExecutor {
@Param(description = "Overwrite existing object files", defaultValue = "false", aliases = "force")
boolean overwrite
) {
IrisObject o = WandSVC.createSchematic(player().getInventory().getItemInMainHand());
IrisObject o = WandSVC.createSchematic(player());
if(o == null) {
sender().sendMessage(C.YELLOW + "You need to hold your wand!");
@@ -401,7 +393,7 @@ public class CommandObject implements DecreeExecutor {
return;
}
Location[] b = WandSVC.getCuboid(player().getInventory().getItemInMainHand());
Location[] b = WandSVC.getCuboid(player());
Location a1 = b[0].clone();
Location a2 = b[1].clone();
Direction d = Direction.closest(player().getLocation().getDirection()).reverse();
@@ -426,6 +418,25 @@ public class CommandObject implements DecreeExecutor {
sender().sendMessage("Reverted " + actualReverts + " pastes!");
}
@Decree(description = "Gets an object wand and grabs the current WorldEdit selection.", aliases = "we", origin = DecreeOrigin.PLAYER, studio = true)
public void we() {
if(!Bukkit.getPluginManager().isPluginEnabled("WorldEdit")) {
sender().sendMessage(C.RED + "You can't get a WorldEdit selection without WorldEdit, you know.");
return;
}
Cuboid locs = WorldEditLink.getSelection(sender().player());
if(locs == null)
{
sender().sendMessage(C.RED + "You don't have a WorldEdit selection in this world.");
return;
}
sender().player().getInventory().addItem(WandSVC.createWand(locs.getLowerNE(), locs.getUpperSW()));
sender().sendMessage(C.GREEN + "A fresh wand with your current WorldEdit selection on it!");
}
@Decree(description = "Get an object wand", sync = true)
public void wand() {
player().getInventory().addItem(WandSVC.createWand());
@@ -440,7 +451,7 @@ public class CommandObject implements DecreeExecutor {
return;
}
Location[] b = WandSVC.getCuboid(player().getInventory().getItemInMainHand());
Location[] b = WandSVC.getCuboid(player());
Location a1 = b[0].clone();
Location a2 = b[1].clone();
Location a1x = b[0].clone();
@@ -487,7 +498,7 @@ public class CommandObject implements DecreeExecutor {
return;
}
Location[] b = WandSVC.getCuboid(player().getInventory().getItemInMainHand());
Location[] b = WandSVC.getCuboid(player());
b[0].add(new Vector(0, 1, 0));
b[1].add(new Vector(0, 1, 0));
Location a1 = b[0].clone();

View File

@@ -0,0 +1,37 @@
package com.volmit.iris.core.link;
import com.volmit.iris.util.data.Cuboid;
import org.bukkit.World;
import org.bukkit.entity.Player;
public class WorldEditLink {
public static Cuboid getSelection(Player p)
{
try
{
Object instance = Class.forName("com.sk89q.worldedit.WorldEdit").getDeclaredMethod("getInstance").invoke(null);
Object sessionManager = instance.getClass().getDeclaredMethod("getSessionManager").invoke(instance);
Object player = Class.forName("com.sk89q.worldedit.bukkit.BukkitAdapter").getDeclaredMethod("adapt", Player.class).invoke(null, p);
Object localSession = sessionManager.getClass().getDeclaredMethod("getIfPresent", Class.forName("com.sk89q.worldedit.session.SessionOwner")).invoke(sessionManager, player);
Object world = Class.forName("com.sk89q.worldedit.bukkit.BukkitAdapter").getDeclaredMethod("adapt", World.class).invoke(null, p.getWorld());
Object region = localSession.getClass().getDeclaredMethod("getSelection", world.getClass()).invoke(localSession, world);
Object min = region.getClass().getDeclaredMethod("getMinimumPoint").invoke(region);
Object max = region.getClass().getDeclaredMethod("getMaximumPoint").invoke(region);
return new Cuboid(p.getWorld(),
(int)min.getClass().getDeclaredMethod("getX").invoke(min),
(int)min.getClass().getDeclaredMethod("getY").invoke(min),
(int)min.getClass().getDeclaredMethod("getZ").invoke(min),
(int)min.getClass().getDeclaredMethod("getX").invoke(max),
(int)min.getClass().getDeclaredMethod("getY").invoke(max),
(int)min.getClass().getDeclaredMethod("getZ").invoke(max)
);
}
catch(Throwable e)
{
}
return null;
}
}

View File

@@ -20,7 +20,7 @@ package com.volmit.iris.core.nms;
import com.volmit.iris.Iris;
import com.volmit.iris.core.IrisSettings;
import com.volmit.iris.core.nms.v18_2.NMSBinding18_2;
import com.volmit.iris.core.nms.v19_1.NMSBinding19_1;
import com.volmit.iris.core.nms.v1X.NMSBinding1X;
import com.volmit.iris.util.collection.KMap;
import org.bukkit.Bukkit;
@@ -28,7 +28,7 @@ import org.bukkit.Bukkit;
public class INMS {
//@builder
private static final KMap<String, Class<? extends INMSBinding>> bindings = new KMap<String, Class<? extends INMSBinding>>()
.qput("v1_18_R2", NMSBinding18_2.class);
.qput("v1_19_R1", NMSBinding19_1.class);
//@done
private static final INMSBinding binding = bind();

View File

@@ -24,6 +24,7 @@ import java.util.ArrayList;
import java.util.List;
public enum NMSVersion {
R1_19_1,
R1_18_2,
R1_18,
R1_17,
@@ -102,6 +103,9 @@ public enum NMSVersion {
if(tryVersion("1_18_R2")) {
return R1_18_2;
}
if(tryVersion("1_19_R1")) {
return R1_19_1;
}
return null;
}

View File

@@ -16,7 +16,7 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.volmit.iris.core.nms.v18_2;
package com.volmit.iris.core.nms.v19_1;
import com.volmit.iris.Iris;
@@ -39,10 +39,15 @@ import it.unimi.dsi.fastutil.objects.Object2IntMap;
import net.minecraft.core.*;
import net.minecraft.nbt.NbtIo;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.util.BitStorage;
import net.minecraft.util.Mth;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.chunk.ChunkAccess;
import net.minecraft.world.level.chunk.LevelChunkSection;
import net.minecraft.world.level.chunk.Palette;
import net.minecraft.world.level.chunk.PalettedContainer;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material;
@@ -50,9 +55,10 @@ import org.bukkit.World;
import org.bukkit.block.Biome;
import org.bukkit.block.data.BlockData;
import org.bukkit.craftbukkit.v1_18_R2.CraftServer;
import org.bukkit.craftbukkit.v1_18_R2.CraftWorld;
import org.bukkit.craftbukkit.v1_18_R2.block.data.CraftBlockData;
import org.bukkit.craftbukkit.v1_19_R1.CraftServer;
import org.bukkit.craftbukkit.v1_19_R1.CraftWorld;
import org.bukkit.craftbukkit.v1_19_R1.block.data.CraftBlockData;
import org.bukkit.entity.Entity;
import org.bukkit.generator.ChunkGenerator;
import org.jetbrains.annotations.NotNull;
@@ -68,7 +74,7 @@ import java.util.Iterator;
import java.util.List;
import java.util.concurrent.atomic.AtomicInteger;
public class NMSBinding18_2 implements INMSBinding {
public class NMSBinding19_1 implements INMSBinding {
private final KMap<Biome, Object> baseBiomeCache = new KMap<>();
private final BlockData AIR = Material.AIR.createBlockData();
@@ -126,8 +132,8 @@ public class NMSBinding18_2 implements INMSBinding {
}
@Override
public void deserializeTile(CompoundTag c, Location newPosition) {
((CraftWorld) newPosition.getWorld()).getHandle().getChunkAt(new BlockPos(newPosition.getBlockX(), 0, newPosition.getBlockZ())).setBlockEntityNbt(convert(c));
public void deserializeTile(CompoundTag c, Location pos) {
((CraftWorld) pos.getWorld()).getHandle().getChunkAt(new BlockPos(pos.getBlockX(), 0, pos.getBlockZ())).setBlockEntityNbt(convert(c));
}
@Override
@@ -231,13 +237,13 @@ public class NMSBinding18_2 implements INMSBinding {
return v;
}
//noinspection unchecked
v = org.bukkit.craftbukkit.v1_18_R2.block.CraftBlock.biomeToBiomeBase((Registry<net.minecraft.world.level.biome.Biome>) registry, biome);
v = org.bukkit.craftbukkit.v1_19_R1.block.CraftBlock.biomeToBiomeBase((Registry<net.minecraft.world.level.biome.Biome>) registry, biome);
if(v == null) {
// Ok so there is this new biome name called "CUSTOM" in Paper's new releases.
// But, this does NOT exist within CraftBukkit which makes it return an error.
// So, we will just return the ID that the plains biome returns instead.
//noinspection unchecked
return org.bukkit.craftbukkit.v1_18_R2.block.CraftBlock.biomeToBiomeBase((Registry<net.minecraft.world.level.biome.Biome>) registry, Biome.PLAINS);
return org.bukkit.craftbukkit.v1_19_R1.block.CraftBlock.biomeToBiomeBase((Registry<net.minecraft.world.level.biome.Biome>) registry, Biome.PLAINS);
}
baseBiomeCache.put(biome, v);
return v;
@@ -336,13 +342,46 @@ public class NMSBinding18_2 implements INMSBinding {
public void forceBiomeInto(int x, int y, int z, Object somethingVeryDirty, ChunkGenerator.BiomeGrid chunk) {
try {
ChunkAccess s = (ChunkAccess) getFieldForBiomeStorage(chunk).get(chunk);
s.setBiome(x, y, z, (Holder<net.minecraft.world.level.biome.Biome>) somethingVeryDirty); // probably not safe? it said it wanted a holder, so i made it a holder...
Holder<net.minecraft.world.level.biome.Biome> biome = (Holder<net.minecraft.world.level.biome.Biome>) somethingVeryDirty;
s.setBiome(x, y, z, biome);
/*int l = QuartPos.fromBlock(s.getMinBuildHeight());
int i1 = l + QuartPos.fromBlock(s.getHeight()) - 1;
PalettedContainer<Holder<net.minecraft.world.level.biome.Biome>> palette = getPalette(s, s.getSectionIndex(QuartPos.toBlock(Mth.clamp(y, l, i1))));
int index = getPaletteIndex(x, y, z, s, palette);
int data = getPaletteDataId(palette, biome);
setPaletteData(palette, index, data);*/
} catch(IllegalAccessException e) {
Iris.reportError(e);
e.printStackTrace();
}
}
private PalettedContainer<Holder<net.minecraft.world.level.biome.Biome>> getPalette(ChunkAccess ca, int index) {
LevelChunkSection[] sections = fieldForClass(LevelChunkSection[].class, ChunkAccess.class, ca);
return fieldForClass(PalettedContainer.class, LevelChunkSection.class, sections[index]);
}
private int getPaletteIndex(int x, int y, int z, ChunkAccess s, PalettedContainer<?> palette) {
int l = QuartPos.fromBlock(s.getMinBuildHeight());
int i1 = l + QuartPos.fromBlock(s.getHeight()) - 1;
int j1 = Mth.clamp(y, l, i1);
return fieldForClass(PalettedContainer.Strategy.class, PalettedContainer.class, palette).getIndex(x & 3, j1 & 3, z & 3);
}
private <T extends Holder<?>> int getPaletteDataId(PalettedContainer<T> palette, T data) throws ClassNotFoundException {
Class<?> dataType = getClassType(PalettedContainer.class, 1);
Object paletteData = fieldFor(dataType, palette);
Palette<T> fuckinFinally = fieldForClass(Palette.class,dataType, paletteData);
return fuckinFinally.idFor(data);
}
private void setPaletteData(PalettedContainer<?> palette, int index, int data) throws ClassNotFoundException {
Class<?> dataType = getClassType(PalettedContainer.class, 1);
Object paletteData = fieldFor(dataType, palette);
BitStorage storage = fieldForClass(BitStorage.class, dataType, paletteData);
storage.set(index, data);
}
private Field getFieldForBiomeStorage(Object storage) {
Field f = biomeStorageCache;
@@ -404,7 +443,7 @@ public class NMSBinding18_2 implements INMSBinding {
if(i.getReturnType().equals(returns)) {
i.setAccessible(true);
try {
Iris.info("[NMS] Found " + returns.getSimpleName() + " in " + in.getClass().getSimpleName() + "." + i.getName() + "()");
Iris.debug("[NMS] Found " + returns.getSimpleName() + " in " + in.getClass().getSimpleName() + "." + i.getName() + "()");
return i.invoke(in);
} catch(Throwable e) {
e.printStackTrace();
@@ -416,18 +455,26 @@ public class NMSBinding18_2 implements INMSBinding {
}
private static Object fieldFor(Class<?> returns, Object in) {
for(Field i : in.getClass().getFields()) {
if(i.getType().equals(returns)) {
return fieldForClass(returns, in.getClass(), in);
}
@SuppressWarnings("unchecked")
private static <T> T fieldForClass(Class<T> returnType, Class<?> sourceType, Object in) {
for(Field i : sourceType.getDeclaredFields()) {
if(i.getType().equals(returnType)) {
i.setAccessible(true);
try {
Iris.info("[NMS] Found " + returns.getSimpleName() + " in " + in.getClass().getSimpleName() + "." + i.getName());
return i.get(in);
Iris.debug("[NMS] Found " + returnType.getSimpleName() + " in " + sourceType.getSimpleName() + "." + i.getName());
return (T) i.get(in);
} catch(IllegalAccessException e) {
e.printStackTrace();
}
}
}
return null;
}
private static Class<?> getClassType(Class<?> type, int ordinal) {
return type.getDeclaredClasses()[ordinal];
}
}

View File

@@ -0,0 +1,61 @@
package com.volmit.iris.core.service;
import com.volmit.iris.util.collection.KList;
import com.volmit.iris.util.plugin.IrisService;
import org.apache.logging.log4j.Level;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Marker;
import org.apache.logging.log4j.core.Filter;
import org.apache.logging.log4j.core.LogEvent;
import org.apache.logging.log4j.core.Logger;
import org.apache.logging.log4j.message.Message;
public class LogFilterSVC implements IrisService, Filter {
private static final String HEIGHTMAP_MISMATCH = "Ignoring heightmap data for chunk";
private static final String RAID_PERSISTENCE = "Could not save data net.minecraft.world.entity.raid.PersistentRaid";
private static final String DUPLICATE_ENTITY_UUID = "UUID of added entity already exists";
private static final KList<String> FILTERS = new KList<>();
public void onEnable() {
FILTERS.add(HEIGHTMAP_MISMATCH, RAID_PERSISTENCE, DUPLICATE_ENTITY_UUID);
((Logger)LogManager.getRootLogger()).addFilter(this);
}
public void initialize() { }
public void start() { }
public void stop() { }
public void onDisable() { }
public boolean isStarted() { return true; }
public boolean isStopped() { return false; }
public State getState() {
try { return State.STARTED; }
catch (Exception var2) { return null; }
}
public Filter.Result getOnMatch() { return Result.NEUTRAL; }
public Filter.Result getOnMismatch() { return Result.NEUTRAL; }
public Result filter(LogEvent event) { return check(event.getMessage().getFormattedMessage()); }
public Result filter(Logger logger, Level level, Marker marker, Object msg, Throwable t) { return check(msg.toString()); }
public Result filter(Logger logger, Level level, Marker marker, Message msg, Throwable t) { return check(msg.getFormattedMessage()); }
public Result filter(Logger logger, Level level, Marker marker, String message, Object... params) { return check(message); }
public Result filter(Logger logger, Level level, Marker marker, String message, Object p0) { return check(message); }
public Result filter(Logger logger, Level level, Marker marker, String message, Object p0, Object p1) { return check(message); }
public Result filter(Logger logger, Level level, Marker marker, String message, Object p0, Object p1, Object p2) { return check(message); }
public Result filter(Logger logger, Level level, Marker marker, String message, Object p0, Object p1, Object p2, Object p3) { return check(message); }
public Result filter(Logger logger, Level level, Marker marker, String message, Object p0, Object p1, Object p2, Object p3, Object p4) { return check(message); }
public Result filter(Logger logger, Level level, Marker marker, String message, Object p0, Object p1, Object p2, Object p3, Object p4, Object p5) { return check(message); }
public Result filter(Logger logger, Level level, Marker marker, String message, Object p0, Object p1, Object p2, Object p3, Object p4, Object p5, Object p6) { return check(message); }
public Result filter(Logger logger, Level level, Marker marker, String message, Object p0, Object p1, Object p2, Object p3, Object p4, Object p5, Object p6, Object p7) { return check(message); }
public Result filter(Logger logger, Level level, Marker marker, String message, Object p0, Object p1, Object p2, Object p3, Object p4, Object p5, Object p6, Object p7, Object p8) { return check(message); }
public Result filter(Logger logger, Level level, Marker marker, String message, Object p0, Object p1, Object p2, Object p3, Object p4, Object p5, Object p6, Object p7, Object p8, Object p9) { return check(message); }
private Result check(String string) {
if(FILTERS.stream().anyMatch(string::contains))
return Result.DENY;
return Result.NEUTRAL;
}
}

View File

@@ -19,7 +19,9 @@
package com.volmit.iris.core.service;
import com.volmit.iris.Iris;
import com.volmit.iris.core.IrisSettings;
import com.volmit.iris.core.edit.DustRevealer;
import com.volmit.iris.core.link.WorldEditLink;
import com.volmit.iris.core.wand.WandSelection;
import com.volmit.iris.engine.object.IrisObject;
import com.volmit.iris.util.collection.KList;
@@ -64,17 +66,17 @@ public class WandSVC implements IrisService {
/**
* Creates an Iris Object from the 2 coordinates selected with a wand
*
* @param wand
* The wand itemstack
* @param p
* The wand player
* @return The new object
*/
public static IrisObject createSchematic(ItemStack wand) {
if(!isWand(wand)) {
public static IrisObject createSchematic(Player p) {
if(!isHoldingWand(p)) {
return null;
}
try {
Location[] f = getCuboid(wand);
Location[] f = getCuboid(p);
Cuboid c = new Cuboid(f[0], f[1]);
IrisObject s = new IrisObject(c.getSizeX(), c.getSizeY(), c.getSizeZ());
for(Block b : c) {
@@ -98,17 +100,15 @@ public class WandSVC implements IrisService {
/**
* Creates an Iris Object from the 2 coordinates selected with a wand
*
* @param wand
* The wand itemstack
* @return The new object
*/
public static Matter createMatterSchem(Player p, ItemStack wand) {
if(!isWand(wand)) {
public static Matter createMatterSchem(Player p) {
if(!isHoldingWand(p)) {
return null;
}
try {
Location[] f = getCuboid(wand);
Location[] f = getCuboid(p);
return WorldMatter.createMatter(p.getName(), f[0], f[1]);
} catch(Throwable e) {
@@ -226,26 +226,32 @@ public class WandSVC implements IrisService {
return is;
}
/**
* Get a pair of locations that are selected in an Iris wand
*
* @param is
* The wand item
* @return An array with the 2 locations
*/
public static Location[] getCuboid(ItemStack is) {
public static Location[] getCuboidFromItem(ItemStack is) {
ItemMeta im = is.getItemMeta();
return new Location[] {stringToLocation(im.getLore().get(0)), stringToLocation(im.getLore().get(1))};
}
/**
* Is a player holding an Iris wand
*
* @param p
* The player
* @return True if they are
*/
public static Location[] getCuboid(Player p) {
if(isHoldingIrisWand(p))
{
return getCuboidFromItem(p.getInventory().getItemInMainHand());
}
Cuboid c = WorldEditLink.getSelection(p);
if(c != null)
{
return new Location[] {c.getLowerNE(), c.getUpperSW()};
}
return null;
}
public static boolean isHoldingWand(Player p) {
return isHoldingIrisWand(p) || WorldEditLink.getSelection(p) != null;
}
public static boolean isHoldingIrisWand(Player p) {
ItemStack is = p.getInventory().getItemInMainHand();
return is != null && isWand(is);
}
@@ -286,8 +292,8 @@ public class WandSVC implements IrisService {
public void tick(Player p) {
try {
try {
if(isWand(p.getInventory().getItemInMainHand())) {
Location[] d = getCuboid(p.getInventory().getItemInMainHand());
if((IrisSettings.get().getWorld().worldEditWandCUI && isHoldingWand(p)) || isWand(p.getInventory().getItemInMainHand())) {
Location[] d = getCuboid(p);
new WandSelection(new Cuboid(d[0], d[1]), p).draw();
}
} catch(Throwable e) {
@@ -457,7 +463,7 @@ public class WandSVC implements IrisService {
return item;
}
Location[] f = getCuboid(item);
Location[] f = getCuboidFromItem(item);
Location other = left ? f[1] : f[0];
if(other != null && !other.getWorld().getName().equals(a.getWorld().getName())) {

View File

@@ -233,20 +233,17 @@ public class IrisToolbelt {
return isIrisWorld(i) && access(i).isStudio();
}
public static void retainMantleDataForSlice(String className)
{
public static void retainMantleDataForSlice(String className) {
toolbeltConfiguration.put("retain.mantle." + className, true);
}
public static <T> T getMantleData(World world, int x, int y, int z, Class<T> of)
{
public static <T> T getMantleData(World world, int x, int y, int z, Class<T> of) {
PlatformChunkGenerator e = access(world);
if(e == null) {return null;}
return e.getEngine().getMantle().getMantle().get(x, y - world.getMinHeight(), z, of);
}
public static <T> void deleteMantleData(World world, int x, int y, int z, Class<T> of)
{
public static <T> void deleteMantleData(World world, int x, int y, int z, Class<T> of) {
PlatformChunkGenerator e = access(world);
if(e == null) {return;}
e.getEngine().getMantle().getMantle().remove(x, y - world.getMinHeight(), z, of);

View File

@@ -112,8 +112,8 @@ public class IrisComplex implements DataProvider {
.getAllBiomes(this).forEach((b) -> b
.getGenerators()
.forEach((c) -> registerGenerator(c.getCachedGenerator(this)))));
overlayStream = ProceduralStream.ofDouble((x, z) -> 0D);
engine.getDimension().getOverlayNoise().forEach((i) -> overlayStream.add((x, z) -> i.get(rng, getData(), x, z)));
overlayStream = ProceduralStream.ofDouble((x, z) -> 0.0D);
engine.getDimension().getOverlayNoise().forEach(i -> overlayStream = overlayStream.add((x, z) -> i.get(rng, getData(), x, z)));
rockStream = engine.getDimension().getRockPalette().getLayerGenerator(rng.nextParallelRNG(45), data).stream()
.select(engine.getDimension().getRockPalette().getBlockData(data));
fluidStream = engine.getDimension().getFluidPalette().getLayerGenerator(rng.nextParallelRNG(78), data).stream()

View File

@@ -79,7 +79,6 @@ import java.util.stream.Stream;
public class IrisWorldManager extends EngineAssignedWorldManager {
private final Looper looper;
private final int id;
private final KMap<Long, Long> chunkCooldowns;
private final KList<Runnable> updateQueue = new KList<>();
private final ChronoLatch cl;
private final ChronoLatch clw;
@@ -99,7 +98,6 @@ public class IrisWorldManager extends EngineAssignedWorldManager {
ecl = null;
cln = null;
clw = null;
chunkCooldowns = null;
looper = null;
chunkUpdater = null;
id = -1;
@@ -112,7 +110,6 @@ public class IrisWorldManager extends EngineAssignedWorldManager {
cl = new ChronoLatch(3000);
ecl = new ChronoLatch(250);
clw = new ChronoLatch(1000, true);
chunkCooldowns = new KMap<>();
id = engine.getCacheID();
energy = 25;
looper = new Looper() {
@@ -255,14 +252,6 @@ public class IrisWorldManager extends EngineAssignedWorldManager {
}
}
int chunkCooldownSeconds = 60;
for(Long i : chunkCooldowns.k()) {
if(M.ms() - chunkCooldowns.get(i) > TimeUnit.SECONDS.toMillis(chunkCooldownSeconds)) {
chunkCooldowns.remove(i);
}
}
int spawnBuffer = RNG.r.i(2, 12);
Chunk[] cc = getEngine().getWorld().realWorld().getLoadedChunks();
@@ -279,7 +268,6 @@ public class IrisWorldManager extends EngineAssignedWorldManager {
}
spawnIn(c, false);
chunkCooldowns.put(Cache.key(c), M.ms());
}
energy -= (actuallySpawned / 2D);

View File

@@ -32,6 +32,7 @@ import com.volmit.iris.util.math.RNG;
import com.volmit.iris.util.parallel.BurstExecutor;
import com.volmit.iris.util.scheduling.ChronoLatch;
import com.volmit.iris.util.scheduling.PrecisionStopwatch;
import io.papermc.lib.PaperLib;
import org.bukkit.block.Biome;
import org.bukkit.generator.ChunkGenerator;
@@ -67,7 +68,7 @@ public class IrisBiomeActuator extends EngineAssignedActuator<Biome> {
@Override
public void onActuate(int x, int z, Hunk<Biome> h, boolean multicore) {
PrecisionStopwatch p = PrecisionStopwatch.start();
BurstExecutor burst = burst().burst(multicore);
BurstExecutor burst = burst().burst(PaperLib.isPaper() && multicore);
for(int xf = 0; xf < h.getWidth(); xf++) {
int finalXf = xf;
@@ -80,7 +81,7 @@ public class IrisBiomeActuator extends EngineAssignedActuator<Biome> {
try {
IrisBiomeCustom custom = ib.getCustomBiome(rng, x, 0, z);
Object biomeBase = INMS.get().getCustomBiomeBaseHolderFor(getDimension().getLoadKey() + ":" + custom.getId());
//
if(biomeBase == null || !injectBiome(h, x, 0, z, biomeBase)) {
throw new RuntimeException("Cant inject biome!");
}

View File

@@ -101,7 +101,6 @@ public class IrisTerrainNormalActuator extends EngineAssignedActuator<BlockData>
KList<BlockData> blocks = null;
KList<BlockData> fblocks = null;
int depth, fdepth;
for(int i = hf; i >= 0; i--) {
if(i >= h.getHeight()) {
continue;
@@ -156,7 +155,6 @@ public class IrisTerrainNormalActuator extends EngineAssignedActuator<BlockData>
} else {
h.set(xf, i, zf, getComplex().getRockStream().get(realX, realZ));
}
}
}
}

View File

@@ -24,25 +24,12 @@ import com.volmit.iris.core.gui.components.RenderType;
import com.volmit.iris.core.gui.components.Renderer;
import com.volmit.iris.core.loader.IrisData;
import com.volmit.iris.core.loader.IrisRegistrant;
import com.volmit.iris.core.nms.INMS;
import com.volmit.iris.engine.IrisComplex;
import com.volmit.iris.engine.data.cache.Cache;
import com.volmit.iris.engine.data.chunk.TerrainChunk;
import com.volmit.iris.engine.mantle.EngineMantle;
import com.volmit.iris.engine.object.InventorySlotType;
import com.volmit.iris.engine.object.IrisBiome;
import com.volmit.iris.engine.object.IrisColor;
import com.volmit.iris.engine.object.IrisDimension;
import com.volmit.iris.engine.object.IrisEngineData;
import com.volmit.iris.engine.object.IrisJigsawStructure;
import com.volmit.iris.engine.object.IrisJigsawStructurePlacement;
import com.volmit.iris.engine.object.IrisLootMode;
import com.volmit.iris.engine.object.IrisLootReference;
import com.volmit.iris.engine.object.IrisLootTable;
import com.volmit.iris.engine.object.IrisObject;
import com.volmit.iris.engine.object.IrisObjectPlacement;
import com.volmit.iris.engine.object.IrisPosition;
import com.volmit.iris.engine.object.IrisRegion;
import com.volmit.iris.engine.object.IrisWorld;
import com.volmit.iris.engine.object.*;
import com.volmit.iris.engine.scripting.EngineExecutionEnvironment;
import com.volmit.iris.util.collection.KList;
import com.volmit.iris.util.collection.KMap;
@@ -61,6 +48,7 @@ import com.volmit.iris.util.math.Position2;
import com.volmit.iris.util.math.RNG;
import com.volmit.iris.util.matter.MatterCavern;
import com.volmit.iris.util.matter.MatterUpdate;
import com.volmit.iris.util.matter.TileWrapper;
import com.volmit.iris.util.parallel.BurstExecutor;
import com.volmit.iris.util.parallel.MultiBurst;
import com.volmit.iris.util.scheduling.ChronoLatch;
@@ -262,11 +250,6 @@ public interface Engine extends DataProvider, Fallible, LootProvider, BlockUpdat
}
}
@ChunkCoordinates
default void placeTiles(Chunk c) {
}
void blockUpdatedMetric();
@ChunkCoordinates
@@ -280,6 +263,15 @@ public interface Engine extends DataProvider, Fallible, LootProvider, BlockUpdat
&& c.getWorld().isChunkLoaded(c.getX() - 1, c.getZ())
&& c.getWorld().isChunkLoaded(c.getX() + 1, c.getZ() - 1)
&& c.getWorld().isChunkLoaded(c.getX() - 1, c.getZ() + 1) && getMantle().getMantle().isLoaded(c)) {
getMantle().getMantle().raiseFlag(c.getX(), c.getZ(), MantleFlag.TILE, () -> J.s(() -> {
getMantle().getMantle().iterateChunk(c.getX(), c.getZ(), TileWrapper.class, (x, y, z, tile) -> {
int betterY = y + getWorld().minHeight();
if(!TileData.setTileState(c.getBlock(x, betterY, z), tile.getData()))
Iris.warn("Failed to set tile entity data at [%d %d %d | %s] for tile %s!", x, betterY ,z, c.getBlock(x, betterY, z).getBlockData().getMaterial().getKey(), tile.getData().getTileId());
});
}));
getMantle().getMantle().raiseFlag(c.getX(), c.getZ(), MantleFlag.UPDATE, () -> J.s(() -> {
PrecisionStopwatch p = PrecisionStopwatch.start();
KMap<Long, Integer> updates = new KMap<>();

View File

@@ -38,10 +38,7 @@ import com.volmit.iris.util.hunk.Hunk;
import com.volmit.iris.util.mantle.Mantle;
import com.volmit.iris.util.mantle.MantleChunk;
import com.volmit.iris.util.mantle.MantleFlag;
import com.volmit.iris.util.matter.Matter;
import com.volmit.iris.util.matter.MatterCavern;
import com.volmit.iris.util.matter.MatterFluidBody;
import com.volmit.iris.util.matter.MatterMarker;
import com.volmit.iris.util.matter.*;
import com.volmit.iris.util.matter.slices.UpdateMatter;
import com.volmit.iris.util.parallel.BurstExecutor;
import com.volmit.iris.util.parallel.MultiBurst;
@@ -109,17 +106,14 @@ public interface EngineMantle extends IObjectPlacer {
@Override
default void setTile(int x, int y, int z, TileData<? extends TileState> d) {
// TODO SET TILE
getMantle().set(x, y, z, new TileWrapper(d));
}
@Override
default BlockData get(int x, int y, int z) {
BlockData block = getMantle().get(x, y, z, BlockData.class);
if(block == null) {
if(block == null)
return AIR;
}
return block;
}

View File

@@ -38,6 +38,7 @@ import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;
import org.bukkit.block.data.BlockData;
import org.bukkit.entity.EntityType;
import java.util.Map;
@@ -199,6 +200,19 @@ public class IrisBlockData extends IrisRegistrant {
});
}
public TileData<?> tryGetTile() {
//TODO Do like a registry thing with the tile data registry. Also update the parsing of data to include **block** entities.
if(data.containsKey("entitySpawn")) {
TileSpawner spawner = new TileSpawner();
String name = (String)data.get("entitySpawn");
if(name.contains(":"))
name = name.split(":")[1];
spawner.setEntityType(EntityType.fromName(name));
return spawner;
}
return null;
}
private String keyify(String dat) {
if(dat.contains(":")) {
return dat;

View File

@@ -228,8 +228,6 @@ public class IrisDimension extends IrisRegistrant {
private IrisMaterialPalette rockPalette = new IrisMaterialPalette().qclear().qadd("stone");
@Desc("The palette of blocks for 'water'")
private IrisMaterialPalette fluidPalette = new IrisMaterialPalette().qclear().qadd("water");
// @Desc("Cartographer map trade overrides")
// private IrisVillagerOverride patchCartographers = new IrisVillagerOverride().setDisableTrade(false);
@Desc("Remove cartographers so they do not crash the server (Iris worlds only)")
private boolean removeCartographersDueToCrash = true;
@Desc("Notify players of cancelled cartographer villager in this radius in blocks (set to -1 to disable, -2 for everyone)")
@@ -418,7 +416,7 @@ public class IrisDimension extends IrisRegistrant {
{
"pack": {
"description": "Iris Data Pack. This pack contains all installed Iris Packs' resources.",
"pack_format": 9
"pack_format": 10
}
}
""");
@@ -481,6 +479,8 @@ public class IrisDimension extends IrisRegistrant {
"bed_works": true,
"respawn_anchor_works": false,
"has_raids": true,
"monster_spawn_block_light_limit": 7,
"monster_spawn_light_level": 1,
"infiniburn": "#minecraft:infiniburn_overworld",
"effects": "minecraft:overworld"
}""";

View File

@@ -35,6 +35,8 @@ import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;
import java.util.Objects;
@Snippet("style")
@Accessors(chain = true)
@NoArgsConstructor
@@ -70,6 +72,10 @@ public class IrisGeneratorStyle {
@MaxNumber(64)
@Desc("The exponent")
private double exponent = 1;
@MinNumber(0)
@MaxNumber(8192)
@Desc("If the cache size is set above 0, this generator will be cached")
private int cacheSize = 0;
public IrisGeneratorStyle(NoiseStyle s) {
this.style = s;
@@ -81,6 +87,18 @@ public class IrisGeneratorStyle {
}
public CNG createNoCache(RNG rng, IrisData data) {
return createNoCache(rng, data, false);
}
private int hash()
{
return Objects.hash(expression, imageMap, multiplier, axialFracturing, fracture != null ? fracture.hash() : 0, exponent, cacheSize, zoom, cellularZoom, cellularFrequency, style);
}
public CNG createNoCache(RNG rng, IrisData data, boolean actuallyCached) {
String cacheKey = hash() + "";
if(getExpression() != null) {
IrisExpression e = data.getExpressionLoader().load(getExpression());
@@ -134,7 +152,7 @@ public class IrisGeneratorStyle {
}
public CNG create(RNG rng, IrisData data) {
return cng.aquire(() -> createNoCache(rng, data));
return cng.aquire(() -> createNoCache(rng, data, true));
}
@SuppressWarnings("BooleanMethodIsAlwaysInverted")

View File

@@ -46,7 +46,7 @@ import net.minecraft.nbt.TagParser;
import org.bukkit.DyeColor;
import org.bukkit.Material;
import org.bukkit.NamespacedKey;
import org.bukkit.craftbukkit.v1_18_R2.inventory.CraftItemStack;
import org.bukkit.craftbukkit.v1_19_R1.inventory.CraftItemStack;
import org.bukkit.inventory.ItemFlag;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.Damageable;

View File

@@ -34,6 +34,8 @@ import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;
import org.bukkit.block.data.BlockData;
import java.util.Optional;
@Snippet("palette")
@Accessors(chain = true)
@NoArgsConstructor
@@ -66,6 +68,14 @@ public class IrisMaterialPalette {
return getLayerGenerator(rng, rdata).fit(getBlockData(rdata), x / zoom, y / zoom, z / zoom);
}
public Optional<TileData<?>> getTile(RNG rng, double x, double y, double z, IrisData rdata) {
if(getBlockData(rdata).isEmpty())
return Optional.empty();
TileData<?> tile = getBlockData(rdata).size() == 1 ? palette.get(0).tryGetTile() : palette.getRandom(rng).tryGetTile();
return tile != null ? Optional.of(tile) : Optional.empty();
}
public CNG getLayerGenerator(RNG rng, IrisData rdata) {
return layerGenerator.aquire(() ->
{

View File

@@ -34,8 +34,6 @@ import com.volmit.iris.util.math.AxisAlignedBB;
import com.volmit.iris.util.math.BlockPosition;
import com.volmit.iris.util.math.Position2;
import com.volmit.iris.util.math.RNG;
import com.volmit.iris.util.matter.IrisMatter;
import com.volmit.iris.util.matter.Matter;
import com.volmit.iris.util.matter.MatterMarker;
import com.volmit.iris.util.parallel.BurstExecutor;
import com.volmit.iris.util.parallel.MultiBurst;
@@ -65,11 +63,7 @@ import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.*;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.function.Consumer;
@@ -512,7 +506,9 @@ public class IrisObject extends IrisRegistrant {
}
boolean warped = !config.getWarp().isFlat();
boolean stilting = (config.getMode().equals(ObjectPlaceMode.STILT) || config.getMode().equals(ObjectPlaceMode.FAST_STILT));
boolean stilting = (config.getMode().equals(ObjectPlaceMode.STILT) || config.getMode().equals(ObjectPlaceMode.FAST_STILT) ||
config.getMode() == ObjectPlaceMode.MIN_STILT || config.getMode() == ObjectPlaceMode.FAST_MIN_STILT ||
config.getMode() == ObjectPlaceMode.CENTER_STILT);
KMap<Position2, Integer> heightmap = config.getSnow() > 0 ? new KMap<>() : null;
int spinx = rng.imax() / 1000;
int spiny = rng.imax() / 1000;
@@ -526,7 +522,7 @@ public class IrisObject extends IrisRegistrant {
boolean bail = false;
if(yv < 0) {
if(config.getMode().equals(ObjectPlaceMode.CENTER_HEIGHT)) {
if(config.getMode().equals(ObjectPlaceMode.CENTER_HEIGHT) || config.getMode() == ObjectPlaceMode.CENTER_STILT) {
y = (c != null ? c.getSurface() : placer.getHighest(x, z, getLoader(), config.isUnderwater())) + rty;
if(placer.isCarved(x, y, z) || placer.isCarved(x, y - 1, z) || placer.isCarved(x, y - 2, z) || placer.isCarved(x, y - 3, z)) {
bail = true;
@@ -534,48 +530,62 @@ public class IrisObject extends IrisRegistrant {
} else if(config.getMode().equals(ObjectPlaceMode.MAX_HEIGHT) || config.getMode().equals(ObjectPlaceMode.STILT)) {
BlockVector offset = new BlockVector(config.getTranslate().getX(), config.getTranslate().getY(), config.getTranslate().getZ());
BlockVector rotatedDimensions = config.getRotation().rotate(new BlockVector(getW(), getH(), getD()), spinx, spiny, spinz).clone();
for(int i = x - (rotatedDimensions.getBlockX() / 2) + offset.getBlockX(); i <= x + (rotatedDimensions.getBlockX() / 2) + offset.getBlockX(); i++) {
for(int j = z - (rotatedDimensions.getBlockZ() / 2) + offset.getBlockZ(); j <= z + (rotatedDimensions.getBlockZ() / 2) + offset.getBlockZ(); j++) {
int h = placer.getHighest(i, j, getLoader(), config.isUnderwater()) + rty;
if(placer.isCarved(i, h, j) || placer.isCarved(i, h - 1, j) || placer.isCarved(i, h - 2, j) || placer.isCarved(i, h - 3, j)) {
int xLength = (rotatedDimensions.getBlockX() / 2) + offset.getBlockX();
int minX = Math.min(x - xLength, x + xLength);
int maxX = Math.max(x - xLength, x + xLength);
int zLength = (rotatedDimensions.getBlockZ() / 2) + offset.getBlockZ();
int minZ = Math.min(z - zLength, z + zLength);
int maxZ = Math.max(z - zLength, z + zLength);
for(int i = minX; i <= maxX; i++) {
for(int ii = minZ; ii <= maxZ; ii++) {
int h = placer.getHighest(i, ii, getLoader(), config.isUnderwater()) + rty;
if(placer.isCarved(i, h, ii) || placer.isCarved(i, h - 1, ii) || placer.isCarved(i, h - 2, ii) || placer.isCarved(i, h - 3, ii)) {
bail = true;
break;
}
if(h > y) {
if(h > y)
y = h;
}
}
}
} else if(config.getMode().equals(ObjectPlaceMode.FAST_MAX_HEIGHT) || config.getMode().equals(ObjectPlaceMode.FAST_STILT)) {
BlockVector offset = new BlockVector(config.getTranslate().getX(), config.getTranslate().getY(), config.getTranslate().getZ());
BlockVector rotatedDimensions = config.getRotation().rotate(new BlockVector(getW(), getH(), getD()), spinx, spiny, spinz).clone();
for(int i = x - (rotatedDimensions.getBlockX() / 2) + offset.getBlockX(); i <= x + (rotatedDimensions.getBlockX() / 2) + offset.getBlockX(); i += (rotatedDimensions.getBlockX() / 2) + 1) {
for(int j = z - (rotatedDimensions.getBlockZ() / 2) + offset.getBlockZ(); j <= z + (rotatedDimensions.getBlockZ() / 2) + offset.getBlockZ(); j += (rotatedDimensions.getBlockZ() / 2) + 1) {
int h = placer.getHighest(i, j, getLoader(), config.isUnderwater()) + rty;
int xRadius = (rotatedDimensions.getBlockX() / 2);
int xLength = xRadius + offset.getBlockX();
int minX = Math.min(x - xLength, x + xLength);
int maxX = Math.max(x - xLength, x + xLength);
int zRadius = (rotatedDimensions.getBlockZ() / 2);
int zLength = zRadius + offset.getBlockZ();
int minZ = Math.min(z - zLength, z + zLength);
int maxZ = Math.max(z - zLength, z + zLength);
if(placer.isCarved(i, h, j) || placer.isCarved(i, h - 1, j) || placer.isCarved(i, h - 2, j) || placer.isCarved(i, h - 3, j)) {
for(int i = minX; i <= maxX; i += Math.abs(xRadius) + 1) {
for(int ii = minZ; ii <= maxZ; ii += Math.abs(zRadius) + 1) {
int h = placer.getHighest(i, ii, getLoader(), config.isUnderwater()) + rty;
if(placer.isCarved(i, h, ii) || placer.isCarved(i, h - 1, ii) || placer.isCarved(i, h - 2, ii) || placer.isCarved(i, h - 3, ii)) {
bail = true;
break;
}
if(h > y) {
if(h > y)
y = h;
}
}
}
} else if(config.getMode().equals(ObjectPlaceMode.MIN_HEIGHT)) {
y = 257;
} else if(config.getMode().equals(ObjectPlaceMode.MIN_HEIGHT) || config.getMode() == ObjectPlaceMode.MIN_STILT) {
y = rdata.getEngine().getHeight() + 1;
BlockVector offset = new BlockVector(config.getTranslate().getX(), config.getTranslate().getY(), config.getTranslate().getZ());
BlockVector rotatedDimensions = config.getRotation().rotate(new BlockVector(getW(), getH(), getD()), spinx, spiny, spinz).clone();
for(int i = x - (rotatedDimensions.getBlockX() / 2) + offset.getBlockX(); i <= x + (rotatedDimensions.getBlockX() / 2) + offset.getBlockX(); i++) {
for(int j = z - (rotatedDimensions.getBlockZ() / 2) + offset.getBlockZ(); j <= z + (rotatedDimensions.getBlockZ() / 2) + offset.getBlockZ(); j++) {
int h = placer.getHighest(i, j, getLoader(), config.isUnderwater()) + rty;
if(placer.isCarved(i, h, j) || placer.isCarved(i, h - 1, j) || placer.isCarved(i, h - 2, j) || placer.isCarved(i, h - 3, j)) {
int xLength = (rotatedDimensions.getBlockX() / 2) + offset.getBlockX();
int minX = Math.min(x - xLength, x + xLength);
int maxX = Math.max(x - xLength, x + xLength);
int zLength = (rotatedDimensions.getBlockZ() / 2) + offset.getBlockZ();
int minZ = Math.min(z - zLength, z + zLength);
int maxZ = Math.max(z - zLength, z + zLength);
for(int i = minX; i <= maxX; i++) {
for(int ii = minZ; ii <= maxZ; ii++) {
int h = placer.getHighest(i, ii, getLoader(), config.isUnderwater()) + rty;
if(placer.isCarved(i, h, ii) || placer.isCarved(i, h - 1, ii) || placer.isCarved(i, h - 2, ii) || placer.isCarved(i, h - 3, ii)) {
bail = true;
break;
}
@@ -584,15 +594,24 @@ public class IrisObject extends IrisRegistrant {
}
}
}
} else if(config.getMode().equals(ObjectPlaceMode.FAST_MIN_HEIGHT)) {
y = 257;
} else if(config.getMode().equals(ObjectPlaceMode.FAST_MIN_HEIGHT) || config.getMode() == ObjectPlaceMode.FAST_MIN_STILT) {
y = rdata.getEngine().getHeight() + 1;
BlockVector offset = new BlockVector(config.getTranslate().getX(), config.getTranslate().getY(), config.getTranslate().getZ());
BlockVector rotatedDimensions = config.getRotation().rotate(new BlockVector(getW(), getH(), getD()), spinx, spiny, spinz).clone();
for(int i = x - (rotatedDimensions.getBlockX() / 2) + offset.getBlockX(); i <= x + (rotatedDimensions.getBlockX() / 2) + offset.getBlockX(); i += (rotatedDimensions.getBlockX() / 2) + 1) {
for(int j = z - (rotatedDimensions.getBlockZ() / 2) + offset.getBlockZ(); j <= z + (rotatedDimensions.getBlockZ() / 2) + offset.getBlockZ(); j += (rotatedDimensions.getBlockZ() / 2) + 1) {
int h = placer.getHighest(i, j, getLoader(), config.isUnderwater()) + rty;
if(placer.isCarved(i, h, j) || placer.isCarved(i, h - 1, j) || placer.isCarved(i, h - 2, j) || placer.isCarved(i, h - 3, j)) {
int xRadius = (rotatedDimensions.getBlockX() / 2);
int xLength = xRadius + offset.getBlockX();
int minX = Math.min(x - xLength, x + xLength);
int maxX = Math.max(x - xLength, x + xLength);
int zRadius = (rotatedDimensions.getBlockZ() / 2);
int zLength = zRadius + offset.getBlockZ();
int minZ = Math.min(z - zLength, z + zLength);
int maxZ = Math.max(z - zLength, z + zLength);
for(int i = minX; i <= maxX; i += Math.abs(xRadius) + 1) {
for(int ii = minZ; ii <= maxZ; ii += Math.abs(zRadius) + 1) {
int h = placer.getHighest(i, ii, getLoader(), config.isUnderwater()) + rty;
if(placer.isCarved(i, h, ii) || placer.isCarved(i, h - 1, ii) || placer.isCarved(i, h - 2, ii) || placer.isCarved(i, h - 3, ii)) {
bail = true;
break;
}
@@ -733,10 +752,16 @@ public class IrisObject extends IrisRegistrant {
if(j.isExact() ? k.matches(data) : k.getMaterial().equals(data.getMaterial())) {
BlockData newData = j.getReplace(rng, i.getX() + x, i.getY() + y, i.getZ() + z, rdata).clone();
if(newData.getMaterial() == data.getMaterial()) {
if(newData.getMaterial() == data.getMaterial())
data = data.merge(newData);
} else {
else
data = newData;
if(newData.getMaterial() == Material.SPAWNER) {
Optional<TileData<?>> t = j.getReplace().getTile(rng, x, y, z, rdata);
if(t.isPresent()) {
tile = t.get();
}
}
}
}
@@ -745,6 +770,7 @@ public class IrisObject extends IrisRegistrant {
data = config.getRotation().rotate(data, spinx, spiny, spinz);
xx = x + (int) Math.round(i.getX());
int yy = y + (int) Math.round(i.getY());
zz = z + (int) Math.round(i.getZ());
@@ -787,7 +813,6 @@ public class IrisObject extends IrisRegistrant {
if(!data.getMaterial().equals(Material.AIR) && !data.getMaterial().equals(Material.CAVE_AIR)) {
placer.set(xx, yy, zz, data);
if(tile != null) {
placer.setTile(xx, yy, zz, tile);
}
@@ -800,21 +825,26 @@ public class IrisObject extends IrisRegistrant {
if(stilting) {
readLock.lock();
IrisStiltSettings settings = config.getStiltSettings();
for(BlockVector g : getBlocks().keySet()) {
BlockData d;
try {
d = getBlocks().get(g);
} catch(Throwable e) {
Iris.reportError(e);
Iris.warn("Failed to read block node " + g.getBlockX() + "," + g.getBlockY() + "," + g.getBlockZ() + " in object " + getLoadKey() + " (stilt cme)");
d = AIR;
}
if(settings == null || settings.getPalette() == null) {
try {
d = getBlocks().get(g);
} catch(Throwable e) {
Iris.reportError(e);
Iris.warn("Failed to read block node " + g.getBlockX() + "," + g.getBlockY() + "," + g.getBlockZ() + " in object " + getLoadKey() + " (stilt cme)");
d = AIR;
}
if(d == null) {
Iris.warn("Failed to read block node " + g.getBlockX() + "," + g.getBlockY() + "," + g.getBlockZ() + " in object " + getLoadKey() + " (stilt null)");
d = AIR;
}
} else
d = config.getStiltSettings().getPalette().get(rng, x, y, z, rdata);
if(d == null) {
Iris.warn("Failed to read block node " + g.getBlockX() + "," + g.getBlockY() + "," + g.getBlockZ() + " in object " + getLoadKey() + " (stilt null)");
d = AIR;
}
BlockVector i = g.clone();
i = config.getRotation().rotate(i.clone(), spinx, spiny, spinz).clone();
@@ -850,19 +880,22 @@ public class IrisObject extends IrisRegistrant {
zz += config.warp(rng, i.getZ() + z, i.getY() + y, i.getX() + x, getLoader());
}
int yg = placer.getHighest(xx, zz, getLoader(), true);
int highest = placer.getHighest(xx, zz, getLoader(), true);
if(config.isWaterloggable() && yg <= placer.getFluidHeight() && d instanceof Waterlogged) {
if(config.isWaterloggable() && highest <= placer.getFluidHeight() && d instanceof Waterlogged)
((Waterlogged) d).setWaterlogged(true);
}
if(yv >= 0 && config.isBottom()) {
if(yv >= 0 && config.isBottom())
y += Math.floorDiv(h, 2);
}
for(int j = lowest + y; j > yg - config.getOverStilt() - 1; j--) {
placer.set(xx, j, zz, d);
int lowerBound = highest - 1;
if(settings != null) {
lowerBound -= config.getStiltSettings().getOverStilt() - rng.i(0, config.getStiltSettings().getYRand());
if(settings.getYMax() != 0)
lowerBound -= Math.min(config.getStiltSettings().getYMax() - (lowest + y - highest), 0);
}
for(int j = lowest + y; j > lowerBound; j--)
placer.set(xx, j, zz, d);
}
readLock.unlock();

View File

@@ -75,10 +75,8 @@ public class IrisObjectPlacement {
private int density = 1;
@Desc("If the chance check passes, and you specify this, it picks a number in the range based on noise, and 'density' is ignored.")
private IrisStyledRange densityStyle = null;
@MaxNumber(64)
@MinNumber(0)
@Desc("If the place mode is set to stilt, you can over-stilt it even further into the ground. Especially useful when using fast stilt due to inaccuracies.")
private int overStilt = 0;
@Desc("When stilting is enabled, this object will define various properties related to it.")
private IrisStiltSettings stiltSettings;
@MaxNumber(64)
@MinNumber(0)
@Desc("When bore is enabled, expand max-y of the cuboid it removes")
@@ -146,7 +144,7 @@ public class IrisObjectPlacement {
p.setUnderwater(underwater);
p.setBoreExtendMaxY(boreExtendMaxY);
p.setBoreExtendMinY(boreExtendMinY);
p.setOverStilt(overStilt);
p.setStiltSettings(stiltSettings);
p.setDensity(density);
p.setChance(chance);
p.setSnow(snow);

View File

@@ -44,7 +44,7 @@ public class IrisObjectTranslate {
@Required
@MinNumber(-128) // TODO: WARNING HEIGHT
@MaxNumber(128) // TODO: WARNING HEIGHT
@Desc("The x shift in blocks")
@Desc("The y shift in blocks")
private int y = 0;
@MinNumber(-128) // TODO: WARNING HEIGHT
@@ -54,7 +54,7 @@ public class IrisObjectTranslate {
@MinNumber(-128) // TODO: WARNING HEIGHT
@MaxNumber(128) // TODO: WARNING HEIGHT
@Desc("The x shift in blocks")
@Desc("The z shift in blocks")
private int z = 0;
public boolean canTranslate() {

View File

@@ -0,0 +1,34 @@
package com.volmit.iris.engine.object;
import com.volmit.iris.engine.object.annotations.Desc;
import com.volmit.iris.engine.object.annotations.MaxNumber;
import com.volmit.iris.engine.object.annotations.MinNumber;
import com.volmit.iris.engine.object.annotations.Snippet;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;
@Snippet("stilt-settings")
@Accessors(chain = true)
@NoArgsConstructor
@AllArgsConstructor
@Desc("Defines stilting behaviour.")
@Data
public class IrisStiltSettings {
@MinNumber(0)
@MaxNumber(64)
@Desc("Defines the maximum amount of blocks the object stilts verticially before overstilting and randomRange.")
private int yMax;
@MinNumber(0)
@MaxNumber(64)
@Desc("Defines the upper boundary for additional blocks after overstilting and/or maxStiltRange.")
private int yRand;
@MaxNumber(64)
@MinNumber(0)
@Desc("If the place mode is set to stilt, you can over-stilt it even further into the ground. Especially useful when using fast stilt due to inaccuracies.")
private int overStilt;
@Desc("If defined, stilting will be done using this block palette rather than the last layer of the object.")
private IrisMaterialPalette palette;
}

View File

@@ -50,6 +50,18 @@ public enum ObjectPlaceMode {
FAST_STILT,
@Desc("Stilting is MIN_HEIGHT but it repeats the bottom most block of your object until it hits the surface. This is expensive because it has to first sample every height value for each x,z position of your object. Avoid using this unless its structures for performance reasons.")
MIN_STILT,
@Desc("Just like MIN_STILT but very inaccurate. Useful for stilting a lot of objects without too much care on accuracy (you can use the over-stilt value to force stilts under ground further)")
FAST_MIN_STILT,
@Desc("Stilting is CENTER_HEIGHT but it repeats the bottom most block of your object until it hits the surface. This is expensive because it has to first sample every height value for each x,z position of your object. Avoid using this unless its structures for performance reasons.")
CENTER_STILT,
@Desc("Samples the height of the terrain at every x,z position of your object and pushes it down to the surface. It's pretty much like a melt function over the terrain.")
PAINT

View File

@@ -98,7 +98,7 @@ public class TileBanner implements TileData<Banner> {
@SuppressWarnings("deprecation")
@Override
public void toNBT(CompoundTag tag) {
public CompoundTag toNBT(CompoundTag tag) {
@SuppressWarnings("unchecked") ListTag<CompoundTag> listTag = (ListTag<CompoundTag>) ListTag.createUnchecked(CompoundTag.class);
for(Pattern p : patterns) {
CompoundTag pattern = new CompoundTag();
@@ -107,6 +107,7 @@ public class TileBanner implements TileData<Banner> {
listTag.add(pattern);
}
tag.put("Patterns", listTag);
return tag;
}
public boolean isBanner(Material material) {

View File

@@ -29,11 +29,12 @@ import org.bukkit.block.data.BlockData;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import java.lang.reflect.InvocationTargetException;
@SuppressWarnings("ALL")
public interface TileData<T extends TileState> extends Cloneable {
KList<TileData<? extends TileState>> registry = setup();
static final KList<TileData<? extends TileState>> registry = setup();
static KList<TileData<? extends TileState>> setup() {
KList<TileData<? extends TileState>> registry = new KList<>();
@@ -45,17 +46,21 @@ public interface TileData<T extends TileState> extends Cloneable {
return registry;
}
static TileData<? extends TileState> read(DataInputStream s) throws Throwable {
int id = s.readShort();
@SuppressWarnings("unchecked") TileData<? extends TileState> d = registry.get(id).getClass().getConstructor().newInstance();
d.fromBinary(s);
return d;
static TileData<? extends TileState> read(DataInputStream s) throws IOException {
try {
int id = s.readShort();
@SuppressWarnings("unchecked") TileData<? extends TileState> d = registry.get(id).getClass().getConstructor().newInstance();
d.fromBinary(s);
return d;
} catch(InvocationTargetException | InstantiationException | IllegalAccessException | NoSuchMethodException e) {
throw new IOException("Failed to create TileData instance due to missing type registrar!");
}
}
static void setTileState(Block block, TileData<? extends TileState> data) {
if(data.isApplicable(block.getBlockData())) {
data.toBukkitTry(block.getState());
}
static boolean setTileState(Block block, TileData<? extends TileState> data) {
if(block.getState() instanceof TileState && data.isApplicable(block.getBlockData()))
return data.toBukkitTry(block.getState());
return false;
}
static TileData<? extends TileState> getTileState(Block block) {
@@ -89,6 +94,7 @@ public interface TileData<T extends TileState> extends Cloneable {
try {
//noinspection unchecked
toBukkit((T) t);
t.update();
return true;
} catch(Throwable e) {
Iris.reportError(e);
@@ -111,11 +117,11 @@ public interface TileData<T extends TileState> extends Cloneable {
return false;
}
TileData<T> clone();
CompoundTag toNBT(CompoundTag parent);
void toBinary(DataOutputStream out) throws IOException;
void toNBT(CompoundTag tag);
void fromBinary(DataInputStream in) throws IOException;
TileData<T> clone();
}

View File

@@ -98,11 +98,12 @@ public class TileSign implements TileData<Sign> {
}
@Override
public void toNBT(CompoundTag tag) {
public CompoundTag toNBT(CompoundTag tag) {
tag.putString("Text1", line1);
tag.putString("Text2", line2);
tag.putString("Text3", line3);
tag.putString("Text4", line4);
tag.putString("Color", dyeColor.name().toLowerCase());
return tag;
}
}

View File

@@ -32,12 +32,13 @@ import java.io.IOException;
@Data
public class TileSpawner implements TileData<CreatureSpawner> {
public static final int id = 1;
private EntityType entityType;
public static final int id = 1;
private EntityType entityType;
@Override
public String getTileId() {
return "minecraft:spawner";
return "minecraft:mob_spawner";
}
@Override
@@ -75,7 +76,7 @@ public class TileSpawner implements TileData<CreatureSpawner> {
}
@Override
public void toNBT(CompoundTag tag) {
public CompoundTag toNBT(CompoundTag parent) {
@SuppressWarnings("unchecked") ListTag<CompoundTag> potentials = (ListTag<CompoundTag>) ListTag.createUnchecked(CompoundTag.class);
CompoundTag t = new CompoundTag();
CompoundTag ent = new CompoundTag();
@@ -83,6 +84,7 @@ public class TileSpawner implements TileData<CreatureSpawner> {
t.put("Entity", ent);
t.putInt("Weight", 1);
potentials.add(t);
tag.put("SpawnPotentials", potentials);
parent.put("SpawnPotentials", potentials);
return parent;
}
}

View File

@@ -31,11 +31,15 @@ import com.volmit.iris.engine.object.StudioMode;
import com.volmit.iris.engine.platform.studio.StudioGenerator;
import com.volmit.iris.util.collection.KList;
import com.volmit.iris.util.data.IrisBiomeStorage;
import com.volmit.iris.util.format.Form;
import com.volmit.iris.util.hunk.Hunk;
import com.volmit.iris.util.hunk.view.BiomeGridHunkHolder;
import com.volmit.iris.util.hunk.view.ChunkDataHunkHolder;
import com.volmit.iris.util.io.ReactiveFolder;
import com.volmit.iris.util.scheduling.ChronoLatch;
import com.volmit.iris.util.scheduling.J;
import com.volmit.iris.util.scheduling.Looper;
import com.volmit.iris.util.scheduling.PrecisionStopwatch;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.Setter;
@@ -64,7 +68,7 @@ import java.util.function.Consumer;
@EqualsAndHashCode(callSuper = true)
@Data
public class BukkitChunkGenerator extends ChunkGenerator implements PlatformChunkGenerator {
private static final int LOAD_LOCKS = 1_000_000;
private static final int LOAD_LOCKS = Runtime.getRuntime().availableProcessors() * 4;
private final Semaphore loadLock;
private final IrisWorld world;
private final File dataLocation;
@@ -278,9 +282,11 @@ public class BukkitChunkGenerator extends ChunkGenerator implements PlatformChun
if(studioGenerator != null) {
studioGenerator.generateChunk(getEngine(), tc, x, z);
} else {
Hunk<BlockData> blocks = Hunk.view(tc);
Hunk<Biome> biomes = Hunk.view(tc, tc.getMinHeight(), tc.getMaxHeight());
ChunkDataHunkHolder blocks = new ChunkDataHunkHolder(tc);
BiomeGridHunkHolder biomes = new BiomeGridHunkHolder(tc, tc.getMinHeight(), tc.getMaxHeight());
getEngine().generate(x << 4, z << 4, blocks, biomes, true);
blocks.apply();
biomes.apply();
}
ChunkData c = tc.getRaw();

View File

@@ -0,0 +1,82 @@
/*
* Iris is a World Generator for Minecraft Bukkit Servers
* Copyright (c) 2022 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.cache;
import com.volmit.iris.engine.data.cache.Cache;
import com.volmit.iris.util.hunk.bits.Writable;
import java.io.DataInput;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
public interface ArrayCache<T> extends Writable<T> {
T get(int i);
void set(int i, T t);
void iset(int i, int v);
int getWidth();
int getHeight();
void writeCache(DataOutputStream dos) throws IOException;
static int zigZag(int coord, int size)
{
if(coord < 0)
{
coord = Math.abs(coord);
}
if(coord % (size * 2) >= size)
{
return (size) - (coord % size) - 1;
}
else {
return coord % size;
}
}
default void set(int x, int y, T v)
{
set((zigZag(y, getHeight()) * getWidth()) + zigZag(x, getWidth()), v);
}
default T get(int x, int y)
{
try
{
return get((zigZag(y, getHeight()) * getWidth()) + zigZag(x, getWidth()));
}
catch(Throwable e)
{
e.printStackTrace();
throw e;
}
}
default void iset(int x, int y, int v)
{
iset((zigZag(y, getHeight()) * getWidth()) + zigZag(x, getWidth()), v);
}
}

View File

@@ -0,0 +1,44 @@
/*
* Iris is a World Generator for Minecraft Bukkit Servers
* Copyright (c) 2022 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.cache;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
public class ByteBitCache extends DataBitCache<Integer> {
public ByteBitCache(int width, int height) {
super(width, height);
}
@Override
public Integer readNodeData(DataInputStream din) throws IOException {
return (int) din.readByte();
}
@Override
public void writeNodeData(DataOutputStream dos, Integer integer) throws IOException {
dos.writeByte(integer);
}
@Override
public void iset(int i, int v) {
set(i, v);
}
}

View File

@@ -0,0 +1,76 @@
/*
* Iris is a World Generator for Minecraft Bukkit Servers
* Copyright (c) 2022 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.cache;
import lombok.Getter;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
public class ByteCache implements ArrayCache<Integer> {
@Getter
private final int width;
@Getter
private final int height;
private final byte[] cache;
public ByteCache(int width, int height)
{
this.width = width;
this.height = height;
cache = new byte[width * height];
}
public void set(int i, Integer v)
{
cache[i] = v.byteValue();
}
public Integer get(int i)
{
return (int)cache[i];
}
@Override
public void writeCache(DataOutputStream dos) throws IOException {
dos.writeInt(width);
dos.writeInt(height);
for(int i = 0; i < width * height; i++)
{
dos.writeByte(get(i));
}
}
@Override
public Integer readNodeData(DataInputStream din) throws IOException {
return (int) din.readByte();
}
@Override
public void writeNodeData(DataOutputStream dos, Integer integer) throws IOException {
dos.writeByte(integer);
}
@Override
public void iset(int i, int v) {
set(i, v);
}
}

View File

@@ -0,0 +1,58 @@
/*
* Iris is a World Generator for Minecraft Bukkit Servers
* Copyright (c) 2022 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.cache;
import com.volmit.iris.util.hunk.bits.DataContainer;
import lombok.Getter;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
public abstract class DataBitCache<T> implements ArrayCache<T> {
@Getter
private final int width;
@Getter
private final int height;
private final DataContainer<T> cache;
public DataBitCache(int width, int height)
{
this.width = width;
this.height = height;
cache = new DataContainer<>(this, width * height);
}
public void set(int i, T v)
{
cache.set(i, v);
}
public T get(int i)
{
return cache.get(i);
}
@Override
public void writeCache(DataOutputStream dos) throws IOException {
dos.writeInt(width);
dos.writeInt(height);
cache.writeDos(dos);
}
}

View File

@@ -0,0 +1,44 @@
/*
* Iris is a World Generator for Minecraft Bukkit Servers
* Copyright (c) 2022 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.cache;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
public class FloatBitCache extends DataBitCache<Float> {
public FloatBitCache(int width, int height) {
super(width, height);
}
@Override
public Float readNodeData(DataInputStream din) throws IOException {
return din.readFloat();
}
@Override
public void writeNodeData(DataOutputStream dos, Float integer) throws IOException {
dos.writeFloat(integer);
}
@Override
public void iset(int i, int v) {
set(i, (float)v);
}
}

View File

@@ -0,0 +1,93 @@
/*
* Iris is a World Generator for Minecraft Bukkit Servers
* Copyright (c) 2022 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.cache;
import lombok.Getter;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
public class FloatCache implements ArrayCache<Float> {
@Getter
private final int width;
@Getter
private final int height;
private final float[] cache;
public FloatCache(File file) throws IOException {
this(new DataInputStream(new FileInputStream(file)));
}
public FloatCache(DataInputStream din) throws IOException {
this(din.readInt(), din.readInt());
for(int i = 0; i < width * height; i++)
{
cache[i] = din.readFloat();
}
din.close();
}
public FloatCache(int width, int height)
{
this.width = width;
this.height = height;
cache = new float[width * height];
}
public void set(int i, Float v)
{
cache[i] = v;
}
public Float get(int i)
{
return cache[i];
}
@Override
public void writeCache(DataOutputStream dos) throws IOException {
dos.writeInt(width);
dos.writeInt(height);
for(int i = 0; i < width * height; i++)
{
dos.writeFloat(get(i));
}
}
@Override
public Float readNodeData(DataInputStream din) throws IOException {
return din.readFloat();
}
@Override
public void writeNodeData(DataOutputStream dos, Float integer) throws IOException {
dos.writeFloat(integer);
}
@Override
public void iset(int i, int v) {
set(i, (float) v);
}
}

View File

@@ -0,0 +1,44 @@
/*
* Iris is a World Generator for Minecraft Bukkit Servers
* Copyright (c) 2022 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.cache;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
public class IntBitCache extends DataBitCache<Integer> {
public IntBitCache(int width, int height) {
super(width, height);
}
@Override
public Integer readNodeData(DataInputStream din) throws IOException {
return din.readInt();
}
@Override
public void writeNodeData(DataOutputStream dos, Integer integer) throws IOException {
dos.writeInt(integer);
}
@Override
public void iset(int i, int v) {
set(i, v);
}
}

View File

@@ -0,0 +1,78 @@
/*
* Iris is a World Generator for Minecraft Bukkit Servers
* Copyright (c) 2022 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.cache;
import com.volmit.iris.util.hunk.bits.DataContainer;
import com.volmit.iris.util.hunk.bits.Writable;
import lombok.Getter;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
public class IntCache implements ArrayCache<Integer> {
@Getter
private final int width;
@Getter
private final int height;
private final int[] cache;
public IntCache(int width, int height)
{
this.width = width;
this.height = height;
cache = new int[width * height];
}
public void set(int i, Integer v)
{
cache[i] = v;
}
public Integer get(int i)
{
return cache[i];
}
@Override
public void writeCache(DataOutputStream dos) throws IOException {
dos.writeInt(width);
dos.writeInt(height);
for(int i = 0; i < width * height; i++)
{
dos.writeInt(get(i));
}
}
@Override
public Integer readNodeData(DataInputStream din) throws IOException {
return din.readInt();
}
@Override
public void writeNodeData(DataOutputStream dos, Integer integer) throws IOException {
dos.writeInt(integer);
}
@Override
public void iset(int i, int v) {
set(i, v);
}
}

View File

@@ -0,0 +1,44 @@
/*
* Iris is a World Generator for Minecraft Bukkit Servers
* Copyright (c) 2022 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.cache;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
public class ShortBitCache extends DataBitCache<Short> {
public ShortBitCache(int width, int height) {
super(width, height);
}
@Override
public Short readNodeData(DataInputStream din) throws IOException {
return din.readShort();
}
@Override
public void writeNodeData(DataOutputStream dos, Short integer) throws IOException {
dos.writeShort(integer);
}
@Override
public void iset(int i, int v) {
set(i, (short) v);
}
}

View File

@@ -0,0 +1,76 @@
/*
* Iris is a World Generator for Minecraft Bukkit Servers
* Copyright (c) 2022 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.cache;
import lombok.Getter;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
public class ShortCache implements ArrayCache<Short> {
@Getter
private final int width;
@Getter
private final int height;
private final short[] cache;
public ShortCache(int width, int height)
{
this.width = width;
this.height = height;
cache = new short[width * height];
}
public void set(int i, Short v)
{
cache[i] = v;
}
public Short get(int i)
{
return cache[i];
}
@Override
public void writeCache(DataOutputStream dos) throws IOException {
dos.writeInt(width);
dos.writeInt(height);
for(int i = 0; i < width * height; i++)
{
dos.writeShort(get(i));
}
}
@Override
public Short readNodeData(DataInputStream din) throws IOException {
return din.readShort();
}
@Override
public void writeNodeData(DataOutputStream dos, Short integer) throws IOException {
dos.writeShort(integer);
}
@Override
public void iset(int i, int v) {
set(i, (short) v);
}
}

View File

@@ -0,0 +1,40 @@
/*
* Iris is a World Generator for Minecraft Bukkit Servers
* Copyright (c) 2022 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.cache;
public class UByteBitCache extends ByteBitCache {
public UByteBitCache(int width, int height) {
super(width, height);
}
@Override
public void set(int i, Integer v) {
super.set(i, v + Byte.MIN_VALUE);
}
@Override
public Integer get(int i) {
return super.get(i) - Byte.MIN_VALUE;
}
@Override
public void iset(int i, int v) {
set(i, v);
}
}

View File

@@ -0,0 +1,40 @@
/*
* Iris is a World Generator for Minecraft Bukkit Servers
* Copyright (c) 2022 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.cache;
public class UByteCache extends ByteCache {
public UByteCache(int width, int height) {
super(width, height);
}
@Override
public void set(int i, Integer v) {
super.set(i, v + Byte.MIN_VALUE);
}
@Override
public Integer get(int i) {
return super.get(i) - Byte.MIN_VALUE;
}
@Override
public void iset(int i, int v) {
set(i, v);
}
}

View File

@@ -0,0 +1,86 @@
/*
* Iris is a World Generator for Minecraft Bukkit Servers
* Copyright (c) 2022 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.hunk.view;
import com.volmit.iris.core.nms.INMS;
import com.volmit.iris.engine.data.chunk.LinkedTerrainChunk;
import com.volmit.iris.util.hunk.storage.AtomicHunk;
import lombok.Getter;
import org.bukkit.block.Biome;
import org.bukkit.generator.ChunkGenerator.BiomeGrid;
@SuppressWarnings("ClassCanBeRecord")
public class BiomeGridHunkHolder extends AtomicHunk<Biome> {
@Getter
private final BiomeGrid chunk;
private final int minHeight;
private final int maxHeight;
public BiomeGridHunkHolder(BiomeGrid chunk, int minHeight, int maxHeight) {
super(16, maxHeight - minHeight, 16);
this.chunk = chunk;
this.minHeight = minHeight;
this.maxHeight = maxHeight;
}
@Override
public int getWidth() {
return 16;
}
@Override
public int getDepth() {
return 16;
}
@Override
public int getHeight() {
return maxHeight - minHeight;
}
public void apply() {
for(int i = 0; i < getHeight(); i++) {
for(int j = 0; j < getWidth(); j++) {
for(int k = 0; k < getDepth(); k++) {
Biome b = super.getRaw(j, i, k);
if(b != null)
{
chunk.setBiome(j, i + minHeight, k, b);
}
}
}
}
}
@Override
public Biome getRaw(int x, int y, int z) {
Biome b = super.getRaw(x, y, z);
return b != null ? b : Biome.PLAINS;
}
public void forceBiomeBaseInto(int x, int y, int z, Object somethingVeryDirty) {
if(chunk instanceof LinkedTerrainChunk) {
INMS.get().forceBiomeInto(x, y + minHeight, z, somethingVeryDirty, ((LinkedTerrainChunk) chunk).getRawBiome());
return;
}
INMS.get().forceBiomeInto(x, y + minHeight, z, somethingVeryDirty, chunk);
}
}

View File

@@ -18,6 +18,7 @@
package com.volmit.iris.util.hunk.view;
import com.volmit.iris.Iris;
import com.volmit.iris.core.nms.INMS;
import com.volmit.iris.engine.data.chunk.LinkedTerrainChunk;
import com.volmit.iris.util.hunk.Hunk;
@@ -31,6 +32,7 @@ public class BiomeGridHunkView implements Hunk<Biome> {
private final BiomeGrid chunk;
private final int minHeight;
private final int maxHeight;
private int highest = -1000;
public BiomeGridHunkView(BiomeGrid chunk, int minHeight, int maxHeight) {
this.chunk = chunk;
@@ -56,6 +58,12 @@ public class BiomeGridHunkView implements Hunk<Biome> {
@Override
public void setRaw(int x, int y, int z, Biome t) {
chunk.setBiome(x, y + minHeight, z, t);
if(y > highest)
{
highest = y;
Iris.info("Highest = " + highest);
}
}
@Override

View File

@@ -0,0 +1,76 @@
/*
* Iris is a World Generator for Minecraft Bukkit Servers
* Copyright (c) 2022 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.hunk.view;
import com.volmit.iris.util.hunk.Hunk;
import com.volmit.iris.util.hunk.storage.AtomicHunk;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.block.data.BlockData;
import org.bukkit.generator.ChunkGenerator.ChunkData;
import java.util.concurrent.atomic.AtomicReferenceArray;
@SuppressWarnings("ClassCanBeRecord")
public class ChunkDataHunkHolder extends AtomicHunk<BlockData> {
private static final BlockData AIR = Material.AIR.createBlockData();
private final ChunkData chunk;
public ChunkDataHunkHolder(ChunkData chunk) {
super(16, chunk.getMaxHeight() - chunk.getMinHeight(), 16);
this.chunk = chunk;
}
@Override
public int getWidth() {
return 16;
}
@Override
public int getDepth() {
return 16;
}
@Override
public int getHeight() {
return chunk.getMaxHeight() - chunk.getMinHeight();
}
@Override
public BlockData getRaw(int x, int y, int z) {
BlockData b = super.getRaw(x, y, z);
return b != null ? b : AIR;
}
public void apply() {
for(int i = 0; i < getHeight(); i++) {
for(int j = 0; j < getWidth(); j++) {
for(int k = 0; k < getDepth(); k++) {
BlockData b = super.getRaw(j, i, k);
if(b != null)
{
chunk.setBlock(j, i + chunk.getMinHeight(), k, b);
}
}
}
}
}
}

View File

@@ -32,7 +32,8 @@ public enum MantleFlag {
INITIAL_SPAWNED_MARKER,
CLEANED,
PLANNED,
ETCHED;
ETCHED,
TILE;
static StateList getStateList() {
return new StateList(MantleFlag.values());

View File

@@ -18,12 +18,10 @@
package com.volmit.iris.util.matter;
import com.volmit.iris.util.nbt.tag.CompoundTag;
import lombok.AllArgsConstructor;
import com.volmit.iris.engine.object.TileData;
import lombok.Data;
@Data
@AllArgsConstructor
public class MatterTile {
private final CompoundTag tileData;
public class TileWrapper {
private final TileData<?> data;
}

View File

@@ -33,8 +33,8 @@ public class WorldMatter {
matter.slice(MatterEntityGroup.class).writeInto(at);
}
if(matter.hasSlice(MatterTile.class)) {
matter.slice(MatterTile.class).writeInto(at);
if(matter.hasSlice(TileWrapper.class)) {
matter.slice(TileWrapper.class).writeInto(at);
}
}
@@ -45,7 +45,7 @@ public class WorldMatter {
s.getHeader().setAuthor(author);
s.slice(BlockData.class).readFrom(c.getLowerNE());
s.slice(MatterEntityGroup.class).readFrom(c.getLowerNE());
s.slice(MatterTile.class).readFrom(c.getLowerNE());
s.slice(TileWrapper.class).readFrom(c.getLowerNE());
s.trimSlices();
return s;

View File

@@ -18,11 +18,12 @@
package com.volmit.iris.util.matter.slices;
import com.volmit.iris.Iris;
import com.volmit.iris.core.nms.INMS;
import com.volmit.iris.engine.object.TileData;
import com.volmit.iris.util.data.palette.Palette;
import com.volmit.iris.util.matter.MatterTile;
import com.volmit.iris.util.matter.Sliced;
import com.volmit.iris.util.nbt.io.NBTUtil;
import com.volmit.iris.util.matter.TileWrapper;
import com.volmit.iris.util.nbt.tag.CompoundTag;
import org.bukkit.Location;
import org.bukkit.World;
@@ -31,43 +32,49 @@ import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
@SuppressWarnings("rawtypes")
@Sliced
public class TileMatter extends RawMatter<MatterTile> {
public static final MatterTile EMPTY = new MatterTile(new CompoundTag());
public class TileMatter extends RawMatter<TileWrapper> {
public TileMatter() {
this(1, 1, 1);
}
@Override
public Palette<MatterTile> getGlobalPalette() {
public Palette<TileWrapper> getGlobalPalette() {
return null;
}
public TileMatter(int width, int height, int depth) {
super(width, height, depth, MatterTile.class);
registerWriter(World.class, ((w, d, x, y, z) -> INMS.get().deserializeTile(d.getTileData(), new Location(w, x, y, z))));
super(width, height, depth, TileWrapper.class);
registerWriter(World.class, (w, d, x, y, z) -> {
CompoundTag tag = commonNbt(x, y, z, d.getData().getTileId());
INMS.get().deserializeTile(d.getData().toNBT(d.getData().toNBT(tag)), new Location(w, x, y, z));
Iris.warn("S: " + tag);
});
registerReader(World.class, (w, x, y, z) -> {
Location l = new Location(w, x, y, z);
if(INMS.get().hasTile(l)) {
CompoundTag tag = INMS.get().serializeTile(l);
if(tag != null) {
return new MatterTile(tag);
}
}
return null;
TileData d = TileData.getTileState(w.getBlockAt(new Location(w, x, y, z)));
if(d == null)
return null;
return new TileWrapper(d);
});
}
@Override
public void writeNode(MatterTile b, DataOutputStream dos) throws IOException {
NBTUtil.write(b.getTileData(), dos, false);
public void writeNode(TileWrapper b, DataOutputStream dos) throws IOException {
b.getData().toBinary(dos);
}
@Override
public MatterTile readNode(DataInputStream din) throws IOException {
return new MatterTile((CompoundTag) NBTUtil.read(din, false).getTag());
public TileWrapper readNode(DataInputStream din) throws IOException {
return new TileWrapper(TileData.read(din));
}
private CompoundTag commonNbt(int x, int y, int z, String mobId) {
CompoundTag tag = new CompoundTag();
tag.putInt("x", x);
tag.putInt("y", y);
tag.putInt("z", z);
tag.putBoolean("keepPacked", false);
tag.putString("id", mobId);
return tag;
}
}

View File

@@ -21,15 +21,25 @@ package com.volmit.iris.util.noise;
import com.volmit.iris.Iris;
import com.volmit.iris.engine.data.cache.AtomicCache;
import com.volmit.iris.engine.object.IRare;
import com.volmit.iris.engine.object.NoiseStyle;
import com.volmit.iris.util.cache.FloatBitCache;
import com.volmit.iris.util.cache.FloatCache;
import com.volmit.iris.util.collection.KList;
import com.volmit.iris.util.format.Form;
import com.volmit.iris.util.function.NoiseInjector;
import com.volmit.iris.util.interpolation.IrisInterpolation;
import com.volmit.iris.util.math.RNG;
import com.volmit.iris.util.scheduling.PrecisionStopwatch;
import com.volmit.iris.util.stream.ProceduralStream;
import com.volmit.iris.util.stream.arithmetic.FittedStream;
import com.volmit.iris.util.stream.sources.CNGStream;
import lombok.Data;
import java.io.DataOutputStream;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.List;
@Data
@@ -53,6 +63,7 @@ public class CNG {
private boolean trueFracturing = false;
private KList<CNG> children;
private CNG fracture;
private FloatCache cache;
private NoiseGenerator generator;
private NoiseInjector injector;
private RNG rng;
@@ -120,7 +131,7 @@ public class CNG {
@Override
public double noise(double x, double z) {
return (cellularFilter.GetCellular((float) x, (float) z, str, 1) / 2D) + 0.5D;
return (cellularFilter.GetCellular((float) x, (float) z, str, 1) * 0.5) + 0.5D;
}
@Override
@@ -130,14 +141,55 @@ public class CNG {
}, 1D, 1);
}
public CNG cached(int size)
public CNG cached(int size, String key, File cacheFolder)
{
if(size <= 0)
{
return this;
}
generator = new CachedNoise(generator, size);
cache = null;
File f = new File(new File(cacheFolder, ".cache"), key + ".cnm");
FloatCache fbc;
boolean cached = false;
if(f.exists())
{
try {
fbc = new FloatCache(f);
cached = true;
} catch(IOException e) {
fbc = new FloatCache(size, size);
}
}
else {
fbc = new FloatCache(size, size);
}
if(!cached)
{
for(int i = 0; i < size; i++)
{
for(int j = 0; j < size; j++)
{
fbc.set(i, j, (float) noise(i, j));
}
}
try {
f.getParentFile().mkdirs();
FileOutputStream fos = new FileOutputStream(f);
DataOutputStream dos = new DataOutputStream(fos);
fbc.writeCache(dos);
dos.close();
Iris.info("Saved Noise Cache " + f.getName());
} catch(IOException e) {
throw new RuntimeException(e);
}
}
cache = fbc;
return this;
}
@@ -432,6 +484,11 @@ public class CNG {
}
public double noise(double... dim) {
if(cache != null && dim.length == 2)
{
return cache.get((int)dim[0], (int)dim[1]);
}
double n = getNoise(dim);
n = power != 1D ? (n < 0 ? -Math.pow(Math.abs(n), power) : Math.pow(n, power)) : n;
double m = 1;
@@ -466,4 +523,18 @@ public class CNG {
public boolean isStatic() {
return generator != null && generator.isStatic();
}
public static void main(String[] a)
{
CNG cng = NoiseStyle.SIMPLEX.create(new RNG(1234));
PrecisionStopwatch p = PrecisionStopwatch.start();
double r = 0;
for(int i = 0; i < 30000000 * 10; i++)
{
r += cng.fit(-1000, 1000, i, i);
}
System.out.println(Form.duration(p.getMilliseconds(), 10) + " merged = " + r);
}
}

View File

@@ -51,6 +51,7 @@ import java.util.concurrent.ExecutionException;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicReference;
import java.util.function.Function;
/**
* Represents a volume sender. A command sender with extra crap in it
@@ -230,7 +231,7 @@ public class VolmitSender implements CommandSender {
Iris.audiences.player(player()).showTitle(Title.title(
createComponent(title),
createComponent(subtitle),
Title.Times.of(Duration.ofMillis(i), Duration.ofMillis(s), Duration.ofMillis(o))));
Title.Times.times(Duration.ofMillis(i), Duration.ofMillis(s), Duration.ofMillis(o))));
}
public void sendProgress(double percent, String thing) {
@@ -260,43 +261,43 @@ public class VolmitSender implements CommandSender {
Iris.audiences.player(player()).showTitle(Title.title(
createNoPrefixComponent(" "),
createNoPrefixComponent(subtitle),
Title.Times.of(Duration.ofMillis(i), Duration.ofMillis(s), Duration.ofMillis(o))));
Title.Times.times(Duration.ofMillis(i), Duration.ofMillis(s), Duration.ofMillis(o))));
}
private Component createNoPrefixComponent(String message) {
if(!IrisSettings.get().getGeneral().canUseCustomColors(this)) {
String t = C.translateAlternateColorCodes('&', MiniMessage.get().stripTokens(message));
return MiniMessage.get().parse(t);
String t = C.translateAlternateColorCodes('&', MiniMessage.miniMessage().stripTags(message));
return MiniMessage.miniMessage().deserialize(t);
}
String t = C.translateAlternateColorCodes('&', message);
String a = C.aura(t, IrisSettings.get().getGeneral().getSpinh(), IrisSettings.get().getGeneral().getSpins(), IrisSettings.get().getGeneral().getSpinb(), 0.36);
return MiniMessage.get().parse(a);
return MiniMessage.miniMessage().deserialize(a);
}
private Component createNoPrefixComponentNoProcessing(String message) {
return MiniMessage.get().parse(message);
return MiniMessage.builder().postProcessor(c -> c).build().deserialize(message);
}
private Component createComponent(String message) {
if(!IrisSettings.get().getGeneral().canUseCustomColors(this)) {
String t = C.translateAlternateColorCodes('&', MiniMessage.get().stripTokens(getTag() + message));
return MiniMessage.get().parse(t);
String t = C.translateAlternateColorCodes('&', MiniMessage.miniMessage().stripTags(getTag() + message));
return MiniMessage.miniMessage().deserialize(t);
}
String t = C.translateAlternateColorCodes('&', getTag() + message);
String a = C.aura(t, IrisSettings.get().getGeneral().getSpinh(), IrisSettings.get().getGeneral().getSpins(), IrisSettings.get().getGeneral().getSpinb());
return MiniMessage.get().parse(a);
return MiniMessage.miniMessage().deserialize(a);
}
private Component createComponentRaw(String message) {
if(!IrisSettings.get().getGeneral().canUseCustomColors(this)) {
String t = C.translateAlternateColorCodes('&', MiniMessage.get().stripTokens(getTag() + message));
return MiniMessage.get().parse(t);
String t = C.translateAlternateColorCodes('&', MiniMessage.miniMessage().stripTags(getTag() + message));
return MiniMessage.miniMessage().deserialize(t);
}
String t = C.translateAlternateColorCodes('&', getTag() + message);
return MiniMessage.get().parse(t);
return MiniMessage.miniMessage().deserialize(t);
}
public <T> void showWaiting(String passive, CompletableFuture<T> f) {