Compare commits
100 Commits
2.0.2-1.18
...
2.1.2-1.18
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
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 | ||
|
|
1c5774fca5 | ||
|
|
0b332b06b6 | ||
|
|
0be9b049a3 | ||
|
|
6993639cc0 | ||
|
|
74172e3123 | ||
|
|
6e1c4f682e | ||
|
|
af0d282a1f | ||
|
|
09bf15fa05 | ||
|
|
43f7d95b4c | ||
|
|
8b536b1775 | ||
|
|
60a7f4bc35 | ||
|
|
0ed0e0c983 | ||
|
|
f4b1ca9f21 | ||
|
|
609104cfa8 | ||
|
|
935d11b433 | ||
|
|
e9eeb8335d | ||
|
|
4a2f42437f | ||
|
|
51b0693c99 | ||
|
|
185b366d8d | ||
|
|
a40e533068 | ||
|
|
5b3918fcb1 | ||
|
|
d315e99b63 | ||
|
|
8090ba0259 | ||
|
|
584400d011 | ||
|
|
124ad23a95 | ||
|
|
6b59aa38ae | ||
|
|
03554eb372 | ||
|
|
dabfe41f29 | ||
|
|
6e2c6fc51e | ||
|
|
d81986bcc5 | ||
|
|
ea17e916b8 | ||
|
|
ce56224038 | ||
|
|
9978932391 | ||
|
|
2ebc9e0deb | ||
|
|
7ddc621009 | ||
|
|
aa4e574eef | ||
|
|
15bc964fcc | ||
|
|
99713ac964 | ||
|
|
f9a6bd1343 | ||
|
|
f4bee872e1 | ||
|
|
be99b286b3 | ||
|
|
c7d5212f82 | ||
|
|
75726b3d34 | ||
|
|
8d7e76ed81 | ||
|
|
01b08b2297 | ||
|
|
cf51581ac1 | ||
|
|
d99fd56995 | ||
|
|
d149051c27 | ||
|
|
660aaa87ca | ||
|
|
4010f03b05 | ||
|
|
e2d2dcf337 | ||
|
|
b11aaf3f0c | ||
|
|
30ae065cb4 |
29
build.gradle
@@ -24,11 +24,10 @@ plugins {
|
||||
id "de.undercouch.download" version "5.0.1"
|
||||
}
|
||||
|
||||
group 'com.volmit.iris'
|
||||
version '2.0.2-1.18.X'
|
||||
def nmsVersion = "1.18.1"
|
||||
version '2.1.2-1.18.2' // Needs to be version specific
|
||||
def nmsVersion = "1.18.2"
|
||||
def apiVersion = '1.18'
|
||||
def spigotJarVersion = '1.18.1-R0.1-SNAPSHOT'
|
||||
def spigotJarVersion = '1.18.2-R0.1-SNAPSHOT'
|
||||
def name = getRootProject().getName() // Defined in settings.gradle
|
||||
def main = 'com.volmit.iris.Iris'
|
||||
|
||||
@@ -39,9 +38,9 @@ registerCustomOutputTask('Psycho', 'D://Dan/MinecraftDevelopment/server/plugins'
|
||||
registerCustomOutputTask('ArcaneArts', 'C://Users/arcane/Documents/development/server/plugins')
|
||||
registerCustomOutputTask('Coco', 'D://Documents/MC/plugins')
|
||||
registerCustomOutputTask('Strange', 'D://Servers/1.17 Test Server/plugins')
|
||||
registerCustomOutputTask('Vatuu', 'D://Minecraft/Servers/1.18.1/plugins')
|
||||
registerCustomOutputTask('Vatuu', 'D://Minecraft/Servers/1.18.2/plugins')
|
||||
// ========================== UNIX ==============================
|
||||
registerCustomOutputTaskUnix('CyberpwnLT', '/Users/danielmills/Documents/development/server/plugins')
|
||||
registerCustomOutputTaskUnix('CyberpwnLT', '/Users/danielmills/development/server/plugins')
|
||||
registerCustomOutputTaskUnix('PsychoLT', '/Users/brianfopiano/Desktop/REMOTES/RemoteMinecraft/plugins')
|
||||
// ==============================================================
|
||||
|
||||
@@ -75,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"}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -123,10 +124,12 @@ dependencies {
|
||||
// Provided or Classpath
|
||||
compileOnly 'org.projectlombok:lombok:1.18.22'
|
||||
annotationProcessor 'org.projectlombok:lombok:1.18.22'
|
||||
implementation 'org.spigotmc:spigot-api:1.18.1-R0.1-SNAPSHOT'
|
||||
implementation 'me.clip:placeholderapi:2.10.10'
|
||||
implementation 'org.spigotmc:spigot-api:1.18.2-R0.1-SNAPSHOT'
|
||||
implementation 'me.clip:placeholderapi:2.11.1'
|
||||
implementation 'io.th0rgal:oraxen:1.94.0'
|
||||
implementation 'org.bukkit:craftbukkit:1.18.1-R0.1-SNAPSHOT:remapped-mojang'
|
||||
implementation 'org.bukkit:craftbukkit:1.18.2-R0.1-SNAPSHOT:remapped-mojang'
|
||||
implementation 'com.github.LoneDev6:api-itemsadder:3.1.0b'
|
||||
implementation 'com.sk89q.worldedit:worldedit-bukkit:7.2.9'
|
||||
|
||||
// Shaded
|
||||
implementation 'com.dfsek:Paralithic:0.4.0'
|
||||
@@ -137,15 +140,15 @@ dependencies {
|
||||
|
||||
// Dynamically Loaded
|
||||
implementation 'io.timeandspace:smoothie-map:2.0.2'
|
||||
implementation 'it.unimi.dsi:fastutil:8.5.6'
|
||||
implementation 'it.unimi.dsi:fastutil:8.5.8'
|
||||
implementation 'com.googlecode.concurrentlinkedhashmap:concurrentlinkedhashmap-lru:1.4.2'
|
||||
implementation 'org.zeroturnaround:zt-zip:1.14'
|
||||
implementation 'com.google.code.gson:gson:2.8.9'
|
||||
implementation 'com.google.code.gson:gson:2.9.0'
|
||||
implementation 'org.ow2.asm:asm:9.2'
|
||||
implementation 'com.google.guava:guava:31.0.1-jre'
|
||||
implementation 'com.google.guava:guava:31.1-jre'
|
||||
implementation 'bsf:bsf:2.4.0'
|
||||
implementation 'rhino:js:1.7R2'
|
||||
implementation 'com.github.ben-manes.caffeine:caffeine:3.0.5'
|
||||
implementation 'com.github.ben-manes.caffeine:caffeine:3.0.6'
|
||||
implementation 'org.apache.commons:commons-lang3:3.12.0'
|
||||
}
|
||||
|
||||
|
||||
@@ -18,17 +18,17 @@
|
||||
|
||||
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.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.IrisWorld;
|
||||
@@ -40,10 +40,7 @@ import com.volmit.iris.util.exceptions.IrisException;
|
||||
import com.volmit.iris.util.format.C;
|
||||
import com.volmit.iris.util.format.Form;
|
||||
import com.volmit.iris.util.function.NastyRunnable;
|
||||
import com.volmit.iris.util.io.FileWatcher;
|
||||
import com.volmit.iris.util.io.IO;
|
||||
import com.volmit.iris.util.io.InstanceState;
|
||||
import com.volmit.iris.util.io.JarScanner;
|
||||
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.parallel.MultiBurst;
|
||||
@@ -65,7 +62,6 @@ import org.bukkit.World;
|
||||
import org.bukkit.WorldCreator;
|
||||
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.Player;
|
||||
@@ -79,15 +75,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 {
|
||||
@@ -95,7 +88,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;
|
||||
@@ -189,7 +181,6 @@ public class Iris extends VolmitPlugin implements Listener {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static File getCached(String name, String url) {
|
||||
String h = IO.hash(name + "@" + url);
|
||||
File f = Iris.instance.getDataFile("cache", h.substring(0, 2), h.substring(3, 5), h);
|
||||
@@ -253,12 +244,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) {
|
||||
@@ -401,7 +392,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);
|
||||
@@ -686,17 +676,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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,7 +32,7 @@ import java.io.IOException;
|
||||
@SuppressWarnings("SynchronizeOnNonFinalField")
|
||||
@Data
|
||||
public class IrisSettings {
|
||||
public static transient IrisSettings settings;
|
||||
public static IrisSettings settings;
|
||||
private IrisSettingsGeneral general = new IrisSettingsGeneral();
|
||||
private IrisSettingsWorld world = new IrisSettingsWorld();
|
||||
private IrisSettingsGUI gui = new IrisSettingsGUI();
|
||||
|
||||
@@ -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()
|
||||
@@ -101,7 +101,7 @@ public class CommandIris implements DecreeExecutor {
|
||||
sender().sendMessage(C.GREEN + "Iris v" + Iris.instance.getDescription().getVersion() + " by Volmit Software");
|
||||
}
|
||||
|
||||
@Decree(description = "Print version information", origin = DecreeOrigin.PLAYER)
|
||||
@Decree(description = "Print world height information", origin = DecreeOrigin.PLAYER)
|
||||
public void height() {
|
||||
sender().sendMessage(C.GREEN + "" + sender().player().getWorld().getMinHeight() + " to " + sender().player().getWorld().getMaxHeight());
|
||||
sender().sendMessage(C.GREEN + "Total Height: " + (sender().player().getWorld().getMaxHeight() - sender().player().getWorld().getMinHeight()));
|
||||
|
||||
@@ -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;
|
||||
@@ -327,7 +324,11 @@ public class CommandObject implements DecreeExecutor {
|
||||
|
||||
Map<Block, BlockData> futureChanges = new HashMap<>();
|
||||
|
||||
o = o.scaled(scale, IrisObjectPlacementScaleInterpolator.TRICUBIC);
|
||||
if(scale != 1)
|
||||
{
|
||||
o = o.scaled(scale, IrisObjectPlacementScaleInterpolator.TRICUBIC);
|
||||
}
|
||||
|
||||
o.place(block.getBlockX(), block.getBlockY() + (int) o.getCenter().getY(), block.getBlockZ(), createPlacer(block.getWorld(), futureChanges), placement, new RNG(), null);
|
||||
|
||||
Iris.service(ObjectSVC.class).addChanges(futureChanges);
|
||||
@@ -422,6 +423,24 @@ 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;
|
||||
}
|
||||
|
||||
Pair<Location, Location> locs = WorldEditLink.getSelection(sender().player());
|
||||
if(locs.getFirst() == null)
|
||||
sender().sendMessage(C.RED + "You don't have a WorldEdit selection!");
|
||||
else if(locs.getSecond() == null)
|
||||
sender().sendMessage(C.RED + "You need a valid WorldRegion selection in the current world!");
|
||||
else {
|
||||
sender().player().getInventory().addItem(WandSVC.createWand(locs.getFirst(), locs.getSecond()));
|
||||
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());
|
||||
|
||||
@@ -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 {
|
||||
@@ -68,6 +71,10 @@ public class JigsawEditor implements Listener {
|
||||
}
|
||||
|
||||
editors.put(player, this);
|
||||
if(object == null)
|
||||
{
|
||||
throw new RuntimeException("Object is null! " + piece.getObject());
|
||||
}
|
||||
this.object = object;
|
||||
this.player = player;
|
||||
origin = player.getLocation().clone().add(0, 7, 0);
|
||||
@@ -77,7 +84,7 @@ public class JigsawEditor implements Listener {
|
||||
this.piece.setObject(object.getLoadKey());
|
||||
cuboid = new Cuboid(origin.clone(), origin.clone().add(object.getW() - 1, object.getH() - 1, object.getD() - 1));
|
||||
ticker = J.sr(this::onTick, 0);
|
||||
object.placeCenterY(origin);
|
||||
J.s(() -> object.placeCenterY(origin));
|
||||
Iris.instance.registerListener(this);
|
||||
}
|
||||
|
||||
@@ -150,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;
|
||||
}
|
||||
}
|
||||
@@ -65,7 +65,7 @@ public class MythicMobsLink {
|
||||
}
|
||||
|
||||
try {
|
||||
Class<?> mythicMobClass = Class.forName("io.lumine.xikage.mythicmobs.MythicMobs");
|
||||
Class<?> mythicMobClass = Class.forName("io.lumine.mythic.bukkit.MythicBukkit");
|
||||
Method getInst = mythicMobClass.getDeclaredMethod("inst");
|
||||
Object inst = getInst.invoke(null);
|
||||
Method getAPIHelper = mythicMobClass.getDeclaredMethod("getAPIHelper");
|
||||
|
||||
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");
|
||||
}
|
||||
}
|
||||
32
src/main/java/com/volmit/iris/core/link/WorldEditLink.java
Normal file
@@ -0,0 +1,32 @@
|
||||
package com.volmit.iris.core.link;
|
||||
|
||||
import com.mojang.datafixers.util.Pair;
|
||||
import com.sk89q.worldedit.IncompleteRegionException;
|
||||
import com.sk89q.worldedit.LocalSession;
|
||||
import com.sk89q.worldedit.WorldEdit;
|
||||
import com.sk89q.worldedit.bukkit.BukkitAdapter;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.regions.Region;
|
||||
import com.sk89q.worldedit.session.MissingSessionException;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class WorldEditLink {
|
||||
|
||||
public static Pair<Location, Location> getSelection(Player p) {
|
||||
LocalSession session = WorldEdit.getInstance().getSessionManager().getIfPresent(BukkitAdapter.adapt(p));
|
||||
try {
|
||||
if(session == null)
|
||||
throw new MissingSessionException();
|
||||
Region r = session.getSelection(BukkitAdapter.adapt(p.getWorld()));
|
||||
BlockVector3 p1 = r.getMinimumPoint();
|
||||
BlockVector3 p2 = r.getMaximumPoint();
|
||||
return new Pair<>(new Location(p.getWorld(), p1.getX(), p1.getY(), p1.getZ()), new Location(p.getWorld(), p2.getX(), p2.getY(), p2.getZ()));
|
||||
} catch(MissingSessionException e) {
|
||||
return new Pair<>(null, new Location(null, 0, 0, 0));
|
||||
} catch(IncompleteRegionException e) {
|
||||
return new Pair<>(new Location(null, 0, 0, 0), null);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -31,26 +31,9 @@ import com.google.gson.stream.JsonWriter;
|
||||
import com.volmit.iris.Iris;
|
||||
import com.volmit.iris.engine.data.cache.AtomicCache;
|
||||
import com.volmit.iris.engine.framework.Engine;
|
||||
import com.volmit.iris.engine.object.IrisBiome;
|
||||
import com.volmit.iris.engine.object.IrisBlockData;
|
||||
import com.volmit.iris.engine.object.IrisCave;
|
||||
import com.volmit.iris.engine.object.IrisDimension;
|
||||
import com.volmit.iris.engine.object.IrisEntity;
|
||||
import com.volmit.iris.engine.object.IrisExpression;
|
||||
import com.volmit.iris.engine.object.IrisGenerator;
|
||||
import com.volmit.iris.engine.object.IrisImage;
|
||||
import com.volmit.iris.engine.object.IrisJigsawPiece;
|
||||
import com.volmit.iris.engine.object.IrisJigsawPool;
|
||||
import com.volmit.iris.engine.object.IrisJigsawStructure;
|
||||
import com.volmit.iris.engine.object.IrisLootTable;
|
||||
import com.volmit.iris.engine.object.IrisMarker;
|
||||
import com.volmit.iris.engine.object.IrisMod;
|
||||
import com.volmit.iris.engine.object.IrisObject;
|
||||
import com.volmit.iris.engine.object.IrisRavine;
|
||||
import com.volmit.iris.engine.object.IrisRegion;
|
||||
import com.volmit.iris.engine.object.IrisScript;
|
||||
import com.volmit.iris.engine.object.IrisSpawner;
|
||||
import com.volmit.iris.engine.object.*;
|
||||
import com.volmit.iris.engine.object.annotations.Snippet;
|
||||
import com.volmit.iris.engine.object.matter.IrisMatterObject;
|
||||
import com.volmit.iris.util.collection.KList;
|
||||
import com.volmit.iris.util.collection.KMap;
|
||||
import com.volmit.iris.util.context.IrisContext;
|
||||
@@ -87,10 +70,12 @@ public class IrisData implements ExclusionStrategy, TypeAdapterFactory {
|
||||
private ResourceLoader<IrisBlockData> blockLoader;
|
||||
private ResourceLoader<IrisExpression> expressionLoader;
|
||||
private ResourceLoader<IrisObject> objectLoader;
|
||||
private ResourceLoader<IrisMatterObject> matterLoader;
|
||||
private ResourceLoader<IrisImage> imageLoader;
|
||||
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;
|
||||
@@ -131,6 +116,9 @@ public class IrisData implements ExclusionStrategy, TypeAdapterFactory {
|
||||
public static IrisObject loadAnyObject(String key) {
|
||||
return loadAny(key, (dm) -> dm.getObjectLoader().load(key, false));
|
||||
}
|
||||
public static IrisMatterObject loadAnyMatter(String key) {
|
||||
return loadAny(key, (dm) -> dm.getMatterLoader().load(key, false));
|
||||
}
|
||||
|
||||
public static IrisBiome loadAnyBiome(String key) {
|
||||
return loadAny(key, (dm) -> dm.getBiomeLoader().load(key, false));
|
||||
@@ -295,9 +283,12 @@ public class IrisData implements ExclusionStrategy, TypeAdapterFactory {
|
||||
if(registrant.equals(IrisObject.class)) {
|
||||
r = (ResourceLoader<T>) new ObjectResourceLoader(dataFolder, this, rr.getFolderName(),
|
||||
rr.getTypeName());
|
||||
} else if(registrant.equals(IrisMatterObject.class)) {
|
||||
r = (ResourceLoader<T>) new MatterObjectResourceLoader(dataFolder, this, rr.getFolderName(),
|
||||
rr.getTypeName());
|
||||
} else if(registrant.equals(IrisScript.class)) {
|
||||
r = (ResourceLoader<T>) new ScriptResourceLoader(dataFolder, this, rr.getFolderName(),
|
||||
rr.getTypeName());
|
||||
rr.getTypeName());
|
||||
} else if(registrant.equals(IrisImage.class)) {
|
||||
r = (ResourceLoader<T>) new ImageResourceLoader(dataFolder, this, rr.getFolderName(),
|
||||
rr.getTypeName());
|
||||
@@ -347,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();
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,146 @@
|
||||
/*
|
||||
* 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.loader;
|
||||
|
||||
import com.volmit.iris.Iris;
|
||||
import com.volmit.iris.core.IrisSettings;
|
||||
import com.volmit.iris.engine.object.matter.IrisMatterObject;
|
||||
import com.volmit.iris.util.collection.KList;
|
||||
import com.volmit.iris.util.collection.KSet;
|
||||
import com.volmit.iris.util.data.KCache;
|
||||
import com.volmit.iris.util.scheduling.PrecisionStopwatch;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
public class MatterObjectResourceLoader extends ResourceLoader<IrisMatterObject> {
|
||||
public MatterObjectResourceLoader(File root, IrisData idm, String folderName, String resourceTypeName) {
|
||||
super(root, idm, folderName, resourceTypeName, IrisMatterObject.class);
|
||||
loadCache = new KCache<>(this::loadRaw, IrisSettings.get().getPerformance().getObjectLoaderCacheSize());
|
||||
}
|
||||
|
||||
public boolean supportsSchemas() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public long getSize() {
|
||||
return loadCache.getSize();
|
||||
}
|
||||
|
||||
public long getTotalStorage() {
|
||||
return getSize();
|
||||
}
|
||||
|
||||
protected IrisMatterObject loadFile(File j, String name) {
|
||||
try {
|
||||
PrecisionStopwatch p = PrecisionStopwatch.start();
|
||||
IrisMatterObject t = IrisMatterObject.from(j);
|
||||
t.setLoadKey(name);
|
||||
t.setLoader(manager);
|
||||
t.setLoadFile(j);
|
||||
logLoad(j, t);
|
||||
tlt.addAndGet(p.getMilliseconds());
|
||||
return t;
|
||||
} catch(Throwable e) {
|
||||
Iris.reportError(e);
|
||||
Iris.warn("Couldn't read " + resourceTypeName + " file: " + j.getPath() + ": " + e.getMessage());
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public String[] getPossibleKeys() {
|
||||
if(possibleKeys != null) {
|
||||
return possibleKeys;
|
||||
}
|
||||
|
||||
Iris.debug("Building " + resourceTypeName + " Possibility Lists");
|
||||
KSet<String> m = new KSet<>();
|
||||
|
||||
for(File i : getFolders()) {
|
||||
for(File j : i.listFiles()) {
|
||||
if(j.isFile() && j.getName().endsWith(".mat")) {
|
||||
m.add(j.getName().replaceAll("\\Q.mat\\E", ""));
|
||||
} else if(j.isDirectory()) {
|
||||
for(File k : j.listFiles()) {
|
||||
if(k.isFile() && k.getName().endsWith(".mat")) {
|
||||
m.add(j.getName() + "/" + k.getName().replaceAll("\\Q.mat\\E", ""));
|
||||
} else if(k.isDirectory()) {
|
||||
for(File l : k.listFiles()) {
|
||||
if(l.isFile() && l.getName().endsWith(".mat")) {
|
||||
m.add(j.getName() + "/" + k.getName() + "/" + l.getName().replaceAll("\\Q.mat\\E", ""));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
KList<String> v = new KList<>(m);
|
||||
possibleKeys = v.toArray(new String[0]);
|
||||
return possibleKeys;
|
||||
}
|
||||
|
||||
public File findFile(String name) {
|
||||
for(File i : getFolders(name)) {
|
||||
for(File j : i.listFiles()) {
|
||||
if(j.isFile() && j.getName().endsWith(".mat") && j.getName().split("\\Q.\\E")[0].equals(name)) {
|
||||
return j;
|
||||
}
|
||||
}
|
||||
|
||||
File file = new File(i, name + ".mat");
|
||||
|
||||
if(file.exists()) {
|
||||
return file;
|
||||
}
|
||||
}
|
||||
|
||||
Iris.warn("Couldn't find " + resourceTypeName + ": " + name);
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public IrisMatterObject load(String name) {
|
||||
return load(name, true);
|
||||
}
|
||||
|
||||
private IrisMatterObject loadRaw(String name) {
|
||||
for(File i : getFolders(name)) {
|
||||
for(File j : i.listFiles()) {
|
||||
if(j.isFile() && j.getName().endsWith(".mat") && j.getName().split("\\Q.\\E")[0].equals(name)) {
|
||||
return loadFile(j, name);
|
||||
}
|
||||
}
|
||||
|
||||
File file = new File(i, name + ".mat");
|
||||
|
||||
if(file.exists()) {
|
||||
return loadFile(file, name);
|
||||
}
|
||||
}
|
||||
|
||||
Iris.warn("Couldn't find " + resourceTypeName + ": " + name);
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public IrisMatterObject load(String name, boolean warn) {
|
||||
return loadCache.get(name);
|
||||
}
|
||||
}
|
||||
@@ -20,7 +20,7 @@ package com.volmit.iris.core.nms;
|
||||
|
||||
import com.volmit.iris.Iris;
|
||||
import com.volmit.iris.core.IrisSettings;
|
||||
import com.volmit.iris.core.nms.v18_1.NMSBinding18_1;
|
||||
import com.volmit.iris.core.nms.v18_2.NMSBinding18_2;
|
||||
import com.volmit.iris.core.nms.v1X.NMSBinding1X;
|
||||
import com.volmit.iris.util.collection.KMap;
|
||||
import org.bukkit.Bukkit;
|
||||
@@ -28,7 +28,7 @@ import org.bukkit.Bukkit;
|
||||
public class INMS {
|
||||
//@builder
|
||||
private static final KMap<String, Class<? extends INMSBinding>> bindings = new KMap<String, Class<? extends INMSBinding>>()
|
||||
.qput("v1_18_R1", NMSBinding18_1.class);
|
||||
.qput("v1_18_R2", NMSBinding18_2.class);
|
||||
//@done
|
||||
private static final INMSBinding binding = bind();
|
||||
|
||||
|
||||
@@ -54,6 +54,7 @@ public interface INMSBinding {
|
||||
String getTrueBiomeBaseKey(Location location);
|
||||
|
||||
Object getCustomBiomeBaseFor(String mckey);
|
||||
Object getCustomBiomeBaseHolderFor(String mckey);
|
||||
|
||||
String getKeyForBiomeBase(Object biomeBase);
|
||||
|
||||
|
||||
@@ -24,6 +24,7 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public enum NMSVersion {
|
||||
R1_18_2,
|
||||
R1_18,
|
||||
R1_17,
|
||||
R1_16,
|
||||
@@ -98,6 +99,9 @@ public enum NMSVersion {
|
||||
if(tryVersion("1_18_R1")) {
|
||||
return R1_18;
|
||||
}
|
||||
if(tryVersion("1_18_R2")) {
|
||||
return R1_18_2;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.volmit.iris.core.nms.v18_1;
|
||||
package com.volmit.iris.core.nms.v18_2;
|
||||
|
||||
|
||||
import com.volmit.iris.Iris;
|
||||
@@ -36,10 +36,7 @@ import com.volmit.iris.util.nbt.mca.palette.MCAPalettedContainer;
|
||||
import com.volmit.iris.util.nbt.mca.palette.MCAWrappedPalettedContainer;
|
||||
import com.volmit.iris.util.nbt.tag.CompoundTag;
|
||||
import it.unimi.dsi.fastutil.objects.Object2IntMap;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.IdMap;
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.core.RegistryAccess;
|
||||
import net.minecraft.core.*;
|
||||
import net.minecraft.nbt.NbtIo;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
@@ -52,9 +49,10 @@ import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.Biome;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
import org.bukkit.craftbukkit.v1_18_R1.CraftServer;
|
||||
import org.bukkit.craftbukkit.v1_18_R1.CraftWorld;
|
||||
import org.bukkit.craftbukkit.v1_18_R1.block.data.CraftBlockData;
|
||||
|
||||
import org.bukkit.craftbukkit.v1_18_R2.CraftServer;
|
||||
import org.bukkit.craftbukkit.v1_18_R2.CraftWorld;
|
||||
import org.bukkit.craftbukkit.v1_18_R2.block.data.CraftBlockData;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.generator.ChunkGenerator;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -70,7 +68,7 @@ import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
public class NMSBinding18_1 implements INMSBinding {
|
||||
public class NMSBinding18_2 implements INMSBinding {
|
||||
|
||||
private final KMap<Biome, Object> baseBiomeCache = new KMap<>();
|
||||
private final BlockData AIR = Material.AIR.createBlockData();
|
||||
@@ -148,7 +146,7 @@ public class NMSBinding18_1 implements INMSBinding {
|
||||
}
|
||||
|
||||
private RegistryAccess registry() {
|
||||
return registryAccess.aquire(() -> (RegistryAccess) getFor(RegistryAccess.class, ((CraftServer) Bukkit.getServer()).getHandle().getServer()));
|
||||
return registryAccess.aquire(() -> (RegistryAccess) getFor(RegistryAccess.Frozen.class, ((CraftServer) Bukkit.getServer()).getHandle().getServer()));
|
||||
}
|
||||
|
||||
private Registry<net.minecraft.world.level.biome.Biome> getCustomBiomeRegistry() {
|
||||
@@ -210,6 +208,10 @@ public class NMSBinding18_1 implements INMSBinding {
|
||||
public Object getCustomBiomeBaseFor(String mckey) {
|
||||
return getCustomBiomeRegistry().get(new ResourceLocation(mckey));
|
||||
}
|
||||
@Override
|
||||
public Object getCustomBiomeBaseHolderFor(String mckey) {
|
||||
return getCustomBiomeRegistry().getHolder(getTrueBiomeBaseId(getCustomBiomeRegistry().get(new ResourceLocation(mckey)))).get();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getKeyForBiomeBase(Object biomeBase) {
|
||||
@@ -229,13 +231,13 @@ public class NMSBinding18_1 implements INMSBinding {
|
||||
return v;
|
||||
}
|
||||
//noinspection unchecked
|
||||
v = org.bukkit.craftbukkit.v1_18_R1.block.CraftBlock.biomeToBiomeBase((Registry<net.minecraft.world.level.biome.Biome>) registry, biome);
|
||||
v = org.bukkit.craftbukkit.v1_18_R2.block.CraftBlock.biomeToBiomeBase((Registry<net.minecraft.world.level.biome.Biome>) registry, biome);
|
||||
if(v == null) {
|
||||
// Ok so there is this new biome name called "CUSTOM" in Paper's new releases.
|
||||
// But, this does NOT exist within CraftBukkit which makes it return an error.
|
||||
// So, we will just return the ID that the plains biome returns instead.
|
||||
//noinspection unchecked
|
||||
return org.bukkit.craftbukkit.v1_18_R1.block.CraftBlock.biomeToBiomeBase((Registry<net.minecraft.world.level.biome.Biome>) registry, Biome.PLAINS);
|
||||
return org.bukkit.craftbukkit.v1_18_R2.block.CraftBlock.biomeToBiomeBase((Registry<net.minecraft.world.level.biome.Biome>) registry, Biome.PLAINS);
|
||||
}
|
||||
baseBiomeCache.put(biome, v);
|
||||
return v;
|
||||
@@ -334,7 +336,7 @@ public class NMSBinding18_1 implements INMSBinding {
|
||||
public void forceBiomeInto(int x, int y, int z, Object somethingVeryDirty, ChunkGenerator.BiomeGrid chunk) {
|
||||
try {
|
||||
ChunkAccess s = (ChunkAccess) getFieldForBiomeStorage(chunk).get(chunk);
|
||||
s.setBiome(x, y, z, (net.minecraft.world.level.biome.Biome) somethingVeryDirty);
|
||||
s.setBiome(x, y, z, (Holder<net.minecraft.world.level.biome.Biome>) somethingVeryDirty); // probably not safe? it said it wanted a holder, so i made it a holder...
|
||||
} catch(IllegalAccessException e) {
|
||||
Iris.reportError(e);
|
||||
e.printStackTrace();
|
||||
@@ -414,18 +416,21 @@ public class NMSBinding18_1 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;
|
||||
}
|
||||
}
|
||||
@@ -112,6 +112,11 @@ public class NMSBinding1X implements INMSBinding {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getCustomBiomeBaseHolderFor(String mckey) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getKeyForBiomeBase(Object biomeBase) {
|
||||
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;
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -42,6 +42,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;
|
||||
@@ -388,6 +389,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 +411,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) {
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
package com.volmit.iris.core.tools;
|
||||
|
||||
import com.volmit.iris.util.data.B;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
|
||||
/**
|
||||
* This class is used by an external IrisLib for other plugins to interact with Iris. Do not change
|
||||
* existing methods or their parameters as it will break the library that uses these methods
|
||||
* feel free to add more methods so long as you also add the reflective methods to the library
|
||||
*/
|
||||
public class IrisReflectiveAPI {
|
||||
public static boolean isIrisWorld(World world) {
|
||||
return IrisToolbelt.isIrisWorld(world);
|
||||
}
|
||||
|
||||
public static boolean isIrisStudioWorld(World world) {
|
||||
return IrisToolbelt.isIrisStudioWorld(world);
|
||||
}
|
||||
|
||||
public static void registerCustomBlockData(String namespace, String key, BlockData blockData) {
|
||||
B.registerCustomBlockData(namespace, key, blockData);
|
||||
}
|
||||
|
||||
public static void retainMantleData(String classname) {
|
||||
IrisToolbelt.retainMantleDataForSlice(classname);
|
||||
}
|
||||
|
||||
public static void setMantleData(World world, int x, int y, int z, Object data) {
|
||||
IrisToolbelt.access(world).getEngine().getMantle().getMantle().set(x, y, z, data);
|
||||
}
|
||||
|
||||
public static void deleteMantleData(World world, int x, int y, int z, Class c) {
|
||||
IrisToolbelt.access(world).getEngine().getMantle().getMantle().remove(x, y, z, c);
|
||||
}
|
||||
|
||||
public static Object getMantleData(World world, int x, int y, int z, Class c) {
|
||||
return IrisToolbelt.access(world).getEngine().getMantle().getMantle().get(x, y, z, c);
|
||||
}
|
||||
}
|
||||
@@ -32,15 +32,21 @@ import com.volmit.iris.engine.platform.PlatformChunkGenerator;
|
||||
import com.volmit.iris.util.plugin.VolmitSender;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.io.File;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Something you really want to wear if working on Iris. Shit gets pretty hectic down there.
|
||||
* Hope you packed snacks & road sodas.
|
||||
*/
|
||||
public class IrisToolbelt {
|
||||
public static Map<String, Boolean> toolbeltConfiguration = new HashMap<>();
|
||||
|
||||
/**
|
||||
* Will find / download / search for the dimension or return null
|
||||
* <p>
|
||||
@@ -110,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;
|
||||
}
|
||||
|
||||
@@ -210,4 +232,20 @@ public class IrisToolbelt {
|
||||
public static boolean isStudio(World i) {
|
||||
return isIrisWorld(i) && access(i).isStudio();
|
||||
}
|
||||
|
||||
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) {
|
||||
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) {
|
||||
PlatformChunkGenerator e = access(world);
|
||||
if(e == null) {return;}
|
||||
e.getEngine().getMantle().getMantle().remove(x, y - world.getMinHeight(), z, of);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -336,8 +336,7 @@ public class IrisComplex implements DataProvider {
|
||||
}
|
||||
|
||||
private double getHeight(Engine engine, IrisBiome b, double x, double z, long seed) {
|
||||
return Math.min(engine.getWorld().maxHeight(),
|
||||
Math.max(getInterpolatedHeight(engine, x, z, seed) + fluidHeight + overlayStream.get(x, z), engine.getWorld().minHeight()));
|
||||
return Math.max(Math.min(getInterpolatedHeight(engine, x, z, seed) + fluidHeight + overlayStream.get(x, z), engine.getHeight()), 0);
|
||||
}
|
||||
|
||||
private void registerGenerator(IrisGenerator cachedGenerator) {
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -57,7 +57,7 @@ public class IrisBiomeActuator extends EngineAssignedActuator<Biome> {
|
||||
return true;
|
||||
}
|
||||
} catch(Throwable e) {
|
||||
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return false;
|
||||
@@ -79,7 +79,7 @@ public class IrisBiomeActuator extends EngineAssignedActuator<Biome> {
|
||||
if(ib.isCustom()) {
|
||||
try {
|
||||
IrisBiomeCustom custom = ib.getCustomBiome(rng, x, 0, z);
|
||||
Object biomeBase = INMS.get().getCustomBiomeBaseFor(getDimension().getLoadKey() + ":" + custom.getId());
|
||||
Object biomeBase = INMS.get().getCustomBiomeBaseHolderFor(getDimension().getLoadKey() + ":" + custom.getId());
|
||||
//
|
||||
if(biomeBase == null || !injectBiome(h, x, 0, z, biomeBase)) {
|
||||
throw new RuntimeException("Cant inject biome!");
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
|
||||
package com.volmit.iris.engine.data.chunk;
|
||||
|
||||
import com.volmit.iris.Iris;
|
||||
import com.volmit.iris.core.nms.BiomeBaseInjector;
|
||||
import com.volmit.iris.core.nms.INMS;
|
||||
import com.volmit.iris.util.data.IrisBiomeStorage;
|
||||
|
||||
@@ -472,6 +472,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 +748,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;
|
||||
}
|
||||
|
||||
@@ -69,24 +69,31 @@ public abstract class EngineAssignedWorldManager extends EngineAssignedComponent
|
||||
|
||||
protected AtomicBoolean ignoreTP = new AtomicBoolean(false);
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||
public void on(PlayerTeleportEvent e) {
|
||||
if(ignoreTP.get()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if(!PaperLib.isPaper() || e.getTo() == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
if(e.getTo().getWorld().equals(getTarget().getWorld().realWorld())) {
|
||||
getEngine().getWorldManager().teleportAsync(e);
|
||||
}
|
||||
} catch(Throwable ex) {
|
||||
|
||||
}
|
||||
}
|
||||
// @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||
// public void on(PlayerTeleportEvent e) {
|
||||
// if(ignoreTP.get()) {
|
||||
// System.out.println("IgTP1");
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// if(!PaperLib.isPaper() || e.getTo() == null) {
|
||||
// System.out.println("IgTP2");
|
||||
//
|
||||
//// return;
|
||||
// }
|
||||
//
|
||||
//// try {
|
||||
//// System.out.println("IgTP3");
|
||||
////
|
||||
//// if(e.getTo().getWorld().equals(getTarget().getWorld().realWorld())) {
|
||||
//// System.out.println("IgTP4");
|
||||
////
|
||||
//// getEngine().getWorldManager().teleportAsync(e);
|
||||
//// }
|
||||
//// } catch(Throwable ex) {
|
||||
////
|
||||
//// }
|
||||
// }
|
||||
|
||||
@EventHandler
|
||||
public void on(WorldSaveEvent e) {
|
||||
|
||||
@@ -24,6 +24,7 @@ import com.volmit.iris.core.loader.IrisData;
|
||||
import com.volmit.iris.engine.data.cache.Cache;
|
||||
import com.volmit.iris.engine.framework.Engine;
|
||||
import com.volmit.iris.engine.object.IObjectPlacer;
|
||||
import com.volmit.iris.engine.object.IrisGeneratorStyle;
|
||||
import com.volmit.iris.engine.object.IrisPosition;
|
||||
import com.volmit.iris.engine.object.TileData;
|
||||
import com.volmit.iris.util.collection.KMap;
|
||||
@@ -31,6 +32,7 @@ import com.volmit.iris.util.collection.KSet;
|
||||
import com.volmit.iris.util.function.Function3;
|
||||
import com.volmit.iris.util.mantle.Mantle;
|
||||
import com.volmit.iris.util.mantle.MantleChunk;
|
||||
import com.volmit.iris.util.math.RNG;
|
||||
import com.volmit.iris.util.matter.Matter;
|
||||
import lombok.Data;
|
||||
import org.bukkit.block.TileState;
|
||||
@@ -121,6 +123,13 @@ public class MantleWriter implements IObjectPlacer {
|
||||
return (x * x) + (z * z);
|
||||
}
|
||||
|
||||
public <T> void setDataWarped(int x, int y, int z, T t, RNG rng, IrisData data, IrisGeneratorStyle style)
|
||||
{
|
||||
setData((int)Math.round(style.warp(rng, data, x, x, y, -z)),
|
||||
(int)Math.round(style.warp(rng, data, y, z, -x, y)),
|
||||
(int)Math.round(style.warp(rng, data, z, -y, z, x)), t);
|
||||
}
|
||||
|
||||
public <T> void setData(int x, int y, int z, T t) {
|
||||
if(t == null) {
|
||||
return;
|
||||
@@ -233,6 +242,10 @@ public class MantleWriter implements IObjectPlacer {
|
||||
setElipsoidFunction(cx, cy, cz, rx, ry, rz, fill, (a, b, c) -> data);
|
||||
}
|
||||
|
||||
public <T> void setElipsoidWarped(int cx, int cy, int cz, double rx, double ry, double rz, boolean fill, T data, RNG rng, IrisData idata, IrisGeneratorStyle style) {
|
||||
setElipsoidFunctionWarped(cx, cy, cz, rx, ry, rz, fill, (a, b, c) -> data, rng, idata, style);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set an elipsoid into the mantle
|
||||
*
|
||||
@@ -312,6 +325,63 @@ public class MantleWriter implements IObjectPlacer {
|
||||
}
|
||||
}
|
||||
|
||||
public <T> void setElipsoidFunctionWarped(int cx, int cy, int cz, double rx, double ry, double rz, boolean fill, Function3<Integer, Integer, Integer, T> data, RNG rng, IrisData idata, IrisGeneratorStyle style) {
|
||||
rx += 0.5;
|
||||
ry += 0.5;
|
||||
rz += 0.5;
|
||||
final double invRadiusX = 1 / rx;
|
||||
final double invRadiusY = 1 / ry;
|
||||
final double invRadiusZ = 1 / rz;
|
||||
final int ceilRadiusX = (int) Math.ceil(rx);
|
||||
final int ceilRadiusY = (int) Math.ceil(ry);
|
||||
final int ceilRadiusZ = (int) Math.ceil(rz);
|
||||
double nextXn = 0;
|
||||
|
||||
forX:
|
||||
for(int x = 0; x <= ceilRadiusX; ++x) {
|
||||
final double xn = nextXn;
|
||||
nextXn = (x + 1) * invRadiusX;
|
||||
double nextYn = 0;
|
||||
forY:
|
||||
for(int y = 0; y <= ceilRadiusY; ++y) {
|
||||
final double yn = nextYn;
|
||||
nextYn = (y + 1) * invRadiusY;
|
||||
double nextZn = 0;
|
||||
for(int z = 0; z <= ceilRadiusZ; ++z) {
|
||||
final double zn = nextZn;
|
||||
nextZn = (z + 1) * invRadiusZ;
|
||||
|
||||
double distanceSq = lengthSq(xn, yn, zn);
|
||||
if(distanceSq > 1) {
|
||||
if(z == 0) {
|
||||
if(y == 0) {
|
||||
break forX;
|
||||
}
|
||||
break forY;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
if(!fill) {
|
||||
if(lengthSq(nextXn, yn, zn) <= 1 && lengthSq(xn, nextYn, zn) <= 1 && lengthSq(xn, yn, nextZn) <= 1) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
setDataWarped(x + cx, y + cy, z + cz, data.apply(x + cx, y + cy, z + cz), rng, idata, style);
|
||||
setDataWarped(-x + cx, y + cy, z + cz, data.apply(-x + cx, y + cy, z + cz), rng, idata, style);
|
||||
setDataWarped(x + cx, -y + cy, z + cz, data.apply(x + cx, -y + cy, z + cz), rng, idata, style);
|
||||
setDataWarped(x + cx, y + cy, -z + cz, data.apply(x + cx, y + cy, -z + cz), rng, idata, style);
|
||||
setDataWarped(-x + cx, y + cy, -z + cz, data.apply(-x + cx, y + cy, -z + cz), rng, idata, style);
|
||||
setDataWarped(-x + cx, -y + cy, z + cz, data.apply(-x + cx, -y + cy, z + cz), rng, idata, style);
|
||||
setDataWarped(x + cx, -y + cy, -z + cz, data.apply(x + cx, -y + cy, -z + cz), rng, idata, style);
|
||||
setDataWarped(-x + cx, y + cy, -z + cz, data.apply(-x + cx, y + cy, -z + cz), rng, idata, style);
|
||||
setDataWarped(-x + cx, -y + cy, -z + cz, data.apply(-x + cx, -y + cy, -z + cz), rng, idata, style);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a cuboid of data in the mantle
|
||||
*
|
||||
|
||||
@@ -29,6 +29,7 @@ import com.volmit.iris.engine.object.IrisDecorator;
|
||||
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.context.IrisContext;
|
||||
import com.volmit.iris.util.data.B;
|
||||
import com.volmit.iris.util.function.Consumer4;
|
||||
import com.volmit.iris.util.hunk.Hunk;
|
||||
@@ -148,7 +149,7 @@ public class IrisCarveModifier extends EngineAssignedModifier<BlockData> {
|
||||
int buf = v.get(0) - 1;
|
||||
|
||||
for(Integer i : v) {
|
||||
if(i < 0 || i > 255) {
|
||||
if(i < 0 || i > getEngine().getHeight()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -275,7 +276,7 @@ public class IrisCarveModifier extends EngineAssignedModifier<BlockData> {
|
||||
}
|
||||
|
||||
public boolean isValid() {
|
||||
return floor < ceiling && ceiling - floor >= 1 && floor >= 0 && ceiling <= 255 && airThickness() > 0;
|
||||
return floor < ceiling && ceiling - floor >= 1 && floor >= 0 && ceiling <= IrisContext.get().getEngine().getHeight() && airThickness() > 0;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
|
||||
@@ -101,7 +101,7 @@ public class IrisDepositModifier extends EngineAssignedModifier<BlockData> {
|
||||
|
||||
int i = Math.max(0, k.getMinHeight());
|
||||
// TODO: WARNING HEIGHT
|
||||
int a = Math.min(height, Math.min(256, k.getMaxHeight()));
|
||||
int a = Math.min(height, Math.min(getEngine().getHeight(), k.getMaxHeight()));
|
||||
|
||||
if(i >= a) {
|
||||
return;
|
||||
@@ -118,7 +118,7 @@ public class IrisDepositModifier extends EngineAssignedModifier<BlockData> {
|
||||
int ny = j.getBlockY() + h;
|
||||
int nz = j.getBlockZ() + z;
|
||||
|
||||
if(ny > height || nx > 15 || nx < 0 || ny > 255 || ny < 0 || nz < 0 || nz > 15) {
|
||||
if(ny > height || nx > 15 || nx < 0 || ny > getEngine().getHeight() || ny < 0 || nz < 0 || nz > 15) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
@@ -293,7 +293,7 @@ public class IrisBiome extends IrisRegistrant implements IRare {
|
||||
height += i.getHeight(xg, x, z, seed);
|
||||
}
|
||||
|
||||
return Math.max(0, Math.min(height, 255));
|
||||
return Math.max(0, Math.min(height, xg.getHeight()));
|
||||
}
|
||||
|
||||
public CNG getBiomeGenerator(RNG random) {
|
||||
@@ -448,7 +448,7 @@ public class IrisBiome extends IrisRegistrant implements IRare {
|
||||
}
|
||||
|
||||
for(int i = 0; i < maxDepth; i++) {
|
||||
int offset = (255 - height) - i;
|
||||
int offset = (512 - height) - i;
|
||||
int index = offset % data.size();
|
||||
real.add(data.get(Math.max(index, 0)));
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
@@ -157,7 +158,7 @@ public class IrisDimension extends IrisRegistrant {
|
||||
private KList<IrisJigsawStructurePlacement> jigsawStructures = new KList<>();
|
||||
@Required
|
||||
@MinNumber(0)
|
||||
@MaxNumber(255)
|
||||
@MaxNumber(1024)
|
||||
@Desc("The fluid height for this dimension")
|
||||
private int fluidHeight = 63;
|
||||
@Desc("Define the min and max Y bounds of this dimension. Please keep in mind that Iris internally generates from 0 to (max - min). \n\nFor example at -64 to 320, Iris is internally generating to 0 to 384, then on outputting chunks, it shifts it down by the min height (64 blocks). The default is -64 to 320. \n\nThe fluid height is placed at (fluid height + min height). So a fluid height of 63 would actually show up in the world at 1.")
|
||||
@@ -405,20 +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");
|
||||
@@ -427,7 +418,7 @@ public class IrisDimension extends IrisRegistrant {
|
||||
{
|
||||
"pack": {
|
||||
"description": "Iris Data Pack. This pack contains all installed Iris Packs' resources.",
|
||||
"pack_format": 7
|
||||
"pack_format": 9
|
||||
}
|
||||
}
|
||||
""");
|
||||
@@ -456,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());
|
||||
@@ -466,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"
|
||||
}""";
|
||||
}
|
||||
|
||||
@@ -25,6 +25,7 @@ import com.volmit.iris.engine.object.annotations.MaxNumber;
|
||||
import com.volmit.iris.engine.object.annotations.MinNumber;
|
||||
import com.volmit.iris.engine.object.annotations.RegistryListResource;
|
||||
import com.volmit.iris.engine.object.annotations.Snippet;
|
||||
import com.volmit.iris.util.interpolation.IrisInterpolation;
|
||||
import com.volmit.iris.util.math.RNG;
|
||||
import com.volmit.iris.util.noise.CNG;
|
||||
import com.volmit.iris.util.noise.ExpressionNoise;
|
||||
@@ -50,7 +51,6 @@ public class IrisGeneratorStyle {
|
||||
|
||||
@Desc("Cell zooms")
|
||||
private double cellularZoom = 1;
|
||||
|
||||
@MinNumber(0.00001)
|
||||
@Desc("The zoom of this style")
|
||||
private double zoom = 1;
|
||||
@@ -128,6 +128,11 @@ public class IrisGeneratorStyle {
|
||||
return cng;
|
||||
}
|
||||
|
||||
public double warp(RNG rng, IrisData data, double value, double... coords)
|
||||
{
|
||||
return create(rng, data).noise(coords) + value;
|
||||
}
|
||||
|
||||
public CNG create(RNG rng, IrisData data) {
|
||||
return cng.aquire(() -> createNoCache(rng, data));
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
@@ -35,19 +36,17 @@ import com.volmit.iris.util.format.C;
|
||||
import com.volmit.iris.util.format.Form;
|
||||
import com.volmit.iris.util.json.JSONObject;
|
||||
import com.volmit.iris.util.math.RNG;
|
||||
import com.volmit.iris.util.nbt.io.NBTUtil;
|
||||
import com.volmit.iris.util.noise.CNG;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.Accessors;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.nbt.NbtUtils;
|
||||
import net.minecraft.nbt.TagParser;
|
||||
import net.minecraft.server.commands.GiveCommand;
|
||||
import org.bukkit.DyeColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.craftbukkit.v1_18_R1.inventory.CraftItemStack;
|
||||
import org.bukkit.NamespacedKey;
|
||||
import org.bukkit.craftbukkit.v1_18_R2.inventory.CraftItemStack;
|
||||
import org.bukkit.inventory.ItemFlag;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.Damageable;
|
||||
@@ -56,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)
|
||||
@@ -120,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))));
|
||||
}
|
||||
|
||||
@@ -187,7 +200,6 @@ public class IrisLoot {
|
||||
return applyCustomNbt(is);
|
||||
} catch(Throwable e) {
|
||||
Iris.reportError(e);
|
||||
|
||||
}
|
||||
|
||||
return new ItemStack(Material.AIR);
|
||||
@@ -199,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))));
|
||||
}
|
||||
|
||||
@@ -263,7 +283,8 @@ public class IrisLoot {
|
||||
is.setItemMeta(m);
|
||||
return applyCustomNbt(is);
|
||||
} catch(Throwable e) {
|
||||
Iris.reportError(e);
|
||||
//Iris.reportError(e);
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -277,7 +298,6 @@ public class IrisLoot {
|
||||
CompoundTag tag = TagParser.parseTag(new JSONObject(customNbt).toString());
|
||||
tag.merge(s.getOrCreateTag());
|
||||
s.setTag(tag);
|
||||
System.out.println(customNbt);
|
||||
return CraftItemStack.asBukkitCopy(s);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,36 +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.engine.object;
|
||||
|
||||
import com.volmit.iris.engine.object.annotations.Desc;
|
||||
import com.volmit.iris.engine.object.annotations.Snippet;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
@Snippet("matter-placer")
|
||||
@EqualsAndHashCode()
|
||||
@Accessors(chain = true)
|
||||
@NoArgsConstructor
|
||||
@Desc("Represents an iris object placer. It places objects.")
|
||||
@Data
|
||||
public class IrisMatterPlacement {
|
||||
|
||||
}
|
||||
@@ -34,6 +34,8 @@ 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;
|
||||
@@ -532,41 +534,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();
|
||||
|
||||
@@ -583,7 +591,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();
|
||||
|
||||
@@ -743,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());
|
||||
|
||||
@@ -785,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);
|
||||
}
|
||||
@@ -818,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());
|
||||
@@ -835,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();
|
||||
@@ -1116,7 +1138,5 @@ public class IrisObject extends IrisRegistrant {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void scanForErrors(JSONObject p, VolmitSender sender) {
|
||||
|
||||
}
|
||||
public void scanForErrors(JSONObject p, VolmitSender sender) { }
|
||||
}
|
||||
|
||||
@@ -35,14 +35,14 @@ import lombok.experimental.Accessors;
|
||||
@Data
|
||||
public class IrisObjectLimit {
|
||||
@MinNumber(0)
|
||||
@MaxNumber(255)
|
||||
@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(255)
|
||||
@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;
|
||||
|
||||
|
||||
@@ -35,12 +35,12 @@ import lombok.experimental.Accessors;
|
||||
@Data
|
||||
public class IrisSlopeClip {
|
||||
@MinNumber(0)
|
||||
@MaxNumber(255)
|
||||
@MaxNumber(1024)
|
||||
@Desc("The minimum slope for placement")
|
||||
private double minimumSlope = 0;
|
||||
|
||||
@MinNumber(0)
|
||||
@MaxNumber(255)
|
||||
@MaxNumber(1024)
|
||||
@Desc("The maximum slope for placement")
|
||||
private double maximumSlope = 10;
|
||||
|
||||
|
||||
@@ -0,0 +1,58 @@
|
||||
package com.volmit.iris.engine.object.matter;
|
||||
|
||||
import com.volmit.iris.core.loader.IrisRegistrant;
|
||||
import com.volmit.iris.engine.object.IrisObject;
|
||||
import com.volmit.iris.util.json.JSONObject;
|
||||
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;
|
||||
|
||||
public IrisMatterObject()
|
||||
{
|
||||
this(1,1,1);
|
||||
}
|
||||
|
||||
public IrisMatterObject(int w, int h, int d)
|
||||
{
|
||||
this(new IrisMatter(w,h,d));
|
||||
}
|
||||
|
||||
public IrisMatterObject(Matter matter)
|
||||
{
|
||||
this.matter = matter;
|
||||
}
|
||||
|
||||
public static IrisMatterObject from(IrisObject object)
|
||||
{
|
||||
return new IrisMatterObject(Matter.from(object));
|
||||
}
|
||||
|
||||
public static IrisMatterObject from(File j) throws IOException, ClassNotFoundException {
|
||||
return new IrisMatterObject(Matter.read(j));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getFolderName() {
|
||||
return "matter";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTypeName() {
|
||||
return "Matter";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void scanForErrors(JSONObject p, VolmitSender sender) {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,93 @@
|
||||
/*
|
||||
* Iris is a World Generator for Minecraft Bukkit Servers
|
||||
* Copyright (c) 2022 Arcane Arts (Volmit Software)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.volmit.iris.engine.object.matter;
|
||||
|
||||
import com.volmit.iris.core.loader.IrisData;
|
||||
import com.volmit.iris.engine.IrisEngine;
|
||||
import com.volmit.iris.engine.object.IRare;
|
||||
import com.volmit.iris.engine.object.IrisStyledRange;
|
||||
import com.volmit.iris.engine.object.annotations.*;
|
||||
import com.volmit.iris.util.collection.KList;
|
||||
import com.volmit.iris.util.mantle.Mantle;
|
||||
import com.volmit.iris.util.math.RNG;
|
||||
import com.volmit.iris.util.matter.MatterSlice;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
@Snippet("matter-placer")
|
||||
@EqualsAndHashCode()
|
||||
@Accessors(chain = true)
|
||||
@NoArgsConstructor
|
||||
@Desc("Represents an iris object placer. It places matter objects.")
|
||||
@Data
|
||||
public class IrisMatterPlacement implements IRare {
|
||||
@RegistryListResource(IrisMatterObject.class)
|
||||
@Required
|
||||
@ArrayType(min = 1, type = String.class)
|
||||
@Desc("List of objects to place")
|
||||
private KList<String> place = new KList<>();
|
||||
|
||||
@MinNumber(0)
|
||||
@Desc("The rarity of this object placing")
|
||||
private int rarity = 0;
|
||||
|
||||
@MinNumber(0)
|
||||
@Desc("The styled density of this object")
|
||||
private IrisStyledRange densityRange;
|
||||
|
||||
@Desc("The absolute density for this object")
|
||||
private double density = 1;
|
||||
|
||||
@Desc("Translate this matter object before placement")
|
||||
private IrisMatterTranslate translate;
|
||||
|
||||
@Desc("Place this object on the surface height, bedrock or the sky, then use translate if need be.")
|
||||
private IrisMatterPlacementLocation location = IrisMatterPlacementLocation.SURFACE;
|
||||
|
||||
public void place(IrisEngine engine, IrisData data, RNG rng, int ax, int az)
|
||||
{
|
||||
IrisMatterObject object = data.getMatterLoader().load(place.getRandom(rng));
|
||||
int x = ax;
|
||||
int z = az;
|
||||
int yoff = 0;
|
||||
|
||||
if(translate != null)
|
||||
{
|
||||
x += translate.xOffset(data, rng, x, z);
|
||||
yoff += translate.yOffset(data, rng, x, z);
|
||||
z += translate.zOffset(data, rng, x, z);
|
||||
}
|
||||
|
||||
int y = yoff + location.at(engine, x, z);
|
||||
Mantle mantle = engine.getMantle().getMantle();
|
||||
|
||||
int xx = x;
|
||||
int yy = y;
|
||||
int zz = z;
|
||||
|
||||
for(MatterSlice<?> slice : object.getMatter().getSliceMap().values())
|
||||
{
|
||||
slice.iterate((mx, my, mz, v) -> {
|
||||
mantle.set(xx + mx, yy + my, zz + mz, v);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
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)),
|
||||
BEDROCK((e, x, z) -> 0),
|
||||
SKY((e, x, z) -> e.getHeight());
|
||||
|
||||
private final Function3<IrisEngine, Integer, Integer, Integer> computer;
|
||||
|
||||
private IrisMatterPlacementLocation(Function3<IrisEngine, Integer, Integer, Integer> computer)
|
||||
{
|
||||
this.computer = computer;
|
||||
}
|
||||
|
||||
public int at(IrisEngine engine, int x, int z) {
|
||||
return computer.apply(engine, x, z);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
package com.volmit.iris.engine.object.matter;
|
||||
|
||||
import com.volmit.iris.core.loader.IrisData;
|
||||
import com.volmit.iris.engine.IrisEngine;
|
||||
import com.volmit.iris.engine.object.IrisStyledRange;
|
||||
import com.volmit.iris.engine.object.annotations.Desc;
|
||||
import com.volmit.iris.util.math.RNG;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@EqualsAndHashCode()
|
||||
@Accessors(chain = true)
|
||||
@Desc("Represents a matter translator")
|
||||
public class IrisMatterTranslate {
|
||||
@Desc("For varied coordinate shifts use ranges not the literal coordinate")
|
||||
private IrisStyledRange rangeX = null;
|
||||
@Desc("For varied coordinate shifts use ranges not the literal coordinate")
|
||||
private IrisStyledRange rangeY = null;
|
||||
@Desc("For varied coordinate shifts use ranges not the literal coordinate")
|
||||
private IrisStyledRange rangeZ = null;
|
||||
@Desc("Define an absolute shift instead of varied.")
|
||||
private int x = 0;
|
||||
@Desc("Define an absolute shift instead of varied.")
|
||||
private int y = 0;
|
||||
@Desc("Define an absolute shift instead of varied.")
|
||||
private int z = 0;
|
||||
|
||||
public int xOffset(IrisData data, RNG rng, int rx, int rz)
|
||||
{
|
||||
if(rangeX != null)
|
||||
{
|
||||
return (int) Math.round(rangeX.get(rng, rx, rz, data));
|
||||
}
|
||||
|
||||
return x;
|
||||
}
|
||||
|
||||
public int yOffset(IrisData data, RNG rng, int rx, int rz)
|
||||
{
|
||||
if(rangeY != null)
|
||||
{
|
||||
return (int) Math.round(rangeY.get(rng, rx, rz, data));
|
||||
}
|
||||
|
||||
return y;
|
||||
}
|
||||
|
||||
public int zOffset(IrisData data, RNG rng, int rx, int rz)
|
||||
{
|
||||
if(rangeZ != null)
|
||||
{
|
||||
return (int) Math.round(rangeZ.get(rng, rx, rz, data));
|
||||
}
|
||||
|
||||
return z;
|
||||
}
|
||||
}
|
||||
@@ -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,8 +20,9 @@ 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;
|
||||
import it.unimi.dsi.fastutil.ints.Int2IntMap;
|
||||
import it.unimi.dsi.fastutil.ints.Int2IntOpenHashMap;
|
||||
@@ -30,6 +31,7 @@ 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;
|
||||
@@ -38,12 +40,14 @@ import org.bukkit.block.data.type.PointedDripstone;
|
||||
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.*;
|
||||
|
||||
public class B {
|
||||
private static final KMap<String, BlockData> custom = new KMap<>();
|
||||
|
||||
private static final Material AIR_MATERIAL = Material.AIR;
|
||||
private static final BlockData AIR = AIR_MATERIAL.createBlockData();
|
||||
private static final IntSet foliageCache = buildFoliageCache();
|
||||
@@ -405,6 +409,11 @@ public class B {
|
||||
try {
|
||||
String bd = bdxf.trim();
|
||||
|
||||
if(!custom.isEmpty() && custom.containsKey(bd))
|
||||
{
|
||||
return custom.get(bd);
|
||||
}
|
||||
|
||||
if(bd.startsWith("minecraft:cauldron[level=")) {
|
||||
bd = bd.replaceAll("\\Q:cauldron[\\E", ":water_cauldron[");
|
||||
}
|
||||
@@ -461,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) {
|
||||
@@ -652,19 +647,9 @@ public class B {
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
for(String i : Iris.linkOraxen.getItemTypes()) {
|
||||
bt.add("oraxen:" + i);
|
||||
}
|
||||
} catch(Throwable e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
try {
|
||||
bt.addAll(Iris.service(RegistrySVC.class).getCustomBlockRegistry().compile());
|
||||
} catch(Throwable e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
for(NamespacedKey id : Iris.service(ExternalDataSVC.class).getAllIdentifiers())
|
||||
bt.add(id.toString());
|
||||
bt.addAll(custom.k());
|
||||
|
||||
return bt.toArray(new String[0]);
|
||||
}
|
||||
@@ -683,4 +668,8 @@ public class B {
|
||||
public static boolean isWaterLogged(BlockData b) {
|
||||
return (b instanceof Waterlogged) && ((Waterlogged) b).isWaterlogged();
|
||||
}
|
||||
|
||||
public static void registerCustomBlockData(String namespace, String key, BlockData blockData) {
|
||||
custom.put(namespace + ":" + key, blockData);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,18 +21,18 @@ package com.volmit.iris.util.data;
|
||||
import java.util.Arrays;
|
||||
|
||||
public class HeightMap {
|
||||
private final byte[] height;
|
||||
private final int[] height;
|
||||
|
||||
public HeightMap() {
|
||||
height = new byte[256];
|
||||
Arrays.fill(height, Byte.MIN_VALUE);
|
||||
height = new int[256];
|
||||
Arrays.fill(height, 0);
|
||||
}
|
||||
|
||||
public void setHeight(int x, int z, int h) {
|
||||
height[x * 16 + z] = (byte) (h + Byte.MIN_VALUE);
|
||||
height[x * 16 + z] = (h);
|
||||
}
|
||||
|
||||
public int getHeight(int x, int z) {
|
||||
return height[x * 16 + z] - Byte.MIN_VALUE;
|
||||
return height[x * 16 + z];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
|
||||
package com.volmit.iris.util.hunk;
|
||||
|
||||
import com.volmit.iris.Iris;
|
||||
import com.volmit.iris.engine.object.IrisPosition;
|
||||
import com.volmit.iris.util.collection.KList;
|
||||
import com.volmit.iris.util.function.Consumer2;
|
||||
@@ -1254,6 +1255,12 @@ public interface Hunk<T> {
|
||||
* the value
|
||||
*/
|
||||
default void set(int x, int y, int z, T t) {
|
||||
if(!contains(x, y, z))
|
||||
{
|
||||
Iris.warn("OUT OF BOUNDS " + x + " " + y + " "+ z + " in bounds " + getWidth() + " " + getHeight() + " " + getDepth() );
|
||||
return;
|
||||
}
|
||||
|
||||
setRaw(x, y, z, t);
|
||||
}
|
||||
|
||||
@@ -1561,4 +1568,9 @@ public interface Hunk<T> {
|
||||
default boolean contains(int x, int y, int z) {
|
||||
return x < getWidth() && x >= 0 && y < getHeight() && y >= 0 && z < getDepth() && z >= 0;
|
||||
}
|
||||
|
||||
default int volume()
|
||||
{
|
||||
return getWidth() * getDepth() * getHeight();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
package com.volmit.iris.util.interpolation;
|
||||
|
||||
import com.google.common.util.concurrent.AtomicDouble;
|
||||
import com.volmit.iris.engine.data.chunk.LinkedTerrainChunk;
|
||||
import com.volmit.iris.engine.object.NoiseStyle;
|
||||
import com.volmit.iris.util.format.Form;
|
||||
import com.volmit.iris.util.function.Consumer2;
|
||||
@@ -284,9 +285,24 @@ public class IrisInterpolation {
|
||||
//@done
|
||||
}
|
||||
|
||||
public static int getRadiusFactor(int coord, double radius)
|
||||
{
|
||||
if(radius == 2) {return coord >> 1;}
|
||||
if(radius == 4) {return coord >> 2;}
|
||||
if(radius == 8) {return coord >> 3;}
|
||||
if(radius == 16) {return coord >> 4;}
|
||||
if(radius == 32) {return coord >> 5;}
|
||||
if(radius == 64) {return coord >> 6;}
|
||||
if(radius == 128) {return coord >> 7;}
|
||||
if(radius == 256) {return coord >> 8;}
|
||||
if(radius == 512) {return coord >> 9;}
|
||||
if(radius == 1024) {return coord >> 10;}
|
||||
return (int) Math.floor(coord / radius);
|
||||
}
|
||||
|
||||
public static double getBilinearNoise(int x, int z, double rad, NoiseProvider n) {
|
||||
int fx = (int) Math.floor(x / rad);
|
||||
int fz = (int) Math.floor(z / rad);
|
||||
int fx = getRadiusFactor(x, rad);
|
||||
int fz = getRadiusFactor(z, rad);
|
||||
int x1 = (int) Math.round(fx * rad);
|
||||
int z1 = (int) Math.round(fz * rad);
|
||||
int x2 = (int) Math.round((fx + 1) * rad);
|
||||
@@ -375,8 +391,8 @@ public class IrisInterpolation {
|
||||
}
|
||||
|
||||
public static double getBilinearBezierNoise(int x, int z, double rad, NoiseProvider n) {
|
||||
int fx = (int) Math.floor(x / rad);
|
||||
int fz = (int) Math.floor(z / rad);
|
||||
int fx = getRadiusFactor(x, rad);
|
||||
int fz = getRadiusFactor(z, rad);
|
||||
int x1 = (int) Math.round(fx * rad);
|
||||
int z1 = (int) Math.round(fz * rad);
|
||||
int x2 = (int) Math.round((fx + 1) * rad);
|
||||
@@ -394,8 +410,8 @@ public class IrisInterpolation {
|
||||
}
|
||||
|
||||
public static double getBilinearParametricNoise(int x, int z, double rad, NoiseProvider n, double a) {
|
||||
int fx = (int) Math.floor(x / rad);
|
||||
int fz = (int) Math.floor(z / rad);
|
||||
int fx = getRadiusFactor(x, rad);
|
||||
int fz = getRadiusFactor(z, rad);
|
||||
int x1 = (int) Math.round(fx * rad);
|
||||
int z1 = (int) Math.round(fz * rad);
|
||||
int x2 = (int) Math.round((fx + 1) * rad);
|
||||
@@ -417,9 +433,9 @@ public class IrisInterpolation {
|
||||
}
|
||||
|
||||
public static double getTrilinear(int x, int y, int z, double radx, double rady, double radz, NoiseProvider3 n) {
|
||||
int fx = (int) Math.floor(x / radx);
|
||||
int fy = (int) Math.floor(y / rady);
|
||||
int fz = (int) Math.floor(z / radz);
|
||||
int fx = getRadiusFactor(x, radx);
|
||||
int fy = getRadiusFactor(y, rady);
|
||||
int fz = getRadiusFactor(z, radz);
|
||||
int x1 = (int) Math.round(fx * radx);
|
||||
int y1 = (int) Math.round(fy * rady);
|
||||
int z1 = (int) Math.round(fz * radz);
|
||||
@@ -448,9 +464,9 @@ public class IrisInterpolation {
|
||||
}
|
||||
|
||||
public static double getTricubic(int x, int y, int z, double radx, double rady, double radz, NoiseProvider3 n) {
|
||||
int fx = (int) Math.floor(x / radx);
|
||||
int fy = (int) Math.floor(y / rady);
|
||||
int fz = (int) Math.floor(z / radz);
|
||||
int fx = getRadiusFactor(x, radx);
|
||||
int fy = getRadiusFactor(y, rady);
|
||||
int fz = getRadiusFactor(z, radz);
|
||||
int x0 = (int) Math.round((fx - 1) * radx);
|
||||
int y0 = (int) Math.round((fy - 1) * rady);
|
||||
int z0 = (int) Math.round((fz - 1) * radz);
|
||||
@@ -551,9 +567,9 @@ public class IrisInterpolation {
|
||||
}
|
||||
|
||||
public static double getTrihermite(int x, int y, int z, double radx, double rady, double radz, NoiseProvider3 n, double tension, double bias) {
|
||||
int fx = (int) Math.floor(x / radx);
|
||||
int fy = (int) Math.floor(y / rady);
|
||||
int fz = (int) Math.floor(z / radz);
|
||||
int fx = getRadiusFactor(x, radx);
|
||||
int fy = getRadiusFactor(y, rady);
|
||||
int fz = getRadiusFactor(z, radz);
|
||||
int x0 = (int) Math.round((fx - 1) * radx);
|
||||
int y0 = (int) Math.round((fy - 1) * rady);
|
||||
int z0 = (int) Math.round((fz - 1) * radz);
|
||||
@@ -642,8 +658,8 @@ public class IrisInterpolation {
|
||||
}
|
||||
|
||||
public static double getBilinearCenterSineNoise(int x, int z, double rad, NoiseProvider n) {
|
||||
int fx = (int) Math.floor(x / rad);
|
||||
int fz = (int) Math.floor(z / rad);
|
||||
int fx = getRadiusFactor(x, rad);
|
||||
int fz = getRadiusFactor(z, rad);
|
||||
int x1 = (int) Math.round(fx * rad);
|
||||
int z1 = (int) Math.round(fz * rad);
|
||||
int x2 = (int) Math.round((fx + 1) * rad);
|
||||
@@ -661,8 +677,8 @@ public class IrisInterpolation {
|
||||
}
|
||||
|
||||
public static double getBicubicNoise(int x, int z, double rad, NoiseProvider n) {
|
||||
int fx = (int) Math.floor(x / rad);
|
||||
int fz = (int) Math.floor(z / rad);
|
||||
int fx = getRadiusFactor(x, rad);
|
||||
int fz = getRadiusFactor(z, rad);
|
||||
int x0 = (int) Math.round((fx - 1) * rad);
|
||||
int z0 = (int) Math.round((fz - 1) * rad);
|
||||
int x1 = (int) Math.round(fx * rad);
|
||||
@@ -696,8 +712,8 @@ public class IrisInterpolation {
|
||||
}
|
||||
|
||||
public static double getBicubicBezierNoise(int x, int z, double rad, NoiseProvider n) {
|
||||
int fx = (int) Math.floor(x / rad);
|
||||
int fz = (int) Math.floor(z / rad);
|
||||
int fx = getRadiusFactor(x, rad);
|
||||
int fz = getRadiusFactor(z, rad);
|
||||
int x0 = (int) Math.round((fx - 1) * rad);
|
||||
int z0 = (int) Math.round((fz - 1) * rad);
|
||||
int x1 = (int) Math.round(fx * rad);
|
||||
@@ -731,8 +747,8 @@ public class IrisInterpolation {
|
||||
}
|
||||
|
||||
public static double getBicubicParametricNoise(int x, int z, double rad, NoiseProvider n, double a) {
|
||||
int fx = (int) Math.floor(x / rad);
|
||||
int fz = (int) Math.floor(z / rad);
|
||||
int fx = getRadiusFactor(x, rad);
|
||||
int fz = getRadiusFactor(z, rad);
|
||||
int x0 = (int) Math.round((fx - 1) * rad);
|
||||
int z0 = (int) Math.round((fz - 1) * rad);
|
||||
int x1 = (int) Math.round(fx * rad);
|
||||
@@ -778,8 +794,8 @@ public class IrisInterpolation {
|
||||
}
|
||||
|
||||
public static double getHermiteNoise(int x, int z, double rad, NoiseProvider n, double t, double b) {
|
||||
int fx = (int) Math.floor(x / rad);
|
||||
int fz = (int) Math.floor(z / rad);
|
||||
int fx = getRadiusFactor(x, rad);
|
||||
int fz = getRadiusFactor(z, rad);
|
||||
int x0 = (int) Math.round((fx - 1) * rad);
|
||||
int z0 = (int) Math.round((fz - 1) * rad);
|
||||
int x1 = (int) Math.round(fx * rad);
|
||||
@@ -813,8 +829,8 @@ public class IrisInterpolation {
|
||||
}
|
||||
|
||||
public static double getHermiteBezierNoise(int x, int z, double rad, NoiseProvider n, double t, double b) {
|
||||
int fx = (int) Math.floor(x / rad);
|
||||
int fz = (int) Math.floor(z / rad);
|
||||
int fx = getRadiusFactor(x, rad);
|
||||
int fz = getRadiusFactor(z, rad);
|
||||
int x0 = (int) Math.round((fx - 1) * rad);
|
||||
int z0 = (int) Math.round((fz - 1) * rad);
|
||||
int x1 = (int) Math.round(fx * rad);
|
||||
@@ -848,8 +864,8 @@ public class IrisInterpolation {
|
||||
}
|
||||
|
||||
public static double getHermiteParametricNoise(int x, int z, double rad, NoiseProvider n, double t, double b, double a) {
|
||||
int fx = (int) Math.floor(x / rad);
|
||||
int fz = (int) Math.floor(z / rad);
|
||||
int fx = getRadiusFactor(x, rad);
|
||||
int fz = getRadiusFactor(z, rad);
|
||||
int x0 = (int) Math.round((fx - 1) * rad);
|
||||
int z0 = (int) Math.round((fz - 1) * rad);
|
||||
int x1 = (int) Math.round(fx * rad);
|
||||
@@ -1027,7 +1043,6 @@ public class IrisInterpolation {
|
||||
|
||||
return n.noise(x, z);
|
||||
}
|
||||
|
||||
public static double rangeScale(double amin, double amax, double bmin, double bmax, double b) {
|
||||
return amin + ((amax - amin) * ((b - bmin) / (bmax - bmin)));
|
||||
}
|
||||
|
||||
@@ -20,6 +20,7 @@ package com.volmit.iris.util.mantle;
|
||||
|
||||
import com.volmit.iris.Iris;
|
||||
import com.volmit.iris.core.IrisSettings;
|
||||
import com.volmit.iris.core.tools.IrisToolbelt;
|
||||
import com.volmit.iris.engine.data.cache.Cache;
|
||||
import com.volmit.iris.engine.framework.Engine;
|
||||
import com.volmit.iris.engine.mantle.EngineMantle;
|
||||
@@ -329,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
|
||||
@@ -378,6 +379,14 @@ public class Mantle {
|
||||
return closed.get();
|
||||
}
|
||||
|
||||
public void set(int x, int y, int z, Matter matter)
|
||||
{
|
||||
for(MatterSlice<?> i : matter.getSliceMap().values())
|
||||
{
|
||||
i.iterate((mx, my, mz, v) -> set(mx + x, my + y, mz + z, v));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Closes the Mantle. By closing the mantle, you can no longer read or writeNodeData
|
||||
* any data to the mantle or it's Tectonic Plates. Closing will also flush any
|
||||
@@ -570,6 +579,11 @@ public class Mantle {
|
||||
}
|
||||
|
||||
public void deleteChunkSlice(int x, int z, Class<?> c) {
|
||||
if(!IrisToolbelt.toolbeltConfiguration.isEmpty() && IrisToolbelt.toolbeltConfiguration.getOrDefault("retain.mantle." + c.getCanonicalName(), false))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
getChunk(x, z).deleteSlices(c);
|
||||
}
|
||||
|
||||
|
||||
@@ -31,7 +31,8 @@ public enum MantleFlag {
|
||||
FLUID_BODIES,
|
||||
INITIAL_SPAWNED_MARKER,
|
||||
CLEANED,
|
||||
PLANNED;
|
||||
PLANNED,
|
||||
ETCHED;
|
||||
|
||||
static StateList getStateList() {
|
||||
return new StateList(MantleFlag.values());
|
||||
|
||||
@@ -24,6 +24,7 @@ import com.volmit.iris.engine.object.IrisPosition;
|
||||
import com.volmit.iris.util.collection.KSet;
|
||||
import com.volmit.iris.util.hunk.Hunk;
|
||||
import com.volmit.iris.util.math.BlockPosition;
|
||||
import com.volmit.iris.util.scheduling.J;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
import org.bukkit.entity.Entity;
|
||||
@@ -59,11 +60,42 @@ import java.util.function.Function;
|
||||
public interface Matter {
|
||||
int VERSION = 1;
|
||||
|
||||
static long convert(File folder)
|
||||
{
|
||||
if(folder.isDirectory())
|
||||
{
|
||||
long v = 0;
|
||||
|
||||
for(File i : folder.listFiles())
|
||||
{
|
||||
v += convert(i);
|
||||
}
|
||||
|
||||
return v;
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
IrisObject object = new IrisObject(1,1,1);
|
||||
try {
|
||||
long fs = folder.length();
|
||||
object.read(folder);
|
||||
Matter.from(object).write(folder);
|
||||
Iris.info("Converted " + folder.getPath() + " Saved " + (fs - folder.length()));
|
||||
} catch(Throwable e) {
|
||||
Iris.error("Failed to convert " + folder.getPath());
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static Matter from(IrisObject object) {
|
||||
object.clean();
|
||||
object.shrinkwrap();
|
||||
BlockVector min = new BlockVector();
|
||||
Matter m = new IrisMatter(object.getW(), object.getH(), object.getD());
|
||||
Matter m = new IrisMatter(Math.max(object.getW(), 1)+1, Math.max( object.getH(), 1)+1, Math.max( object.getD(), 1)+1);
|
||||
|
||||
for(BlockVector i : object.getBlocks().keySet()) {
|
||||
min.setX(Math.min(min.getX(), i.getX()));
|
||||
|
||||
@@ -29,6 +29,7 @@ import java.io.IOException;
|
||||
@Sliced
|
||||
public class CavernMatter extends RawMatter<MatterCavern> {
|
||||
public static final MatterCavern EMPTY = new MatterCavern(false, "", (byte) 0);
|
||||
public static final MatterCavern BASIC = new MatterCavern(true, "", (byte) 0);
|
||||
|
||||
public CavernMatter() {
|
||||
this(1, 1, 1);
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
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.util.collection.KList;
|
||||
import com.volmit.iris.util.function.NoiseInjector;
|
||||
@@ -129,6 +130,17 @@ public class CNG {
|
||||
}, 1D, 1);
|
||||
}
|
||||
|
||||
public CNG cached(int size)
|
||||
{
|
||||
if(size <= 0)
|
||||
{
|
||||
return this;
|
||||
}
|
||||
|
||||
generator = new CachedNoise(generator, size);
|
||||
return this;
|
||||
}
|
||||
|
||||
public static CNG signature(RNG rng) {
|
||||
return signature(rng, NoiseType.SIMPLEX);
|
||||
}
|
||||
|
||||
@@ -16,26 +16,29 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.volmit.iris.core.service;
|
||||
package com.volmit.iris.util.noise;
|
||||
|
||||
import com.volmit.iris.util.plugin.IrisService;
|
||||
import com.volmit.iris.util.plugin.PluginRegistryGroup;
|
||||
import lombok.Data;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
import com.volmit.iris.util.math.RNG;
|
||||
|
||||
import java.util.function.Supplier;
|
||||
public class CachedNoise implements NoiseGenerator {
|
||||
private final CachedNoiseMap n;
|
||||
|
||||
@Data
|
||||
public class RegistrySVC implements IrisService {
|
||||
private PluginRegistryGroup<Supplier<BlockData>> customBlockRegistry;
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
customBlockRegistry = new PluginRegistryGroup<>();
|
||||
public CachedNoise(NoiseGenerator generator, int size) {
|
||||
n = new CachedNoiseMap(size, generator);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDisable() {
|
||||
public double noise(double x) {
|
||||
return n.get((int)Math.round(x), 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public double noise(double x, double z) {
|
||||
return n.get((int)Math.round(x),(int)Math.round(z));
|
||||
}
|
||||
|
||||
@Override
|
||||
public double noise(double x, double y, double z) {
|
||||
return n.get((int)Math.round(x),(int)Math.round(z));
|
||||
}
|
||||
}
|
||||
85
src/main/java/com/volmit/iris/util/noise/CachedNoiseMap.java
Normal file
@@ -0,0 +1,85 @@
|
||||
/*
|
||||
* Iris is a World Generator for Minecraft Bukkit Servers
|
||||
* Copyright (c) 2022 Arcane Arts (Volmit Software)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.volmit.iris.util.noise;
|
||||
|
||||
import com.volmit.iris.util.hunk.bits.Writable;
|
||||
import com.volmit.iris.util.interpolation.InterpolationMethod;
|
||||
import com.volmit.iris.util.matter.IrisMatter;
|
||||
import com.volmit.iris.util.matter.Matter;
|
||||
import com.volmit.iris.util.matter.MatterSlice;
|
||||
|
||||
import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
public class CachedNoiseMap implements Writable<Integer> {
|
||||
private final Matter noise;
|
||||
private final MatterSlice<Integer> slice;
|
||||
|
||||
public CachedNoiseMap(int size, NoiseGenerator cng)
|
||||
{
|
||||
noise = new IrisMatter(size, size, 1);
|
||||
slice = noise.slice(Integer.class);
|
||||
|
||||
for(int i = 0; i < slice.getWidth(); i++)
|
||||
{
|
||||
for(int j = 0; j < slice.getHeight(); j++)
|
||||
{
|
||||
set(i, j, cng.noise(i, j));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public CachedNoiseMap(File file) throws IOException, ClassNotFoundException {
|
||||
noise = Matter.read(file);
|
||||
slice = noise.slice(Integer.class);
|
||||
}
|
||||
|
||||
void write(File file) throws IOException {
|
||||
noise.write(file);
|
||||
}
|
||||
|
||||
void set(int x, int y, double value)
|
||||
{
|
||||
slice.set(x%slice.getWidth(), y%slice.getHeight(), 0, Float.floatToIntBits((float)value));
|
||||
}
|
||||
|
||||
double get(int x, int y)
|
||||
{
|
||||
Integer i = slice.get(x%slice.getWidth(), y%slice.getHeight(), 0);
|
||||
|
||||
if(i == null)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
return Float.intBitsToFloat(i);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer readNodeData(DataInputStream din) throws IOException {
|
||||
return din.readInt();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeNodeData(DataOutputStream dos, Integer integer) throws IOException {
|
||||
dos.writeInt(integer);
|
||||
}
|
||||
}
|
||||
@@ -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 |