Compare commits
64 Commits
2.0.7-1.18
...
2.2.0-1.19
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
fcee61a703 | ||
|
|
ce8cc2cf37 | ||
|
|
3b5bdcfb51 | ||
|
|
4d67e97973 | ||
|
|
da09f4d6d8 | ||
|
|
dbc7e2e0bf | ||
|
|
dd804b6665 | ||
|
|
33eb878834 | ||
|
|
2a2c456011 | ||
|
|
05a12f3899 | ||
|
|
eb04710f71 | ||
|
|
257760453e | ||
|
|
d11baeb08a | ||
|
|
47d322c993 | ||
|
|
d316207a61 | ||
|
|
e6daabbb47 | ||
|
|
53156449f1 | ||
|
|
e3d4c32d03 | ||
|
|
9cd5c39bbe | ||
|
|
a1fbf25465 | ||
|
|
ec74037f05 | ||
|
|
fff650b766 | ||
|
|
bae2a18e24 | ||
|
|
fd8a7ebb4c | ||
|
|
4a3a1491d4 | ||
|
|
9aa2c5ed8a | ||
|
|
d5699a7472 | ||
|
|
df98f8f626 | ||
|
|
d37b298f07 | ||
|
|
62f7fc17d1 | ||
|
|
6e4929246d | ||
|
|
909461975a | ||
|
|
dec191e5e7 | ||
|
|
07b0cd6f5a | ||
|
|
b7a892ecfe | ||
|
|
79d16102fa | ||
|
|
67efdb47aa | ||
|
|
751c233b49 | ||
|
|
f51734fea0 | ||
|
|
516a7111a7 | ||
|
|
1e3ff59b26 | ||
|
|
4c48f812d5 | ||
|
|
a63a6f751f | ||
|
|
923860a90b | ||
|
|
5a4ca2f907 | ||
|
|
ccc2ed0806 | ||
|
|
44c707e059 | ||
|
|
e7c458de3f | ||
|
|
11b05b10a4 | ||
|
|
d133ac0088 | ||
|
|
8951fcdebd | ||
|
|
ecbd5677ce | ||
|
|
e31b9c1a28 | ||
|
|
faa7b7c742 | ||
|
|
d08f326477 | ||
|
|
6500ed2075 | ||
|
|
56eb775a0f | ||
|
|
e225bcfb96 | ||
|
|
4be6abe416 | ||
|
|
c3de8b33de | ||
|
|
5658d6709c | ||
|
|
192538a741 | ||
|
|
b8b9d7bf8c | ||
|
|
1db8603910 |
4
.gitignore
vendored
@@ -6,3 +6,7 @@ build/
|
||||
.idea/
|
||||
|
||||
.DS_Store
|
||||
|
||||
collection/
|
||||
|
||||
src/main/java/com/volmit/iris/util/uniques/
|
||||
|
||||
@@ -24,7 +24,7 @@ plugins {
|
||||
id "de.undercouch.download" version "5.0.1"
|
||||
}
|
||||
|
||||
version '2.0.7-1.18.2' // Needs to be version specific
|
||||
version '2.1.3-1.18.2' // Needs to be version specific
|
||||
def nmsVersion = "1.18.2"
|
||||
def apiVersion = '1.18'
|
||||
def spigotJarVersion = '1.18.2-R0.1-SNAPSHOT'
|
||||
@@ -74,8 +74,10 @@ repositories {
|
||||
}
|
||||
}
|
||||
maven { url "https://dl.cloudsmith.io/public/arcane/archive/maven/" }
|
||||
maven { url "https://maven.enginehub.org/repo/" }
|
||||
mavenCentral()
|
||||
mavenLocal()
|
||||
maven { url "https://jitpack.io"}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -126,6 +128,7 @@ dependencies {
|
||||
implementation 'me.clip:placeholderapi:2.11.1'
|
||||
implementation 'io.th0rgal:oraxen:1.94.0'
|
||||
implementation 'org.bukkit:craftbukkit:1.18.2-R0.1-SNAPSHOT:remapped-mojang'
|
||||
implementation 'com.github.LoneDev6:api-itemsadder:3.1.0b'
|
||||
|
||||
// Shaded
|
||||
implementation 'com.dfsek:Paralithic:0.4.0'
|
||||
|
||||
@@ -18,27 +18,25 @@
|
||||
|
||||
package com.volmit.iris;
|
||||
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.JsonParseException;
|
||||
import com.google.gson.JsonParser;
|
||||
import com.google.gson.stream.JsonReader;
|
||||
import com.volmit.iris.core.IrisSettings;
|
||||
import com.volmit.iris.core.ServerConfigurator;
|
||||
import com.volmit.iris.core.link.IrisPapiExpansion;
|
||||
import com.volmit.iris.core.link.MultiverseCoreLink;
|
||||
import com.volmit.iris.core.link.MythicMobsLink;
|
||||
import com.volmit.iris.core.link.OraxenLink;
|
||||
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.IrisBiome;
|
||||
import com.volmit.iris.engine.object.IrisCompat;
|
||||
import com.volmit.iris.engine.object.IrisDimension;
|
||||
import com.volmit.iris.engine.object.IrisObject;
|
||||
import com.volmit.iris.engine.object.IrisWorld;
|
||||
import com.volmit.iris.engine.platform.BukkitChunkGenerator;
|
||||
import com.volmit.iris.engine.platform.DummyChunkGenerator;
|
||||
import com.volmit.iris.util.collection.KList;
|
||||
import com.volmit.iris.util.collection.KMap;
|
||||
import com.volmit.iris.util.data.B;
|
||||
import com.volmit.iris.util.exceptions.IrisException;
|
||||
import com.volmit.iris.util.format.C;
|
||||
import com.volmit.iris.util.format.Form;
|
||||
@@ -46,8 +44,6 @@ import com.volmit.iris.util.function.NastyRunnable;
|
||||
import com.volmit.iris.util.io.*;
|
||||
import com.volmit.iris.util.math.M;
|
||||
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.parallel.MultiBurst;
|
||||
import com.volmit.iris.util.plugin.IrisService;
|
||||
import com.volmit.iris.util.plugin.Metrics;
|
||||
@@ -63,16 +59,13 @@ import net.kyori.adventure.text.serializer.ComponentSerializer;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
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.InvalidConfigurationException;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
||||
@@ -84,15 +77,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 {
|
||||
@@ -100,7 +90,6 @@ public class Iris extends VolmitPlugin implements Listener {
|
||||
public static Iris instance;
|
||||
public static BukkitAudiences audiences;
|
||||
public static MultiverseCoreLink linkMultiverseCore;
|
||||
public static OraxenLink linkOraxen;
|
||||
public static MythicMobsLink linkMythicMobs;
|
||||
public static IrisCompat compat;
|
||||
public static FileWatcher configWatcher;
|
||||
@@ -257,12 +246,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) {
|
||||
@@ -405,7 +394,6 @@ public class Iris extends VolmitPlugin implements Listener {
|
||||
instance = this;
|
||||
compat = IrisCompat.configured(getDataFile("compat.json"));
|
||||
linkMultiverseCore = new MultiverseCoreLink();
|
||||
linkOraxen = new OraxenLink();
|
||||
linkMythicMobs = new MythicMobsLink();
|
||||
configWatcher = new FileWatcher(getDataFile("settings.json"));
|
||||
services.values().forEach(IrisService::onEnable);
|
||||
@@ -421,6 +409,8 @@ public class Iris extends VolmitPlugin implements Listener {
|
||||
splash();
|
||||
autoStartStudio();
|
||||
checkForBukkitWorlds();
|
||||
IrisToolbelt.retainMantleDataForSlice(String.class.getCanonicalName());
|
||||
IrisToolbelt.retainMantleDataForSlice(BlockData.class.getCanonicalName());
|
||||
});
|
||||
}
|
||||
|
||||
@@ -690,17 +680,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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -18,7 +18,9 @@
|
||||
|
||||
package com.volmit.iris.core.commands;
|
||||
|
||||
import com.mojang.datafixers.util.Pair;
|
||||
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 +43,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 +229,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 +253,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 +276,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 +360,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 +394,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 +419,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 +452,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 +499,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();
|
||||
|
||||
@@ -36,12 +36,11 @@ public class BlockSignal {
|
||||
|
||||
public BlockSignal(Block block, int ticks) {
|
||||
active.incrementAndGet();
|
||||
Location tg = block.getLocation().clone().add(0.5, 0, 0.5).clone();
|
||||
FallingBlock e = block.getWorld().spawnFallingBlock(tg.clone(), block.getBlockData());
|
||||
Location tg = block.getLocation().clone().add(0.5, 0, 0.5);
|
||||
FallingBlock e = block.getWorld().spawnFallingBlock(tg, block.getBlockData());
|
||||
e.setGravity(false);
|
||||
e.setInvulnerable(true);
|
||||
e.setGlowing(true);
|
||||
e.teleport(tg.clone());
|
||||
e.setDropItem(false);
|
||||
e.setHurtEntities(false);
|
||||
e.setSilent(true);
|
||||
|
||||
@@ -49,7 +49,7 @@ public class DustRevealer {
|
||||
this.hits = hits;
|
||||
|
||||
J.s(() -> {
|
||||
new BlockSignal(world.getBlockAt(block.getX(), block.getY(), block.getZ()), 7);
|
||||
new BlockSignal(world.getBlockAt(block.getX(), block.getY(), block.getZ()), 10);
|
||||
if(M.r(0.25)) {
|
||||
world.playSound(block.toBlock(world).getLocation(), Sound.BLOCK_AMETHYST_BLOCK_CHIME, 1f, RNG.r.f(0.2f, 2f));
|
||||
}
|
||||
@@ -98,8 +98,7 @@ public class DustRevealer {
|
||||
Engine access = IrisToolbelt.access(world).getEngine();
|
||||
|
||||
if(access != null) {
|
||||
String a = access.getObjectPlacementKey(block.getX(), block.getY(), block.getZ());
|
||||
|
||||
String a = access.getObjectPlacementKey(block.getX(), block.getY() - block.getWorld().getMinHeight(), block.getZ());
|
||||
if(a != null) {
|
||||
world.playSound(block.getLocation(), Sound.ITEM_LODESTONE_COMPASS_LOCK, 1f, 0.1f);
|
||||
|
||||
@@ -112,7 +111,8 @@ public class DustRevealer {
|
||||
}
|
||||
|
||||
private boolean is(BlockPosition a) {
|
||||
if(isValidTry(a) && engine.getObjectPlacementKey(a.getX(), a.getY(), a.getZ()) != null && engine.getObjectPlacementKey(a.getX(), a.getY(), a.getZ()).equals(key)) {
|
||||
int betterY = a.getY() - world.getMinHeight();
|
||||
if(isValidTry(a) && engine.getObjectPlacementKey(a.getX(), betterY, a.getZ()) != null && engine.getObjectPlacementKey(a.getX(), betterY, a.getZ()).equals(key)) {
|
||||
hits.add(a);
|
||||
new DustRevealer(engine, world, a, key, hits);
|
||||
return true;
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
package com.volmit.iris.core.edit;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.volmit.iris.Iris;
|
||||
import com.volmit.iris.core.service.WandSVC;
|
||||
import com.volmit.iris.engine.object.IrisDirection;
|
||||
@@ -26,6 +27,7 @@ import com.volmit.iris.engine.object.IrisJigsawPiece;
|
||||
import com.volmit.iris.engine.object.IrisJigsawPieceConnector;
|
||||
import com.volmit.iris.engine.object.IrisObject;
|
||||
import com.volmit.iris.engine.object.IrisPosition;
|
||||
import com.volmit.iris.util.collection.KList;
|
||||
import com.volmit.iris.util.collection.KMap;
|
||||
import com.volmit.iris.util.data.Cuboid;
|
||||
import com.volmit.iris.util.io.IO;
|
||||
@@ -47,6 +49,7 @@ import org.bukkit.util.Vector;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
|
||||
public class JigsawEditor implements Listener {
|
||||
@@ -154,10 +157,50 @@ public class JigsawEditor implements Listener {
|
||||
}
|
||||
}
|
||||
|
||||
private void removeKey(JSONObject o, String... path)
|
||||
{
|
||||
if(path.length == 1)
|
||||
{
|
||||
o.remove(path[0]);
|
||||
return;
|
||||
}
|
||||
|
||||
List<String> s = new java.util.ArrayList<>(List.of(path));
|
||||
s.remove(0);
|
||||
removeKey(o.getJSONObject(path[0]), s.toArray(new String[0]));
|
||||
}
|
||||
|
||||
private List<JSONObject> getObjectsInArray(JSONObject a, String key)
|
||||
{
|
||||
KList<JSONObject> o = new KList<>();
|
||||
|
||||
for(int i = 0; i < a.getJSONArray(key).length(); i++)
|
||||
{
|
||||
o.add(a.getJSONArray(key).getJSONObject(i));
|
||||
}
|
||||
|
||||
return o;
|
||||
}
|
||||
|
||||
public void close() {
|
||||
exit();
|
||||
try {
|
||||
IO.writeAll(targetSaveLocation, new JSONObject(new Gson().toJson(piece)).toString(4));
|
||||
JSONObject j = new JSONObject(new Gson().toJson(piece));
|
||||
// Remove sub-key
|
||||
removeKey(j, "placementOptions", "translateCenter"); // should work
|
||||
J.attempt(() -> j.getJSONObject("placementOptions").remove("translateCenter")); // otherwise
|
||||
|
||||
// remove root key
|
||||
removeKey(j, "placementOptions"); // should work
|
||||
j.remove("placementOptions"); // otherwise
|
||||
|
||||
// Remove key in all objects in array
|
||||
for(JSONObject i : getObjectsInArray(j, "connectors"))
|
||||
{
|
||||
removeKey(i, "rotateConnector");
|
||||
}
|
||||
|
||||
IO.writeAll(targetSaveLocation, j.toString(4));
|
||||
} catch(IOException e) {
|
||||
Iris.reportError(e);
|
||||
e.printStackTrace();
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
package com.volmit.iris.core.link;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.NamespacedKey;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
import java.util.MissingResourceException;
|
||||
|
||||
@RequiredArgsConstructor
|
||||
public abstract class ExternalDataProvider {
|
||||
|
||||
@Getter
|
||||
private final String pluginId;
|
||||
|
||||
public Plugin getPlugin() {
|
||||
return Bukkit.getPluginManager().getPlugin(pluginId);
|
||||
}
|
||||
|
||||
public boolean isPresent() {
|
||||
return getPlugin() != null;
|
||||
}
|
||||
|
||||
public abstract void init();
|
||||
|
||||
public abstract BlockData getBlockData(NamespacedKey blockId) throws MissingResourceException;
|
||||
|
||||
public abstract ItemStack getItemStack(NamespacedKey itemId) throws MissingResourceException;
|
||||
|
||||
public abstract NamespacedKey[] getBlockTypes();
|
||||
|
||||
public abstract boolean isValidProvider(NamespacedKey namespace);
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
package com.volmit.iris.core.link;
|
||||
|
||||
import com.volmit.iris.util.collection.KList;
|
||||
import dev.lone.itemsadder.api.CustomBlock;
|
||||
import dev.lone.itemsadder.api.CustomStack;
|
||||
import dev.lone.itemsadder.api.ItemsAdder;
|
||||
import org.bukkit.NamespacedKey;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.util.MissingResourceException;
|
||||
|
||||
public class ItemAdderDataProvider extends ExternalDataProvider {
|
||||
|
||||
public ItemAdderDataProvider() {
|
||||
super("ItemsAdder");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init() { }
|
||||
|
||||
@Override
|
||||
public BlockData getBlockData(NamespacedKey blockId) throws MissingResourceException {
|
||||
return CustomBlock.getBaseBlockData(blockId.toString());
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getItemStack(NamespacedKey itemId) throws MissingResourceException {
|
||||
CustomStack stack = CustomStack.getInstance(itemId.toString());
|
||||
if(stack == null)
|
||||
throw new MissingResourceException("Failed to find ItemData!", itemId.getNamespace(), itemId.getKey());
|
||||
return stack.getItemStack();
|
||||
}
|
||||
|
||||
@Override
|
||||
public NamespacedKey[] getBlockTypes() {
|
||||
KList<NamespacedKey> keys = new KList<>();
|
||||
for(String s : ItemsAdder.getNamespacedBlocksNamesInConfig())
|
||||
keys.add(NamespacedKey.fromString(s));
|
||||
return keys.toArray(new NamespacedKey[0]);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValidProvider(NamespacedKey blockId) {
|
||||
for(NamespacedKey k : getBlockTypes())
|
||||
if(k.equals(blockId)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
112
src/main/java/com/volmit/iris/core/link/OraxenDataProvider.java
Normal file
@@ -0,0 +1,112 @@
|
||||
/*
|
||||
* 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.core.link;
|
||||
|
||||
import com.volmit.iris.Iris;
|
||||
import com.volmit.iris.util.collection.KList;
|
||||
import io.th0rgal.oraxen.items.ItemBuilder;
|
||||
import io.th0rgal.oraxen.items.OraxenItems;
|
||||
import io.th0rgal.oraxen.mechanics.MechanicFactory;
|
||||
import io.th0rgal.oraxen.mechanics.MechanicsManager;
|
||||
import io.th0rgal.oraxen.mechanics.provided.gameplay.block.BlockMechanic;
|
||||
import io.th0rgal.oraxen.mechanics.provided.gameplay.block.BlockMechanicFactory;
|
||||
import io.th0rgal.oraxen.mechanics.provided.gameplay.noteblock.NoteBlockMechanicFactory;
|
||||
import io.th0rgal.oraxen.utils.Utils;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.NamespacedKey;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
import org.bukkit.block.data.MultipleFacing;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.Map;
|
||||
import java.util.MissingResourceException;
|
||||
import java.util.Optional;
|
||||
|
||||
public class OraxenDataProvider extends ExternalDataProvider {
|
||||
|
||||
private static final String FIELD_FACTORIES_MAP = "FACTORIES_BY_MECHANIC_ID";
|
||||
|
||||
private Map<String, MechanicFactory> factories;
|
||||
|
||||
public OraxenDataProvider() { super("Oraxen"); }
|
||||
|
||||
@Override
|
||||
public void init() {
|
||||
try {
|
||||
Field f = MechanicsManager.class.getDeclaredField(FIELD_FACTORIES_MAP);
|
||||
f.setAccessible(true);
|
||||
factories = (Map<String, MechanicFactory>) f.get(null);
|
||||
} catch(NoSuchFieldException | IllegalAccessException e) {
|
||||
Iris.error("Failed to set up Oraxen Link:");
|
||||
Iris.error("\t" + e.getClass().getSimpleName());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockData getBlockData(NamespacedKey blockId) throws MissingResourceException {
|
||||
MechanicFactory f = getFactory(blockId);
|
||||
if(f instanceof NoteBlockMechanicFactory)
|
||||
return ((NoteBlockMechanicFactory)f).createNoteBlockData(blockId.getKey());
|
||||
else if(f instanceof BlockMechanicFactory) {
|
||||
MultipleFacing newBlockData = (MultipleFacing) Bukkit.createBlockData(Material.MUSHROOM_STEM);
|
||||
Utils.setBlockFacing(newBlockData, ((BlockMechanic)f.getMechanic(blockId.getKey())).getCustomVariation());
|
||||
return newBlockData;
|
||||
} else
|
||||
throw new MissingResourceException("Failed to find BlockData!", blockId.getNamespace(), blockId.getKey());
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getItemStack(NamespacedKey itemId) throws MissingResourceException {
|
||||
Optional<ItemBuilder> opt = OraxenItems.getOptionalItemById(itemId.getKey());
|
||||
return opt.orElseThrow(() -> new MissingResourceException("Failed to find ItemData!", itemId.getNamespace(), itemId.getKey())).build();
|
||||
}
|
||||
|
||||
@Override
|
||||
public NamespacedKey[] getBlockTypes() {
|
||||
KList<NamespacedKey> names = new KList<>();
|
||||
for(String name : OraxenItems.getItemNames()) {
|
||||
try {
|
||||
NamespacedKey key = new NamespacedKey("oraxen", name);
|
||||
if(getBlockData(key) != null)
|
||||
names.add(key);
|
||||
} catch(MissingResourceException ignored) { }
|
||||
}
|
||||
|
||||
return names.toArray(new NamespacedKey[0]);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPresent() {
|
||||
return super.isPresent() && factories != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValidProvider(NamespacedKey key) {
|
||||
return key.getNamespace().equalsIgnoreCase("oraxen");
|
||||
}
|
||||
|
||||
private MechanicFactory getFactory(NamespacedKey key) throws MissingResourceException {
|
||||
return factories.values().stream()
|
||||
.filter(i -> i.getItems().contains(key.getKey()))
|
||||
.findFirst()
|
||||
.orElseThrow(() -> new MissingResourceException("Failed to find BlockData!", key.getNamespace(), key.getKey()));
|
||||
}
|
||||
}
|
||||
@@ -1,113 +0,0 @@
|
||||
/*
|
||||
* 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.core.link;
|
||||
|
||||
import com.volmit.iris.util.collection.KList;
|
||||
import io.th0rgal.oraxen.items.OraxenItems;
|
||||
import io.th0rgal.oraxen.mechanics.Mechanic;
|
||||
import io.th0rgal.oraxen.mechanics.MechanicFactory;
|
||||
import io.th0rgal.oraxen.mechanics.MechanicsManager;
|
||||
import io.th0rgal.oraxen.mechanics.provided.gameplay.block.BlockMechanic;
|
||||
import io.th0rgal.oraxen.mechanics.provided.gameplay.block.BlockMechanicFactory;
|
||||
import io.th0rgal.oraxen.mechanics.provided.gameplay.noteblock.NoteBlockMechanicFactory;
|
||||
import io.th0rgal.oraxen.utils.Utils;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
import org.bukkit.block.data.MultipleFacing;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.Map;
|
||||
|
||||
public class OraxenLink {
|
||||
private static final String[] EMPTY = new String[0];
|
||||
|
||||
public boolean supported() {
|
||||
return getOraxen() != null;
|
||||
}
|
||||
|
||||
public BlockData getBlockDataFor(String id) {
|
||||
if(!supported()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
MechanicFactory f = getFactory(id);
|
||||
|
||||
if(f == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
Mechanic m = f.getMechanic(id);
|
||||
|
||||
// TODO: Why isnt there a simple getBlockData() function?
|
||||
if(m.getFactory() instanceof NoteBlockMechanicFactory) {
|
||||
return ((NoteBlockMechanicFactory) m.getFactory()).createNoteBlockData(id);
|
||||
} else if(m.getFactory() instanceof BlockMechanicFactory) {
|
||||
MultipleFacing newBlockData = (MultipleFacing) Bukkit.createBlockData(Material.MUSHROOM_STEM);
|
||||
Utils.setBlockFacing(newBlockData, ((BlockMechanic) m).getCustomVariation());
|
||||
return newBlockData;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public MechanicFactory getFactory(String id) {
|
||||
if(!supported()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
try {
|
||||
Field f = MechanicsManager.class.getDeclaredField("FACTORIES_BY_MECHANIC_ID");
|
||||
f.setAccessible(true);
|
||||
Map<String, MechanicFactory> map = (Map<String, MechanicFactory>) f.get(null);
|
||||
|
||||
for(MechanicFactory i : map.values()) {
|
||||
if(i.getItems().contains(id)) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
} catch(Throwable e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public String[] getItemTypes() {
|
||||
if(!supported()) {
|
||||
return EMPTY;
|
||||
}
|
||||
|
||||
KList<String> v = new KList<>();
|
||||
|
||||
for(String i : OraxenItems.getItemNames()) {
|
||||
if(getBlockDataFor(i) != null) {
|
||||
v.add(i);
|
||||
}
|
||||
}
|
||||
|
||||
return v.toArray(new String[0]);
|
||||
}
|
||||
|
||||
public Plugin getOraxen() {
|
||||
|
||||
return Bukkit.getPluginManager().getPlugin("Oraxen");
|
||||
}
|
||||
}
|
||||
37
src/main/java/com/volmit/iris/core/link/WorldEditLink.java
Normal 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;
|
||||
}
|
||||
}
|
||||
@@ -75,6 +75,7 @@ public class IrisData implements ExclusionStrategy, TypeAdapterFactory {
|
||||
private ResourceLoader<IrisScript> scriptLoader;
|
||||
private ResourceLoader<IrisCave> caveLoader;
|
||||
private ResourceLoader<IrisRavine> ravineLoader;
|
||||
private ResourceLoader<IrisMatterObject> matterObjectLoader;
|
||||
private KMap<String, KList<String>> possibleSnippets;
|
||||
private Gson gson;
|
||||
private Gson snippetLoader;
|
||||
@@ -337,6 +338,7 @@ public class IrisData implements ExclusionStrategy, TypeAdapterFactory {
|
||||
this.objectLoader = registerLoader(IrisObject.class);
|
||||
this.imageLoader = registerLoader(IrisImage.class);
|
||||
this.scriptLoader = registerLoader(IrisScript.class);
|
||||
this.matterObjectLoader = registerLoader(IrisMatterObject.class);
|
||||
gson = builder.create();
|
||||
}
|
||||
|
||||
|
||||
@@ -126,8 +126,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
|
||||
@@ -416,18 +416,21 @@ 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.getFields())
|
||||
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.info("[NMS] Found " + returnType.getSimpleName() + " in " + sourceType.getSimpleName() + "." + i.getName());
|
||||
return (T)i.get(in);
|
||||
} catch(IllegalAccessException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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.core.service;
|
||||
|
||||
import com.volmit.iris.Iris;
|
||||
import com.volmit.iris.core.link.ExternalDataProvider;
|
||||
import com.volmit.iris.core.link.ItemAdderDataProvider;
|
||||
import com.volmit.iris.core.link.OraxenDataProvider;
|
||||
import com.volmit.iris.util.collection.KList;
|
||||
import com.volmit.iris.util.plugin.IrisService;
|
||||
import lombok.Data;
|
||||
import org.bukkit.NamespacedKey;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.util.MissingResourceException;
|
||||
import java.util.Optional;
|
||||
|
||||
@Data
|
||||
public class ExternalDataSVC implements IrisService {
|
||||
|
||||
private KList<ExternalDataProvider> providers = new KList<>();
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
addProvider(new OraxenDataProvider(), new ItemAdderDataProvider());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDisable() { }
|
||||
|
||||
public void addProvider(ExternalDataProvider... provider) {
|
||||
for(ExternalDataProvider p : provider) {
|
||||
if(p.getPlugin() != null) {
|
||||
providers.add(p);
|
||||
p.init();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public Optional<BlockData> getBlockData(NamespacedKey key) {
|
||||
Optional<ExternalDataProvider> provider = providers.stream().filter(p -> p.isPresent() && p.isValidProvider(key)).findFirst();
|
||||
if(provider.isEmpty())
|
||||
return Optional.empty();
|
||||
try {
|
||||
return Optional.of(provider.get().getBlockData(key));
|
||||
} catch(MissingResourceException e) {
|
||||
Iris.error(e.getMessage() + " - [" + e.getClassName() + ":" + e.getKey() + "]");
|
||||
return Optional.empty();
|
||||
}
|
||||
}
|
||||
|
||||
public Optional<ItemStack> getItemStack(NamespacedKey key) {
|
||||
Optional<ExternalDataProvider> provider = providers.stream().filter(p -> p.isPresent() && p.isValidProvider(key)).findFirst();
|
||||
if(provider.isEmpty())
|
||||
return Optional.empty();
|
||||
try {
|
||||
return Optional.of(provider.get().getItemStack(key));
|
||||
} catch(MissingResourceException e) {
|
||||
Iris.error(e.getMessage() + " - [" + e.getClassName() + ":" + e.getKey() + "]");
|
||||
return Optional.empty();
|
||||
}
|
||||
}
|
||||
|
||||
public NamespacedKey[] getAllIdentifiers() {
|
||||
KList<NamespacedKey> names = new KList<>();
|
||||
providers.stream().filter(ExternalDataProvider::isPresent).forEach(p -> names.add(p.getBlockTypes()));
|
||||
return names.toArray(new NamespacedKey[0]);
|
||||
}
|
||||
}
|
||||
61
src/main/java/com/volmit/iris/core/service/LogFilterSVC.java
Normal 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;
|
||||
}
|
||||
}
|
||||
@@ -1,41 +0,0 @@
|
||||
/*
|
||||
* 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.core.service;
|
||||
|
||||
import com.volmit.iris.util.plugin.IrisService;
|
||||
import com.volmit.iris.util.plugin.PluginRegistryGroup;
|
||||
import lombok.Data;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
|
||||
import java.util.function.Supplier;
|
||||
|
||||
@Data
|
||||
public class RegistrySVC implements IrisService {
|
||||
private PluginRegistryGroup<Supplier<BlockData>> customBlockRegistry;
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
customBlockRegistry = new PluginRegistryGroup<>();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDisable() {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -315,7 +315,6 @@ public class StudioSVC implements IrisService {
|
||||
return activeProject != null && activeProject.isOpen();
|
||||
}
|
||||
|
||||
|
||||
public void open(VolmitSender sender, String dimm) {
|
||||
open(sender, 1337, dimm);
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
@@ -42,6 +44,7 @@ import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.block.Action;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
import org.bukkit.inventory.EquipmentSlot;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.ItemFlag;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
@@ -63,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) {
|
||||
@@ -97,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) {
|
||||
@@ -225,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);
|
||||
}
|
||||
@@ -285,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) {
|
||||
@@ -388,6 +395,8 @@ public class WandSVC implements IrisService {
|
||||
|
||||
@EventHandler
|
||||
public void on(PlayerInteractEvent e) {
|
||||
if(e.getHand() != EquipmentSlot.HAND)
|
||||
return;
|
||||
try {
|
||||
if(isHoldingWand(e.getPlayer())) {
|
||||
if(e.getAction().equals(Action.LEFT_CLICK_BLOCK)) {
|
||||
@@ -408,7 +417,6 @@ public class WandSVC implements IrisService {
|
||||
e.setCancelled(true);
|
||||
e.getPlayer().playSound(Objects.requireNonNull(e.getClickedBlock()).getLocation(), Sound.ENTITY_ENDER_EYE_DEATH, 2f, 1.97f);
|
||||
DustRevealer.spawn(e.getClickedBlock(), new VolmitSender(e.getPlayer(), Iris.instance.getTag()));
|
||||
|
||||
}
|
||||
}
|
||||
} catch(Throwable xx) {
|
||||
@@ -455,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())) {
|
||||
|
||||
@@ -116,8 +116,24 @@ public class IrisToolbelt {
|
||||
public static PlatformChunkGenerator access(World world) {
|
||||
if(isIrisWorld(world)) {
|
||||
return ((PlatformChunkGenerator) world.getGenerator());
|
||||
}
|
||||
|
||||
} /*else {
|
||||
Iris.warn("""
|
||||
"---------- No World? ---------------
|
||||
⠀⣞⢽⢪⢣⢣⢣⢫⡺⡵⣝⡮⣗⢷⢽⢽⢽⣮⡷⡽⣜⣜⢮⢺⣜⢷⢽⢝⡽⣝
|
||||
⠸⡸⠜⠕⠕⠁⢁⢇⢏⢽⢺⣪⡳⡝⣎⣏⢯⢞⡿⣟⣷⣳⢯⡷⣽⢽⢯⣳⣫⠇
|
||||
⠀⠀⢀⢀⢄⢬⢪⡪⡎⣆⡈⠚⠜⠕⠇⠗⠝⢕⢯⢫⣞⣯⣿⣻⡽⣏⢗⣗⠏⠀
|
||||
⠀⠪⡪⡪⣪⢪⢺⢸⢢⢓⢆⢤⢀⠀⠀⠀⠀⠈⢊⢞⡾⣿⡯⣏⢮⠷⠁⠀⠀
|
||||
⠀⠀⠀⠈⠊⠆⡃⠕⢕⢇⢇⢇⢇⢇⢏⢎⢎⢆⢄⠀⢑⣽⣿⢝⠲⠉⠀⠀⠀⠀
|
||||
⠀⠀⠀⠀⠀⡿⠂⠠⠀⡇⢇⠕⢈⣀⠀⠁⠡⠣⡣⡫⣂⣿⠯⢪⠰⠂⠀⠀⠀⠀
|
||||
⠀⠀⠀⠀⡦⡙⡂⢀⢤⢣⠣⡈⣾⡃⠠⠄⠀⡄⢱⣌⣶⢏⢊⠂⠀⠀⠀⠀⠀⠀
|
||||
⠀⠀⠀⠀⢝⡲⣜⡮⡏⢎⢌⢂⠙⠢⠐⢀⢘⢵⣽⣿⡿⠁⠁⠀⠀⠀⠀⠀⠀⠀
|
||||
⠀⠀⠀⠀⠨⣺⡺⡕⡕⡱⡑⡆⡕⡅⡕⡜⡼⢽⡻⠏⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
|
||||
⠀⠀⠀⠀⣼⣳⣫⣾⣵⣗⡵⡱⡡⢣⢑⢕⢜⢕⡝⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
|
||||
⠀⠀⠀⣴⣿⣾⣿⣿⣿⡿⡽⡑⢌⠪⡢⡣⣣⡟⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
|
||||
⠀⠀⠀⡟⡾⣿⢿⢿⢵⣽⣾⣼⣘⢸⢸⣞⡟⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
|
||||
⠀⠀⠀⠀⠁⠇⠡⠩⡫⢿⣝⡻⡮⣒⢽⠋⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
|
||||
""");
|
||||
}*/
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -217,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);
|
||||
|
||||
@@ -21,6 +21,7 @@ package com.volmit.iris.engine;
|
||||
import com.google.common.util.concurrent.AtomicDouble;
|
||||
import com.google.gson.Gson;
|
||||
import com.volmit.iris.Iris;
|
||||
import com.volmit.iris.core.ServerConfigurator;
|
||||
import com.volmit.iris.core.events.IrisEngineHotloadEvent;
|
||||
import com.volmit.iris.core.gui.PregeneratorJob;
|
||||
import com.volmit.iris.core.project.IrisProject;
|
||||
@@ -233,6 +234,7 @@ public class IrisEngine implements Engine {
|
||||
getTarget().setDimension(getData().getDimensionLoader().load(getDimension().getLoadKey()));
|
||||
prehotload();
|
||||
setupEngine();
|
||||
J.a(() -> { synchronized(ServerConfigurator.class) { ServerConfigurator.installDataPacks(false); } });
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -80,7 +80,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!");
|
||||
}
|
||||
|
||||
@@ -156,7 +156,6 @@ public class IrisTerrainNormalActuator extends EngineAssignedActuator<BlockData>
|
||||
} else {
|
||||
h.set(xf, i, zf, getComplex().getRockStream().get(realX, realZ));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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<>();
|
||||
@@ -472,6 +464,8 @@ public interface Engine extends DataProvider, Fallible, LootProvider, BlockUpdat
|
||||
|
||||
int b = 4;
|
||||
for(IrisLootTable i : tables) {
|
||||
if(i == null)
|
||||
continue;
|
||||
b++;
|
||||
items.addAll(i.getLoot(debug, items.isEmpty(), rng, slot, x, y, z, b + b, mgf + b));
|
||||
}
|
||||
@@ -746,7 +740,6 @@ public interface Engine extends DataProvider, Fallible, LootProvider, BlockUpdat
|
||||
|
||||
default PlacedObject getObjectPlacement(int x, int y, int z) {
|
||||
String objectAt = getMantle().getMantle().get(x, y, z, String.class);
|
||||
|
||||
if(objectAt == null || objectAt.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -47,14 +47,14 @@ public class IrisBiomeGeneratorLink {
|
||||
private String generator = "default";
|
||||
@DependsOn({"min", "max"})
|
||||
@Required
|
||||
@MinNumber(-256) // TODO: WARNING HEIGHT
|
||||
@MaxNumber(256) // TODO: WARNING HEIGHT
|
||||
@MinNumber(-2032) // TODO: WARNING HEIGHT
|
||||
@MaxNumber(2032) // TODO: WARNING HEIGHT
|
||||
@Desc("The min block value (value + fluidHeight)")
|
||||
private int min = 0;
|
||||
@DependsOn({"min", "max"})
|
||||
@Required
|
||||
@MinNumber(-256) // TODO: WARNING HEIGHT
|
||||
@MaxNumber(256) // TODO: WARNING HEIGHT
|
||||
@MinNumber(-2032) // TODO: WARNING HEIGHT
|
||||
@MaxNumber(2032) // TODO: WARNING HEIGHT
|
||||
@Desc("The max block value (value + fluidHeight)")
|
||||
private int max = 0;
|
||||
|
||||
|
||||
@@ -50,13 +50,13 @@ public class IrisBiomePaletteLayer {
|
||||
private IrisGeneratorStyle style = NoiseStyle.STATIC.style();
|
||||
@DependsOn({"minHeight", "maxHeight"})
|
||||
@MinNumber(0)
|
||||
@MaxNumber(256) // TODO: WARNING HEIGHT
|
||||
@MaxNumber(2032) // TODO: WARNING HEIGHT
|
||||
|
||||
@Desc("The min thickness of this layer")
|
||||
private int minHeight = 1;
|
||||
@DependsOn({"minHeight", "maxHeight"})
|
||||
@MinNumber(1)
|
||||
@MaxNumber(256) // TODO: WARNING HEIGHT
|
||||
@MaxNumber(2032) // TODO: WARNING HEIGHT
|
||||
|
||||
@Desc("The max thickness of this layer")
|
||||
private int maxHeight = 1;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -65,12 +65,12 @@ public class IrisDecorator {
|
||||
private IrisDecorationPart partOf = IrisDecorationPart.NONE;
|
||||
@DependsOn({"stackMin", "stackMax"})
|
||||
@MinNumber(1)
|
||||
@MaxNumber(256) // TODO: WARNING HEIGHT
|
||||
@MaxNumber(2032) // TODO: WARNING HEIGHT
|
||||
@Desc("The minimum repeat stack height (setting to 3 would stack 3 of <block> on top of each other")
|
||||
private int stackMin = 1;
|
||||
@DependsOn({"stackMin", "stackMax"})
|
||||
@MinNumber(1)
|
||||
@MaxNumber(256) // TODO: WARNING HEIGHT
|
||||
@MaxNumber(2032) // TODO: WARNING HEIGHT
|
||||
@Desc("The maximum repeat stack height")
|
||||
private int stackMax = 1;
|
||||
@DependsOn({"stackMin", "stackMax"})
|
||||
|
||||
@@ -46,12 +46,12 @@ public class IrisDepositGenerator {
|
||||
private final transient AtomicCache<KList<BlockData>> blockData = new AtomicCache<>();
|
||||
@Required
|
||||
@MinNumber(0)
|
||||
@MaxNumber(256) // TODO: WARNING HEIGHT
|
||||
@MaxNumber(2032) // TODO: WARNING HEIGHT
|
||||
@Desc("The minimum height this deposit can generate at")
|
||||
private int minHeight = 7;
|
||||
@Required
|
||||
@MinNumber(0)
|
||||
@MaxNumber(256) // TODO: WARNING HEIGHT
|
||||
@MaxNumber(2032) // TODO: WARNING HEIGHT
|
||||
@Desc("The maximum height this deposit can generate at")
|
||||
private int maxHeight = 55;
|
||||
@Required
|
||||
|
||||
@@ -74,6 +74,7 @@ public class IrisDimension extends IrisRegistrant {
|
||||
@MaxNumber(2032)
|
||||
@Desc("Maximum height at which players can be teleported to through gameplay.")
|
||||
private int logicalHeight = 256;
|
||||
|
||||
@RegistryListResource(IrisJigsawStructure.class)
|
||||
@Desc("If defined, Iris will place the given jigsaw structure where minecraft should place the overworld stronghold.")
|
||||
private String stronghold;
|
||||
@@ -405,19 +406,10 @@ public class IrisDimension extends IrisRegistrant {
|
||||
}
|
||||
}
|
||||
|
||||
/* if(!dimensionHeight.equals(new IrisRange(-64, 320))) {
|
||||
File dimType = new File(datapacks, "iris/data/minecraft/dimension_type/" + getLoadKey().toLowerCase() + ".json");
|
||||
if(!dimType.exists())
|
||||
changed = true;
|
||||
|
||||
Iris.verbose(" Installing Data Pack Dimension Type: " + dimType.getPath());
|
||||
dimType.getParentFile().mkdirs();
|
||||
try {
|
||||
IO.writeAll(dimType, generateDatapackJson());
|
||||
} catch(IOException e) {
|
||||
Iris.reportError(e);
|
||||
e.printStackTrace();
|
||||
}*/
|
||||
if(!dimensionHeight.equals(new IrisRange(-64, 320)) && this.name.equalsIgnoreCase("overworld")) {
|
||||
Iris.verbose(" Installing Data Pack Dimension Type: \"minecraft:overworld\"");
|
||||
changed = writeDimensionType(changed, datapacks);
|
||||
}
|
||||
|
||||
if(write) {
|
||||
File mcm = new File(datapacks, "iris/pack.mcmeta");
|
||||
@@ -455,6 +447,20 @@ public class IrisDimension extends IrisRegistrant {
|
||||
|
||||
}
|
||||
|
||||
public boolean writeDimensionType(boolean changed, File datapacks) {
|
||||
File dimType = new File(datapacks, "iris/data/minecraft/dimension_type/overworld.json");
|
||||
if(!dimType.exists())
|
||||
changed = true;
|
||||
dimType.getParentFile().mkdirs();
|
||||
try {
|
||||
IO.writeAll(dimType, generateDatapackJson());
|
||||
} catch(IOException e) {
|
||||
Iris.reportError(e);
|
||||
e.printStackTrace();
|
||||
}
|
||||
return changed;
|
||||
}
|
||||
|
||||
private String generateDatapackJson() {
|
||||
JSONObject obj = new JSONObject(DP_OVERWORLD_DEFAULT);
|
||||
obj.put("min_y", dimensionHeight.getMin());
|
||||
@@ -465,19 +471,17 @@ public class IrisDimension extends IrisRegistrant {
|
||||
|
||||
private static final String DP_OVERWORLD_DEFAULT = """
|
||||
{
|
||||
"name": "minecraft:overworld",
|
||||
"ultrawarm": false,
|
||||
"natural": true,
|
||||
"coordinate_scale": 1.0,
|
||||
"has_skylight": true,
|
||||
"has_ceiling": false,
|
||||
"ambient_light": 0,
|
||||
"fixed_time": false,
|
||||
"piglin_safe": false,
|
||||
"bed_works": true,
|
||||
"respawn_anchor_works": false,
|
||||
"has_raids": true,
|
||||
"infiniburn": "infiniburn_overworld",
|
||||
"infiniburn": "#minecraft:infiniburn_overworld",
|
||||
"effects": "minecraft:overworld"
|
||||
}""";
|
||||
}
|
||||
|
||||
@@ -20,6 +20,7 @@ package com.volmit.iris.engine.object;
|
||||
|
||||
import com.mojang.brigadier.exceptions.CommandSyntaxException;
|
||||
import com.volmit.iris.Iris;
|
||||
import com.volmit.iris.core.service.ExternalDataSVC;
|
||||
import com.volmit.iris.engine.data.cache.AtomicCache;
|
||||
import com.volmit.iris.engine.object.annotations.ArrayType;
|
||||
import com.volmit.iris.engine.object.annotations.Desc;
|
||||
@@ -44,6 +45,7 @@ import net.minecraft.nbt.CompoundTag;
|
||||
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.inventory.ItemFlag;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
@@ -53,6 +55,7 @@ import org.bukkit.inventory.meta.LeatherArmorMeta;
|
||||
import org.bukkit.material.Colorable;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.util.Optional;
|
||||
|
||||
@Snippet("loot")
|
||||
@Accessors(chain = true)
|
||||
@@ -117,11 +120,24 @@ public class IrisLoot {
|
||||
|
||||
public ItemStack get(boolean debug, RNG rng) {
|
||||
try {
|
||||
ItemStack is = new ItemStack(getType(), Math.max(1, rng.i(getMinAmount(), getMaxAmount())));
|
||||
ItemStack is;
|
||||
if(!type.startsWith("minecraft:") && type.contains(":")) {
|
||||
Optional<ItemStack> opt = Iris.service(ExternalDataSVC.class).getItemStack(NamespacedKey.fromString(type));
|
||||
if(opt.isEmpty()) {
|
||||
//TODO Better third party provider
|
||||
Iris.warn("Unknown Material: " + type);
|
||||
return null;
|
||||
}
|
||||
is = opt.get();
|
||||
is.setAmount(Math.max(1, rng.i(getMinAmount(), getMaxAmount())));
|
||||
} else {
|
||||
is = new ItemStack(getType(), Math.max(1, rng.i(getMinAmount(), getMaxAmount())));
|
||||
}
|
||||
|
||||
ItemMeta m = is.getItemMeta();
|
||||
|
||||
if(getType().getMaxDurability() > 0 && m instanceof Damageable d) {
|
||||
int max = getType().getMaxDurability();
|
||||
if(is.getType().getMaxDurability() > 0 && m instanceof Damageable d) {
|
||||
int max = is.getType().getMaxDurability();
|
||||
d.setDamage((int) Math.round(Math.max(0, Math.min(max, (1D - rng.d(getMinDurability(), getMaxDurability())) * max))));
|
||||
}
|
||||
|
||||
@@ -184,7 +200,6 @@ public class IrisLoot {
|
||||
return applyCustomNbt(is);
|
||||
} catch(Throwable e) {
|
||||
Iris.reportError(e);
|
||||
|
||||
}
|
||||
|
||||
return new ItemStack(Material.AIR);
|
||||
@@ -196,17 +211,25 @@ public class IrisLoot {
|
||||
}
|
||||
|
||||
if(giveSomething || chance.aquire(() -> NoiseStyle.STATIC.create(rng)).fit(1, rarity * table.getRarity(), x, y, z) == 1) {
|
||||
if(getType() == null) {
|
||||
Iris.warn("Cant find item type " + type);
|
||||
return null;
|
||||
}
|
||||
|
||||
try {
|
||||
ItemStack is = new ItemStack(getType(), Math.max(1, rng.i(getMinAmount(), getMaxAmount())));
|
||||
ItemStack is;
|
||||
if(!type.startsWith("minecraft:") && type.contains(":")) {
|
||||
Optional<ItemStack> opt = Iris.service(ExternalDataSVC.class).getItemStack(NamespacedKey.fromString(type));
|
||||
if(opt.isEmpty()) {
|
||||
Iris.warn("Unknown Material: " + type);
|
||||
return null;
|
||||
}
|
||||
is = opt.get();
|
||||
is.setAmount(Math.max(1, rng.i(getMinAmount(), getMaxAmount())));
|
||||
return is;
|
||||
} else {
|
||||
is = new ItemStack(getType(), Math.max(1, rng.i(getMinAmount(), getMaxAmount())));
|
||||
}
|
||||
|
||||
ItemMeta m = is.getItemMeta();
|
||||
|
||||
if(getType().getMaxDurability() > 0 && m instanceof Damageable d) {
|
||||
int max = getType().getMaxDurability();
|
||||
if(is.getType().getMaxDurability() > 0 && m instanceof Damageable d) {
|
||||
int max = is.getType().getMaxDurability();
|
||||
d.setDamage((int) Math.round(Math.max(0, Math.min(max, (1D - rng.d(getMinDurability(), getMaxDurability())) * max))));
|
||||
}
|
||||
|
||||
@@ -260,7 +283,8 @@ public class IrisLoot {
|
||||
is.setItemMeta(m);
|
||||
return applyCustomNbt(is);
|
||||
} catch(Throwable e) {
|
||||
Iris.reportError(e);
|
||||
//Iris.reportError(e);
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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(() ->
|
||||
{
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -534,41 +528,47 @@ 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;
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
if(h > y) {
|
||||
if(h > y)
|
||||
y = h;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if(config.getMode().equals(ObjectPlaceMode.MIN_HEIGHT)) {
|
||||
y = 257;
|
||||
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();
|
||||
|
||||
@@ -585,7 +585,7 @@ public class IrisObject extends IrisRegistrant {
|
||||
}
|
||||
}
|
||||
} else if(config.getMode().equals(ObjectPlaceMode.FAST_MIN_HEIGHT)) {
|
||||
y = 257;
|
||||
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();
|
||||
|
||||
@@ -733,10 +733,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 +751,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 +794,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);
|
||||
}
|
||||
@@ -820,14 +826,27 @@ public class IrisObject extends IrisRegistrant {
|
||||
i = config.getRotation().rotate(i.clone(), spinx, spiny, spinz).clone();
|
||||
i = config.getTranslate().translate(i.clone(), config.getRotation(), spinx, spiny, spinz).clone();
|
||||
|
||||
if(i.getBlockY() != lowest) {
|
||||
if(i.getBlockY() != lowest)
|
||||
continue;
|
||||
|
||||
for(IrisObjectReplace j : config.getEdit()) {
|
||||
if(rng.chance(j.getChance())) {
|
||||
for(BlockData k : j.getFind(rdata)) {
|
||||
if(j.isExact() ? k.matches(d) : k.getMaterial().equals(d.getMaterial())) {
|
||||
BlockData newData = j.getReplace(rng, i.getX() + x, i.getY() + y, i.getZ() + z, rdata).clone();
|
||||
|
||||
if(newData.getMaterial() == d.getMaterial()) {
|
||||
d = d.merge(newData);
|
||||
} else {
|
||||
d = newData;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if(d == null || B.isAir(d)) {
|
||||
if(d == null || B.isAir(d))
|
||||
continue;
|
||||
}
|
||||
|
||||
xx = x + (int) Math.round(i.getX());
|
||||
zz = z + (int) Math.round(i.getZ());
|
||||
@@ -837,15 +856,16 @@ 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(), config.isUnderwater());
|
||||
int yg = placer.getHighest(xx, zz, getLoader(), true);
|
||||
|
||||
if(yv >= 0 && config.isBottom()) {
|
||||
if(config.isWaterloggable() && yg <= placer.getFluidHeight() && d instanceof Waterlogged)
|
||||
((Waterlogged) d).setWaterlogged(true);
|
||||
|
||||
if(yv >= 0 && config.isBottom())
|
||||
y += Math.floorDiv(h, 2);
|
||||
}
|
||||
|
||||
for(int j = lowest + y; j > yg - config.getOverStilt() - 1; j--) {
|
||||
for(int j = lowest + y; j > yg - config.getOverStilt() - 1; j--)
|
||||
placer.set(xx, j, zz, d);
|
||||
}
|
||||
}
|
||||
|
||||
readLock.unlock();
|
||||
@@ -1118,7 +1138,5 @@ public class IrisObject extends IrisRegistrant {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void scanForErrors(JSONObject p, VolmitSender sender) {
|
||||
|
||||
}
|
||||
public void scanForErrors(JSONObject p, VolmitSender sender) { }
|
||||
}
|
||||
|
||||
@@ -37,12 +37,12 @@ public class IrisObjectLimit {
|
||||
@MinNumber(0)
|
||||
@MaxNumber(1024)
|
||||
@Desc("The minimum height for placement (bottom of object)")
|
||||
private int minimumHeight = 0;
|
||||
private int minimumHeight = -2048; //TODO: WARNING HEIGHT
|
||||
|
||||
@MinNumber(0)
|
||||
@MaxNumber(1024)
|
||||
@Desc("The maximum height for placement (top of object)")
|
||||
private int maximumHeight = 255;
|
||||
private int maximumHeight = 2048; //TODO: WARNING HEIGHT
|
||||
|
||||
public boolean canPlace(int h, int l) {
|
||||
return h <= maximumHeight && l >= minimumHeight;
|
||||
|
||||
@@ -42,8 +42,8 @@ public class IrisObjectTranslate {
|
||||
private int x = 0;
|
||||
|
||||
@Required
|
||||
@MinNumber(-256) // TODO: WARNING HEIGHT
|
||||
@MaxNumber(256) // TODO: WARNING HEIGHT
|
||||
@MinNumber(-128) // TODO: WARNING HEIGHT
|
||||
@MaxNumber(128) // TODO: WARNING HEIGHT
|
||||
@Desc("The x shift in blocks")
|
||||
private int y = 0;
|
||||
|
||||
|
||||
@@ -42,14 +42,14 @@ public class IrisShapedGeneratorStyle {
|
||||
private IrisGeneratorStyle generator = new IrisGeneratorStyle(NoiseStyle.IRIS);
|
||||
|
||||
@Required
|
||||
@MinNumber(-256) // TODO: WARNING HEIGHT
|
||||
@MaxNumber(256) // TODO: WARNING HEIGHT
|
||||
@MinNumber(-2032) // TODO: WARNING HEIGHT
|
||||
@MaxNumber(2032) // TODO: WARNING HEIGHT
|
||||
@Desc("The min block value")
|
||||
private int min = 0;
|
||||
|
||||
@Required
|
||||
@MinNumber(-256) // TODO: WARNING HEIGHT
|
||||
@MaxNumber(256) // TODO: WARNING HEIGHT
|
||||
@MinNumber(-2032) // TODO: WARNING HEIGHT
|
||||
@MaxNumber(2032) // TODO: WARNING HEIGHT
|
||||
@Desc("The max block value")
|
||||
private int max = 0;
|
||||
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,11 +7,13 @@ import com.volmit.iris.util.matter.IrisMatter;
|
||||
import com.volmit.iris.util.matter.Matter;
|
||||
import com.volmit.iris.util.plugin.VolmitSender;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
public class IrisMatterObject extends IrisRegistrant {
|
||||
private final Matter matter;
|
||||
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
package com.volmit.iris.engine.object.matter;
|
||||
|
||||
import com.volmit.iris.engine.IrisEngine;
|
||||
import com.volmit.iris.engine.object.annotations.Desc;
|
||||
import com.volmit.iris.util.function.Function3;
|
||||
|
||||
import java.util.function.Function;
|
||||
|
||||
@Desc("WHERE THINGS PLACE")
|
||||
public enum IrisMatterPlacementLocation {
|
||||
SURFACE((e, x, z) -> e.getHeight(x, z, true)),
|
||||
SURFACE_ON_FLUID((e, x, z) -> e.getHeight(x, z, false)),
|
||||
|
||||
@@ -64,7 +64,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;
|
||||
@@ -164,7 +164,6 @@ public class BukkitChunkGenerator extends ChunkGenerator implements PlatformChun
|
||||
if(yy + (finalI << 4) >= engine.getHeight() || yy + (finalI << 4) < 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
c.getBlock(xx, yy + (finalI << 4) + world.getMinHeight(), zz)
|
||||
.setBlockData(tc.getBlockData(xx, yy + (finalI << 4) + world.getMinHeight(), zz), false);
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@ package com.volmit.iris.util.data;
|
||||
|
||||
import com.volmit.iris.Iris;
|
||||
import com.volmit.iris.core.IrisSettings;
|
||||
import com.volmit.iris.core.service.RegistrySVC;
|
||||
import com.volmit.iris.core.service.ExternalDataSVC;
|
||||
import com.volmit.iris.util.collection.KList;
|
||||
import com.volmit.iris.util.collection.KMap;
|
||||
import com.volmit.iris.util.scheduling.ChronoLatch;
|
||||
@@ -31,16 +31,16 @@ import it.unimi.dsi.fastutil.ints.IntSet;
|
||||
import it.unimi.dsi.fastutil.ints.IntSets;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.NamespacedKey;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
import org.bukkit.block.data.Waterlogged;
|
||||
import org.bukkit.block.data.type.Leaves;
|
||||
import org.bukkit.block.data.type.PointedDripstone;
|
||||
import org.checkerframework.checker.units.qual.K;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.function.Supplier;
|
||||
import java.util.Optional;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static org.bukkit.Material.*;
|
||||
@@ -470,25 +470,11 @@ public class B {
|
||||
try {
|
||||
BlockData bx = null;
|
||||
|
||||
if(!ix.startsWith("minecraft:")) {
|
||||
if(ix.startsWith("oraxen:") && Iris.linkOraxen.supported()) {
|
||||
bx = Iris.linkOraxen.getBlockDataFor(ix.split("\\Q:\\E")[1]);
|
||||
}
|
||||
|
||||
if(bx == null) {
|
||||
try {
|
||||
if(ix.contains(":")) {
|
||||
String[] v = ix.toLowerCase().split("\\Q:\\E");
|
||||
Supplier<BlockData> b = Iris.service(RegistrySVC.class).getCustomBlockRegistry().resolve(v[0], v[1]);
|
||||
|
||||
if(b != null) {
|
||||
bx = b.get();
|
||||
}
|
||||
}
|
||||
} catch(Throwable e) {
|
||||
e.printStackTrace();// TODO: REMOVE
|
||||
}
|
||||
}
|
||||
if(!ix.startsWith("minecraft:") && ix.contains(":")) {
|
||||
NamespacedKey key = NamespacedKey.fromString(ix);
|
||||
Optional<BlockData> bd = Iris.service(ExternalDataSVC.class).getBlockData(key);
|
||||
if(bd.isPresent())
|
||||
bx = bd.get();
|
||||
}
|
||||
|
||||
if(bx == null) {
|
||||
@@ -661,22 +647,10 @@ public class B {
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
for(String i : Iris.linkOraxen.getItemTypes()) {
|
||||
bt.add("oraxen:" + i);
|
||||
}
|
||||
} catch(Throwable e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
for(NamespacedKey id : Iris.service(ExternalDataSVC.class).getAllIdentifiers())
|
||||
bt.add(id.toString());
|
||||
bt.addAll(custom.k());
|
||||
|
||||
try {
|
||||
bt.addAll(Iris.service(RegistrySVC.class).getCustomBlockRegistry().compile());
|
||||
} catch(Throwable e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return bt.toArray(new String[0]);
|
||||
}
|
||||
|
||||
|
||||
@@ -330,7 +330,7 @@ public class Mantle {
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the data tat the current block position This method will attempt to find a
|
||||
* Gets the data at the current block position This method will attempt to find a
|
||||
* Tectonic Plate either by loading it or creating a new one. This method uses
|
||||
* the hyper lock packaged with each Mantle. The hyperlock allows locking of multiple
|
||||
* threads at a single region while still allowing other threads to continue
|
||||
|
||||
@@ -32,7 +32,8 @@ public enum MantleFlag {
|
||||
INITIAL_SPAWNED_MARKER,
|
||||
CLEANED,
|
||||
PLANNED,
|
||||
ETCHED;
|
||||
ETCHED,
|
||||
TILE;
|
||||
|
||||
static StateList getStateList() {
|
||||
return new StateList(MantleFlag.values());
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,10 +21,13 @@ 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.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;
|
||||
@@ -120,7 +123,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
|
||||
@@ -466,4 +469,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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,4 +21,5 @@ commands:
|
||||
iris:
|
||||
aliases: [ ir, irs ]
|
||||
api-version: ${apiversion}
|
||||
hotload-dependencies: false
|
||||
hotload-dependencies: false
|
||||
softdepend: [ "Oraxen", "ItemsAdder", "IrisFeller", "WorldEdit"]
|
||||
BIN
storepage/two/Footer.png
Normal file
|
After Width: | Height: | Size: 85 KiB |
BIN
storepage/two/Header.png
Normal file
|
After Width: | Height: | Size: 2.3 MiB |
BIN
storepage/two/Iris.xd
Normal file
BIN
storepage/two/NOTE.png
Normal file
|
After Width: | Height: | Size: 1.3 MiB |
BIN
storepage/two/NOTERED.png
Normal file
|
After Width: | Height: | Size: 1.1 MiB |
BIN
storepage/two/SUPERTHANKS.png
Normal file
|
After Width: | Height: | Size: 1.7 MiB |
BIN
storepage/two/WhyChooseIris.png
Normal file
|
After Width: | Height: | Size: 2.4 MiB |
BIN
storepage/two/allnewfeatures.png
Normal file
|
After Width: | Height: | Size: 1.6 MiB |
BIN
storepage/two/c1.png
Normal file
|
After Width: | Height: | Size: 2.9 MiB |
BIN
storepage/two/c2.png
Normal file
|
After Width: | Height: | Size: 3.5 MiB |
BIN
storepage/two/c3.png
Normal file
|
After Width: | Height: | Size: 2.9 MiB |
BIN
storepage/two/c4.png
Normal file
|
After Width: | Height: | Size: 3.9 MiB |
BIN
storepage/two/c5.png
Normal file
|
After Width: | Height: | Size: 4.3 MiB |
BIN
storepage/two/dlshare.png
Normal file
|
After Width: | Height: | Size: 1.2 MiB |
BIN
storepage/two/icard.png
Normal file
|
After Width: | Height: | Size: 2.7 MiB |
BIN
storepage/two/speed.png
Normal file
|
After Width: | Height: | Size: 1.5 MiB |