mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2025-07-18 18:23:06 +00:00
Merge branch 'master' into onlyWarnWhenPlayer
This commit is contained in:
commit
88469f6141
@ -1,3 +1,21 @@
|
|||||||
|
/*
|
||||||
|
* Iris is a World Generator for Minecraft Bukkit Servers
|
||||||
|
* Copyright (c) 2021 Arcane Arts (Volmit Software)
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
plugins {
|
plugins {
|
||||||
id 'java'
|
id 'java'
|
||||||
}
|
}
|
||||||
|
@ -22,7 +22,7 @@ plugins {
|
|||||||
}
|
}
|
||||||
|
|
||||||
group 'com.volmit.iris'
|
group 'com.volmit.iris'
|
||||||
version '1.8.13'
|
version '1.9'
|
||||||
def apiVersion = '1.17'
|
def apiVersion = '1.17'
|
||||||
def name = getRootProject().getName() // Defined in settings.gradle
|
def name = getRootProject().getName() // Defined in settings.gradle
|
||||||
def main = 'com.volmit.iris.Iris'
|
def main = 'com.volmit.iris.Iris'
|
||||||
|
1
plugins/Iris/cache/instance
vendored
1
plugins/Iris/cache/instance
vendored
@ -1 +0,0 @@
|
|||||||
1036166928
|
|
@ -18,6 +18,9 @@
|
|||||||
|
|
||||||
package com.volmit.iris;
|
package com.volmit.iris;
|
||||||
|
|
||||||
|
import com.google.gson.ExclusionStrategy;
|
||||||
|
import com.google.gson.Gson;
|
||||||
|
import com.google.gson.GsonBuilder;
|
||||||
import com.volmit.iris.core.IrisSettings;
|
import com.volmit.iris.core.IrisSettings;
|
||||||
import com.volmit.iris.core.ServerConfigurator;
|
import com.volmit.iris.core.ServerConfigurator;
|
||||||
import com.volmit.iris.core.link.IrisPapiExpansion;
|
import com.volmit.iris.core.link.IrisPapiExpansion;
|
||||||
@ -27,6 +30,7 @@ import com.volmit.iris.core.link.OraxenLink;
|
|||||||
import com.volmit.iris.core.loader.IrisData;
|
import com.volmit.iris.core.loader.IrisData;
|
||||||
import com.volmit.iris.core.nms.INMS;
|
import com.volmit.iris.core.nms.INMS;
|
||||||
import com.volmit.iris.core.service.StudioSVC;
|
import com.volmit.iris.core.service.StudioSVC;
|
||||||
|
import com.volmit.iris.engine.EnginePanic;
|
||||||
import com.volmit.iris.engine.object.IrisCompat;
|
import com.volmit.iris.engine.object.IrisCompat;
|
||||||
import com.volmit.iris.engine.object.IrisDimension;
|
import com.volmit.iris.engine.object.IrisDimension;
|
||||||
import com.volmit.iris.engine.object.IrisWorld;
|
import com.volmit.iris.engine.object.IrisWorld;
|
||||||
@ -37,15 +41,14 @@ import com.volmit.iris.util.collection.KMap;
|
|||||||
import com.volmit.iris.util.exceptions.IrisException;
|
import com.volmit.iris.util.exceptions.IrisException;
|
||||||
import com.volmit.iris.util.format.C;
|
import com.volmit.iris.util.format.C;
|
||||||
import com.volmit.iris.util.format.Form;
|
import com.volmit.iris.util.format.Form;
|
||||||
import com.volmit.iris.util.format.MemoryMonitor;
|
|
||||||
import com.volmit.iris.util.function.NastyRunnable;
|
import com.volmit.iris.util.function.NastyRunnable;
|
||||||
|
import com.volmit.iris.util.hunk.bits.TecTest;
|
||||||
import com.volmit.iris.util.io.FileWatcher;
|
import com.volmit.iris.util.io.FileWatcher;
|
||||||
import com.volmit.iris.util.io.IO;
|
import com.volmit.iris.util.io.IO;
|
||||||
import com.volmit.iris.util.io.InstanceState;
|
import com.volmit.iris.util.io.InstanceState;
|
||||||
import com.volmit.iris.util.io.JarScanner;
|
import com.volmit.iris.util.io.JarScanner;
|
||||||
import com.volmit.iris.util.math.M;
|
import com.volmit.iris.util.math.M;
|
||||||
import com.volmit.iris.util.math.RNG;
|
import com.volmit.iris.util.math.RNG;
|
||||||
import com.volmit.iris.util.matter.MatterTest;
|
|
||||||
import com.volmit.iris.util.parallel.MultiBurst;
|
import com.volmit.iris.util.parallel.MultiBurst;
|
||||||
import com.volmit.iris.util.plugin.IrisService;
|
import com.volmit.iris.util.plugin.IrisService;
|
||||||
import com.volmit.iris.util.plugin.Metrics;
|
import com.volmit.iris.util.plugin.Metrics;
|
||||||
@ -68,6 +71,7 @@ import org.bukkit.event.Event;
|
|||||||
import org.bukkit.event.HandlerList;
|
import org.bukkit.event.HandlerList;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
import org.bukkit.generator.ChunkGenerator;
|
import org.bukkit.generator.ChunkGenerator;
|
||||||
|
import org.bukkit.plugin.IllegalPluginAccessException;
|
||||||
import org.bukkit.plugin.Plugin;
|
import org.bukkit.plugin.Plugin;
|
||||||
|
|
||||||
import java.io.BufferedInputStream;
|
import java.io.BufferedInputStream;
|
||||||
@ -299,6 +303,8 @@ public class Iris extends VolmitPlugin implements Listener {
|
|||||||
|
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
public static void later(NastyRunnable object) {
|
public static void later(NastyRunnable object) {
|
||||||
|
try
|
||||||
|
{
|
||||||
Bukkit.getScheduler().scheduleAsyncDelayedTask(instance, () ->
|
Bukkit.getScheduler().scheduleAsyncDelayedTask(instance, () ->
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
@ -310,6 +316,12 @@ public class Iris extends VolmitPlugin implements Listener {
|
|||||||
}, RNG.r.i(100, 1200));
|
}, RNG.r.i(100, 1200));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
catch(IllegalPluginAccessException ignored)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static int jobCount() {
|
public static int jobCount() {
|
||||||
return syncJobs.size();
|
return syncJobs.size();
|
||||||
}
|
}
|
||||||
@ -446,9 +458,9 @@ public class Iris extends VolmitPlugin implements Listener {
|
|||||||
J.ar(this::checkConfigHotload, 60);
|
J.ar(this::checkConfigHotload, 60);
|
||||||
J.sr(this::tickQueue, 0);
|
J.sr(this::tickQueue, 0);
|
||||||
J.s(this::setupPapi);
|
J.s(this::setupPapi);
|
||||||
|
J.s(TecTest::go);
|
||||||
J.a(ServerConfigurator::configure, 20);
|
J.a(ServerConfigurator::configure, 20);
|
||||||
splash();
|
splash();
|
||||||
J.a(MatterTest::test, 20);
|
|
||||||
|
|
||||||
if (IrisSettings.get().getStudio().isAutoStartDefaultStudio()) {
|
if (IrisSettings.get().getStudio().isAutoStartDefaultStudio()) {
|
||||||
Iris.info("Starting up auto Studio!");
|
Iris.info("Starting up auto Studio!");
|
||||||
@ -468,6 +480,16 @@ public class Iris extends VolmitPlugin implements Listener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void panic()
|
||||||
|
{
|
||||||
|
EnginePanic.panic();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void addPanic(String s, String v)
|
||||||
|
{
|
||||||
|
EnginePanic.add(s, v);
|
||||||
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public void onEnable() {
|
public void onEnable() {
|
||||||
enable();
|
enable();
|
||||||
|
@ -34,6 +34,7 @@ import java.io.IOException;
|
|||||||
public class IrisSettings {
|
public class IrisSettings {
|
||||||
public static transient IrisSettings settings;
|
public static transient IrisSettings settings;
|
||||||
private IrisSettingsGeneral general = new IrisSettingsGeneral();
|
private IrisSettingsGeneral general = new IrisSettingsGeneral();
|
||||||
|
private IrisSettingsWorld world = new IrisSettingsWorld();
|
||||||
private IrisSettingsGUI gui = new IrisSettingsGUI();
|
private IrisSettingsGUI gui = new IrisSettingsGUI();
|
||||||
private IrisSettingsAutoconfiguration autoConfiguration = new IrisSettingsAutoconfiguration();
|
private IrisSettingsAutoconfiguration autoConfiguration = new IrisSettingsAutoconfiguration();
|
||||||
private IrisSettingsGenerator generator = new IrisSettingsGenerator();
|
private IrisSettingsGenerator generator = new IrisSettingsGenerator();
|
||||||
@ -56,6 +57,24 @@ public class IrisSettings {
|
|||||||
public boolean autoRestartOnCustomBiomeInstall = true;
|
public boolean autoRestartOnCustomBiomeInstall = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public static class IrisAsyncTeleport {
|
||||||
|
public boolean enabled = false;
|
||||||
|
public int loadViewDistance = 2;
|
||||||
|
public boolean urgent = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public static class IrisSettingsWorld {
|
||||||
|
public IrisAsyncTeleport asyncTeleport = new IrisAsyncTeleport();
|
||||||
|
public boolean postLoadBlockUpdates = true;
|
||||||
|
public boolean anbientEntitySpawningSystem = true;
|
||||||
|
public long asyncTickIntervalMS = 700;
|
||||||
|
public double targetSpawnEntitiesPerChunk = 0.95;
|
||||||
|
public boolean markerEntitySpawningSystem = true;
|
||||||
|
public boolean effectSystem = true;
|
||||||
|
}
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
public static class IrisSettingsConcurrency {
|
public static class IrisSettingsConcurrency {
|
||||||
public int parallelism = -1;
|
public int parallelism = -1;
|
||||||
@ -64,11 +83,11 @@ public class IrisSettings {
|
|||||||
@Data
|
@Data
|
||||||
public static class IrisSettingsPerformance {
|
public static class IrisSettingsPerformance {
|
||||||
public boolean trimMantleInStudio = false;
|
public boolean trimMantleInStudio = false;
|
||||||
public int mantleKeepAliveSeconds = 25;
|
public int mantleKeepAlive = 60;
|
||||||
public int maxStreamCacheSize = 256_000;
|
public int cacheSize = 4_096;
|
||||||
public int maxResourceLoaderCacheSize = 1_000;
|
public int resourceLoaderCacheSize = 1_024;
|
||||||
public int maxObjectLoaderCacheSize = 3_000;
|
public int objectLoaderCacheSize = 4_096;
|
||||||
public int maxScriptLoaderCacheSize = 500;
|
public int scriptLoaderCacheSize = 512;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
@ -100,7 +119,7 @@ public class IrisSettings {
|
|||||||
@Data
|
@Data
|
||||||
public static class IrisSettingsGenerator {
|
public static class IrisSettingsGenerator {
|
||||||
public String defaultWorldType = "overworld";
|
public String defaultWorldType = "overworld";
|
||||||
public boolean headlessPregeneration = false;
|
public boolean headlessPregeneration = true;
|
||||||
public int maxBiomeChildDepth = 4;
|
public int maxBiomeChildDepth = 4;
|
||||||
public boolean preventLeafDecay = true;
|
public boolean preventLeafDecay = true;
|
||||||
}
|
}
|
||||||
|
@ -41,16 +41,13 @@ import java.io.IOException;
|
|||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
public class ServerConfigurator {
|
public class ServerConfigurator {
|
||||||
public static void configure()
|
public static void configure() {
|
||||||
{
|
|
||||||
IrisSettings.IrisSettingsAutoconfiguration s = IrisSettings.get().getAutoConfiguration();
|
IrisSettings.IrisSettingsAutoconfiguration s = IrisSettings.get().getAutoConfiguration();
|
||||||
if(s.isConfigureSpigotTimeoutTime())
|
if (s.isConfigureSpigotTimeoutTime()) {
|
||||||
{
|
|
||||||
J.attempt(ServerConfigurator::increaseKeepAliveSpigot);
|
J.attempt(ServerConfigurator::increaseKeepAliveSpigot);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(s.isConfigurePaperWatchdogDelay())
|
if (s.isConfigurePaperWatchdogDelay()) {
|
||||||
{
|
|
||||||
J.attempt(ServerConfigurator::increasePaperWatchdog);
|
J.attempt(ServerConfigurator::increasePaperWatchdog);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -63,9 +60,9 @@ public class ServerConfigurator {
|
|||||||
f.load(spigotConfig);
|
f.load(spigotConfig);
|
||||||
long tt = f.getLong("settings.timeout-time");
|
long tt = f.getLong("settings.timeout-time");
|
||||||
|
|
||||||
if(tt < TimeUnit.MINUTES.toSeconds(5))
|
if (tt < TimeUnit.MINUTES.toSeconds(5)) {
|
||||||
{
|
Iris.warn("Updating spigot.yml timeout-time: " + tt + " -> " + TimeUnit.MINUTES.toSeconds(5) + " (5 minutes)");
|
||||||
Iris.warn("Updating spigot.yml timeout-time: " + tt + " -> " + TimeUnit.MINUTES.toSeconds(5) + " (5 minutes). You can disable this change (autoconfigureServer) in Iris settings, then change back the value.");
|
Iris.warn("You can disable this change (autoconfigureServer) in Iris settings, then change back the value.");
|
||||||
f.set("settings.timeout-time", TimeUnit.MINUTES.toSeconds(5));
|
f.set("settings.timeout-time", TimeUnit.MINUTES.toSeconds(5));
|
||||||
f.save(spigotConfig);
|
f.save(spigotConfig);
|
||||||
}
|
}
|
||||||
@ -77,9 +74,9 @@ public class ServerConfigurator {
|
|||||||
f.load(spigotConfig);
|
f.load(spigotConfig);
|
||||||
long tt = f.getLong("settings.watchdog.early-warning-delay");
|
long tt = f.getLong("settings.watchdog.early-warning-delay");
|
||||||
|
|
||||||
if(tt < TimeUnit.MINUTES.toMillis(3))
|
if (tt < TimeUnit.MINUTES.toMillis(3)) {
|
||||||
{
|
Iris.warn("Updating paper.yml watchdog early-warning-delay: " + tt + " -> " + TimeUnit.MINUTES.toMillis(3) + " (3 minutes)");
|
||||||
Iris.warn("Updating paper.yml watchdog early-warning-delay: " + tt + " -> " + TimeUnit.MINUTES.toMillis(3) + " (3 minutes). You can disable this change (autoconfigureServer) in Iris settings, then change back the value.");
|
Iris.warn("You can disable this change (autoconfigureServer) in Iris settings, then change back the value.");
|
||||||
f.set("settings.watchdog.early-warning-delay", TimeUnit.MINUTES.toMillis(3));
|
f.set("settings.watchdog.early-warning-delay", TimeUnit.MINUTES.toMillis(3));
|
||||||
f.save(spigotConfig);
|
f.save(spigotConfig);
|
||||||
}
|
}
|
||||||
@ -110,8 +107,7 @@ public class ServerConfigurator {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void installDataPacks(boolean fullInstall)
|
public static void installDataPacks(boolean fullInstall) {
|
||||||
{
|
|
||||||
Iris.info("Checking Data Packs...");
|
Iris.info("Checking Data Packs...");
|
||||||
boolean reboot = false;
|
boolean reboot = false;
|
||||||
File packs = new File("plugins/Iris/packs");
|
File packs = new File("plugins/Iris/packs");
|
||||||
@ -151,8 +147,7 @@ public class ServerConfigurator {
|
|||||||
|
|
||||||
Iris.info("Data Packs Setup!");
|
Iris.info("Data Packs Setup!");
|
||||||
|
|
||||||
if(fullInstall)
|
if (fullInstall) {
|
||||||
{
|
|
||||||
verifyDataPacksPost(IrisSettings.get().getAutoConfiguration().isAutoRestartOnCustomBiomeInstall());
|
verifyDataPacksPost(IrisSettings.get().getAutoConfiguration().isAutoRestartOnCustomBiomeInstall());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -194,14 +189,10 @@ public class ServerConfigurator {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(bad)
|
if (bad) {
|
||||||
{
|
if (allowRestarting) {
|
||||||
if(allowRestarting)
|
|
||||||
{
|
|
||||||
restart();
|
restart();
|
||||||
}
|
} else if (INMS.get().supportsDataPacks()) {
|
||||||
|
|
||||||
else if (INMS.get().supportsDataPacks()) {
|
|
||||||
Iris.error("============================================================================");
|
Iris.error("============================================================================");
|
||||||
Iris.error(C.ITALIC + "You need to restart your server to properly generate custom biomes.");
|
Iris.error(C.ITALIC + "You need to restart your server to properly generate custom biomes.");
|
||||||
Iris.error(C.ITALIC + "By continuing, Iris will use backup biomes in place of the custom biomes.");
|
Iris.error(C.ITALIC + "By continuing, Iris will use backup biomes in place of the custom biomes.");
|
||||||
@ -224,7 +215,9 @@ public class ServerConfigurator {
|
|||||||
|
|
||||||
public static void restart() {
|
public static void restart() {
|
||||||
J.s(() -> {
|
J.s(() -> {
|
||||||
Iris.warn("New data pack entries have been installed in Iris! Restarting server! (You can disable this auto restart in iris settings). This will only happen when your pack changes (updates/first time setup)");
|
Iris.warn("New data pack entries have been installed in Iris! Restarting server!");
|
||||||
|
Iris.warn("This will only happen when your pack changes (updates/first time setup)");
|
||||||
|
Iris.warn("(You can disable this auto restart in iris settings)");
|
||||||
J.s(() -> {
|
J.s(() -> {
|
||||||
Iris.warn("Looks like the restart command diddn't work. Stopping the server instead!");
|
Iris.warn("Looks like the restart command diddn't work. Stopping the server instead!");
|
||||||
Bukkit.shutdown();
|
Bukkit.shutdown();
|
||||||
@ -268,7 +261,8 @@ public class ServerConfigurator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (warn) {
|
if (warn) {
|
||||||
Iris.error("The Pack " + dimension.getLoadKey() + " is INCAPABLE of generating custom biomes, restart your server before generating with this pack!");
|
Iris.error("The Pack " + dimension.getLoadKey() + " is INCAPABLE of generating custom biomes");
|
||||||
|
Iris.error("If not done automatically, restart your server before generating with this pack!");
|
||||||
}
|
}
|
||||||
|
|
||||||
return !warn;
|
return !warn;
|
||||||
|
@ -62,7 +62,6 @@ import com.volmit.iris.util.math.RNG;
|
|||||||
import com.volmit.iris.util.math.Spiraler;
|
import com.volmit.iris.util.math.Spiraler;
|
||||||
import com.volmit.iris.util.noise.CNG;
|
import com.volmit.iris.util.noise.CNG;
|
||||||
import com.volmit.iris.util.parallel.MultiBurst;
|
import com.volmit.iris.util.parallel.MultiBurst;
|
||||||
import com.volmit.iris.util.plugin.IrisService;
|
|
||||||
import com.volmit.iris.util.scheduling.J;
|
import com.volmit.iris.util.scheduling.J;
|
||||||
import com.volmit.iris.util.scheduling.O;
|
import com.volmit.iris.util.scheduling.O;
|
||||||
import com.volmit.iris.util.scheduling.PrecisionStopwatch;
|
import com.volmit.iris.util.scheduling.PrecisionStopwatch;
|
||||||
@ -367,7 +366,7 @@ public class CommandStudio implements DecreeExecutor {
|
|||||||
|
|
||||||
@Decree(description = "Hotload a studio", aliases = "reload")
|
@Decree(description = "Hotload a studio", aliases = "reload")
|
||||||
public void hotload() {
|
public void hotload() {
|
||||||
if (!Iris.service(StudioSVC.class).isProjectOpen()){
|
if (!Iris.service(StudioSVC.class).isProjectOpen()) {
|
||||||
sender().sendMessage(C.RED + "No studio world open!");
|
sender().sendMessage(C.RED + "No studio world open!");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -24,7 +24,6 @@ import com.volmit.iris.core.pregenerator.IrisPregenerator;
|
|||||||
import com.volmit.iris.core.pregenerator.PregenListener;
|
import com.volmit.iris.core.pregenerator.PregenListener;
|
||||||
import com.volmit.iris.core.pregenerator.PregenTask;
|
import com.volmit.iris.core.pregenerator.PregenTask;
|
||||||
import com.volmit.iris.core.pregenerator.PregeneratorMethod;
|
import com.volmit.iris.core.pregenerator.PregeneratorMethod;
|
||||||
import com.volmit.iris.engine.data.cache.Cache;
|
|
||||||
import com.volmit.iris.engine.framework.Engine;
|
import com.volmit.iris.engine.framework.Engine;
|
||||||
import com.volmit.iris.util.collection.KList;
|
import com.volmit.iris.util.collection.KList;
|
||||||
import com.volmit.iris.util.format.Form;
|
import com.volmit.iris.util.format.Form;
|
||||||
@ -35,7 +34,6 @@ import com.volmit.iris.util.math.M;
|
|||||||
import com.volmit.iris.util.math.Position2;
|
import com.volmit.iris.util.math.Position2;
|
||||||
import com.volmit.iris.util.scheduling.ChronoLatch;
|
import com.volmit.iris.util.scheduling.ChronoLatch;
|
||||||
import com.volmit.iris.util.scheduling.J;
|
import com.volmit.iris.util.scheduling.J;
|
||||||
import com.volmit.iris.util.scheduling.Looper;
|
|
||||||
|
|
||||||
import javax.swing.JFrame;
|
import javax.swing.JFrame;
|
||||||
import javax.swing.JPanel;
|
import javax.swing.JPanel;
|
||||||
@ -46,7 +44,6 @@ import java.awt.Graphics2D;
|
|||||||
import java.awt.event.KeyEvent;
|
import java.awt.event.KeyEvent;
|
||||||
import java.awt.event.KeyListener;
|
import java.awt.event.KeyListener;
|
||||||
import java.awt.image.BufferedImage;
|
import java.awt.image.BufferedImage;
|
||||||
import java.util.List;
|
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
import java.util.concurrent.locks.ReentrantLock;
|
import java.util.concurrent.locks.ReentrantLock;
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
@ -72,9 +69,9 @@ public class PregeneratorJob implements PregenListener {
|
|||||||
private JFrame frame;
|
private JFrame frame;
|
||||||
private PregenRenderer renderer;
|
private PregenRenderer renderer;
|
||||||
private int rgc = 0;
|
private int rgc = 0;
|
||||||
private ChronoLatch cl = new ChronoLatch(TimeUnit.MINUTES.toMillis(1));
|
private final ChronoLatch cl = new ChronoLatch(TimeUnit.MINUTES.toMillis(1));
|
||||||
private String[] info;
|
private String[] info;
|
||||||
private Engine engine;
|
private final Engine engine;
|
||||||
|
|
||||||
public PregeneratorJob(PregenTask task, PregeneratorMethod method, Engine engine) {
|
public PregeneratorJob(PregenTask task, PregeneratorMethod method, Engine engine) {
|
||||||
this.engine = engine;
|
this.engine = engine;
|
||||||
@ -101,8 +98,7 @@ public class PregeneratorJob implements PregenListener {
|
|||||||
J.a(this.pregenerator::start, 20);
|
J.a(this.pregenerator::start, 20);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Mantle getMantle()
|
public Mantle getMantle() {
|
||||||
{
|
|
||||||
return pregenerator.getMantle();
|
return pregenerator.getMantle();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -243,8 +239,7 @@ public class PregeneratorJob implements PregenListener {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onChunkGenerating(int x, int z) {
|
public void onChunkGenerating(int x, int z) {
|
||||||
if(engine != null)
|
if (engine != null) {
|
||||||
{
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -253,8 +248,7 @@ public class PregeneratorJob implements PregenListener {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onChunkGenerated(int x, int z) {
|
public void onChunkGenerated(int x, int z) {
|
||||||
if(engine != null)
|
if (engine != null) {
|
||||||
{
|
|
||||||
draw(x, z, engine.draw((x << 4) + 8, (z << 4) + 8));
|
draw(x, z, engine.draw((x << 4) + 8, (z << 4) + 8));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -269,8 +263,7 @@ public class PregeneratorJob implements PregenListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void shouldGc() {
|
private void shouldGc() {
|
||||||
if(cl.flip() && rgc > 16)
|
if (cl.flip() && rgc > 16) {
|
||||||
{
|
|
||||||
System.gc();
|
System.gc();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -329,8 +322,7 @@ public class PregeneratorJob implements PregenListener {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onChunkExistsInRegionGen(int x, int z) {
|
public void onChunkExistsInRegionGen(int x, int z) {
|
||||||
if(engine != null)
|
if (engine != null) {
|
||||||
{
|
|
||||||
draw(x, z, engine.draw((x << 4) + 8, (z << 4) + 8));
|
draw(x, z, engine.draw((x << 4) + 8, (z << 4) + 8));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -55,7 +55,6 @@ import com.volmit.iris.util.collection.KMap;
|
|||||||
import com.volmit.iris.util.context.IrisContext;
|
import com.volmit.iris.util.context.IrisContext;
|
||||||
import com.volmit.iris.util.format.C;
|
import com.volmit.iris.util.format.C;
|
||||||
import com.volmit.iris.util.math.RNG;
|
import com.volmit.iris.util.math.RNG;
|
||||||
import com.volmit.iris.util.matter.IrisMatter;
|
|
||||||
import com.volmit.iris.util.scheduling.ChronoLatch;
|
import com.volmit.iris.util.scheduling.ChronoLatch;
|
||||||
import com.volmit.iris.util.scheduling.J;
|
import com.volmit.iris.util.scheduling.J;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
@ -22,23 +22,16 @@ import com.volmit.iris.Iris;
|
|||||||
import com.volmit.iris.core.IrisSettings;
|
import com.volmit.iris.core.IrisSettings;
|
||||||
import com.volmit.iris.engine.object.IrisObject;
|
import com.volmit.iris.engine.object.IrisObject;
|
||||||
import com.volmit.iris.util.collection.KList;
|
import com.volmit.iris.util.collection.KList;
|
||||||
import com.volmit.iris.util.collection.KMap;
|
|
||||||
import com.volmit.iris.util.collection.KSet;
|
import com.volmit.iris.util.collection.KSet;
|
||||||
import com.volmit.iris.util.data.KCache;
|
import com.volmit.iris.util.data.KCache;
|
||||||
import com.volmit.iris.util.format.C;
|
|
||||||
import com.volmit.iris.util.format.Form;
|
|
||||||
import com.volmit.iris.util.math.M;
|
|
||||||
import com.volmit.iris.util.scheduling.ChronoLatch;
|
|
||||||
import com.volmit.iris.util.scheduling.J;
|
|
||||||
import com.volmit.iris.util.scheduling.PrecisionStopwatch;
|
import com.volmit.iris.util.scheduling.PrecisionStopwatch;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.concurrent.atomic.AtomicInteger;
|
|
||||||
|
|
||||||
public class ObjectResourceLoader extends ResourceLoader<IrisObject> {
|
public class ObjectResourceLoader extends ResourceLoader<IrisObject> {
|
||||||
public ObjectResourceLoader(File root, IrisData idm, String folderName, String resourceTypeName) {
|
public ObjectResourceLoader(File root, IrisData idm, String folderName, String resourceTypeName) {
|
||||||
super(root, idm, folderName, resourceTypeName, IrisObject.class);
|
super(root, idm, folderName, resourceTypeName, IrisObject.class);
|
||||||
loadCache = new KCache<>(this::loadRaw, IrisSettings.get().getPerformance().getMaxObjectLoaderCacheSize());
|
loadCache = new KCache<>(this::loadRaw, IrisSettings.get().getPerformance().getObjectLoaderCacheSize());
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean supportsSchemas() {
|
public boolean supportsSchemas() {
|
||||||
@ -128,7 +121,7 @@ public class ObjectResourceLoader extends ResourceLoader<IrisObject> {
|
|||||||
return load(name, true);
|
return load(name, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
private IrisObject loadRaw(String name){
|
private IrisObject loadRaw(String name) {
|
||||||
for (File i : getFolders(name)) {
|
for (File i : getFolders(name)) {
|
||||||
for (File j : i.listFiles()) {
|
for (File j : i.listFiles()) {
|
||||||
if (j.isFile() && j.getName().endsWith(".iob") && j.getName().split("\\Q.\\E")[0].equals(name)) {
|
if (j.isFile() && j.getName().endsWith(".iob") && j.getName().split("\\Q.\\E")[0].equals(name)) {
|
||||||
|
@ -25,7 +25,6 @@ import com.volmit.iris.core.project.SchemaBuilder;
|
|||||||
import com.volmit.iris.core.service.PreservationSVC;
|
import com.volmit.iris.core.service.PreservationSVC;
|
||||||
import com.volmit.iris.engine.framework.MeteredCache;
|
import com.volmit.iris.engine.framework.MeteredCache;
|
||||||
import com.volmit.iris.util.collection.KList;
|
import com.volmit.iris.util.collection.KList;
|
||||||
import com.volmit.iris.util.collection.KMap;
|
|
||||||
import com.volmit.iris.util.collection.KSet;
|
import com.volmit.iris.util.collection.KSet;
|
||||||
import com.volmit.iris.util.data.KCache;
|
import com.volmit.iris.util.data.KCache;
|
||||||
import com.volmit.iris.util.format.C;
|
import com.volmit.iris.util.format.C;
|
||||||
@ -34,7 +33,6 @@ import com.volmit.iris.util.io.IO;
|
|||||||
import com.volmit.iris.util.json.JSONArray;
|
import com.volmit.iris.util.json.JSONArray;
|
||||||
import com.volmit.iris.util.json.JSONObject;
|
import com.volmit.iris.util.json.JSONObject;
|
||||||
import com.volmit.iris.util.scheduling.ChronoLatch;
|
import com.volmit.iris.util.scheduling.ChronoLatch;
|
||||||
import com.volmit.iris.util.scheduling.IrisLock;
|
|
||||||
import com.volmit.iris.util.scheduling.J;
|
import com.volmit.iris.util.scheduling.J;
|
||||||
import com.volmit.iris.util.scheduling.PrecisionStopwatch;
|
import com.volmit.iris.util.scheduling.PrecisionStopwatch;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
@ -42,6 +40,8 @@ import lombok.Data;
|
|||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
import java.util.concurrent.atomic.AtomicInteger;
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
|
import java.util.concurrent.atomic.AtomicReference;
|
||||||
|
import java.util.concurrent.atomic.AtomicReferenceArray;
|
||||||
import java.util.function.Predicate;
|
import java.util.function.Predicate;
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
@ -53,7 +53,7 @@ public class ResourceLoader<T extends IrisRegistrant> implements MeteredCache {
|
|||||||
protected String folderName;
|
protected String folderName;
|
||||||
protected String resourceTypeName;
|
protected String resourceTypeName;
|
||||||
protected KCache<String, T> loadCache;
|
protected KCache<String, T> loadCache;
|
||||||
protected KList<File> folderCache;
|
protected final AtomicReference<KList<File>> folderCache;
|
||||||
protected Class<? extends T> objectClass;
|
protected Class<? extends T> objectClass;
|
||||||
protected String cname;
|
protected String cname;
|
||||||
protected String[] possibleKeys = null;
|
protected String[] possibleKeys = null;
|
||||||
@ -63,6 +63,7 @@ public class ResourceLoader<T extends IrisRegistrant> implements MeteredCache {
|
|||||||
|
|
||||||
public ResourceLoader(File root, IrisData manager, String folderName, String resourceTypeName, Class<? extends T> objectClass) {
|
public ResourceLoader(File root, IrisData manager, String folderName, String resourceTypeName, Class<? extends T> objectClass) {
|
||||||
this.manager = manager;
|
this.manager = manager;
|
||||||
|
folderCache = new AtomicReference<>();
|
||||||
sec = new ChronoLatch(5000);
|
sec = new ChronoLatch(5000);
|
||||||
loads = new AtomicInteger();
|
loads = new AtomicInteger();
|
||||||
this.objectClass = objectClass;
|
this.objectClass = objectClass;
|
||||||
@ -70,7 +71,7 @@ public class ResourceLoader<T extends IrisRegistrant> implements MeteredCache {
|
|||||||
this.resourceTypeName = resourceTypeName;
|
this.resourceTypeName = resourceTypeName;
|
||||||
this.root = root;
|
this.root = root;
|
||||||
this.folderName = folderName;
|
this.folderName = folderName;
|
||||||
loadCache = new KCache<>(this::loadRaw, IrisSettings.get().getPerformance().getMaxResourceLoaderCacheSize());
|
loadCache = new KCache<>(this::loadRaw, IrisSettings.get().getPerformance().getResourceLoaderCacheSize());
|
||||||
Iris.debug("Loader<" + C.GREEN + resourceTypeName + C.LIGHT_PURPLE + "> created in " + C.RED + "IDM/" + manager.getId() + C.LIGHT_PURPLE + " on " + C.GRAY + manager.getDataFolder().getPath());
|
Iris.debug("Loader<" + C.GREEN + resourceTypeName + C.LIGHT_PURPLE + "> created in " + C.RED + "IDM/" + manager.getId() + C.LIGHT_PURPLE + " on " + C.GRAY + manager.getDataFolder().getPath());
|
||||||
Iris.service(PreservationSVC.class).registerCache(this);
|
Iris.service(PreservationSVC.class).registerCache(this);
|
||||||
}
|
}
|
||||||
@ -238,8 +239,7 @@ public class ResourceLoader<T extends IrisRegistrant> implements MeteredCache {
|
|||||||
return load(name, true);
|
return load(name, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
private T loadRaw(String name)
|
private T loadRaw(String name) {
|
||||||
{
|
|
||||||
for (File i : getFolders(name)) {
|
for (File i : getFolders(name)) {
|
||||||
//noinspection ConstantConditions
|
//noinspection ConstantConditions
|
||||||
for (File j : i.listFiles()) {
|
for (File j : i.listFiles()) {
|
||||||
@ -271,26 +271,20 @@ public class ResourceLoader<T extends IrisRegistrant> implements MeteredCache {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public KList<File> getFolders() {
|
public KList<File> getFolders() {
|
||||||
if (folderCache == null) {
|
if (folderCache.get() == null) {
|
||||||
folderCache = new KList<>();
|
folderCache.set(new KList<>());
|
||||||
|
|
||||||
for (File i : root.listFiles()) {
|
for (File i : root.listFiles()) {
|
||||||
if (i.isDirectory()) {
|
if (i.isDirectory()) {
|
||||||
if (i.getName().equals(folderName)) {
|
if (i.getName().equals(folderName)) {
|
||||||
folderCache.add(i);
|
folderCache.get().add(i);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (folderCache == null) {
|
return folderCache.get();
|
||||||
synchronized (this) {
|
|
||||||
return getFolderCache();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return folderCache;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public KList<File> getFolders(String rc) {
|
public KList<File> getFolders(String rc) {
|
||||||
@ -310,7 +304,7 @@ public class ResourceLoader<T extends IrisRegistrant> implements MeteredCache {
|
|||||||
public void clearCache() {
|
public void clearCache() {
|
||||||
possibleKeys = null;
|
possibleKeys = null;
|
||||||
loadCache.invalidate();
|
loadCache.invalidate();
|
||||||
folderCache = null;
|
folderCache.set(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public File fileFor(T b) {
|
public File fileFor(T b) {
|
||||||
@ -336,7 +330,7 @@ public class ResourceLoader<T extends IrisRegistrant> implements MeteredCache {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void clearList() {
|
public void clearList() {
|
||||||
folderCache = null;
|
folderCache.set(null);
|
||||||
possibleKeys = null;
|
possibleKeys = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -364,6 +358,11 @@ public class ResourceLoader<T extends IrisRegistrant> implements MeteredCache {
|
|||||||
return loadCache.getSize();
|
return loadCache.getSize();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public KCache<?, ?> getRawCache() {
|
||||||
|
return loadCache;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public long getMaxSize() {
|
public long getMaxSize() {
|
||||||
return loadCache.getMaxSize();
|
return loadCache.getMaxSize();
|
||||||
|
@ -32,7 +32,7 @@ import java.io.File;
|
|||||||
public class ScriptResourceLoader extends ResourceLoader<IrisScript> {
|
public class ScriptResourceLoader extends ResourceLoader<IrisScript> {
|
||||||
public ScriptResourceLoader(File root, IrisData idm, String folderName, String resourceTypeName) {
|
public ScriptResourceLoader(File root, IrisData idm, String folderName, String resourceTypeName) {
|
||||||
super(root, idm, folderName, resourceTypeName, IrisScript.class);
|
super(root, idm, folderName, resourceTypeName, IrisScript.class);
|
||||||
loadCache = new KCache<>(this::loadRaw, IrisSettings.get().getPerformance().getMaxScriptLoaderCacheSize());
|
loadCache = new KCache<>(this::loadRaw, IrisSettings.get().getPerformance().getScriptLoaderCacheSize());
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean supportsSchemas() {
|
public boolean supportsSchemas() {
|
||||||
@ -113,8 +113,7 @@ public class ScriptResourceLoader extends ResourceLoader<IrisScript> {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private IrisScript loadRaw(String name)
|
private IrisScript loadRaw(String name) {
|
||||||
{
|
|
||||||
for (File i : getFolders(name)) {
|
for (File i : getFolders(name)) {
|
||||||
for (File j : i.listFiles()) {
|
for (File j : i.listFiles()) {
|
||||||
if (j.isFile() && j.getName().endsWith(".js") && j.getName().split("\\Q.\\E")[0].equals(name)) {
|
if (j.isFile() && j.getName().endsWith(".js") && j.getName().split("\\Q.\\E")[0].equals(name)) {
|
||||||
|
@ -18,28 +18,20 @@
|
|||||||
|
|
||||||
package com.volmit.iris.core.pregenerator;
|
package com.volmit.iris.core.pregenerator;
|
||||||
|
|
||||||
import com.volmit.iris.Iris;
|
|
||||||
import com.volmit.iris.core.gui.PregeneratorJob;
|
|
||||||
import com.volmit.iris.util.collection.KList;
|
import com.volmit.iris.util.collection.KList;
|
||||||
import com.volmit.iris.util.collection.KMap;
|
import com.volmit.iris.util.collection.KMap;
|
||||||
import com.volmit.iris.util.collection.KSet;
|
|
||||||
import com.volmit.iris.util.math.Position2;
|
import com.volmit.iris.util.math.Position2;
|
||||||
import com.volmit.iris.util.math.RNG;
|
|
||||||
import com.volmit.iris.util.math.Spiraled;
|
import com.volmit.iris.util.math.Spiraled;
|
||||||
import com.volmit.iris.util.math.Spiraler;
|
import com.volmit.iris.util.math.Spiraler;
|
||||||
import lombok.Builder;
|
import lombok.Builder;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import org.checkerframework.checker.units.qual.K;
|
|
||||||
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
import java.util.Set;
|
|
||||||
import java.util.function.Function;
|
|
||||||
|
|
||||||
@Builder
|
@Builder
|
||||||
@Data
|
@Data
|
||||||
public class PregenTask {
|
public class PregenTask {
|
||||||
private static final Position2 ZERO = new Position2(0,0);
|
private static final Position2 ZERO = new Position2(0, 0);
|
||||||
private static final KList<Position2> ORDER_CENTER = computeChunkOrder();
|
private static final KList<Position2> ORDER_CENTER = computeChunkOrder();
|
||||||
private static final KMap<Position2, KList<Position2>> ORDERS = new KMap<>();
|
private static final KMap<Position2, KList<Position2>> ORDERS = new KMap<>();
|
||||||
|
|
||||||
@ -57,7 +49,7 @@ public class PregenTask {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void iterateRegion(int xr, int zr, Spiraled s) {
|
public static void iterateRegion(int xr, int zr, Spiraled s) {
|
||||||
iterateRegion(xr, zr, s, new Position2(0,0));
|
iterateRegion(xr, zr, s, new Position2(0, 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
private static KList<Position2> computeOrder(Position2 pull) {
|
private static KList<Position2> computeOrder(Position2 pull) {
|
||||||
|
@ -133,8 +133,7 @@ public class AsyncPregenMethod implements PregeneratorMethod {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Mantle getMantle() {
|
public Mantle getMantle() {
|
||||||
if(IrisToolbelt.isIrisWorld(world))
|
if (IrisToolbelt.isIrisWorld(world)) {
|
||||||
{
|
|
||||||
return IrisToolbelt.access(world).getEngine().getMantle().getMantle();
|
return IrisToolbelt.access(world).getEngine().getMantle().getMantle();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -102,8 +102,7 @@ public class HybridPregenMethod implements PregeneratorMethod {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Mantle getMantle() {
|
public Mantle getMantle() {
|
||||||
if (headless == null)
|
if (headless == null) {
|
||||||
{
|
|
||||||
return inWorld.getMantle();
|
return inWorld.getMantle();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -111,8 +111,7 @@ public class MedievalPregenMethod implements PregeneratorMethod {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Mantle getMantle() {
|
public Mantle getMantle() {
|
||||||
if(IrisToolbelt.isIrisWorld(world))
|
if (IrisToolbelt.isIrisWorld(world)) {
|
||||||
{
|
|
||||||
return IrisToolbelt.access(world).getEngine().getMantle().getMantle();
|
return IrisToolbelt.access(world).getEngine().getMantle().getMantle();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -31,11 +31,14 @@ import com.volmit.iris.util.plugin.VolmitSender;
|
|||||||
import com.volmit.iris.util.scheduling.J;
|
import com.volmit.iris.util.scheduling.J;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
||||||
|
import org.bukkit.event.server.ServerCommandEvent;
|
||||||
|
|
||||||
|
import java.util.Locale;
|
||||||
import java.util.concurrent.CompletableFuture;
|
import java.util.concurrent.CompletableFuture;
|
||||||
|
|
||||||
public class CommandSVC implements IrisService, DecreeSystem {
|
public class CommandSVC implements IrisService, DecreeSystem {
|
||||||
private final KMap<String, CompletableFuture<String>> futures = new KMap<>();
|
private final KMap<String, CompletableFuture<String>> futures = new KMap<>();
|
||||||
|
private CompletableFuture<String> consoleFuture = null;
|
||||||
private final transient AtomicCache<VirtualDecreeCommand> commandCache = new AtomicCache<>();
|
private final transient AtomicCache<VirtualDecreeCommand> commandCache = new AtomicCache<>();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -70,6 +73,17 @@ public class CommandSVC implements IrisService, DecreeSystem {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void on(ServerCommandEvent e) {
|
||||||
|
if (consoleFuture != null && !consoleFuture.isCancelled() && !consoleFuture.isDone()) {
|
||||||
|
if (!e.getCommand().contains(" ")) {
|
||||||
|
String pick = e.getCommand().trim().toLowerCase(Locale.ROOT);
|
||||||
|
consoleFuture.complete(pick);
|
||||||
|
e.setCancelled(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public VirtualDecreeCommand getRoot() {
|
public VirtualDecreeCommand getRoot() {
|
||||||
return commandCache.aquireNastyPrint(() -> VirtualDecreeCommand.createRoot(new CommandIris()));
|
return commandCache.aquireNastyPrint(() -> VirtualDecreeCommand.createRoot(new CommandIris()));
|
||||||
@ -78,4 +92,8 @@ public class CommandSVC implements IrisService, DecreeSystem {
|
|||||||
public void post(String password, CompletableFuture<String> future) {
|
public void post(String password, CompletableFuture<String> future) {
|
||||||
futures.put(password, future);
|
futures.put(password, future);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void postConsole(CompletableFuture<String> future) {
|
||||||
|
consoleFuture = future;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -19,27 +19,25 @@
|
|||||||
package com.volmit.iris.core.service;
|
package com.volmit.iris.core.service;
|
||||||
|
|
||||||
import com.volmit.iris.Iris;
|
import com.volmit.iris.Iris;
|
||||||
import com.volmit.iris.core.IrisSettings;
|
|
||||||
import com.volmit.iris.core.loader.IrisData;
|
import com.volmit.iris.core.loader.IrisData;
|
||||||
import com.volmit.iris.engine.framework.Engine;
|
|
||||||
import com.volmit.iris.engine.framework.MeteredCache;
|
import com.volmit.iris.engine.framework.MeteredCache;
|
||||||
import com.volmit.iris.util.collection.KList;
|
|
||||||
import com.volmit.iris.util.context.IrisContext;
|
import com.volmit.iris.util.context.IrisContext;
|
||||||
|
import com.volmit.iris.util.data.KCache;
|
||||||
import com.volmit.iris.util.format.Form;
|
import com.volmit.iris.util.format.Form;
|
||||||
import com.volmit.iris.util.parallel.MultiBurst;
|
import com.volmit.iris.util.parallel.MultiBurst;
|
||||||
import com.volmit.iris.util.plugin.IrisService;
|
import com.volmit.iris.util.plugin.IrisService;
|
||||||
import com.volmit.iris.util.scheduling.Looper;
|
import com.volmit.iris.util.scheduling.Looper;
|
||||||
import com.volmit.iris.util.stream.utility.CachedStream2D;
|
|
||||||
|
|
||||||
import java.util.Comparator;
|
import java.util.List;
|
||||||
import java.util.Objects;
|
import java.util.concurrent.CopyOnWriteArrayList;
|
||||||
import java.util.concurrent.ExecutorService;
|
import java.util.concurrent.ExecutorService;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
public class PreservationSVC implements IrisService {
|
public class PreservationSVC implements IrisService {
|
||||||
private final KList<Thread> threads = new KList<>();
|
private final List<Thread> threads = new CopyOnWriteArrayList<>();
|
||||||
private final KList<ExecutorService> services = new KList<>();
|
private final List<ExecutorService> services = new CopyOnWriteArrayList<>();
|
||||||
private Looper dereferencer;
|
private Looper dereferencer;
|
||||||
private final KList<MeteredCache> caches = new KList<>();
|
private final List<MeteredCache> caches = new CopyOnWriteArrayList<>();
|
||||||
|
|
||||||
public void register(Thread t) {
|
public void register(Thread t) {
|
||||||
threads.add(t);
|
threads.add(t);
|
||||||
@ -53,34 +51,31 @@ public class PreservationSVC implements IrisService {
|
|||||||
services.add(service);
|
services.add(service);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void printCaches()
|
public void printCaches() {
|
||||||
{
|
|
||||||
long s = caches.stream().filter(i -> !i.isClosed()).mapToLong(MeteredCache::getSize).sum();
|
long s = caches.stream().filter(i -> !i.isClosed()).mapToLong(MeteredCache::getSize).sum();
|
||||||
long m = caches.stream().filter(i -> !i.isClosed()).mapToLong(MeteredCache::getMaxSize).sum();
|
long m = caches.stream().filter(i -> !i.isClosed()).mapToLong(MeteredCache::getMaxSize).sum();
|
||||||
double p = 0;
|
double p = 0;
|
||||||
double mf = 0;
|
double mf = 0;
|
||||||
|
|
||||||
for(MeteredCache i : caches)
|
for (MeteredCache i : caches) {
|
||||||
{
|
if (i.isClosed()) {
|
||||||
if(i.isClosed())
|
|
||||||
{
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
mf++;
|
mf++;
|
||||||
p+= i.getUsage();
|
p += i.getUsage();
|
||||||
}
|
}
|
||||||
|
|
||||||
mf = mf == 0 ? 1 : mf;
|
mf = mf == 0 ? 1 : mf;
|
||||||
|
|
||||||
Iris.info("Cached " + Form.f(s) + " / " + Form.f(m) + " (" + Form.pc(p/mf) + ") from " + caches.size() + " Caches");
|
Iris.info("Cached " + Form.f(s) + " / " + Form.f(m) + " (" + Form.pc(p / mf) + ") from " + caches.size() + " Caches");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void dereference() {
|
public void dereference() {
|
||||||
IrisContext.dereference();
|
IrisContext.dereference();
|
||||||
IrisData.dereference();
|
IrisData.dereference();
|
||||||
threads.removeWhere((i) -> !i.isAlive());
|
threads.removeIf((i) -> !i.isAlive());
|
||||||
services.removeWhere(ExecutorService::isShutdown);
|
services.removeIf(ExecutorService::isShutdown);
|
||||||
updateCaches();
|
updateCaches();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -127,12 +122,15 @@ public class PreservationSVC implements IrisService {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateCaches()
|
public void updateCaches() {
|
||||||
{
|
caches.removeIf(MeteredCache::isClosed);
|
||||||
caches.removeWhere(MeteredCache::isClosed);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void registerCache(MeteredCache cache) {
|
public void registerCache(MeteredCache cache) {
|
||||||
caches.add(cache);
|
caches.add(cache);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<KCache<?, ?>> caches() {
|
||||||
|
return caches.stream().map(MeteredCache::getRawCache).collect(Collectors.toList());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
54
src/main/java/com/volmit/iris/engine/EnginePanic.java
Normal file
54
src/main/java/com/volmit/iris/engine/EnginePanic.java
Normal file
@ -0,0 +1,54 @@
|
|||||||
|
/*
|
||||||
|
* Iris is a World Generator for Minecraft Bukkit Servers
|
||||||
|
* Copyright (c) 2021 Arcane Arts (Volmit Software)
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.volmit.iris.engine;
|
||||||
|
|
||||||
|
import com.volmit.iris.Iris;
|
||||||
|
import com.volmit.iris.util.collection.KMap;
|
||||||
|
|
||||||
|
public class EnginePanic {
|
||||||
|
private static final KMap<String, String> stuff = new KMap<>();
|
||||||
|
private static KMap<String, String> last = new KMap<>();
|
||||||
|
|
||||||
|
public static void add(String key, String value)
|
||||||
|
{
|
||||||
|
stuff.put(key, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void saveLast()
|
||||||
|
{
|
||||||
|
last = stuff.copy();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void lastPanic()
|
||||||
|
{
|
||||||
|
for(String i : last.keySet())
|
||||||
|
{
|
||||||
|
Iris.error("Last Panic " + i + ": " + stuff.get(i));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void panic()
|
||||||
|
{
|
||||||
|
lastPanic();
|
||||||
|
for(String i : stuff.keySet())
|
||||||
|
{
|
||||||
|
Iris.error("Engine Panic " + i + ": " + stuff.get(i));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -89,7 +89,7 @@ public class IrisComplex implements DataProvider {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public IrisComplex(Engine engine, boolean simple) {
|
public IrisComplex(Engine engine, boolean simple) {
|
||||||
int cacheSize = IrisSettings.get().getPerformance().getMaxStreamCacheSize();
|
int cacheSize = IrisSettings.get().getPerformance().getCacheSize();
|
||||||
IrisBiome emptyBiome = new IrisBiome();
|
IrisBiome emptyBiome = new IrisBiome();
|
||||||
UUID focusUUID = UUID.nameUUIDFromBytes("focus".getBytes());
|
UUID focusUUID = UUID.nameUUIDFromBytes("focus".getBytes());
|
||||||
this.rng = new RNG(engine.getSeedManager().getComplex());
|
this.rng = new RNG(engine.getSeedManager().getComplex());
|
||||||
@ -124,7 +124,7 @@ public class IrisComplex implements DataProvider {
|
|||||||
Interpolated.of(a -> 0D, a -> focusRegion))
|
Interpolated.of(a -> 0D, a -> focusRegion))
|
||||||
: regionStyleStream
|
: regionStyleStream
|
||||||
.selectRarity(engine.getDimension().getRegions(), (i) -> data.getRegionLoader().load(i))
|
.selectRarity(engine.getDimension().getRegions(), (i) -> data.getRegionLoader().load(i))
|
||||||
.convertCached((s) -> data.getRegionLoader().load(s)).cache2D(engine, cacheSize);
|
.convertCached((s) -> data.getRegionLoader().load(s)).cache2D("regionStream", engine, cacheSize);
|
||||||
regionIDStream = regionIdentityStream.convertCached((i) -> new UUID(Double.doubleToLongBits(i), String.valueOf(i * 38445).hashCode() * 3245556666L));
|
regionIDStream = regionIdentityStream.convertCached((i) -> new UUID(Double.doubleToLongBits(i), String.valueOf(i * 38445).hashCode() * 3245556666L));
|
||||||
caveBiomeStream = regionStream.convert((r)
|
caveBiomeStream = regionStream.convert((r)
|
||||||
-> engine.getDimension().getCaveBiomeStyle().create(rng.nextParallelRNG(InferredType.CAVE.ordinal()), getData()).stream()
|
-> engine.getDimension().getCaveBiomeStyle().create(rng.nextParallelRNG(InferredType.CAVE.ordinal()), getData()).stream()
|
||||||
@ -139,7 +139,7 @@ public class IrisComplex implements DataProvider {
|
|||||||
return data.getBiomeLoader().load(s)
|
return data.getBiomeLoader().load(s)
|
||||||
.setInferredType(InferredType.CAVE);
|
.setInferredType(InferredType.CAVE);
|
||||||
})
|
})
|
||||||
).convertAware2D(ProceduralStream::get).cache2D(engine, cacheSize);
|
).convertAware2D(ProceduralStream::get).cache2D("caveBiomeStream", engine, cacheSize);
|
||||||
inferredStreams.put(InferredType.CAVE, caveBiomeStream);
|
inferredStreams.put(InferredType.CAVE, caveBiomeStream);
|
||||||
landBiomeStream = regionStream.convert((r)
|
landBiomeStream = regionStream.convert((r)
|
||||||
-> engine.getDimension().getLandBiomeStyle().create(rng.nextParallelRNG(InferredType.LAND.ordinal()), getData()).stream()
|
-> engine.getDimension().getLandBiomeStyle().create(rng.nextParallelRNG(InferredType.LAND.ordinal()), getData()).stream()
|
||||||
@ -148,7 +148,7 @@ public class IrisComplex implements DataProvider {
|
|||||||
.convertCached((s) -> data.getBiomeLoader().load(s)
|
.convertCached((s) -> data.getBiomeLoader().load(s)
|
||||||
.setInferredType(InferredType.LAND))
|
.setInferredType(InferredType.LAND))
|
||||||
).convertAware2D(ProceduralStream::get)
|
).convertAware2D(ProceduralStream::get)
|
||||||
.cache2D(engine, cacheSize);
|
.cache2D("landBiomeStream", engine, cacheSize);
|
||||||
inferredStreams.put(InferredType.LAND, landBiomeStream);
|
inferredStreams.put(InferredType.LAND, landBiomeStream);
|
||||||
seaBiomeStream = regionStream.convert((r)
|
seaBiomeStream = regionStream.convert((r)
|
||||||
-> engine.getDimension().getSeaBiomeStyle().create(rng.nextParallelRNG(InferredType.SEA.ordinal()), getData()).stream()
|
-> engine.getDimension().getSeaBiomeStyle().create(rng.nextParallelRNG(InferredType.SEA.ordinal()), getData()).stream()
|
||||||
@ -157,7 +157,7 @@ public class IrisComplex implements DataProvider {
|
|||||||
.convertCached((s) -> data.getBiomeLoader().load(s)
|
.convertCached((s) -> data.getBiomeLoader().load(s)
|
||||||
.setInferredType(InferredType.SEA))
|
.setInferredType(InferredType.SEA))
|
||||||
).convertAware2D(ProceduralStream::get)
|
).convertAware2D(ProceduralStream::get)
|
||||||
.cache2D(engine, cacheSize);
|
.cache2D("seaBiomeStream", engine, cacheSize);
|
||||||
inferredStreams.put(InferredType.SEA, seaBiomeStream);
|
inferredStreams.put(InferredType.SEA, seaBiomeStream);
|
||||||
shoreBiomeStream = regionStream.convert((r)
|
shoreBiomeStream = regionStream.convert((r)
|
||||||
-> engine.getDimension().getShoreBiomeStyle().create(rng.nextParallelRNG(InferredType.SHORE.ordinal()), getData()).stream()
|
-> engine.getDimension().getShoreBiomeStyle().create(rng.nextParallelRNG(InferredType.SHORE.ordinal()), getData()).stream()
|
||||||
@ -165,60 +165,54 @@ public class IrisComplex implements DataProvider {
|
|||||||
.selectRarity(r.getShoreBiomes(), (i) -> data.getBiomeLoader().load(i))
|
.selectRarity(r.getShoreBiomes(), (i) -> data.getBiomeLoader().load(i))
|
||||||
.convertCached((s) -> data.getBiomeLoader().load(s)
|
.convertCached((s) -> data.getBiomeLoader().load(s)
|
||||||
.setInferredType(InferredType.SHORE))
|
.setInferredType(InferredType.SHORE))
|
||||||
).convertAware2D(ProceduralStream::get).cache2D(engine, cacheSize);
|
).convertAware2D(ProceduralStream::get).cache2D("shoreBiomeStream", engine, cacheSize);
|
||||||
inferredStreams.put(InferredType.SHORE, shoreBiomeStream);
|
inferredStreams.put(InferredType.SHORE, shoreBiomeStream);
|
||||||
bridgeStream = focus != null ? ProceduralStream.of((x, z) -> focus.getInferredType(),
|
bridgeStream = focus != null ? ProceduralStream.of((x, z) -> focus.getInferredType(),
|
||||||
Interpolated.of(a -> 0D, a -> focus.getInferredType())) :
|
Interpolated.of(a -> 0D, a -> focus.getInferredType())) :
|
||||||
engine.getDimension().getContinentalStyle().create(rng.nextParallelRNG(234234565), getData())
|
engine.getDimension().getContinentalStyle().create(rng.nextParallelRNG(234234565), getData())
|
||||||
.bake().scale(1D / engine.getDimension().getContinentZoom()).bake().stream()
|
.bake().scale(1D / engine.getDimension().getContinentZoom()).bake().stream()
|
||||||
.convert((v) -> v >= engine.getDimension().getLandChance() ? InferredType.SEA : InferredType.LAND).cache2D(engine, cacheSize);
|
.convert((v) -> v >= engine.getDimension().getLandChance() ? InferredType.SEA : InferredType.LAND)
|
||||||
|
.cache2D("bridgeStream", engine, cacheSize);
|
||||||
baseBiomeStream = focus != null ? ProceduralStream.of((x, z) -> focus,
|
baseBiomeStream = focus != null ? ProceduralStream.of((x, z) -> focus,
|
||||||
Interpolated.of(a -> 0D, a -> focus)) :
|
Interpolated.of(a -> 0D, a -> focus)) :
|
||||||
bridgeStream.convertAware2D((t, x, z) -> inferredStreams.get(t).get(x, z))
|
bridgeStream.convertAware2D((t, x, z) -> inferredStreams.get(t).get(x, z))
|
||||||
.convertAware2D(this::implode).cache2D(engine, cacheSize);
|
.convertAware2D(this::implode).cache2D("baseBiomeStream", engine, cacheSize);
|
||||||
heightStream = ProceduralStream.of((x, z) -> {
|
heightStream = ProceduralStream.of((x, z) -> {
|
||||||
IrisBiome b = focus != null ? focus : baseBiomeStream.get(x, z);
|
IrisBiome b = focus != null ? focus : baseBiomeStream.get(x, z);
|
||||||
return getHeight(engine, b, x, z, engine.getSeedManager().getHeight());
|
return getHeight(engine, b, x, z, engine.getSeedManager().getHeight());
|
||||||
}, Interpolated.DOUBLE).clamp(0, engine.getHeight()).cache2D(engine, cacheSize, true);
|
}, Interpolated.DOUBLE).clamp(0, engine.getHeight()).cache2D("heightStream", engine, cacheSize);
|
||||||
roundedHeighteightStream = heightStream.round();
|
roundedHeighteightStream = heightStream.round();
|
||||||
slopeStream = heightStream.slope(3).cache2D(engine, cacheSize);
|
slopeStream = heightStream.slope(3).cache2D("slopeStream", engine, cacheSize);
|
||||||
trueBiomeStream = focus != null ? ProceduralStream.of((x, y) -> focus, Interpolated.of(a -> 0D,
|
trueBiomeStream = focus != null ? ProceduralStream.of((x, y) -> focus, Interpolated.of(a -> 0D,
|
||||||
b -> focus))
|
b -> focus))
|
||||||
.cache2D(engine, cacheSize) : heightStream
|
.cache2D("trueBiomeStream-focus", engine, cacheSize) : heightStream
|
||||||
.convertAware2D((h, x, z) ->
|
.convertAware2D((h, x, z) ->
|
||||||
fixBiomeType(h, baseBiomeStream.get(x, z),
|
fixBiomeType(h, baseBiomeStream.get(x, z),
|
||||||
regionStream.get(x, z), x, z, fluidHeight))
|
regionStream.get(x, z), x, z, fluidHeight))
|
||||||
.cache2D(engine, cacheSize);
|
.cache2D("trueBiomeStream", engine, cacheSize);
|
||||||
trueBiomeStream = focus != null ? ProceduralStream.of((x, y) -> focus, Interpolated.of(a -> 0D,
|
trueBiomeDerivativeStream = trueBiomeStream.convert(IrisBiome::getDerivative).cache2D("trueBiomeDerivativeStream", engine, cacheSize);
|
||||||
b -> focus))
|
heightFluidStream = heightStream.max(fluidHeight).cache2D("heightFluidStream", engine, cacheSize);
|
||||||
.cache2D(engine, cacheSize) : heightStream
|
|
||||||
.convertAware2D((h, x, z) ->
|
|
||||||
fixBiomeType(h, baseBiomeStream.get(x, z),
|
|
||||||
regionStream.get(x, z), x, z, fluidHeight))
|
|
||||||
.cache2D(engine, cacheSize);
|
|
||||||
trueBiomeDerivativeStream = trueBiomeStream.convert(IrisBiome::getDerivative).cache2D(engine, cacheSize);
|
|
||||||
heightFluidStream = heightStream.max(fluidHeight).cache2D(engine, cacheSize, true);
|
|
||||||
maxHeightStream = ProceduralStream.ofDouble((x, z) -> height);
|
maxHeightStream = ProceduralStream.ofDouble((x, z) -> height);
|
||||||
terrainSurfaceDecoration = trueBiomeStream
|
terrainSurfaceDecoration = trueBiomeStream
|
||||||
.convertAware2D((b, xx, zz) -> decorateFor(b, xx, zz, IrisDecorationPart.NONE)).cache2D(engine, cacheSize);
|
.convertAware2D((b, xx, zz) -> decorateFor(b, xx, zz, IrisDecorationPart.NONE)).cache2D("terrainSurfaceDecoration", engine, cacheSize);
|
||||||
terrainCeilingDecoration = trueBiomeStream
|
terrainCeilingDecoration = trueBiomeStream
|
||||||
.convertAware2D((b, xx, zz) -> decorateFor(b, xx, zz, IrisDecorationPart.CEILING)).cache2D(engine, cacheSize);
|
.convertAware2D((b, xx, zz) -> decorateFor(b, xx, zz, IrisDecorationPart.CEILING)).cache2D("terrainCeilingDecoration", engine, cacheSize);
|
||||||
terrainCaveSurfaceDecoration = caveBiomeStream
|
terrainCaveSurfaceDecoration = caveBiomeStream
|
||||||
.convertAware2D((b, xx, zz) -> decorateFor(b, xx, zz, IrisDecorationPart.NONE)).cache2D(engine, cacheSize);
|
.convertAware2D((b, xx, zz) -> decorateFor(b, xx, zz, IrisDecorationPart.NONE)).cache2D("terrainCaveSurfaceDecoration", engine, cacheSize);
|
||||||
terrainCaveCeilingDecoration = caveBiomeStream
|
terrainCaveCeilingDecoration = caveBiomeStream
|
||||||
.convertAware2D((b, xx, zz) -> decorateFor(b, xx, zz, IrisDecorationPart.CEILING)).cache2D(engine, cacheSize);
|
.convertAware2D((b, xx, zz) -> decorateFor(b, xx, zz, IrisDecorationPart.CEILING)).cache2D("terrainCaveCeilingDecoration", engine, cacheSize);
|
||||||
shoreSurfaceDecoration = trueBiomeStream
|
shoreSurfaceDecoration = trueBiomeStream
|
||||||
.convertAware2D((b, xx, zz) -> decorateFor(b, xx, zz, IrisDecorationPart.SHORE_LINE)).cache2D(engine, cacheSize);
|
.convertAware2D((b, xx, zz) -> decorateFor(b, xx, zz, IrisDecorationPart.SHORE_LINE)).cache2D("shoreSurfaceDecoration", engine, cacheSize);
|
||||||
seaSurfaceDecoration = trueBiomeStream
|
seaSurfaceDecoration = trueBiomeStream
|
||||||
.convertAware2D((b, xx, zz) -> decorateFor(b, xx, zz, IrisDecorationPart.SEA_SURFACE)).cache2D(engine, cacheSize);
|
.convertAware2D((b, xx, zz) -> decorateFor(b, xx, zz, IrisDecorationPart.SEA_SURFACE)).cache2D("seaSurfaceDecoration", engine, cacheSize);
|
||||||
seaFloorDecoration = trueBiomeStream
|
seaFloorDecoration = trueBiomeStream
|
||||||
.convertAware2D((b, xx, zz) -> decorateFor(b, xx, zz, IrisDecorationPart.SEA_FLOOR)).cache2D(engine, cacheSize);
|
.convertAware2D((b, xx, zz) -> decorateFor(b, xx, zz, IrisDecorationPart.SEA_FLOOR)).cache2D("seaFloorDecoration", engine, cacheSize);
|
||||||
baseBiomeIDStream = trueBiomeStream.convertAware2D((b, x, z) -> {
|
baseBiomeIDStream = trueBiomeStream.convertAware2D((b, x, z) -> {
|
||||||
UUID d = regionIDStream.get(x, z);
|
UUID d = regionIDStream.get(x, z);
|
||||||
return new UUID(b.getLoadKey().hashCode() * 818223L,
|
return new UUID(b.getLoadKey().hashCode() * 818223L,
|
||||||
d.hashCode());
|
d.hashCode());
|
||||||
})
|
})
|
||||||
.cache2D(engine, cacheSize);
|
.cache2D("", engine, cacheSize);
|
||||||
//@done
|
//@done
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -21,30 +21,20 @@ package com.volmit.iris.engine;
|
|||||||
import com.google.common.util.concurrent.AtomicDouble;
|
import com.google.common.util.concurrent.AtomicDouble;
|
||||||
import com.google.gson.Gson;
|
import com.google.gson.Gson;
|
||||||
import com.volmit.iris.Iris;
|
import com.volmit.iris.Iris;
|
||||||
import com.volmit.iris.core.IrisSettings;
|
|
||||||
import com.volmit.iris.core.events.IrisEngineHotloadEvent;
|
import com.volmit.iris.core.events.IrisEngineHotloadEvent;
|
||||||
import com.volmit.iris.core.gui.PregeneratorJob;
|
import com.volmit.iris.core.gui.PregeneratorJob;
|
||||||
import com.volmit.iris.core.project.IrisProject;
|
import com.volmit.iris.core.project.IrisProject;
|
||||||
import com.volmit.iris.core.service.PreservationSVC;
|
import com.volmit.iris.core.service.PreservationSVC;
|
||||||
import com.volmit.iris.engine.actuator.IrisBiomeActuator;
|
|
||||||
import com.volmit.iris.engine.actuator.IrisDecorantActuator;
|
|
||||||
import com.volmit.iris.engine.actuator.IrisTerrainNormalActuator;
|
|
||||||
import com.volmit.iris.engine.data.cache.AtomicCache;
|
import com.volmit.iris.engine.data.cache.AtomicCache;
|
||||||
import com.volmit.iris.engine.framework.Engine;
|
import com.volmit.iris.engine.framework.Engine;
|
||||||
import com.volmit.iris.engine.framework.EngineEffects;
|
import com.volmit.iris.engine.framework.EngineEffects;
|
||||||
import com.volmit.iris.engine.framework.EngineMetrics;
|
import com.volmit.iris.engine.framework.EngineMetrics;
|
||||||
import com.volmit.iris.engine.framework.EngineMode;
|
import com.volmit.iris.engine.framework.EngineMode;
|
||||||
import com.volmit.iris.engine.framework.EngineStage;
|
|
||||||
import com.volmit.iris.engine.framework.EngineTarget;
|
import com.volmit.iris.engine.framework.EngineTarget;
|
||||||
import com.volmit.iris.engine.framework.EngineWorldManager;
|
import com.volmit.iris.engine.framework.EngineWorldManager;
|
||||||
import com.volmit.iris.engine.framework.SeedManager;
|
import com.volmit.iris.engine.framework.SeedManager;
|
||||||
import com.volmit.iris.engine.framework.WrongEngineBroException;
|
import com.volmit.iris.engine.framework.WrongEngineBroException;
|
||||||
import com.volmit.iris.engine.mantle.EngineMantle;
|
import com.volmit.iris.engine.mantle.EngineMantle;
|
||||||
import com.volmit.iris.engine.mode.ModeOverworld;
|
|
||||||
import com.volmit.iris.engine.modifier.IrisCarveModifier;
|
|
||||||
import com.volmit.iris.engine.modifier.IrisDepositModifier;
|
|
||||||
import com.volmit.iris.engine.modifier.IrisPerfectionModifier;
|
|
||||||
import com.volmit.iris.engine.modifier.IrisPostModifier;
|
|
||||||
import com.volmit.iris.engine.object.IrisBiome;
|
import com.volmit.iris.engine.object.IrisBiome;
|
||||||
import com.volmit.iris.engine.object.IrisBiomePaletteLayer;
|
import com.volmit.iris.engine.object.IrisBiomePaletteLayer;
|
||||||
import com.volmit.iris.engine.object.IrisDecorator;
|
import com.volmit.iris.engine.object.IrisDecorator;
|
||||||
@ -53,10 +43,8 @@ import com.volmit.iris.engine.object.IrisJigsawStructure;
|
|||||||
import com.volmit.iris.engine.object.IrisObjectPlacement;
|
import com.volmit.iris.engine.object.IrisObjectPlacement;
|
||||||
import com.volmit.iris.engine.scripting.EngineExecutionEnvironment;
|
import com.volmit.iris.engine.scripting.EngineExecutionEnvironment;
|
||||||
import com.volmit.iris.util.atomics.AtomicRollingSequence;
|
import com.volmit.iris.util.atomics.AtomicRollingSequence;
|
||||||
import com.volmit.iris.util.collection.KList;
|
|
||||||
import com.volmit.iris.util.collection.KMap;
|
import com.volmit.iris.util.collection.KMap;
|
||||||
import com.volmit.iris.util.context.IrisContext;
|
import com.volmit.iris.util.context.IrisContext;
|
||||||
import com.volmit.iris.util.data.B;
|
|
||||||
import com.volmit.iris.util.documentation.BlockCoordinates;
|
import com.volmit.iris.util.documentation.BlockCoordinates;
|
||||||
import com.volmit.iris.util.format.C;
|
import com.volmit.iris.util.format.C;
|
||||||
import com.volmit.iris.util.format.Form;
|
import com.volmit.iris.util.format.Form;
|
||||||
@ -65,8 +53,6 @@ import com.volmit.iris.util.io.IO;
|
|||||||
import com.volmit.iris.util.mantle.MantleFlag;
|
import com.volmit.iris.util.mantle.MantleFlag;
|
||||||
import com.volmit.iris.util.math.M;
|
import com.volmit.iris.util.math.M;
|
||||||
import com.volmit.iris.util.math.RNG;
|
import com.volmit.iris.util.math.RNG;
|
||||||
import com.volmit.iris.util.matter.MatterCavern;
|
|
||||||
import com.volmit.iris.util.matter.MatterFluidBody;
|
|
||||||
import com.volmit.iris.util.scheduling.ChronoLatch;
|
import com.volmit.iris.util.scheduling.ChronoLatch;
|
||||||
import com.volmit.iris.util.scheduling.J;
|
import com.volmit.iris.util.scheduling.J;
|
||||||
import com.volmit.iris.util.scheduling.PrecisionStopwatch;
|
import com.volmit.iris.util.scheduling.PrecisionStopwatch;
|
||||||
@ -196,8 +182,7 @@ public class IrisEngine implements Engine {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void setupMode() {
|
private void setupMode() {
|
||||||
if(mode != null)
|
if (mode != null) {
|
||||||
{
|
|
||||||
mode.close();
|
mode.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -462,18 +447,7 @@ public class IrisEngine implements Engine {
|
|||||||
mode.generate(x, z, blocks, vbiomes, multicore);
|
mode.generate(x, z, blocks, vbiomes, multicore);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!multicore)
|
getMantle().getMantle().flag(x >> 4, z >> 4, MantleFlag.REAL, true);
|
||||||
{
|
|
||||||
for(int i = 0; i < 16; i++)
|
|
||||||
{
|
|
||||||
for(int j = 0; j < 16; j++)
|
|
||||||
{
|
|
||||||
blocks.set(i, 255, j, B.get("GLASS"));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
getMantle().getMantle().flag(x>>4, z>>4, MantleFlag.REAL, true);
|
|
||||||
getMetrics().getTotal().put(p.getMilliseconds());
|
getMetrics().getTotal().put(p.getMilliseconds());
|
||||||
generated.incrementAndGet();
|
generated.incrementAndGet();
|
||||||
recycle();
|
recycle();
|
||||||
|
@ -21,7 +21,6 @@ package com.volmit.iris.engine;
|
|||||||
import com.volmit.iris.Iris;
|
import com.volmit.iris.Iris;
|
||||||
import com.volmit.iris.core.IrisSettings;
|
import com.volmit.iris.core.IrisSettings;
|
||||||
import com.volmit.iris.engine.data.cache.Cache;
|
import com.volmit.iris.engine.data.cache.Cache;
|
||||||
import com.volmit.iris.engine.data.cache.Multicache;
|
|
||||||
import com.volmit.iris.engine.framework.Engine;
|
import com.volmit.iris.engine.framework.Engine;
|
||||||
import com.volmit.iris.engine.framework.EngineAssignedWorldManager;
|
import com.volmit.iris.engine.framework.EngineAssignedWorldManager;
|
||||||
import com.volmit.iris.engine.object.IRare;
|
import com.volmit.iris.engine.object.IRare;
|
||||||
@ -43,8 +42,6 @@ import com.volmit.iris.util.mantle.Mantle;
|
|||||||
import com.volmit.iris.util.mantle.MantleFlag;
|
import com.volmit.iris.util.mantle.MantleFlag;
|
||||||
import com.volmit.iris.util.math.M;
|
import com.volmit.iris.util.math.M;
|
||||||
import com.volmit.iris.util.math.RNG;
|
import com.volmit.iris.util.math.RNG;
|
||||||
import com.volmit.iris.util.matter.MatterCavern;
|
|
||||||
import com.volmit.iris.util.matter.MatterFluidBody;
|
|
||||||
import com.volmit.iris.util.matter.MatterMarker;
|
import com.volmit.iris.util.matter.MatterMarker;
|
||||||
import com.volmit.iris.util.parallel.MultiBurst;
|
import com.volmit.iris.util.parallel.MultiBurst;
|
||||||
import com.volmit.iris.util.plugin.Chunks;
|
import com.volmit.iris.util.plugin.Chunks;
|
||||||
@ -56,10 +53,8 @@ import com.volmit.iris.util.scheduling.jobs.QueueJob;
|
|||||||
import io.papermc.lib.PaperLib;
|
import io.papermc.lib.PaperLib;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.EqualsAndHashCode;
|
import lombok.EqualsAndHashCode;
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.Chunk;
|
import org.bukkit.Chunk;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.block.data.BlockData;
|
|
||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
import org.bukkit.entity.LivingEntity;
|
import org.bukkit.entity.LivingEntity;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
@ -68,7 +63,6 @@ import org.bukkit.event.block.BlockPlaceEvent;
|
|||||||
import org.bukkit.event.player.PlayerTeleportEvent;
|
import org.bukkit.event.player.PlayerTeleportEvent;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
import java.net.MalformedURLException;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
@ -76,7 +70,6 @@ import java.util.concurrent.CompletableFuture;
|
|||||||
import java.util.concurrent.ExecutionException;
|
import java.util.concurrent.ExecutionException;
|
||||||
import java.util.concurrent.Future;
|
import java.util.concurrent.Future;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
import java.util.concurrent.TimeoutException;
|
|
||||||
import java.util.concurrent.atomic.AtomicBoolean;
|
import java.util.concurrent.atomic.AtomicBoolean;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
@ -133,6 +126,10 @@ public class IrisWorldManager extends EngineAssignedWorldManager {
|
|||||||
getEngine().getWorld().tryGetRealWorld();
|
getEngine().getWorld().tryGetRealWorld();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!IrisSettings.get().getWorld().isMarkerEntitySpawningSystem() && !IrisSettings.get().getWorld().isAnbientEntitySpawningSystem()) {
|
||||||
|
return 3000;
|
||||||
|
}
|
||||||
|
|
||||||
if (getEngine().getWorld().hasRealWorld()) {
|
if (getEngine().getWorld().hasRealWorld()) {
|
||||||
if (getEngine().getWorld().getPlayers().isEmpty()) {
|
if (getEngine().getWorld().getPlayers().isEmpty()) {
|
||||||
return 5000;
|
return 5000;
|
||||||
@ -179,7 +176,7 @@ public class IrisWorldManager extends EngineAssignedWorldManager {
|
|||||||
onAsyncTick();
|
onAsyncTick();
|
||||||
}
|
}
|
||||||
|
|
||||||
return 700;
|
return IrisSettings.get().getWorld().getAsyncTickIntervalMS();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
looper.setPriority(Thread.MIN_PRIORITY);
|
looper.setPriority(Thread.MIN_PRIORITY);
|
||||||
@ -195,7 +192,12 @@ public class IrisWorldManager extends EngineAssignedWorldManager {
|
|||||||
for (int x = -r; x <= r; x++) {
|
for (int x = -r; x <= r; x++) {
|
||||||
for (int z = -r; z <= r; z++) {
|
for (int z = -r; z <= r; z++) {
|
||||||
if (c.getWorld().isChunkLoaded(c.getX() + x, c.getZ() + z) && Chunks.isSafe(getEngine().getWorld().realWorld(), c.getX() + x, c.getZ() + z)) {
|
if (c.getWorld().isChunkLoaded(c.getX() + x, c.getZ() + z) && Chunks.isSafe(getEngine().getWorld().realWorld(), c.getX() + x, c.getZ() + z)) {
|
||||||
|
|
||||||
|
if (IrisSettings.get().getWorld().isPostLoadBlockUpdates()) {
|
||||||
getEngine().updateChunk(c.getWorld().getChunkAt(c.getX() + x, c.getZ() + z));
|
getEngine().updateChunk(c.getWorld().getChunkAt(c.getX() + x, c.getZ() + z));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (IrisSettings.get().getWorld().isMarkerEntitySpawningSystem()) {
|
||||||
Chunk cx = getEngine().getWorld().realWorld().getChunkAt(c.getX() + x, c.getZ() + z);
|
Chunk cx = getEngine().getWorld().realWorld().getChunkAt(c.getX() + x, c.getZ() + z);
|
||||||
int finalX = c.getX() + x;
|
int finalX = c.getX() + x;
|
||||||
int finalZ = c.getZ() + z;
|
int finalZ = c.getZ() + z;
|
||||||
@ -216,6 +218,7 @@ public class IrisWorldManager extends EngineAssignedWorldManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private boolean onAsyncTick() {
|
private boolean onAsyncTick() {
|
||||||
if (getEngine().isClosed()) {
|
if (getEngine().isClosed()) {
|
||||||
@ -231,12 +234,12 @@ public class IrisWorldManager extends EngineAssignedWorldManager {
|
|||||||
|
|
||||||
if (!getEngine().getWorld().hasRealWorld()) {
|
if (!getEngine().getWorld().hasRealWorld()) {
|
||||||
Iris.debug("Can't spawn. No real world");
|
Iris.debug("Can't spawn. No real world");
|
||||||
J.sleep(10000);
|
J.sleep(5000);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
double epx = getEntitySaturation();
|
double epx = getEntitySaturation();
|
||||||
if (epx > 1) {
|
if (epx > IrisSettings.get().getWorld().getTargetSpawnEntitiesPerChunk()) {
|
||||||
Iris.debug("Can't spawn. The entity per chunk ratio is at " + Form.pc(epx, 2) + " > 100% (total entities " + entityCount + ")");
|
Iris.debug("Can't spawn. The entity per chunk ratio is at " + Form.pc(epx, 2) + " > 100% (total entities " + entityCount + ")");
|
||||||
J.sleep(5000);
|
J.sleep(5000);
|
||||||
return false;
|
return false;
|
||||||
@ -286,8 +289,7 @@ public class IrisWorldManager extends EngineAssignedWorldManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void spawnIn(Chunk c, boolean initial) {
|
private void spawnIn(Chunk c, boolean initial) {
|
||||||
if(getEngine().isClosed())
|
if (getEngine().isClosed()) {
|
||||||
{
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -295,10 +297,11 @@ public class IrisWorldManager extends EngineAssignedWorldManager {
|
|||||||
energy += 1.2;
|
energy += 1.2;
|
||||||
}
|
}
|
||||||
|
|
||||||
IrisBiome biome = getEngine().getSurfaceBiome(c);
|
|
||||||
IrisRegion region = getEngine().getRegion(c);
|
|
||||||
//@builder
|
//@builder
|
||||||
IrisEntitySpawn v = spawnRandomly(Stream.concat(getData().getSpawnerLoader()
|
IrisBiome biome = IrisSettings.get().getWorld().isAnbientEntitySpawningSystem()
|
||||||
|
? getEngine().getSurfaceBiome(c) : null;
|
||||||
|
IrisEntitySpawn v = IrisSettings.get().getWorld().isAnbientEntitySpawningSystem()
|
||||||
|
? spawnRandomly(Stream.concat(getData().getSpawnerLoader()
|
||||||
.loadAll(getDimension().getEntitySpawners())
|
.loadAll(getDimension().getEntitySpawners())
|
||||||
.shuffleCopy(RNG.r).stream()
|
.shuffleCopy(RNG.r).stream()
|
||||||
.filter(this::canSpawn)
|
.filter(this::canSpawn)
|
||||||
@ -313,8 +316,10 @@ public class IrisWorldManager extends EngineAssignedWorldManager {
|
|||||||
.shuffleCopy(RNG.r).stream().filter(this::canSpawn)
|
.shuffleCopy(RNG.r).stream().filter(this::canSpawn)
|
||||||
.flatMap((i) -> stream(i, initial))))
|
.flatMap((i) -> stream(i, initial))))
|
||||||
.collect(Collectors.toList()))
|
.collect(Collectors.toList()))
|
||||||
.popRandom(RNG.r);
|
.popRandom(RNG.r) : null;
|
||||||
|
//@done
|
||||||
|
|
||||||
|
if (IrisSettings.get().getWorld().isMarkerEntitySpawningSystem()) {
|
||||||
getSpawnersFromMarkers(c).forEach((block, spawners) -> {
|
getSpawnersFromMarkers(c).forEach((block, spawners) -> {
|
||||||
if (spawners.isEmpty()) {
|
if (spawners.isEmpty()) {
|
||||||
return;
|
return;
|
||||||
@ -325,6 +330,7 @@ public class IrisWorldManager extends EngineAssignedWorldManager {
|
|||||||
J.a(() -> getMantle().raiseFlag(c.getX(), c.getZ(), MantleFlag.INITIAL_SPAWNED_MARKER,
|
J.a(() -> getMantle().raiseFlag(c.getX(), c.getZ(), MantleFlag.INITIAL_SPAWNED_MARKER,
|
||||||
() -> spawn(block, s, true)));
|
() -> spawn(block, s, true)));
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
|
||||||
if (v != null && v.getReferenceSpawner() != null) {
|
if (v != null && v.getReferenceSpawner() != null) {
|
||||||
int maxEntCount = v.getReferenceSpawner().getMaxEntitiesPerChunk();
|
int maxEntCount = v.getReferenceSpawner().getMaxEntitiesPerChunk();
|
||||||
@ -343,7 +349,6 @@ public class IrisWorldManager extends EngineAssignedWorldManager {
|
|||||||
J.s(() -> spawn(c, v));
|
J.s(() -> spawn(c, v));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//@done
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void spawn(Chunk c, IrisEntitySpawn i) {
|
private void spawn(Chunk c, IrisEntitySpawn i) {
|
||||||
@ -479,8 +484,7 @@ public class IrisWorldManager extends EngineAssignedWorldManager {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onChunkLoad(Chunk e, boolean generated) {
|
public void onChunkLoad(Chunk e, boolean generated) {
|
||||||
if(getEngine().isClosed())
|
if (getEngine().isClosed()) {
|
||||||
{
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -490,8 +494,7 @@ public class IrisWorldManager extends EngineAssignedWorldManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void spawn(IrisPosition block, IrisSpawner spawner, boolean initial) {
|
private void spawn(IrisPosition block, IrisSpawner spawner, boolean initial) {
|
||||||
if(getEngine().isClosed())
|
if (getEngine().isClosed()) {
|
||||||
{
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -521,33 +524,35 @@ public class IrisWorldManager extends EngineAssignedWorldManager {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void teleportAsync(PlayerTeleportEvent e) {
|
public void teleportAsync(PlayerTeleportEvent e) {
|
||||||
|
if (IrisSettings.get().getWorld().getAsyncTeleport().isEnabled()) {
|
||||||
e.setCancelled(true);
|
e.setCancelled(true);
|
||||||
warmupAreaAsync(e.getPlayer(), e.getTo(), ()
|
warmupAreaAsync(e.getPlayer(), e.getTo(), () -> J.s(() -> {
|
||||||
-> J.s(() -> {
|
|
||||||
ignoreTP.set(true);
|
ignoreTP.set(true);
|
||||||
e.getPlayer().teleport(e.getTo(), e.getCause());
|
e.getPlayer().teleport(e.getTo(), e.getCause());
|
||||||
ignoreTP.set(false);
|
ignoreTP.set(false);
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void warmupAreaAsync(Player player, Location to, Runnable r) {
|
private void warmupAreaAsync(Player player, Location to, Runnable r) {
|
||||||
J.a(() -> {
|
J.a(() -> {
|
||||||
int viewDistance = 3;
|
int viewDistance = IrisSettings.get().getWorld().getAsyncTeleport().getLoadViewDistance();
|
||||||
KList<Future<Chunk>> futures = new KList<>();
|
KList<Future<Chunk>> futures = new KList<>();
|
||||||
for(int i = -viewDistance; i <= viewDistance; i++)
|
for (int i = -viewDistance; i <= viewDistance; i++) {
|
||||||
{
|
for (int j = -viewDistance; j <= viewDistance; j++) {
|
||||||
for(int j = -viewDistance; j <= viewDistance; j++)
|
|
||||||
{
|
|
||||||
int finalJ = j;
|
int finalJ = j;
|
||||||
int finalI = i;
|
int finalI = i;
|
||||||
|
|
||||||
if(to.getWorld().isChunkLoaded((to.getBlockX() >> 4) + i, (to.getBlockZ() >> 4) + j))
|
if (to.getWorld().isChunkLoaded((to.getBlockX() >> 4) + i, (to.getBlockZ() >> 4) + j)) {
|
||||||
{
|
|
||||||
futures.add(CompletableFuture.completedFuture(null));
|
futures.add(CompletableFuture.completedFuture(null));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
futures.add(MultiBurst.burst.completeValue(() -> PaperLib.getChunkAtAsync(to.getWorld(), (to.getBlockX() >> 4) + finalI, (to.getBlockZ() >> 4) + finalJ, true).get()));
|
futures.add(MultiBurst.burst.completeValue(()
|
||||||
|
-> PaperLib.getChunkAtAsync(to.getWorld(),
|
||||||
|
(to.getBlockX() >> 4) + finalI,
|
||||||
|
(to.getBlockZ() >> 4) + finalJ,
|
||||||
|
true, IrisSettings.get().getWorld().getAsyncTeleport().isUrgent()).get()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -25,7 +25,6 @@ import com.volmit.iris.core.gui.components.Renderer;
|
|||||||
import com.volmit.iris.core.loader.IrisData;
|
import com.volmit.iris.core.loader.IrisData;
|
||||||
import com.volmit.iris.core.loader.IrisRegistrant;
|
import com.volmit.iris.core.loader.IrisRegistrant;
|
||||||
import com.volmit.iris.engine.IrisComplex;
|
import com.volmit.iris.engine.IrisComplex;
|
||||||
import com.volmit.iris.engine.IrisWorldManager;
|
|
||||||
import com.volmit.iris.engine.data.cache.Cache;
|
import com.volmit.iris.engine.data.cache.Cache;
|
||||||
import com.volmit.iris.engine.data.chunk.TerrainChunk;
|
import com.volmit.iris.engine.data.chunk.TerrainChunk;
|
||||||
import com.volmit.iris.engine.mantle.EngineMantle;
|
import com.volmit.iris.engine.mantle.EngineMantle;
|
||||||
@ -61,7 +60,6 @@ import com.volmit.iris.util.math.M;
|
|||||||
import com.volmit.iris.util.math.Position2;
|
import com.volmit.iris.util.math.Position2;
|
||||||
import com.volmit.iris.util.math.RNG;
|
import com.volmit.iris.util.math.RNG;
|
||||||
import com.volmit.iris.util.matter.MatterCavern;
|
import com.volmit.iris.util.matter.MatterCavern;
|
||||||
import com.volmit.iris.util.matter.MatterFluidBody;
|
|
||||||
import com.volmit.iris.util.matter.MatterUpdate;
|
import com.volmit.iris.util.matter.MatterUpdate;
|
||||||
import com.volmit.iris.util.parallel.BurstExecutor;
|
import com.volmit.iris.util.parallel.BurstExecutor;
|
||||||
import com.volmit.iris.util.parallel.MultiBurst;
|
import com.volmit.iris.util.parallel.MultiBurst;
|
||||||
@ -74,13 +72,11 @@ import org.bukkit.Bukkit;
|
|||||||
import org.bukkit.Chunk;
|
import org.bukkit.Chunk;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.Sound;
|
|
||||||
import org.bukkit.block.Biome;
|
import org.bukkit.block.Biome;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.block.BlockFace;
|
import org.bukkit.block.BlockFace;
|
||||||
import org.bukkit.block.data.BlockData;
|
import org.bukkit.block.data.BlockData;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.EnderSignal;
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.generator.ChunkGenerator;
|
import org.bukkit.generator.ChunkGenerator;
|
||||||
import org.bukkit.inventory.Inventory;
|
import org.bukkit.inventory.Inventory;
|
||||||
@ -794,12 +790,10 @@ public interface Engine extends DataProvider, Fallible, LootProvider, BlockUpdat
|
|||||||
}
|
}
|
||||||
|
|
||||||
default void gotoJigsaw(IrisJigsawStructure s, Player player) {
|
default void gotoJigsaw(IrisJigsawStructure s, Player player) {
|
||||||
if(s.getLoadKey().equals(getDimension().getStronghold()))
|
if (s.getLoadKey().equals(getDimension().getStronghold())) {
|
||||||
{
|
|
||||||
KList<Position2> p = getDimension().getStrongholds(getSeedManager().getSpawn());
|
KList<Position2> p = getDimension().getStrongholds(getSeedManager().getSpawn());
|
||||||
|
|
||||||
if(p.isEmpty())
|
if (p.isEmpty()) {
|
||||||
{
|
|
||||||
player.sendMessage(C.GOLD + "No strongholds in world.");
|
player.sendMessage(C.GOLD + "No strongholds in world.");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -905,10 +899,8 @@ public interface Engine extends DataProvider, Fallible, LootProvider, BlockUpdat
|
|||||||
Locator.region(r.getLoadKey()).find(player);
|
Locator.region(r.getLoadKey()).find(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
default void cleanupMantleChunk(int x, int z)
|
default void cleanupMantleChunk(int x, int z) {
|
||||||
{
|
if (IrisSettings.get().getPerformance().isTrimMantleInStudio() || !isStudio()) {
|
||||||
if(IrisSettings.get().getPerformance().isTrimMantleInStudio() || !isStudio())
|
|
||||||
{
|
|
||||||
J.a(() -> getMantle().cleanupChunk(x, z));
|
J.a(() -> getMantle().cleanupChunk(x, z));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -71,26 +71,19 @@ public abstract class EngineAssignedWorldManager extends EngineAssignedComponent
|
|||||||
|
|
||||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||||
public void on(PlayerTeleportEvent e) {
|
public void on(PlayerTeleportEvent e) {
|
||||||
if(ignoreTP.get())
|
if (ignoreTP.get()) {
|
||||||
{
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!PaperLib.isPaper() || e.getTo() == null)
|
if (!PaperLib.isPaper() || e.getTo() == null) {
|
||||||
{
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
try
|
try {
|
||||||
{
|
if (e.getTo().getWorld().equals(getTarget().getWorld().realWorld())) {
|
||||||
if(e.getTo().getWorld().equals(getTarget().getWorld().realWorld()))
|
|
||||||
{
|
|
||||||
getEngine().getWorldManager().teleportAsync(e);
|
getEngine().getWorldManager().teleportAsync(e);
|
||||||
}
|
}
|
||||||
}
|
} catch (Throwable ex) {
|
||||||
|
|
||||||
catch(Throwable ex)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -32,19 +32,16 @@ public interface EngineMode extends Staged {
|
|||||||
|
|
||||||
Engine getEngine();
|
Engine getEngine();
|
||||||
|
|
||||||
default MultiBurst burst()
|
default MultiBurst burst() {
|
||||||
{
|
|
||||||
return getEngine().burst();
|
return getEngine().burst();
|
||||||
}
|
}
|
||||||
|
|
||||||
default EngineStage burst(EngineStage... stages)
|
default EngineStage burst(EngineStage... stages) {
|
||||||
{
|
|
||||||
return (x, z, blocks, biomes, multicore) -> {
|
return (x, z, blocks, biomes, multicore) -> {
|
||||||
BurstExecutor e = burst().burst(stages.length);
|
BurstExecutor e = burst().burst(stages.length);
|
||||||
e.setMulticore(multicore);
|
e.setMulticore(multicore);
|
||||||
|
|
||||||
for(EngineStage i : stages)
|
for (EngineStage i : stages) {
|
||||||
{
|
|
||||||
e.queue(() -> i.generate(x, z, blocks, biomes, multicore));
|
e.queue(() -> i.generate(x, z, blocks, biomes, multicore));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -52,13 +49,11 @@ public interface EngineMode extends Staged {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
default IrisComplex getComplex()
|
default IrisComplex getComplex() {
|
||||||
{
|
|
||||||
return getEngine().getComplex();
|
return getEngine().getComplex();
|
||||||
}
|
}
|
||||||
|
|
||||||
default EngineMantle getMantle()
|
default EngineMantle getMantle() {
|
||||||
{
|
|
||||||
return getEngine().getMantle();
|
return getEngine().getMantle();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -67,8 +62,7 @@ public interface EngineMode extends Staged {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@BlockCoordinates
|
@BlockCoordinates
|
||||||
default void generate(int x, int z, Hunk<BlockData> blocks, Hunk<Biome> biomes, boolean multicore)
|
default void generate(int x, int z, Hunk<BlockData> blocks, Hunk<Biome> biomes, boolean multicore) {
|
||||||
{
|
|
||||||
for (EngineStage i : getStages()) {
|
for (EngineStage i : getStages()) {
|
||||||
i.generate(x, z, blocks, biomes, multicore);
|
i.generate(x, z, blocks, biomes, multicore);
|
||||||
}
|
}
|
||||||
|
@ -25,18 +25,15 @@ public abstract class IrisEngineMode implements EngineMode {
|
|||||||
private final KList<EngineStage> stages;
|
private final KList<EngineStage> stages;
|
||||||
private boolean closed;
|
private boolean closed;
|
||||||
|
|
||||||
public IrisEngineMode(Engine engine)
|
public IrisEngineMode(Engine engine) {
|
||||||
{
|
|
||||||
this.engine = engine;
|
this.engine = engine;
|
||||||
this.stages = new KList<>();
|
this.stages = new KList<>();
|
||||||
this.closed = false;
|
this.closed = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public synchronized void close()
|
public synchronized void close() {
|
||||||
{
|
if (closed) {
|
||||||
if(closed)
|
|
||||||
{
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -18,15 +18,17 @@
|
|||||||
|
|
||||||
package com.volmit.iris.engine.framework;
|
package com.volmit.iris.engine.framework;
|
||||||
|
|
||||||
public interface MeteredCache
|
import com.volmit.iris.util.data.KCache;
|
||||||
{
|
|
||||||
|
public interface MeteredCache {
|
||||||
long getSize();
|
long getSize();
|
||||||
|
|
||||||
|
KCache<?, ?> getRawCache();
|
||||||
|
|
||||||
long getMaxSize();
|
long getMaxSize();
|
||||||
|
|
||||||
default double getUsage()
|
default double getUsage() {
|
||||||
{
|
return (double) getSize() / (double) getMaxSize();
|
||||||
return (double)getSize() / (double)getMaxSize();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean isClosed();
|
boolean isClosed();
|
||||||
|
@ -25,8 +25,7 @@ public interface Staged {
|
|||||||
|
|
||||||
void registerStage(EngineStage stage);
|
void registerStage(EngineStage stage);
|
||||||
|
|
||||||
default void dump()
|
default void dump() {
|
||||||
{
|
|
||||||
getStages().forEach(EngineStage::close);
|
getStages().forEach(EngineStage::close);
|
||||||
getStages().clear();
|
getStages().clear();
|
||||||
}
|
}
|
||||||
|
@ -18,7 +18,6 @@
|
|||||||
|
|
||||||
package com.volmit.iris.engine.mantle;
|
package com.volmit.iris.engine.mantle;
|
||||||
|
|
||||||
import com.volmit.iris.Iris;
|
|
||||||
import com.volmit.iris.core.IrisSettings;
|
import com.volmit.iris.core.IrisSettings;
|
||||||
import com.volmit.iris.core.loader.IrisData;
|
import com.volmit.iris.core.loader.IrisData;
|
||||||
import com.volmit.iris.engine.IrisComplex;
|
import com.volmit.iris.engine.IrisComplex;
|
||||||
@ -46,12 +45,9 @@ import com.volmit.iris.util.matter.MatterMarker;
|
|||||||
import com.volmit.iris.util.matter.slices.UpdateMatter;
|
import com.volmit.iris.util.matter.slices.UpdateMatter;
|
||||||
import com.volmit.iris.util.parallel.BurstExecutor;
|
import com.volmit.iris.util.parallel.BurstExecutor;
|
||||||
import com.volmit.iris.util.parallel.MultiBurst;
|
import com.volmit.iris.util.parallel.MultiBurst;
|
||||||
import com.volmit.iris.util.scheduling.J;
|
|
||||||
import io.papermc.lib.PaperLib;
|
|
||||||
import org.bukkit.block.TileState;
|
import org.bukkit.block.TileState;
|
||||||
import org.bukkit.block.data.BlockData;
|
import org.bukkit.block.data.BlockData;
|
||||||
|
|
||||||
import java.util.concurrent.ExecutionException;
|
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
// TODO: MOVE PLACER OUT OF MATTER INTO ITS OWN THING
|
// TODO: MOVE PLACER OUT OF MATTER INTO ITS OWN THING
|
||||||
@ -185,7 +181,7 @@ public interface EngineMantle extends IObjectPlacer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
default void trim() {
|
default void trim() {
|
||||||
getMantle().trim(TimeUnit.SECONDS.toMillis(IrisSettings.get().getPerformance().getMantleKeepAliveSeconds()));
|
getMantle().trim(TimeUnit.SECONDS.toMillis(IrisSettings.get().getPerformance().getMantleKeepAlive()));
|
||||||
}
|
}
|
||||||
|
|
||||||
default MultiBurst burst() {
|
default MultiBurst burst() {
|
||||||
@ -269,16 +265,14 @@ public interface EngineMantle extends IObjectPlacer {
|
|||||||
|
|
||||||
MantleObjectComponent getObjectComponent();
|
MantleObjectComponent getObjectComponent();
|
||||||
|
|
||||||
default boolean isCovered(int x, int z)
|
default boolean isCovered(int x, int z) {
|
||||||
{
|
|
||||||
int s = getRealRadius();
|
int s = getRealRadius();
|
||||||
|
|
||||||
for (int i = -s; i <= s; i++) {
|
for (int i = -s; i <= s; i++) {
|
||||||
for (int j = -s; j <= s; j++) {
|
for (int j = -s; j <= s; j++) {
|
||||||
int xx = i + x;
|
int xx = i + x;
|
||||||
int zz = j + z;
|
int zz = j + z;
|
||||||
if(!getMantle().hasFlag(xx, zz, MantleFlag.REAL))
|
if (!getMantle().hasFlag(xx, zz, MantleFlag.REAL)) {
|
||||||
{
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -287,10 +281,8 @@ public interface EngineMantle extends IObjectPlacer {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
default void cleanupChunk(int x, int z)
|
default void cleanupChunk(int x, int z) {
|
||||||
{
|
if (!getMantle().hasFlag(x, z, MantleFlag.CLEANED) && isCovered(x, z)) {
|
||||||
if(!getMantle().hasFlag(x, z, MantleFlag.CLEANED) && isCovered(x, z))
|
|
||||||
{
|
|
||||||
getMantle().raiseFlag(x, z, MantleFlag.CLEANED, () -> {
|
getMantle().raiseFlag(x, z, MantleFlag.CLEANED, () -> {
|
||||||
getMantle().deleteChunkSlice(x, z, BlockData.class);
|
getMantle().deleteChunkSlice(x, z, BlockData.class);
|
||||||
getMantle().deleteChunkSlice(x, z, String.class);
|
getMantle().deleteChunkSlice(x, z, String.class);
|
||||||
|
@ -524,9 +524,17 @@ public class MantleWriter implements IObjectPlacer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public <T> void set(IrisPosition pos, T data) {
|
public <T> void set(IrisPosition pos, T data) {
|
||||||
|
try
|
||||||
|
{
|
||||||
setData(pos.getX(), pos.getY(), pos.getZ(), data);
|
setData(pos.getX(), pos.getY(), pos.getZ(), data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
catch(Throwable e)
|
||||||
|
{
|
||||||
|
Iris.error("No set? " + data.toString() + " for " + pos.toString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public <T> void set(List<IrisPosition> positions, T data) {
|
public <T> void set(List<IrisPosition> positions, T data) {
|
||||||
for (IrisPosition i : positions) {
|
for (IrisPosition i : positions) {
|
||||||
set(i, data);
|
set(i, data);
|
||||||
|
@ -25,8 +25,7 @@ import com.volmit.iris.engine.framework.EngineMode;
|
|||||||
import com.volmit.iris.engine.framework.IrisEngineMode;
|
import com.volmit.iris.engine.framework.IrisEngineMode;
|
||||||
|
|
||||||
public class ModeEnclosure extends IrisEngineMode implements EngineMode {
|
public class ModeEnclosure extends IrisEngineMode implements EngineMode {
|
||||||
public ModeEnclosure(Engine engine)
|
public ModeEnclosure(Engine engine) {
|
||||||
{
|
|
||||||
super(engine);
|
super(engine);
|
||||||
var terrain = new IrisTerrainNormalActuator(getEngine());
|
var terrain = new IrisTerrainNormalActuator(getEngine());
|
||||||
var biome = new IrisBiomeActuator(getEngine());
|
var biome = new IrisBiomeActuator(getEngine());
|
||||||
|
@ -25,8 +25,7 @@ import com.volmit.iris.engine.framework.EngineMode;
|
|||||||
import com.volmit.iris.engine.framework.IrisEngineMode;
|
import com.volmit.iris.engine.framework.IrisEngineMode;
|
||||||
|
|
||||||
public class ModeIslands extends IrisEngineMode implements EngineMode {
|
public class ModeIslands extends IrisEngineMode implements EngineMode {
|
||||||
public ModeIslands(Engine engine)
|
public ModeIslands(Engine engine) {
|
||||||
{
|
|
||||||
super(engine);
|
super(engine);
|
||||||
var terrain = new IrisTerrainNormalActuator(getEngine());
|
var terrain = new IrisTerrainNormalActuator(getEngine());
|
||||||
var biome = new IrisBiomeActuator(getEngine());
|
var biome = new IrisBiomeActuator(getEngine());
|
||||||
|
@ -31,8 +31,7 @@ import com.volmit.iris.engine.modifier.IrisPostModifier;
|
|||||||
import org.bukkit.block.data.BlockData;
|
import org.bukkit.block.data.BlockData;
|
||||||
|
|
||||||
public class ModeOverworld extends IrisEngineMode implements EngineMode {
|
public class ModeOverworld extends IrisEngineMode implements EngineMode {
|
||||||
public ModeOverworld(Engine engine)
|
public ModeOverworld(Engine engine) {
|
||||||
{
|
|
||||||
super(engine);
|
super(engine);
|
||||||
var terrain = new IrisTerrainNormalActuator(getEngine());
|
var terrain = new IrisTerrainNormalActuator(getEngine());
|
||||||
var biome = new IrisBiomeActuator(getEngine());
|
var biome = new IrisBiomeActuator(getEngine());
|
||||||
@ -49,11 +48,9 @@ public class ModeOverworld extends IrisEngineMode implements EngineMode {
|
|||||||
));
|
));
|
||||||
registerStage((x, z, k, p, m) -> cave.modify(x >> 4, z >> 4, k, m));
|
registerStage((x, z, k, p, m) -> cave.modify(x >> 4, z >> 4, k, m));
|
||||||
registerStage((x, z, k, p, m) -> deposit.modify(x, z, k, m));
|
registerStage((x, z, k, p, m) -> deposit.modify(x, z, k, m));
|
||||||
registerStage(burst(
|
registerStage((x, z, k, p, m) -> decorant.actuate(x, z, k, m));
|
||||||
(x, z, k, p, m) -> decorant.actuate(x, z, k, m),
|
registerStage((x, z, k, p, m) -> post.modify(x, z, k, m));
|
||||||
(x, z, k, p, m) -> post.modify(x, z, k, m),
|
registerStage((x, z, K, p, m) -> getMantle().insertMatter(x >> 4, z >> 4, BlockData.class, K, m));
|
||||||
(x, z, K, p, m) -> getMantle().insertMatter(x >> 4, z >> 4, BlockData.class, K, m)
|
|
||||||
));
|
|
||||||
registerStage((x, z, k, p, m) -> perfection.modify(x, z, k, m));
|
registerStage((x, z, k, p, m) -> perfection.modify(x, z, k, m));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -25,8 +25,7 @@ import com.volmit.iris.engine.framework.EngineMode;
|
|||||||
import com.volmit.iris.engine.framework.IrisEngineMode;
|
import com.volmit.iris.engine.framework.IrisEngineMode;
|
||||||
|
|
||||||
public class ModeSuperFlat extends IrisEngineMode implements EngineMode {
|
public class ModeSuperFlat extends IrisEngineMode implements EngineMode {
|
||||||
public ModeSuperFlat(Engine engine)
|
public ModeSuperFlat(Engine engine) {
|
||||||
{
|
|
||||||
super(engine);
|
super(engine);
|
||||||
var terrain = new IrisTerrainNormalActuator(getEngine());
|
var terrain = new IrisTerrainNormalActuator(getEngine());
|
||||||
var biome = new IrisBiomeActuator(getEngine());
|
var biome = new IrisBiomeActuator(getEngine());
|
||||||
|
@ -39,7 +39,6 @@ import com.volmit.iris.util.math.RNG;
|
|||||||
import com.volmit.iris.util.matter.MatterCavern;
|
import com.volmit.iris.util.matter.MatterCavern;
|
||||||
import com.volmit.iris.util.matter.slices.MarkerMatter;
|
import com.volmit.iris.util.matter.slices.MarkerMatter;
|
||||||
import com.volmit.iris.util.scheduling.PrecisionStopwatch;
|
import com.volmit.iris.util.scheduling.PrecisionStopwatch;
|
||||||
import com.volmit.iris.util.stream.utility.CachedStream2D;
|
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.block.data.BlockData;
|
import org.bukkit.block.data.BlockData;
|
||||||
@ -237,6 +236,7 @@ public class IrisCarveModifier extends EngineAssignedModifier<BlockData> {
|
|||||||
|
|
||||||
blocks = biome.generateCeilingLayers(getDimension(), xx, zz, rng, 3, zone.ceiling, getData(), getComplex());
|
blocks = biome.generateCeilingLayers(getDimension(), xx, zz, rng, 3, zone.ceiling, getData(), getComplex());
|
||||||
|
|
||||||
|
if (zone.ceiling + 1 < mantle.getWorldHeight()) {
|
||||||
for (int i = 0; i < zone.ceiling + 1; i++) {
|
for (int i = 0; i < zone.ceiling + 1; i++) {
|
||||||
if (!blocks.hasIndex(i)) {
|
if (!blocks.hasIndex(i)) {
|
||||||
break;
|
break;
|
||||||
@ -257,6 +257,7 @@ public class IrisCarveModifier extends EngineAssignedModifier<BlockData> {
|
|||||||
output.set(rx, zone.ceiling + i + 1, rz, b);
|
output.set(rx, zone.ceiling + i + 1, rz, b);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
public static class CaveZone {
|
public static class CaveZone {
|
||||||
|
@ -1,9 +1,26 @@
|
|||||||
|
/*
|
||||||
|
* Iris is a World Generator for Minecraft Bukkit Servers
|
||||||
|
* Copyright (c) 2021 Arcane Arts (Volmit Software)
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
package com.volmit.iris.engine.object;
|
package com.volmit.iris.engine.object;
|
||||||
|
|
||||||
import com.volmit.iris.Iris;
|
import com.volmit.iris.Iris;
|
||||||
import com.volmit.iris.engine.object.annotations.ArrayType;
|
import com.volmit.iris.engine.object.annotations.ArrayType;
|
||||||
import com.volmit.iris.engine.object.annotations.Desc;
|
import com.volmit.iris.engine.object.annotations.Desc;
|
||||||
import com.volmit.iris.engine.object.annotations.RegistryListResource;
|
|
||||||
import com.volmit.iris.engine.object.annotations.Snippet;
|
import com.volmit.iris.engine.object.annotations.Snippet;
|
||||||
import com.volmit.iris.util.collection.KList;
|
import com.volmit.iris.util.collection.KList;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
@ -1,6 +1,29 @@
|
|||||||
|
/*
|
||||||
|
* Iris is a World Generator for Minecraft Bukkit Servers
|
||||||
|
* Copyright (c) 2021 Arcane Arts (Volmit Software)
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
package com.volmit.iris.engine.object;
|
package com.volmit.iris.engine.object;
|
||||||
|
|
||||||
import com.volmit.iris.engine.object.annotations.*;
|
import com.volmit.iris.engine.object.annotations.ArrayType;
|
||||||
|
import com.volmit.iris.engine.object.annotations.DependsOn;
|
||||||
|
import com.volmit.iris.engine.object.annotations.Desc;
|
||||||
|
import com.volmit.iris.engine.object.annotations.MaxNumber;
|
||||||
|
import com.volmit.iris.engine.object.annotations.MinNumber;
|
||||||
|
import com.volmit.iris.engine.object.annotations.Snippet;
|
||||||
import com.volmit.iris.util.collection.KList;
|
import com.volmit.iris.util.collection.KList;
|
||||||
import com.volmit.iris.util.math.RNG;
|
import com.volmit.iris.util.math.RNG;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
@ -44,13 +44,11 @@ public enum IrisDimensionModeType {
|
|||||||
;
|
;
|
||||||
private final Function<Engine, EngineMode> factory;
|
private final Function<Engine, EngineMode> factory;
|
||||||
|
|
||||||
IrisDimensionModeType(Function<Engine, EngineMode> factory)
|
IrisDimensionModeType(Function<Engine, EngineMode> factory) {
|
||||||
{
|
|
||||||
this.factory = factory;
|
this.factory = factory;
|
||||||
}
|
}
|
||||||
|
|
||||||
public EngineMode create(Engine e)
|
public EngineMode create(Engine e) {
|
||||||
{
|
|
||||||
return factory.apply(e);
|
return factory.apply(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -21,8 +21,13 @@ package com.volmit.iris.engine.object;
|
|||||||
import com.volmit.iris.Iris;
|
import com.volmit.iris.Iris;
|
||||||
import com.volmit.iris.engine.data.cache.AtomicCache;
|
import com.volmit.iris.engine.data.cache.AtomicCache;
|
||||||
import com.volmit.iris.engine.framework.Engine;
|
import com.volmit.iris.engine.framework.Engine;
|
||||||
import com.volmit.iris.engine.object.annotations.*;
|
import com.volmit.iris.engine.object.annotations.ArrayType;
|
||||||
import com.volmit.iris.util.collection.KList;
|
import com.volmit.iris.engine.object.annotations.DependsOn;
|
||||||
|
import com.volmit.iris.engine.object.annotations.Desc;
|
||||||
|
import com.volmit.iris.engine.object.annotations.MaxNumber;
|
||||||
|
import com.volmit.iris.engine.object.annotations.MinNumber;
|
||||||
|
import com.volmit.iris.engine.object.annotations.Required;
|
||||||
|
import com.volmit.iris.engine.object.annotations.Snippet;
|
||||||
import com.volmit.iris.util.math.RNG;
|
import com.volmit.iris.util.math.RNG;
|
||||||
import com.volmit.iris.util.scheduling.ChronoLatch;
|
import com.volmit.iris.util.scheduling.ChronoLatch;
|
||||||
import com.volmit.iris.util.scheduling.J;
|
import com.volmit.iris.util.scheduling.J;
|
||||||
|
@ -26,10 +26,7 @@ import com.volmit.iris.engine.object.annotations.MinNumber;
|
|||||||
import com.volmit.iris.engine.object.annotations.RegistryListResource;
|
import com.volmit.iris.engine.object.annotations.RegistryListResource;
|
||||||
import com.volmit.iris.engine.object.annotations.Required;
|
import com.volmit.iris.engine.object.annotations.Required;
|
||||||
import com.volmit.iris.engine.object.annotations.Snippet;
|
import com.volmit.iris.engine.object.annotations.Snippet;
|
||||||
import com.volmit.iris.util.collection.KList;
|
|
||||||
import com.volmit.iris.util.math.RNG;
|
import com.volmit.iris.util.math.RNG;
|
||||||
import com.volmit.iris.util.matter.MatterFluidBody;
|
|
||||||
import com.volmit.iris.util.noise.CNG;
|
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.NoArgsConstructor;
|
import lombok.NoArgsConstructor;
|
||||||
|
@ -26,10 +26,7 @@ import com.volmit.iris.engine.object.annotations.MinNumber;
|
|||||||
import com.volmit.iris.engine.object.annotations.RegistryListResource;
|
import com.volmit.iris.engine.object.annotations.RegistryListResource;
|
||||||
import com.volmit.iris.engine.object.annotations.Required;
|
import com.volmit.iris.engine.object.annotations.Required;
|
||||||
import com.volmit.iris.engine.object.annotations.Snippet;
|
import com.volmit.iris.engine.object.annotations.Snippet;
|
||||||
import com.volmit.iris.util.collection.KList;
|
|
||||||
import com.volmit.iris.util.math.RNG;
|
import com.volmit.iris.util.math.RNG;
|
||||||
import com.volmit.iris.util.matter.MatterFluidBody;
|
|
||||||
import com.volmit.iris.util.noise.CNG;
|
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.NoArgsConstructor;
|
import lombok.NoArgsConstructor;
|
||||||
|
@ -29,7 +29,6 @@ import com.volmit.iris.engine.framework.Engine;
|
|||||||
import com.volmit.iris.engine.framework.EngineTarget;
|
import com.volmit.iris.engine.framework.EngineTarget;
|
||||||
import com.volmit.iris.engine.object.HeadlessWorld;
|
import com.volmit.iris.engine.object.HeadlessWorld;
|
||||||
import com.volmit.iris.util.collection.KList;
|
import com.volmit.iris.util.collection.KList;
|
||||||
import com.volmit.iris.util.collection.KSet;
|
|
||||||
import com.volmit.iris.util.documentation.ChunkCoordinates;
|
import com.volmit.iris.util.documentation.ChunkCoordinates;
|
||||||
import com.volmit.iris.util.documentation.RegionCoordinates;
|
import com.volmit.iris.util.documentation.RegionCoordinates;
|
||||||
import com.volmit.iris.util.hunk.Hunk;
|
import com.volmit.iris.util.hunk.Hunk;
|
||||||
@ -41,7 +40,6 @@ import com.volmit.iris.util.nbt.mca.NBTWorld;
|
|||||||
import com.volmit.iris.util.nbt.tag.CompoundTag;
|
import com.volmit.iris.util.nbt.tag.CompoundTag;
|
||||||
import com.volmit.iris.util.parallel.BurstExecutor;
|
import com.volmit.iris.util.parallel.BurstExecutor;
|
||||||
import com.volmit.iris.util.parallel.MultiBurst;
|
import com.volmit.iris.util.parallel.MultiBurst;
|
||||||
import com.volmit.iris.util.scheduling.J;
|
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
@ -51,7 +49,6 @@ import org.bukkit.generator.ChunkGenerator;
|
|||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
@ -135,21 +132,19 @@ public class HeadlessGenerator implements PlatformChunkGenerator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private Position2 avgLast(int x, int z) {
|
private Position2 avgLast(int x, int z) {
|
||||||
while(last.size() > 3)
|
while (last.size() > 3) {
|
||||||
{
|
|
||||||
last.remove(0);
|
last.remove(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
double xx = 0;
|
double xx = 0;
|
||||||
double zz = 0;
|
double zz = 0;
|
||||||
|
|
||||||
for(Position2 i : last)
|
for (Position2 i : last) {
|
||||||
{
|
|
||||||
xx += 27 * (i.getX() - x);
|
xx += 27 * (i.getX() - x);
|
||||||
zz += 27 * (i.getZ() - z);
|
zz += 27 * (i.getZ() - z);
|
||||||
}
|
}
|
||||||
|
|
||||||
return new Position2((int)xx, (int)zz);
|
return new Position2((int) xx, (int) zz);
|
||||||
}
|
}
|
||||||
|
|
||||||
@RegionCoordinates
|
@RegionCoordinates
|
||||||
|
@ -42,12 +42,9 @@ public class KMap<K, V> extends ConcurrentHashMap<K, V> {
|
|||||||
put(gMap);
|
put(gMap);
|
||||||
}
|
}
|
||||||
|
|
||||||
public K getKey(V value)
|
public K getKey(V value) {
|
||||||
{
|
for (KeyPair<K, V> i : keypair()) {
|
||||||
for(KeyPair<K,V> i : keypair())
|
if (i.getV().equals(value)) {
|
||||||
{
|
|
||||||
if(i.getV().equals(value))
|
|
||||||
{
|
|
||||||
return i.getK();
|
return i.getK();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -400,13 +400,11 @@ public class B {
|
|||||||
try {
|
try {
|
||||||
String bd = bdxf.trim();
|
String bd = bdxf.trim();
|
||||||
|
|
||||||
if(bd.startsWith("minecraft:cauldron[level="))
|
if (bd.startsWith("minecraft:cauldron[level=")) {
|
||||||
{
|
|
||||||
bd = bd.replaceAll("\\Q:cauldron[\\E", ":water_cauldron[");
|
bd = bd.replaceAll("\\Q:cauldron[\\E", ":water_cauldron[");
|
||||||
}
|
}
|
||||||
|
|
||||||
if(bd.equals("minecraft:grass_path"))
|
if (bd.equals("minecraft:grass_path")) {
|
||||||
{
|
|
||||||
return DIRT_PATH.createBlockData();
|
return DIRT_PATH.createBlockData();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
50
src/main/java/com/volmit/iris/util/data/ChunkCache.java
Normal file
50
src/main/java/com/volmit/iris/util/data/ChunkCache.java
Normal file
@ -0,0 +1,50 @@
|
|||||||
|
/*
|
||||||
|
* Iris is a World Generator for Minecraft Bukkit Servers
|
||||||
|
* Copyright (c) 2021 Arcane Arts (Volmit Software)
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.volmit.iris.util.data;
|
||||||
|
|
||||||
|
import com.volmit.iris.util.function.Function2;
|
||||||
|
|
||||||
|
import java.util.concurrent.atomic.AtomicReferenceArray;
|
||||||
|
|
||||||
|
public class ChunkCache<T> {
|
||||||
|
private final AtomicReferenceArray<T> cache;
|
||||||
|
|
||||||
|
public ChunkCache() {
|
||||||
|
cache = new AtomicReferenceArray<>(256);
|
||||||
|
}
|
||||||
|
|
||||||
|
public T compute(int x, int z, Function2<Integer, Integer, T> function) {
|
||||||
|
T t = get(x & 15, z & 15);
|
||||||
|
|
||||||
|
if (t == null) {
|
||||||
|
t = function.apply(x, z);
|
||||||
|
set(x & 15, z & 15, t);
|
||||||
|
}
|
||||||
|
|
||||||
|
return t;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void set(int x, int z, T t) {
|
||||||
|
cache.set(x * 16 + z, t);
|
||||||
|
}
|
||||||
|
|
||||||
|
private T get(int x, int z) {
|
||||||
|
return cache.get(x * 16 + z);
|
||||||
|
}
|
||||||
|
}
|
42
src/main/java/com/volmit/iris/util/data/ComplexCache.java
Normal file
42
src/main/java/com/volmit/iris/util/data/ComplexCache.java
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
/*
|
||||||
|
* Iris is a World Generator for Minecraft Bukkit Servers
|
||||||
|
* Copyright (c) 2021 Arcane Arts (Volmit Software)
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.volmit.iris.util.data;
|
||||||
|
|
||||||
|
import com.volmit.iris.engine.data.cache.Cache;
|
||||||
|
import com.volmit.iris.util.collection.KMap;
|
||||||
|
|
||||||
|
public class ComplexCache<T> {
|
||||||
|
private final KMap<Long, ChunkCache<T>> chunks;
|
||||||
|
|
||||||
|
public ComplexCache() {
|
||||||
|
chunks = new KMap<>();
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean has(int x, int z) {
|
||||||
|
return chunks.containsKey(Cache.key(x, z));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void invalidate(int x, int z) {
|
||||||
|
chunks.remove(Cache.key(x, z));
|
||||||
|
}
|
||||||
|
|
||||||
|
public ChunkCache<T> chunk(int x, int z) {
|
||||||
|
return chunks.computeIfAbsent(Cache.key(x, z), (f) -> new ChunkCache<>());
|
||||||
|
}
|
||||||
|
}
|
55
src/main/java/com/volmit/iris/util/data/DUTF.java
Normal file
55
src/main/java/com/volmit/iris/util/data/DUTF.java
Normal file
@ -0,0 +1,55 @@
|
|||||||
|
/*
|
||||||
|
* Iris is a World Generator for Minecraft Bukkit Servers
|
||||||
|
* Copyright (c) 2021 Arcane Arts (Volmit Software)
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.volmit.iris.util.data;
|
||||||
|
|
||||||
|
import java.io.DataInput;
|
||||||
|
import java.io.DataInputStream;
|
||||||
|
import java.io.DataOutput;
|
||||||
|
import java.io.DataOutputStream;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.OutputStream;
|
||||||
|
import java.nio.charset.StandardCharsets;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>Encodes signed and unsigned values using a common variable-length
|
||||||
|
* scheme, found for example in
|
||||||
|
* <a href="http://code.google.com/apis/protocolbuffers/docs/encoding.html">
|
||||||
|
* Google's Protocol Buffers</a>. It uses fewer bytes to encode smaller values,
|
||||||
|
* but will use slightly more bytes to encode large values.</p>
|
||||||
|
* <p/>
|
||||||
|
* <p>Signed values are further encoded using so-called zig-zag encoding
|
||||||
|
* in order to make them "compatible" with variable-length encoding.</p>
|
||||||
|
*/
|
||||||
|
public final class DUTF {
|
||||||
|
|
||||||
|
private DUTF() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void write(String s, DataOutputStream dos) throws IOException {
|
||||||
|
byte[] b = s.getBytes(StandardCharsets.UTF_8);
|
||||||
|
dos.writeShort(b.length);
|
||||||
|
dos.write(b);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String read(DataInputStream din) throws IOException {
|
||||||
|
byte[] d = new byte[din.readShort()];
|
||||||
|
din.read(d);
|
||||||
|
return new String(d, StandardCharsets.UTF_8);
|
||||||
|
}
|
||||||
|
}
|
@ -16,23 +16,9 @@
|
|||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.volmit.iris.util.matter;
|
package com.volmit.iris.util.data;
|
||||||
|
|
||||||
import com.volmit.iris.Iris;
|
@FunctionalInterface
|
||||||
import com.volmit.iris.util.hunk.bits.DataContainer;
|
public interface Heafty {
|
||||||
import com.volmit.iris.util.hunk.bits.Writable;
|
int getHeaft();
|
||||||
import com.volmit.iris.util.io.IO;
|
|
||||||
import com.volmit.iris.util.math.RNG;
|
|
||||||
|
|
||||||
import java.io.ByteArrayInputStream;
|
|
||||||
import java.io.DataInputStream;
|
|
||||||
import java.io.DataOutputStream;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.Arrays;
|
|
||||||
|
|
||||||
public class MatterTest {
|
|
||||||
public static void test()
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
@ -22,48 +22,49 @@ import com.github.benmanes.caffeine.cache.CacheLoader;
|
|||||||
import com.github.benmanes.caffeine.cache.Caffeine;
|
import com.github.benmanes.caffeine.cache.Caffeine;
|
||||||
import com.github.benmanes.caffeine.cache.LoadingCache;
|
import com.github.benmanes.caffeine.cache.LoadingCache;
|
||||||
import com.volmit.iris.engine.framework.MeteredCache;
|
import com.volmit.iris.engine.framework.MeteredCache;
|
||||||
|
import com.volmit.iris.util.math.RollingSequence;
|
||||||
|
|
||||||
import java.util.function.Function;
|
public class KCache<K, V> implements MeteredCache {
|
||||||
|
private final long max;
|
||||||
public class KCache<K,V> implements MeteredCache {
|
|
||||||
private long max;
|
|
||||||
private CacheLoader<K, V> loader;
|
private CacheLoader<K, V> loader;
|
||||||
private LoadingCache<K, V> cache;
|
private final LoadingCache<K, V> cache;
|
||||||
|
private final boolean fastDump;
|
||||||
|
private final RollingSequence msu = new RollingSequence(100);
|
||||||
|
|
||||||
public KCache(CacheLoader<K, V> loader, long max)
|
public KCache(CacheLoader<K, V> loader, long max) {
|
||||||
{
|
this(loader, max, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
public KCache(CacheLoader<K, V> loader, long max, boolean fastDump) {
|
||||||
this.max = max;
|
this.max = max;
|
||||||
|
this.fastDump = fastDump;
|
||||||
this.loader = loader;
|
this.loader = loader;
|
||||||
this.cache = create(loader);
|
this.cache = create(loader);
|
||||||
}
|
}
|
||||||
|
|
||||||
private LoadingCache<K,V> create(CacheLoader<K,V> loader) {
|
private LoadingCache<K, V> create(CacheLoader<K, V> loader) {
|
||||||
return Caffeine
|
return Caffeine
|
||||||
.newBuilder()
|
.newBuilder()
|
||||||
.maximumSize(max)
|
.maximumSize(max)
|
||||||
|
.softValues()
|
||||||
|
.initialCapacity((int) (max))
|
||||||
.build((k) -> loader == null ? null : loader.load(k));
|
.build((k) -> loader == null ? null : loader.load(k));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void setLoader(CacheLoader<K, V> loader)
|
public void setLoader(CacheLoader<K, V> loader) {
|
||||||
{
|
|
||||||
this.loader = loader;
|
this.loader = loader;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void invalidate(K k)
|
public void invalidate(K k) {
|
||||||
{
|
|
||||||
cache.invalidate(k);
|
cache.invalidate(k);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void invalidate()
|
public void invalidate() {
|
||||||
{
|
cache.invalidateAll();
|
||||||
LoadingCache<?,?> c = cache;
|
|
||||||
cache = create(loader);
|
|
||||||
c.invalidateAll();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public V get(K k)
|
public V get(K k) {
|
||||||
{
|
|
||||||
return cache.get(k);
|
return cache.get(k);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -72,6 +73,11 @@ public class KCache<K,V> implements MeteredCache {
|
|||||||
return cache.estimatedSize();
|
return cache.estimatedSize();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public KCache<?, ?> getRawCache() {
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public long getMaxSize() {
|
public long getMaxSize() {
|
||||||
return max;
|
return max;
|
||||||
|
@ -59,32 +59,26 @@ public class BitStorage {
|
|||||||
this(bits, length, (AtomicLongArray) null);
|
this(bits, length, (AtomicLongArray) null);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static AtomicLongArray atomic(long[] data)
|
private static AtomicLongArray atomic(long[] data) {
|
||||||
{
|
if (data == null) {
|
||||||
if(data == null)
|
|
||||||
{
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
AtomicLongArray d = new AtomicLongArray(data.length);
|
AtomicLongArray d = new AtomicLongArray(data.length);
|
||||||
for(int i = 0; i < data.length; i++)
|
for (int i = 0; i < data.length; i++) {
|
||||||
{
|
|
||||||
d.set(i, data[i]);
|
d.set(i, data[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
return d;
|
return d;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static long[] atomic(AtomicLongArray data)
|
private static long[] atomic(AtomicLongArray data) {
|
||||||
{
|
if (data == null) {
|
||||||
if(data == null)
|
|
||||||
{
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
long[] d = new long[data.length()];
|
long[] d = new long[data.length()];
|
||||||
for(int i = 0; i < data.length(); i++)
|
for (int i = 0; i < data.length(); i++) {
|
||||||
{
|
|
||||||
d[i] = data.get(i);
|
d[i] = data.get(i);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -107,8 +101,7 @@ public class BitStorage {
|
|||||||
this.divideShift = MAGIC[var3 + 2];
|
this.divideShift = MAGIC[var3 + 2];
|
||||||
int var4 = (length + this.valuesPerLong - 1) / this.valuesPerLong;
|
int var4 = (length + this.valuesPerLong - 1) / this.valuesPerLong;
|
||||||
if (data != null) {
|
if (data != null) {
|
||||||
if (data.length() != var4)
|
if (data.length() != var4) {
|
||||||
{
|
|
||||||
throw new RuntimeException("NO!");
|
throw new RuntimeException("NO!");
|
||||||
}
|
}
|
||||||
this.data = data;
|
this.data = data;
|
||||||
@ -166,8 +159,7 @@ public class BitStorage {
|
|||||||
|
|
||||||
public void getAll(IntConsumer var0) {
|
public void getAll(IntConsumer var0) {
|
||||||
int var1 = 0;
|
int var1 = 0;
|
||||||
for(int i = 0; i < data.length(); i++)
|
for (int i = 0; i < data.length(); i++) {
|
||||||
{
|
|
||||||
long var5 = data.get(i);
|
long var5 = data.get(i);
|
||||||
for (int var7 = 0; var7 < this.valuesPerLong; var7++) {
|
for (int var7 = 0; var7 < this.valuesPerLong; var7++) {
|
||||||
var0.accept((int) (var5 & this.mask));
|
var0.accept((int) (var5 & this.mask));
|
||||||
|
@ -20,7 +20,6 @@ package com.volmit.iris.util.data.palette;
|
|||||||
|
|
||||||
import com.google.common.collect.Iterators;
|
import com.google.common.collect.Iterators;
|
||||||
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.concurrent.atomic.AtomicIntegerArray;
|
import java.util.concurrent.atomic.AtomicIntegerArray;
|
||||||
@ -49,16 +48,14 @@ public class CrudeIncrementalIntIdentityHashBiMap<K> implements IdMap<K> {
|
|||||||
|
|
||||||
|
|
||||||
public K byId(int var0) {
|
public K byId(int var0) {
|
||||||
if (var0 < 0 || var0 >= this.byId.length())
|
if (var0 < 0 || var0 >= this.byId.length()) {
|
||||||
{
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
return this.byId.get(var0);
|
return this.byId.get(var0);
|
||||||
}
|
}
|
||||||
|
|
||||||
private int getValue(int var0) {
|
private int getValue(int var0) {
|
||||||
if (var0 == -1)
|
if (var0 == -1) {
|
||||||
{
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
return this.values.get(var0);
|
return this.values.get(var0);
|
||||||
@ -79,8 +76,7 @@ public class CrudeIncrementalIntIdentityHashBiMap<K> implements IdMap<K> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private int nextId() {
|
private int nextId() {
|
||||||
while (nextId < byId.length() && byId.get(nextId) != null)
|
while (nextId < byId.length() && byId.get(nextId) != null) {
|
||||||
{
|
|
||||||
nextId++;
|
nextId++;
|
||||||
}
|
}
|
||||||
return nextId;
|
return nextId;
|
||||||
@ -95,8 +91,7 @@ public class CrudeIncrementalIntIdentityHashBiMap<K> implements IdMap<K> {
|
|||||||
this.nextId = 0;
|
this.nextId = 0;
|
||||||
this.size = 0;
|
this.size = 0;
|
||||||
for (int var3 = 0; var3 < var1.length(); var3++) {
|
for (int var3 = 0; var3 < var1.length(); var3++) {
|
||||||
if (var1.get(var3) != null)
|
if (var1.get(var3) != null) {
|
||||||
{
|
|
||||||
addMapping(var1.get(var3), var2.get(var3));
|
addMapping(var1.get(var3), var2.get(var3));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -126,8 +121,7 @@ public class CrudeIncrementalIntIdentityHashBiMap<K> implements IdMap<K> {
|
|||||||
private int indexOf(K var0, int var1) {
|
private int indexOf(K var0, int var1) {
|
||||||
int var2;
|
int var2;
|
||||||
for (var2 = var1; var2 < this.keys.length(); var2++) {
|
for (var2 = var1; var2 < this.keys.length(); var2++) {
|
||||||
if (this.keys.get(var2) == null)
|
if (this.keys.get(var2) == null) {
|
||||||
{
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
if (this.keys.get(var2).equals(var0))
|
if (this.keys.get(var2).equals(var0))
|
||||||
@ -158,11 +152,12 @@ public class CrudeIncrementalIntIdentityHashBiMap<K> implements IdMap<K> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Iterator<K> iterator() {
|
public Iterator<K> iterator() {
|
||||||
return Iterators.filter(new Iterator<K>(){
|
return Iterators.filter(new Iterator<K>() {
|
||||||
int i = 0;
|
int i = 0;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean hasNext() {
|
public boolean hasNext() {
|
||||||
return i < byId.length()-1;
|
return i < byId.length() - 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -174,15 +169,12 @@ public class CrudeIncrementalIntIdentityHashBiMap<K> implements IdMap<K> {
|
|||||||
|
|
||||||
public void clear() {
|
public void clear() {
|
||||||
|
|
||||||
for(int i = 0; i < Math.max(keys.length(), byId.length()); i++)
|
for (int i = 0; i < Math.max(keys.length(), byId.length()); i++) {
|
||||||
{
|
if (i < keys.length() - 1) {
|
||||||
if(i < keys.length() - 1)
|
|
||||||
{
|
|
||||||
keys.set(i, null);
|
keys.set(i, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(i < byId.length() - 1)
|
if (i < byId.length() - 1) {
|
||||||
{
|
|
||||||
byId.set(i, null);
|
byId.set(i, null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -18,8 +18,6 @@
|
|||||||
|
|
||||||
package com.volmit.iris.util.data.palette;
|
package com.volmit.iris.util.data.palette;
|
||||||
|
|
||||||
import com.volmit.iris.util.nbt.tag.ListTag;
|
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.function.Predicate;
|
import java.util.function.Predicate;
|
||||||
|
|
||||||
@ -28,11 +26,9 @@ public class GlobalPalette<T> implements Palette<T> {
|
|||||||
|
|
||||||
private final T defaultValue;
|
private final T defaultValue;
|
||||||
|
|
||||||
public GlobalPalette(T... f)
|
public GlobalPalette(T... f) {
|
||||||
{
|
|
||||||
IdMapper<T> mapper = new IdMapper<>();
|
IdMapper<T> mapper = new IdMapper<>();
|
||||||
for(T i : f)
|
for (T i : f) {
|
||||||
{
|
|
||||||
mapper.add(i);
|
mapper.add(i);
|
||||||
}
|
}
|
||||||
registry = mapper;
|
registry = mapper;
|
||||||
|
@ -20,12 +20,8 @@ package com.volmit.iris.util.data.palette;
|
|||||||
|
|
||||||
import com.volmit.iris.Iris;
|
import com.volmit.iris.Iris;
|
||||||
import com.volmit.iris.util.collection.KMap;
|
import com.volmit.iris.util.collection.KMap;
|
||||||
import com.volmit.iris.util.nbt.tag.CompoundTag;
|
|
||||||
import com.volmit.iris.util.nbt.tag.ListTag;
|
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.function.Function;
|
|
||||||
import java.util.function.Predicate;
|
|
||||||
|
|
||||||
public class HashMapPalette<T> implements Palette<T> {
|
public class HashMapPalette<T> implements Palette<T> {
|
||||||
private final KMap<T, Integer> values;
|
private final KMap<T, Integer> values;
|
||||||
@ -41,16 +37,14 @@ public class HashMapPalette<T> implements Palette<T> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public int idFor(T var0) {
|
public int idFor(T var0) {
|
||||||
if(var0 == null)
|
if (var0 == null) {
|
||||||
{
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
return this.values.computeIfAbsent(var0, (k) -> {
|
return this.values.computeIfAbsent(var0, (k) -> {
|
||||||
int newId = id++;
|
int newId = id++;
|
||||||
|
|
||||||
if (newId >= 1 << this.bits)
|
if (newId >= 1 << this.bits) {
|
||||||
{
|
|
||||||
Iris.info(newId + " to...");
|
Iris.info(newId + " to...");
|
||||||
newId = this.resizeHandler.onResize(this.bits + 1, var0);
|
newId = this.resizeHandler.onResize(this.bits + 1, var0);
|
||||||
Iris.info(newId + "..");
|
Iris.info(newId + "..");
|
||||||
|
@ -49,8 +49,7 @@ public class IdMapper<T> implements IdMap<T> {
|
|||||||
|
|
||||||
public void addMapping(T var0, int var1) {
|
public void addMapping(T var0, int var1) {
|
||||||
this.tToId.put(var0, Integer.valueOf(var1));
|
this.tToId.put(var0, Integer.valueOf(var1));
|
||||||
while (this.idToT.size() <= var1)
|
while (this.idToT.size() <= var1) {
|
||||||
{
|
|
||||||
this.idToT.add(null);
|
this.idToT.add(null);
|
||||||
}
|
}
|
||||||
this.idToT.set(var1, var0);
|
this.idToT.set(var1, var0);
|
||||||
@ -68,8 +67,7 @@ public class IdMapper<T> implements IdMap<T> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public final T byId(int var0) {
|
public final T byId(int var0) {
|
||||||
if (var0 >= 0 && var0 < this.idToT.size())
|
if (var0 >= 0 && var0 < this.idToT.size()) {
|
||||||
{
|
|
||||||
return this.idToT.get(var0);
|
return this.idToT.get(var0);
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
|
@ -20,7 +20,6 @@ package com.volmit.iris.util.data.palette;
|
|||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.concurrent.atomic.AtomicReferenceArray;
|
import java.util.concurrent.atomic.AtomicReferenceArray;
|
||||||
import java.util.function.Predicate;
|
|
||||||
|
|
||||||
public class LinearPalette<T> implements Palette<T> {
|
public class LinearPalette<T> implements Palette<T> {
|
||||||
private final AtomicReferenceArray<T> values;
|
private final AtomicReferenceArray<T> values;
|
||||||
@ -37,13 +36,11 @@ public class LinearPalette<T> implements Palette<T> {
|
|||||||
public int idFor(T var0) {
|
public int idFor(T var0) {
|
||||||
int var1;
|
int var1;
|
||||||
for (var1 = 0; var1 < size; var1++) {
|
for (var1 = 0; var1 < size; var1++) {
|
||||||
if(values.get(var1) == null && var0 == null)
|
if (values.get(var1) == null && var0 == null) {
|
||||||
{
|
|
||||||
return var1;
|
return var1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (values.get(var1) != null && values.get(var1).equals(var0))
|
if (values.get(var1) != null && values.get(var1).equals(var0)) {
|
||||||
{
|
|
||||||
return var1;
|
return var1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -57,8 +54,7 @@ public class LinearPalette<T> implements Palette<T> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public T valueFor(int var0) {
|
public T valueFor(int var0) {
|
||||||
if (var0 >= 0 && var0 < size)
|
if (var0 >= 0 && var0 < size) {
|
||||||
{
|
|
||||||
return this.values.get(var0);
|
return this.values.get(var0);
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
@ -70,8 +66,7 @@ public class LinearPalette<T> implements Palette<T> {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void read(List<T> fromList) {
|
public void read(List<T> fromList) {
|
||||||
for (int i = 0; i < fromList.size(); i++)
|
for (int i = 0; i < fromList.size(); i++) {
|
||||||
{
|
|
||||||
values.set(i, fromList.get(i));
|
values.set(i, fromList.get(i));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -80,8 +75,7 @@ public class LinearPalette<T> implements Palette<T> {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void write(List<T> toList) {
|
public void write(List<T> toList) {
|
||||||
for (int i = 0; i < size; i++)
|
for (int i = 0; i < size; i++) {
|
||||||
{
|
|
||||||
T v = values.get(i);
|
T v = values.get(i);
|
||||||
toList.add(v);
|
toList.add(v);
|
||||||
}
|
}
|
||||||
|
@ -18,11 +18,7 @@
|
|||||||
|
|
||||||
package com.volmit.iris.util.data.palette;
|
package com.volmit.iris.util.data.palette;
|
||||||
|
|
||||||
import com.volmit.iris.util.nbt.tag.CompoundTag;
|
|
||||||
import com.volmit.iris.util.nbt.tag.ListTag;
|
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.function.Predicate;
|
|
||||||
|
|
||||||
public interface Palette<T> {
|
public interface Palette<T> {
|
||||||
int idFor(T paramT);
|
int idFor(T paramT);
|
||||||
|
@ -42,8 +42,7 @@ public interface PaletteType<T> {
|
|||||||
int v = Varint.readUnsignedVarInt(din);
|
int v = Varint.readUnsignedVarInt(din);
|
||||||
List<T> t = new ArrayList<>();
|
List<T> t = new ArrayList<>();
|
||||||
|
|
||||||
for(int i = 0; i < v; i++)
|
for (int i = 0; i < v; i++) {
|
||||||
{
|
|
||||||
t.add(readPaletteNode(din));
|
t.add(readPaletteNode(din));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -21,8 +21,8 @@ package com.volmit.iris.util.data.palette;
|
|||||||
import com.volmit.iris.Iris;
|
import com.volmit.iris.Iris;
|
||||||
import com.volmit.iris.util.math.M;
|
import com.volmit.iris.util.math.M;
|
||||||
import it.unimi.dsi.fastutil.ints.Int2IntOpenHashMap;
|
import it.unimi.dsi.fastutil.ints.Int2IntOpenHashMap;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.function.Predicate;
|
|
||||||
|
|
||||||
@SuppressWarnings("DuplicatedCode")
|
@SuppressWarnings("DuplicatedCode")
|
||||||
public class PalettedContainer<T> implements PaletteResize<T> {
|
public class PalettedContainer<T> implements PaletteResize<T> {
|
||||||
@ -43,8 +43,7 @@ public class PalettedContainer<T> implements PaletteResize<T> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void setBits(int var0) {
|
private void setBits(int var0) {
|
||||||
if (var0 == this.bits)
|
if (var0 == this.bits) {
|
||||||
{
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.bits = var0;
|
this.bits = var0;
|
||||||
@ -65,8 +64,7 @@ public class PalettedContainer<T> implements PaletteResize<T> {
|
|||||||
setBits(var0);
|
setBits(var0);
|
||||||
for (int var4 = 0; var4 < var2.getSize(); var4++) {
|
for (int var4 = 0; var4 < var2.getSize(); var4++) {
|
||||||
T var5 = var3.valueFor(var2.get(var4));
|
T var5 = var3.valueFor(var2.get(var4));
|
||||||
if (var5 != null)
|
if (var5 != null) {
|
||||||
{
|
|
||||||
set(var4, var5);
|
set(var4, var5);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -95,8 +93,7 @@ public class PalettedContainer<T> implements PaletteResize<T> {
|
|||||||
private void set(int var0, T var1) {
|
private void set(int var0, T var1) {
|
||||||
int var2 = this.palette.idFor(var1);
|
int var2 = this.palette.idFor(var1);
|
||||||
|
|
||||||
if(M.r(0.003))
|
if (M.r(0.003)) {
|
||||||
{
|
|
||||||
Iris.info("ID for " + var1 + " is " + var2 + " Palette: " + palette.getSize());
|
Iris.info("ID for " + var1 + " is " + var2 + " Palette: " + palette.getSize());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -113,8 +110,7 @@ public class PalettedContainer<T> implements PaletteResize<T> {
|
|||||||
|
|
||||||
public void read(List<T> palette, long[] data) {
|
public void read(List<T> palette, long[] data) {
|
||||||
int var2 = Math.max(4, Mth.ceillog2(palette.size()));
|
int var2 = Math.max(4, Mth.ceillog2(palette.size()));
|
||||||
if (var2 != this.bits)
|
if (var2 != this.bits) {
|
||||||
{
|
|
||||||
setBits(var2);
|
setBits(var2);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -124,8 +120,7 @@ public class PalettedContainer<T> implements PaletteResize<T> {
|
|||||||
System.arraycopy(data, 0, this.storage.getRaw(), 0, data.length);
|
System.arraycopy(data, 0, this.storage.getRaw(), 0, data.length);
|
||||||
} else {
|
} else {
|
||||||
BitStorage var4 = new BitStorage(var3, 4096, data);
|
BitStorage var4 = new BitStorage(var3, 4096, data);
|
||||||
for (int var5 = 0; var5 < 4096; var5++)
|
for (int var5 = 0; var5 < 4096; var5++) {
|
||||||
{
|
|
||||||
this.storage.set(var5, var4.get(var5));
|
this.storage.set(var5, var4.get(var5));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -528,19 +528,29 @@ public class VirtualDecreeCommand {
|
|||||||
m++;
|
m++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (sender.isPlayer()) {
|
||||||
CompletableFuture<String> future = new CompletableFuture<>();
|
CompletableFuture<String> future = new CompletableFuture<>();
|
||||||
Iris.service(CommandSVC.class).post(password, future);
|
Iris.service(CommandSVC.class).post(password, future);
|
||||||
|
|
||||||
if (IrisSettings.get().getGeneral().isCommandSounds() && sender.isPlayer()) {
|
if (IrisSettings.get().getGeneral().isCommandSounds()) {
|
||||||
(sender.player()).playSound((sender.player()).getLocation(), Sound.BLOCK_AMETHYST_CLUSTER_BREAK, 0.77f, 0.65f);
|
(sender.player()).playSound((sender.player()).getLocation(), Sound.BLOCK_AMETHYST_CLUSTER_BREAK, 0.77f, 0.65f);
|
||||||
(sender.player()).playSound((sender.player()).getLocation(), Sound.BLOCK_BEACON_DEACTIVATE, 0.125f, 1.99f);
|
(sender.player()).playSound((sender.player()).getLocation(), Sound.BLOCK_BEACON_DEACTIVATE, 0.125f, 1.99f);
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
return future.get(15, TimeUnit.SECONDS);
|
return future.get(15, TimeUnit.SECONDS);
|
||||||
} catch (InterruptedException | ExecutionException | TimeoutException e) {
|
} catch (InterruptedException | ExecutionException | TimeoutException ignored) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
CompletableFuture<String> future = new CompletableFuture<>();
|
||||||
|
Iris.service(CommandSVC.class).postConsole(future);
|
||||||
|
try {
|
||||||
|
return future.get(15, TimeUnit.SECONDS);
|
||||||
|
} catch (InterruptedException | ExecutionException | TimeoutException ignored) {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -24,9 +24,11 @@ import com.volmit.iris.util.math.RollingSequence;
|
|||||||
import java.math.BigInteger;
|
import java.math.BigInteger;
|
||||||
import java.text.DecimalFormat;
|
import java.text.DecimalFormat;
|
||||||
import java.text.NumberFormat;
|
import java.text.NumberFormat;
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Calendar;
|
import java.util.Calendar;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.LinkedHashMap;
|
import java.util.LinkedHashMap;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
@ -158,6 +160,40 @@ public class Form {
|
|||||||
return wrap(s, len, newLineSep, soft, " ");
|
return wrap(s, len, newLineSep, soft, " ");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static String hardWrap(String s, int len) {
|
||||||
|
StringBuilder ss = new StringBuilder();
|
||||||
|
|
||||||
|
for(int i = 0; i < s.length(); i+= len)
|
||||||
|
{
|
||||||
|
if(i + len > s.length())
|
||||||
|
{
|
||||||
|
ss.append(s, i, s.length());
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
ss.append(s, i, i + len).append("\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
return ss.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static List<String> hardWrapList(String s, int len) {
|
||||||
|
List<String> l = new ArrayList<>();
|
||||||
|
for(int i = 0; i < s.length(); i+= len)
|
||||||
|
{
|
||||||
|
if(i + len > s.length())
|
||||||
|
{
|
||||||
|
l.add(s.substring(i));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
l.add(s.substring(i, i + len));
|
||||||
|
}
|
||||||
|
|
||||||
|
return l;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Wrap words
|
* Wrap words
|
||||||
*
|
*
|
||||||
|
@ -18,7 +18,6 @@
|
|||||||
|
|
||||||
package com.volmit.iris.util.format;
|
package com.volmit.iris.util.format;
|
||||||
|
|
||||||
import com.volmit.iris.Iris;
|
|
||||||
import com.volmit.iris.util.math.RollingSequence;
|
import com.volmit.iris.util.math.RollingSequence;
|
||||||
import com.volmit.iris.util.scheduling.ChronoLatch;
|
import com.volmit.iris.util.scheduling.ChronoLatch;
|
||||||
import com.volmit.iris.util.scheduling.Looper;
|
import com.volmit.iris.util.scheduling.Looper;
|
||||||
@ -30,14 +29,14 @@ public class MemoryMonitor {
|
|||||||
private long garbageLast;
|
private long garbageLast;
|
||||||
private long garbageBin;
|
private long garbageBin;
|
||||||
private long pressure;
|
private long pressure;
|
||||||
private ChronoLatch cl;
|
private final ChronoLatch cl;
|
||||||
private RollingSequence pressureAvg;
|
private final RollingSequence pressureAvg;
|
||||||
private Runtime runtime;
|
private final Runtime runtime;
|
||||||
|
|
||||||
public MemoryMonitor(int sampleDelay){
|
public MemoryMonitor(int sampleDelay) {
|
||||||
this.runtime = Runtime.getRuntime();
|
this.runtime = Runtime.getRuntime();
|
||||||
usedMemory = -1;
|
usedMemory = -1;
|
||||||
pressureAvg = new RollingSequence(Math.max(Math.min(100, 1000/sampleDelay), 3));
|
pressureAvg = new RollingSequence(Math.max(Math.min(100, 1000 / sampleDelay), 3));
|
||||||
garbageBin = 0;
|
garbageBin = 0;
|
||||||
garbageMemory = -1;
|
garbageMemory = -1;
|
||||||
cl = new ChronoLatch(1000);
|
cl = new ChronoLatch(1000);
|
||||||
@ -56,74 +55,55 @@ public class MemoryMonitor {
|
|||||||
looper.start();
|
looper.start();
|
||||||
}
|
}
|
||||||
|
|
||||||
public long getGarbageBytes()
|
public long getGarbageBytes() {
|
||||||
{
|
|
||||||
return garbageMemory;
|
return garbageMemory;
|
||||||
}
|
}
|
||||||
|
|
||||||
public long getUsedBytes()
|
public long getUsedBytes() {
|
||||||
{
|
|
||||||
return usedMemory;
|
return usedMemory;
|
||||||
}
|
}
|
||||||
|
|
||||||
public long getMaxBytes()
|
public long getMaxBytes() {
|
||||||
{
|
|
||||||
return runtime.maxMemory();
|
return runtime.maxMemory();
|
||||||
}
|
}
|
||||||
|
|
||||||
public long getPressure()
|
public long getPressure() {
|
||||||
{
|
|
||||||
return (long) pressureAvg.getAverage();
|
return (long) pressureAvg.getAverage();
|
||||||
}
|
}
|
||||||
|
|
||||||
public double getUsagePercent()
|
public double getUsagePercent() {
|
||||||
{
|
return usedMemory / (double) getMaxBytes();
|
||||||
return usedMemory / (double)getMaxBytes();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void sample() {
|
private void sample() {
|
||||||
long used = getVMUse();
|
long used = getVMUse();
|
||||||
if(usedMemory == -1)
|
if (usedMemory == -1) {
|
||||||
{
|
|
||||||
usedMemory = used;
|
usedMemory = used;
|
||||||
garbageMemory = 0;
|
garbageMemory = 0;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(used < usedMemory)
|
if (used < usedMemory) {
|
||||||
{
|
|
||||||
usedMemory = used;
|
usedMemory = used;
|
||||||
}
|
} else {
|
||||||
|
|
||||||
else
|
|
||||||
{
|
|
||||||
garbageMemory = used - usedMemory;
|
garbageMemory = used - usedMemory;
|
||||||
}
|
}
|
||||||
|
|
||||||
long g = garbageMemory - garbageLast;
|
long g = garbageMemory - garbageLast;
|
||||||
|
|
||||||
if(g >= 0)
|
if (g >= 0) {
|
||||||
{
|
garbageBin += g;
|
||||||
garbageBin+= g;
|
|
||||||
garbageLast = garbageMemory;
|
garbageLast = garbageMemory;
|
||||||
}
|
} else {
|
||||||
|
|
||||||
else
|
|
||||||
{
|
|
||||||
garbageMemory = 0;
|
garbageMemory = 0;
|
||||||
garbageLast = 0;
|
garbageLast = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(cl.flip())
|
if (cl.flip()) {
|
||||||
{
|
if (garbageMemory > 0) {
|
||||||
if(garbageMemory > 0)
|
|
||||||
{
|
|
||||||
pressure = garbageBin;
|
pressure = garbageBin;
|
||||||
garbageBin = 0;
|
garbageBin = 0;
|
||||||
}
|
} else {
|
||||||
|
|
||||||
else
|
|
||||||
{
|
|
||||||
pressure = 0;
|
pressure = 0;
|
||||||
garbageBin = 0;
|
garbageBin = 0;
|
||||||
}
|
}
|
||||||
@ -136,10 +116,8 @@ public class MemoryMonitor {
|
|||||||
return runtime.totalMemory() - runtime.freeMemory();
|
return runtime.totalMemory() - runtime.freeMemory();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void close()
|
public void close() {
|
||||||
{
|
if (looper != null) {
|
||||||
if(looper != null)
|
|
||||||
{
|
|
||||||
looper.interrupt();
|
looper.interrupt();
|
||||||
looper = null;
|
looper = null;
|
||||||
}
|
}
|
||||||
|
@ -65,9 +65,8 @@ public class DataBits {
|
|||||||
this(bits, length, (AtomicLongArray) null);
|
this(bits, length, (AtomicLongArray) null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public DataBits(int bits, int length, DataInputStream din) throws IOException
|
public DataBits(int bits, int length, DataInputStream din) throws IOException {
|
||||||
{
|
this(bits, length, longs(din, dataLength(bits, length)));
|
||||||
this(bits, length, longs(din));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public DataBits(int bits, int length, AtomicLongArray data) {
|
public DataBits(int bits, int length, AtomicLongArray data) {
|
||||||
@ -83,8 +82,7 @@ public class DataBits {
|
|||||||
int var4 = (length + valuesPerLong - 1) / valuesPerLong;
|
int var4 = (length + valuesPerLong - 1) / valuesPerLong;
|
||||||
|
|
||||||
if (data != null) {
|
if (data != null) {
|
||||||
if (data.length() != var4)
|
if (data.length() != var4) {
|
||||||
{
|
|
||||||
throw new RuntimeException("NO! Trying to load " + data.length() + " into actual size of " + var4 + " because length: " + length + " (bits: " + bits + ")");
|
throw new RuntimeException("NO! Trying to load " + data.length() + " into actual size of " + var4 + " because length: " + length + " (bits: " + bits + ")");
|
||||||
}
|
}
|
||||||
this.data = data;
|
this.data = data;
|
||||||
@ -93,36 +91,30 @@ public class DataBits {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public String toString()
|
public String toString() {
|
||||||
{
|
|
||||||
return "DBits: " + size + "/" + bits + "[" + data.length() + "]";
|
return "DBits: " + size + "/" + bits + "[" + data.length() + "]";
|
||||||
}
|
}
|
||||||
|
|
||||||
private static int dataLength(int bits, int length)
|
private static int dataLength(int bits, int length) {
|
||||||
{
|
|
||||||
return (length + ((char) (64 / bits)) - 1) / ((char) (64 / bits));
|
return (length + ((char) (64 / bits)) - 1) / ((char) (64 / bits));
|
||||||
}
|
}
|
||||||
|
|
||||||
private static AtomicLongArray longs(DataInputStream din) throws IOException{
|
private static AtomicLongArray longs(DataInputStream din, int longSize) throws IOException {
|
||||||
AtomicLongArray a = new AtomicLongArray(din.readInt());
|
AtomicLongArray a = new AtomicLongArray(longSize);
|
||||||
|
|
||||||
for(int i = 0; i < a.length(); i++)
|
for (int i = 0; i < a.length(); i++) {
|
||||||
{
|
a.set(i, Varint.readUnsignedVarLong(din));
|
||||||
a.set(i, din.readLong());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return a;
|
return a;
|
||||||
}
|
}
|
||||||
|
|
||||||
public DataBits setBits(int newBits)
|
public DataBits setBits(int newBits) {
|
||||||
{
|
if (bits != newBits) {
|
||||||
if(bits != newBits)
|
|
||||||
{
|
|
||||||
DataBits newData = new DataBits(newBits, size);
|
DataBits newData = new DataBits(newBits, size);
|
||||||
AtomicInteger c = new AtomicInteger(0);
|
AtomicInteger c = new AtomicInteger(0);
|
||||||
|
|
||||||
for(int i = 0; i < size; i++)
|
for (int i = 0; i < size; i++) {
|
||||||
{
|
|
||||||
newData.set(i, get(i));
|
newData.set(i, get(i));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -183,14 +175,12 @@ public class DataBits {
|
|||||||
|
|
||||||
public void getAll(IntConsumer var0) {
|
public void getAll(IntConsumer var0) {
|
||||||
int var1 = 0;
|
int var1 = 0;
|
||||||
for(int i = 0; i < data.length(); i++)
|
for (int i = 0; i < data.length(); i++) {
|
||||||
{
|
|
||||||
long var5 = data.get(i);
|
long var5 = data.get(i);
|
||||||
for (int var7 = 0; var7 < valuesPerLong; var7++) {
|
for (int var7 = 0; var7 < valuesPerLong; var7++) {
|
||||||
var0.accept((int) (var5 & mask));
|
var0.accept((int) (var5 & mask));
|
||||||
var5 >>= bits;
|
var5 >>= bits;
|
||||||
if (++var1 >= size)
|
if (++var1 >= size) {
|
||||||
{
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -198,11 +188,8 @@ public class DataBits {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void write(DataOutputStream dos) throws IOException {
|
public void write(DataOutputStream dos) throws IOException {
|
||||||
dos.writeInt(data.length());
|
for (int i = 0; i < data.length(); i++) {
|
||||||
|
Varint.writeUnsignedVarLong(data.get(i), dos);
|
||||||
for(int i = 0; i < data.length(); i++)
|
|
||||||
{
|
|
||||||
dos.writeLong(data.get(i));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -31,7 +31,7 @@ import java.util.concurrent.atomic.AtomicReference;
|
|||||||
|
|
||||||
public class DataContainer<T> {
|
public class DataContainer<T> {
|
||||||
protected static final int INITIAL_BITS = 3;
|
protected static final int INITIAL_BITS = 3;
|
||||||
protected static final int LINEAR_BITS_LIMIT = 5;
|
protected static final int LINEAR_BITS_LIMIT = 4;
|
||||||
protected static final int LINEAR_INITIAL_LENGTH = (int) Math.pow(2, LINEAR_BITS_LIMIT) + 1;
|
protected static final int LINEAR_INITIAL_LENGTH = (int) Math.pow(2, LINEAR_BITS_LIMIT) + 1;
|
||||||
protected static final int[] BIT = computeBitLimits();
|
protected static final int[] BIT = computeBitLimits();
|
||||||
private final AtomicReference<Palette<T>> palette;
|
private final AtomicReference<Palette<T>> palette;
|
||||||
@ -40,114 +40,157 @@ public class DataContainer<T> {
|
|||||||
private final int length;
|
private final int length;
|
||||||
private final Writable<T> writer;
|
private final Writable<T> writer;
|
||||||
|
|
||||||
public DataContainer(Writable<T> writer, int length, T empty)
|
public DataContainer(Writable<T> writer, int length) {
|
||||||
{
|
|
||||||
this.writer = writer;
|
this.writer = writer;
|
||||||
this.length = length;
|
this.length = length;
|
||||||
this.bits = new AtomicInteger(INITIAL_BITS);
|
this.bits = new AtomicInteger(INITIAL_BITS);
|
||||||
this.data = new AtomicReference<>(new DataBits(INITIAL_BITS, length));
|
this.data = new AtomicReference<>(new DataBits(INITIAL_BITS, length));
|
||||||
this.palette = new AtomicReference<>(newPalette(INITIAL_BITS));
|
this.palette = new AtomicReference<>(newPalette(INITIAL_BITS));
|
||||||
this.ensurePaletted(empty);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public DataContainer(DataInputStream din, Writable<T> writer) throws IOException {
|
public DataContainer(DataInputStream din, Writable<T> writer) throws IOException {
|
||||||
this.writer = writer;
|
this.writer = writer;
|
||||||
this.length = din.readInt();
|
this.length = Varint.readUnsignedVarInt(din);
|
||||||
this.palette = new AtomicReference<>(newPalette(din));
|
this.palette = new AtomicReference<>(newPalette(din));
|
||||||
this.data = new AtomicReference<>(new DataBits(palette.get().bits(), length, din));
|
this.data = new AtomicReference<>(new DataBits(palette.get().bits(), length, din));
|
||||||
this.bits = new AtomicInteger(palette.get().bits());
|
this.bits = new AtomicInteger(palette.get().bits());
|
||||||
}
|
}
|
||||||
|
|
||||||
public String toString(){
|
public static String readBitString(DataInputStream din) throws IOException
|
||||||
return "DataContainer <" + length + " x " + bits + " bits> -> Palette<"+palette.get().getClass().getSimpleName().replaceAll("\\QPalette\\E", "")+">: " + palette.get().size() +
|
{
|
||||||
|
DataContainer<Character> c = new DataContainer<>(din, new Writable<Character>() {
|
||||||
|
@Override
|
||||||
|
public Character readNodeData(DataInputStream din) throws IOException {
|
||||||
|
return din.readChar();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void writeNodeData(DataOutputStream dos, Character character) throws IOException {
|
||||||
|
dos.writeChar(character);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
|
||||||
|
for(int i = c.size()-1; i >= 0; i--)
|
||||||
|
{
|
||||||
|
sb.setCharAt(i, c.get(i));
|
||||||
|
}
|
||||||
|
|
||||||
|
return sb.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void writeBitString(String s, DataOutputStream dos) throws IOException {
|
||||||
|
DataContainer<Character> c = new DataContainer<>(new Writable<Character>() {
|
||||||
|
@Override
|
||||||
|
public Character readNodeData(DataInputStream din) throws IOException {
|
||||||
|
return din.readChar();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void writeNodeData(DataOutputStream dos, Character character) throws IOException {
|
||||||
|
dos.writeChar(character);
|
||||||
|
}
|
||||||
|
}, s.length());
|
||||||
|
|
||||||
|
for(int i = 0; i < s.length(); i++)
|
||||||
|
{
|
||||||
|
c.set(i, s.charAt(i));
|
||||||
|
}
|
||||||
|
|
||||||
|
c.writeDos(dos);
|
||||||
|
}
|
||||||
|
|
||||||
|
public DataBits getData()
|
||||||
|
{
|
||||||
|
return data.get();
|
||||||
|
}
|
||||||
|
|
||||||
|
public Palette<T> getPalette()
|
||||||
|
{
|
||||||
|
return palette.get();
|
||||||
|
}
|
||||||
|
|
||||||
|
public String toString() {
|
||||||
|
return "DataContainer <" + length + " x " + bits + " bits> -> Palette<" + palette.get().getClass().getSimpleName().replaceAll("\\QPalette\\E", "") + ">: " + palette.get().size() +
|
||||||
" " + data.get().toString() + " PalBit: " + palette.get().bits();
|
" " + data.get().toString() + " PalBit: " + palette.get().bits();
|
||||||
}
|
}
|
||||||
|
|
||||||
public byte[] write() throws IOException
|
public byte[] write() throws IOException {
|
||||||
{
|
|
||||||
ByteArrayOutputStream boas = new ByteArrayOutputStream();
|
ByteArrayOutputStream boas = new ByteArrayOutputStream();
|
||||||
write(boas);
|
write(boas);
|
||||||
return boas.toByteArray();
|
return boas.toByteArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void write(OutputStream out) throws IOException
|
public void write(OutputStream out) throws IOException {
|
||||||
{
|
|
||||||
writeDos(new DataOutputStream(out));
|
writeDos(new DataOutputStream(out));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void writeDos(DataOutputStream dos) throws IOException
|
public void writeDos(DataOutputStream dos) throws IOException {
|
||||||
{
|
Varint.writeUnsignedVarInt(length, dos);
|
||||||
dos.writeInt(length);
|
Varint.writeUnsignedVarInt(palette.get().size(), dos);
|
||||||
dos.writeInt(palette.get().size());
|
|
||||||
palette.get().iterateIO((data, __) -> writer.writeNodeData(dos, data));
|
palette.get().iterateIO((data, __) -> writer.writeNodeData(dos, data));
|
||||||
data.get().write(dos);
|
data.get().write(dos);
|
||||||
dos.flush();
|
dos.flush();
|
||||||
}
|
}
|
||||||
|
|
||||||
private Palette<T> newPalette(DataInputStream din) throws IOException {
|
private Palette<T> newPalette(DataInputStream din) throws IOException {
|
||||||
int paletteSize = din.readInt();
|
int paletteSize = Varint.readUnsignedVarInt(din);
|
||||||
Palette<T> d = newPalette(bits(paletteSize));
|
Palette<T> d = newPalette(bits(paletteSize+1));
|
||||||
d.from(paletteSize, writer, din);
|
d.from(paletteSize, writer, din);
|
||||||
return d;
|
return d;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Palette<T> newPalette(int bits)
|
private Palette<T> newPalette(int bits) {
|
||||||
{
|
if (bits <= LINEAR_BITS_LIMIT) {
|
||||||
if(bits <= LINEAR_BITS_LIMIT)
|
|
||||||
{
|
|
||||||
return new LinearPalette<>(LINEAR_INITIAL_LENGTH);
|
return new LinearPalette<>(LINEAR_INITIAL_LENGTH);
|
||||||
}
|
}
|
||||||
|
|
||||||
return new HashPalette<>();
|
return new HashPalette<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void checkBits()
|
public void ensurePaletted(T t) {
|
||||||
{
|
if (palette.get().id(t) == -1) {
|
||||||
if(palette.get().size() >= BIT[bits.get()])
|
expandOne();
|
||||||
{
|
|
||||||
setBits(bits.get() + 1);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ensurePaletted(T t)
|
public void set(int position, T t) {
|
||||||
{
|
synchronized (this)
|
||||||
if(palette.get().id(t) == -1)
|
|
||||||
{
|
|
||||||
checkBits();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void set(int position, T t)
|
|
||||||
{
|
{
|
||||||
int id = palette.get().id(t);
|
int id = palette.get().id(t);
|
||||||
|
|
||||||
if(id == -1)
|
if (id == -1) {
|
||||||
{
|
expandOne();
|
||||||
checkBits();
|
|
||||||
id = palette.get().add(t);
|
id = palette.get().add(t);
|
||||||
}
|
}
|
||||||
|
|
||||||
data.get().set(position, id);
|
data.get().set(position, id);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public T get(int position)
|
private void expandOne() {
|
||||||
{
|
if (palette.get().size() + 1 >= BIT[bits.get()]) {
|
||||||
int id = data.get().get(position)+1;
|
setBits(bits.get() + 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if(id <= 0)
|
public T get(int position) {
|
||||||
|
synchronized (this)
|
||||||
{
|
{
|
||||||
|
int id = data.get().get(position) + 1;
|
||||||
|
|
||||||
|
if (id <= 0) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
return palette.get().get(id-1);
|
return palette.get().get(id - 1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setBits(int bits)
|
public void setBits(int bits) {
|
||||||
{
|
if (this.bits.get() != bits) {
|
||||||
if(this.bits.get() != bits)
|
if (this.bits.get() <= LINEAR_BITS_LIMIT != bits <= LINEAR_BITS_LIMIT) {
|
||||||
{
|
|
||||||
if(this.bits.get() <= LINEAR_BITS_LIMIT != bits <= LINEAR_BITS_LIMIT)
|
|
||||||
{
|
|
||||||
palette.set(newPalette(bits).from(palette.get()));
|
palette.set(newPalette(bits).from(palette.get()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -159,29 +202,28 @@ public class DataContainer<T> {
|
|||||||
private static int[] computeBitLimits() {
|
private static int[] computeBitLimits() {
|
||||||
int[] m = new int[16];
|
int[] m = new int[16];
|
||||||
|
|
||||||
for(int i = 0; i < m.length; i++)
|
for (int i = 0; i < m.length; i++) {
|
||||||
{
|
|
||||||
m[i] = (int) Math.pow(2, i);
|
m[i] = (int) Math.pow(2, i);
|
||||||
}
|
}
|
||||||
|
|
||||||
return m;
|
return m;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected static int bits(int size)
|
protected static int bits(int size) {
|
||||||
{
|
if (DataContainer.BIT[INITIAL_BITS] >= size) {
|
||||||
if(DataContainer.BIT[INITIAL_BITS] >= size)
|
|
||||||
{
|
|
||||||
return INITIAL_BITS;
|
return INITIAL_BITS;
|
||||||
}
|
}
|
||||||
|
|
||||||
for(int i = 0; i < DataContainer.BIT.length; i++)
|
for (int i = 0; i < DataContainer.BIT.length; i++) {
|
||||||
{
|
if (DataContainer.BIT[i] >= size) {
|
||||||
if(DataContainer.BIT[i] >= size)
|
|
||||||
{
|
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return DataContainer.BIT.length - 1;
|
return DataContainer.BIT.length - 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int size() {
|
||||||
|
return getData().getSize();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -18,7 +18,6 @@
|
|||||||
|
|
||||||
package com.volmit.iris.util.hunk.bits;
|
package com.volmit.iris.util.hunk.bits;
|
||||||
|
|
||||||
import com.googlecode.concurrentlinkedhashmap.ConcurrentLinkedHashMap;
|
|
||||||
import com.volmit.iris.util.collection.KMap;
|
import com.volmit.iris.util.collection.KMap;
|
||||||
import com.volmit.iris.util.function.Consumer2;
|
import com.volmit.iris.util.function.Consumer2;
|
||||||
|
|
||||||
@ -30,17 +29,16 @@ public class HashPalette<T> implements Palette<T> {
|
|||||||
private final KMap<Integer, T> lookup;
|
private final KMap<Integer, T> lookup;
|
||||||
private final AtomicInteger size;
|
private final AtomicInteger size;
|
||||||
|
|
||||||
public HashPalette()
|
public HashPalette() {
|
||||||
{
|
|
||||||
this.size = new AtomicInteger(0);
|
this.size = new AtomicInteger(0);
|
||||||
this.palette = new LinkedHashMap<>();
|
this.palette = new LinkedHashMap<>();
|
||||||
this.lookup = new KMap<>();
|
this.lookup = new KMap<>();
|
||||||
|
add(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public T get(int id) {
|
public T get(int id) {
|
||||||
if(id < 0 || id >= size.get())
|
if (id < 0 || id >= size.get()) {
|
||||||
{
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -52,8 +50,7 @@ public class HashPalette<T> implements Palette<T> {
|
|||||||
int index = size.getAndIncrement();
|
int index = size.getAndIncrement();
|
||||||
palette.put(t, index);
|
palette.put(t, index);
|
||||||
|
|
||||||
if(t != null)
|
if (t != null) {
|
||||||
{
|
|
||||||
lookup.put(index, t);
|
lookup.put(index, t);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -62,19 +59,28 @@ public class HashPalette<T> implements Palette<T> {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int id(T t) {
|
public int id(T t) {
|
||||||
|
if(t == null)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
Integer v = palette.get(t);
|
Integer v = palette.get(t);
|
||||||
return v != null ? v : -1;
|
return v != null ? v : -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int size() {
|
public int size() {
|
||||||
return size.get();
|
return size.get() - 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void iterate(Consumer2<T, Integer> c) {
|
public void iterate(Consumer2<T, Integer> c) {
|
||||||
for(T i : palette.keySet())
|
for (T i : palette.keySet()) {
|
||||||
|
if(i == null)
|
||||||
{
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
c.accept(i, id(i));
|
c.accept(i, id(i));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -18,7 +18,9 @@
|
|||||||
|
|
||||||
package com.volmit.iris.util.hunk.bits;
|
package com.volmit.iris.util.hunk.bits;
|
||||||
|
|
||||||
|
import com.volmit.iris.Iris;
|
||||||
import com.volmit.iris.util.function.Consumer2;
|
import com.volmit.iris.util.function.Consumer2;
|
||||||
|
import org.bukkit.block.data.BlockData;
|
||||||
|
|
||||||
import java.util.concurrent.atomic.AtomicInteger;
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
import java.util.concurrent.atomic.AtomicReference;
|
import java.util.concurrent.atomic.AtomicReference;
|
||||||
@ -28,16 +30,15 @@ public class LinearPalette<T> implements Palette<T> {
|
|||||||
private final AtomicReference<AtomicReferenceArray<T>> palette;
|
private final AtomicReference<AtomicReferenceArray<T>> palette;
|
||||||
private final AtomicInteger size;
|
private final AtomicInteger size;
|
||||||
|
|
||||||
public LinearPalette(int initialSize)
|
public LinearPalette(int initialSize) {
|
||||||
{
|
|
||||||
this.size = new AtomicInteger(0);
|
this.size = new AtomicInteger(0);
|
||||||
this.palette = new AtomicReference<>(new AtomicReferenceArray<>(initialSize));
|
this.palette = new AtomicReference<>(new AtomicReferenceArray<>(initialSize));
|
||||||
|
palette.get().set(size.getAndIncrement(), null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public T get(int id) {
|
public T get(int id) {
|
||||||
if(id < 0 || id >= size.get())
|
if (id < 0 || id >= size.get()) {
|
||||||
{
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -53,12 +54,10 @@ public class LinearPalette<T> implements Palette<T> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void grow(int newLength) {
|
private void grow(int newLength) {
|
||||||
if(newLength > palette.get().length())
|
if (newLength > palette.get().length()) {
|
||||||
{
|
|
||||||
AtomicReferenceArray<T> a = new AtomicReferenceArray<>(newLength + size.get());
|
AtomicReferenceArray<T> a = new AtomicReferenceArray<>(newLength + size.get());
|
||||||
|
|
||||||
for(int i = 0; i < palette.get().length(); i++)
|
for (int i = 0; i < palette.get().length(); i++) {
|
||||||
{
|
|
||||||
a.set(i, palette.get().get(i));
|
a.set(i, palette.get().get(i));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -68,15 +67,13 @@ public class LinearPalette<T> implements Palette<T> {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int id(T t) {
|
public int id(T t) {
|
||||||
for(int i = 0; i < size(); i++)
|
if(t == null)
|
||||||
{
|
{
|
||||||
if(t == null && palette.get().get(i) == null)
|
return 0;
|
||||||
{
|
|
||||||
return i;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(t != null && t.equals(palette.get().get(i)))
|
for (int i = 1; i < size() + 1; i++) {
|
||||||
{
|
if (t.equals(palette.get().get(i))) {
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -86,13 +83,12 @@ public class LinearPalette<T> implements Palette<T> {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int size() {
|
public int size() {
|
||||||
return size.get();
|
return size.get()-1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void iterate(Consumer2<T, Integer> c) {
|
public void iterate(Consumer2<T, Integer> c) {
|
||||||
for(int i = 0; i < size(); i++)
|
for (int i = 1; i < size()+1; i++) {
|
||||||
{
|
|
||||||
c.accept(palette.get().get(i), i);
|
c.accept(palette.get().get(i), i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -34,18 +34,16 @@ public interface Palette<T> {
|
|||||||
|
|
||||||
int size();
|
int size();
|
||||||
|
|
||||||
default int bits()
|
default int bits() {
|
||||||
{
|
return DataContainer.bits(size()+1);
|
||||||
return DataContainer.bits(size());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void iterate(Consumer2<T, Integer> c);
|
void iterate(Consumer2<T, Integer> c);
|
||||||
|
|
||||||
default void iterateIO(Consumer2IO<T, Integer> c)
|
default void iterateIO(Consumer2IO<T, Integer> c) {
|
||||||
{
|
iterate((a, b) -> {
|
||||||
iterate((a,b)-> {
|
|
||||||
try {
|
try {
|
||||||
c.accept(a,b);
|
c.accept(a, b);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
@ -53,22 +51,19 @@ public interface Palette<T> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
default Palette<T> from(int size, Writable<T> writable, DataInputStream in) throws IOException {
|
default Palette<T> from(int size, Writable<T> writable, DataInputStream in) throws IOException {
|
||||||
for(int i = 0; i < size; i++)
|
for (int i = 0; i < size; i++) {
|
||||||
{
|
|
||||||
add(writable.readNodeData(in));
|
add(writable.readNodeData(in));
|
||||||
}
|
}
|
||||||
|
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
default Palette<T> from(Palette<T> oldPalette)
|
default Palette<T> from(Palette<T> oldPalette) {
|
||||||
{
|
oldPalette.iterate((k, v) -> add(k));
|
||||||
oldPalette.iterate((k,v) -> add(k));
|
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
default KList<T> list()
|
default KList<T> list() {
|
||||||
{
|
|
||||||
KList<T> t = new KList<>();
|
KList<T> t = new KList<>();
|
||||||
iterate((tx, __) -> t.add(tx));
|
iterate((tx, __) -> t.add(tx));
|
||||||
return t;
|
return t;
|
||||||
|
110
src/main/java/com/volmit/iris/util/hunk/bits/TecTest.java
Normal file
110
src/main/java/com/volmit/iris/util/hunk/bits/TecTest.java
Normal file
@ -0,0 +1,110 @@
|
|||||||
|
/*
|
||||||
|
* Iris is a World Generator for Minecraft Bukkit Servers
|
||||||
|
* Copyright (c) 2021 Arcane Arts (Volmit Software)
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.volmit.iris.util.hunk.bits;
|
||||||
|
|
||||||
|
import com.volmit.iris.Iris;
|
||||||
|
import com.volmit.iris.util.collection.KList;
|
||||||
|
import com.volmit.iris.util.collection.KSet;
|
||||||
|
import com.volmit.iris.util.format.Form;
|
||||||
|
import com.volmit.iris.util.io.IO;
|
||||||
|
import com.volmit.iris.util.math.RNG;
|
||||||
|
import com.volmit.iris.util.matter.slices.BlockMatter;
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.block.data.BlockData;
|
||||||
|
|
||||||
|
import java.io.ByteArrayInputStream;
|
||||||
|
import java.io.ByteArrayOutputStream;
|
||||||
|
import java.io.DataInputStream;
|
||||||
|
import java.io.DataOutputStream;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.nio.charset.StandardCharsets;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
public class TecTest {
|
||||||
|
public static Set<BlockData> randomBlocks(int max)
|
||||||
|
{
|
||||||
|
KSet<BlockData> d = new KSet<>();
|
||||||
|
|
||||||
|
while(d.size() < max)
|
||||||
|
{
|
||||||
|
Material m = Material.values()[RNG.r.i(Material.values().length - 1)];
|
||||||
|
if(m.isBlock())
|
||||||
|
{
|
||||||
|
d.add(m.createBlockData());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return d;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void go()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean test(int size, int pal)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
Iris.info("Test? " + size + " " + pal);
|
||||||
|
KList<BlockData> blocks = new KList<>(randomBlocks(pal));
|
||||||
|
Iris.info("Fill " + pal + " -> " + size + " Entries");
|
||||||
|
Writable<BlockData> writer = new BlockMatter();
|
||||||
|
DataContainer<BlockData> dc = new DataContainer<>(writer, size);
|
||||||
|
|
||||||
|
for(int i = 0; i < dc.size(); i++)
|
||||||
|
{
|
||||||
|
dc.set(i, blocks.getRandom());
|
||||||
|
}
|
||||||
|
|
||||||
|
Iris.info(dc.toString());
|
||||||
|
byte[] dat = dc.write();
|
||||||
|
DataContainer<BlockData> dx = new DataContainer<>(new DataInputStream(new ByteArrayInputStream(dat)), writer);
|
||||||
|
Iris.info(dx.toString());
|
||||||
|
byte[] dat2 = dx.write();
|
||||||
|
Iris.info("Size: " + Form.memSize(dat.length, 2) + " -> " + Form.memSize(dat2.length, 2));
|
||||||
|
|
||||||
|
if(Arrays.equals(dat, dat2)) {
|
||||||
|
Iris.info("MATCH");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
for(int i = 0; i < dc.size(); i++)
|
||||||
|
{
|
||||||
|
if(!dx.get(i).equals(dc.get(i)))
|
||||||
|
{
|
||||||
|
Iris.info("FAIL Expected " + dc.get(i).getAsString(true) + " but got " + dx.get(i).getAsString(true));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Iris.info("MATCH but different output?");
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
catch(Throwable e)
|
||||||
|
{
|
||||||
|
e.printStackTrace();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -27,7 +27,6 @@ import lombok.EqualsAndHashCode;
|
|||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.concurrent.atomic.AtomicBoolean;
|
|
||||||
|
|
||||||
@SuppressWarnings({"DefaultAnnotationParam", "Lombok"})
|
@SuppressWarnings({"DefaultAnnotationParam", "Lombok"})
|
||||||
@Data
|
@Data
|
||||||
|
@ -18,8 +18,6 @@
|
|||||||
|
|
||||||
package com.volmit.iris.util.hunk.storage;
|
package com.volmit.iris.util.hunk.storage;
|
||||||
|
|
||||||
import com.volmit.iris.util.collection.KMap;
|
|
||||||
import com.volmit.iris.util.data.palette.PalettedContainer;
|
|
||||||
import com.volmit.iris.util.function.Consumer4;
|
import com.volmit.iris.util.function.Consumer4;
|
||||||
import com.volmit.iris.util.function.Consumer4IO;
|
import com.volmit.iris.util.function.Consumer4IO;
|
||||||
import com.volmit.iris.util.hunk.Hunk;
|
import com.volmit.iris.util.hunk.Hunk;
|
||||||
@ -29,7 +27,7 @@ import lombok.Data;
|
|||||||
import lombok.EqualsAndHashCode;
|
import lombok.EqualsAndHashCode;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.Map;
|
import java.util.concurrent.locks.ReentrantLock;
|
||||||
|
|
||||||
@SuppressWarnings({"DefaultAnnotationParam", "Lombok"})
|
@SuppressWarnings({"DefaultAnnotationParam", "Lombok"})
|
||||||
@Data
|
@Data
|
||||||
@ -37,16 +35,15 @@ import java.util.Map;
|
|||||||
public class PaletteHunk<T> extends StorageHunk<T> implements Hunk<T> {
|
public class PaletteHunk<T> extends StorageHunk<T> implements Hunk<T> {
|
||||||
private DataContainer<T> data;
|
private DataContainer<T> data;
|
||||||
|
|
||||||
public PaletteHunk(int w, int h, int d, Writable<T> writer, T e) {
|
public PaletteHunk(int w, int h, int d, Writable<T> writer) {
|
||||||
super(w,h,d);
|
super(w, h, d);
|
||||||
data = new DataContainer<>(writer, w * h * d, e);
|
data = new DataContainer<>(writer, w * h * d);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setPalette(DataContainer<T> c) {
|
public void setPalette(DataContainer<T> c) {
|
||||||
data = c;
|
data = c;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public boolean isMapped() {
|
public boolean isMapped() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -57,16 +54,12 @@ public class PaletteHunk<T> extends StorageHunk<T> implements Hunk<T> {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public synchronized Hunk<T> iterateSync(Consumer4<Integer, Integer, Integer, T> c) {
|
public synchronized Hunk<T> iterateSync(Consumer4<Integer, Integer, Integer, T> c) {
|
||||||
for(int i = 0; i < getWidth(); i++)
|
for (int i = 0; i < getWidth(); i++) {
|
||||||
{
|
for (int j = 0; j < getHeight(); j++) {
|
||||||
for(int j = 0; j < getHeight(); j++)
|
for (int k = 0; k < getDepth(); k++) {
|
||||||
{
|
T t = getRaw(i, j, k);
|
||||||
for(int k = 0; k < getDepth(); k++)
|
if (t != null) {
|
||||||
{
|
c.accept(i, j, k, t);
|
||||||
T t = getRaw(i,j,k);
|
|
||||||
if(t != null)
|
|
||||||
{
|
|
||||||
c.accept(i,j,k,t);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -76,16 +69,12 @@ public class PaletteHunk<T> extends StorageHunk<T> implements Hunk<T> {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public synchronized Hunk<T> iterateSyncIO(Consumer4IO<Integer, Integer, Integer, T> c) throws IOException {
|
public synchronized Hunk<T> iterateSyncIO(Consumer4IO<Integer, Integer, Integer, T> c) throws IOException {
|
||||||
for(int i = 0; i < getWidth(); i++)
|
for (int i = 0; i < getWidth(); i++) {
|
||||||
{
|
for (int j = 0; j < getHeight(); j++) {
|
||||||
for(int j = 0; j < getHeight(); j++)
|
for (int k = 0; k < getDepth(); k++) {
|
||||||
{
|
T t = getRaw(i, j, k);
|
||||||
for(int k = 0; k < getDepth(); k++)
|
if (t != null) {
|
||||||
{
|
c.accept(i, j, k, t);
|
||||||
T t = getRaw(i,j,k);
|
|
||||||
if(t != null)
|
|
||||||
{
|
|
||||||
c.accept(i,j,k,t);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -18,7 +18,6 @@
|
|||||||
|
|
||||||
package com.volmit.iris.util.hunk.storage;
|
package com.volmit.iris.util.hunk.storage;
|
||||||
|
|
||||||
import com.volmit.iris.util.data.palette.PalettedContainer;
|
|
||||||
import com.volmit.iris.util.function.Consumer4;
|
import com.volmit.iris.util.function.Consumer4;
|
||||||
import com.volmit.iris.util.function.Consumer4IO;
|
import com.volmit.iris.util.function.Consumer4IO;
|
||||||
import com.volmit.iris.util.hunk.Hunk;
|
import com.volmit.iris.util.hunk.Hunk;
|
||||||
@ -26,41 +25,38 @@ import com.volmit.iris.util.hunk.bits.DataContainer;
|
|||||||
import com.volmit.iris.util.hunk.bits.Writable;
|
import com.volmit.iris.util.hunk.bits.Writable;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.Map;
|
|
||||||
import java.util.function.Supplier;
|
import java.util.function.Supplier;
|
||||||
|
|
||||||
public abstract class PaletteOrHunk<T> extends StorageHunk<T> implements Hunk<T>, Writable<T> {
|
public abstract class PaletteOrHunk<T> extends StorageHunk<T> implements Hunk<T>, Writable<T> {
|
||||||
private final Hunk<T> hunk;
|
private final Hunk<T> hunk;
|
||||||
public PaletteOrHunk(int width, int height, int depth, boolean allow, Supplier<Hunk<T>> factory, T e) {
|
|
||||||
|
public PaletteOrHunk(int width, int height, int depth, boolean allow, Supplier<Hunk<T>> factory) {
|
||||||
super(width, height, depth);
|
super(width, height, depth);
|
||||||
hunk = (allow) ? new PaletteHunk<>(width, height, depth, this, e) : factory.get();
|
hunk = (allow && (width * height * depth <= 4096)) ? new PaletteHunk<>(width, height, depth, this) : factory.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
public DataContainer<T> palette()
|
public DataContainer<T> palette() {
|
||||||
{
|
return isPalette() ? ((PaletteHunk<T>) hunk).getData() : null;
|
||||||
return isPalette() ? ((PaletteHunk<T>)hunk).getData() : null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setPalette(DataContainer<T> c) {
|
public void setPalette(DataContainer<T> c) {
|
||||||
if(isPalette())
|
if (isPalette()) {
|
||||||
{
|
((PaletteHunk<T>) hunk).setPalette(c);
|
||||||
((PaletteHunk<T>)hunk).setPalette(c);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isPalette()
|
public boolean isPalette() {
|
||||||
{
|
|
||||||
return hunk instanceof PaletteHunk;
|
return hunk instanceof PaletteHunk;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setRaw(int x, int y, int z, T t) {
|
public void setRaw(int x, int y, int z, T t) {
|
||||||
hunk.setRaw(x,y,z,t);
|
hunk.setRaw(x, y, z, t);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public T getRaw(int x, int y, int z) {
|
public T getRaw(int x, int y, int z) {
|
||||||
return hunk.getRaw(x,y,z);
|
return hunk.getRaw(x, y, z);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getEntryCount() {
|
public int getEntryCount() {
|
||||||
|
@ -19,13 +19,13 @@
|
|||||||
package com.volmit.iris.util.io;
|
package com.volmit.iris.util.io;
|
||||||
|
|
||||||
import com.volmit.iris.Iris;
|
import com.volmit.iris.Iris;
|
||||||
|
import com.volmit.iris.util.format.Form;
|
||||||
|
|
||||||
import java.io.BufferedInputStream;
|
import java.io.BufferedInputStream;
|
||||||
import java.io.BufferedReader;
|
import java.io.BufferedReader;
|
||||||
import java.io.ByteArrayInputStream;
|
import java.io.ByteArrayInputStream;
|
||||||
import java.io.ByteArrayOutputStream;
|
import java.io.ByteArrayOutputStream;
|
||||||
import java.io.CharArrayWriter;
|
import java.io.CharArrayWriter;
|
||||||
import java.io.DataOutputStream;
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileInputStream;
|
import java.io.FileInputStream;
|
||||||
import java.io.FileNotFoundException;
|
import java.io.FileNotFoundException;
|
||||||
@ -163,19 +163,22 @@ public class IO {
|
|||||||
return new String(hexChars).toUpperCase();
|
return new String(hexChars).toUpperCase();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static String print(byte[] bytes) {
|
||||||
|
return Form.memSize(bytes.length, 2) + "[" + bytesToHex(bytes) + "]";
|
||||||
|
}
|
||||||
|
|
||||||
public static String longsToHex(long[] bytes) {
|
public static String longsToHex(long[] bytes) {
|
||||||
byte[] v = new byte[bytes.length * 8];
|
byte[] v = new byte[bytes.length * 8];
|
||||||
|
|
||||||
for(int i = 0; i < bytes.length; i++)
|
for (int i = 0; i < bytes.length; i++) {
|
||||||
{
|
v[i * 8] = (byte) (bytes[i] >>> 56);
|
||||||
v[i * 8] = (byte)(bytes[i] >>> 56);
|
v[(i * 8) + 1] = (byte) (bytes[i] >>> 48);
|
||||||
v[(i * 8) + 1] = (byte)(bytes[i] >>> 48);
|
v[(i * 8) + 2] = (byte) (bytes[i] >>> 40);
|
||||||
v[(i * 8) + 2] = (byte)(bytes[i] >>> 40);
|
v[(i * 8) + 3] = (byte) (bytes[i] >>> 32);
|
||||||
v[(i * 8) + 3] = (byte)(bytes[i] >>> 32);
|
v[(i * 8) + 4] = (byte) (bytes[i] >>> 24);
|
||||||
v[(i * 8) + 4] = (byte)(bytes[i] >>> 24);
|
v[(i * 8) + 5] = (byte) (bytes[i] >>> 16);
|
||||||
v[(i * 8) + 5] = (byte)(bytes[i] >>> 16);
|
v[(i * 8) + 6] = (byte) (bytes[i] >>> 8);
|
||||||
v[(i * 8) + 6] = (byte)(bytes[i] >>> 8);
|
v[(i * 8) + 7] = (byte) (bytes[i] >>> 0);
|
||||||
v[(i * 8) + 7] = (byte)(bytes[i] >>> 0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return bytesToHex(v);
|
return bytesToHex(v);
|
||||||
|
@ -38,7 +38,6 @@ import com.volmit.iris.util.matter.MatterSlice;
|
|||||||
import com.volmit.iris.util.parallel.BurstExecutor;
|
import com.volmit.iris.util.parallel.BurstExecutor;
|
||||||
import com.volmit.iris.util.parallel.HyperLock;
|
import com.volmit.iris.util.parallel.HyperLock;
|
||||||
import com.volmit.iris.util.parallel.MultiBurst;
|
import com.volmit.iris.util.parallel.MultiBurst;
|
||||||
import com.volmit.iris.util.scheduling.J;
|
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import org.bukkit.Chunk;
|
import org.bukkit.Chunk;
|
||||||
|
|
||||||
@ -477,6 +476,7 @@ public class Mantle {
|
|||||||
|
|
||||||
if (file.exists()) {
|
if (file.exists()) {
|
||||||
try {
|
try {
|
||||||
|
Iris.addPanic("reading.tectonic-plate", file.getAbsolutePath());
|
||||||
region = TectonicPlate.read(worldHeight, file);
|
region = TectonicPlate.read(worldHeight, file);
|
||||||
|
|
||||||
if (region.getX() != x || region.getZ() != z) {
|
if (region.getX() != x || region.getZ() != z) {
|
||||||
@ -488,6 +488,8 @@ public class Mantle {
|
|||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
Iris.error("Failed to read Tectonic Plate " + file.getAbsolutePath() + " creating a new chunk instead.");
|
Iris.error("Failed to read Tectonic Plate " + file.getAbsolutePath() + " creating a new chunk instead.");
|
||||||
Iris.reportError(e);
|
Iris.reportError(e);
|
||||||
|
e.printStackTrace();
|
||||||
|
Iris.panic();
|
||||||
region = new TectonicPlate(worldHeight, x, z);
|
region = new TectonicPlate(worldHeight, x, z);
|
||||||
loadedRegions.put(k, region);
|
loadedRegions.put(k, region);
|
||||||
Iris.debug("Created new Tectonic Plate (Due to Load Failure) " + C.DARK_GREEN + x + " " + z);
|
Iris.debug("Created new Tectonic Plate (Due to Load Failure) " + C.DARK_GREEN + x + " " + z);
|
||||||
|
@ -18,6 +18,8 @@
|
|||||||
|
|
||||||
package com.volmit.iris.util.mantle;
|
package com.volmit.iris.util.mantle;
|
||||||
|
|
||||||
|
import com.volmit.iris.Iris;
|
||||||
|
import com.volmit.iris.engine.EnginePanic;
|
||||||
import com.volmit.iris.util.documentation.ChunkCoordinates;
|
import com.volmit.iris.util.documentation.ChunkCoordinates;
|
||||||
import com.volmit.iris.util.function.Consumer4;
|
import com.volmit.iris.util.function.Consumer4;
|
||||||
import com.volmit.iris.util.matter.IrisMatter;
|
import com.volmit.iris.util.matter.IrisMatter;
|
||||||
@ -77,8 +79,9 @@ public class MantleChunk {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < s; i++) {
|
for (int i = 0; i < s; i++) {
|
||||||
|
Iris.addPanic("read.section", "Section[" + i + "]");
|
||||||
if (din.readBoolean()) {
|
if (din.readBoolean()) {
|
||||||
sections.set(i, Matter.read(din));
|
sections.set(i, Matter.readDin(din));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -19,13 +19,11 @@
|
|||||||
package com.volmit.iris.util.mantle;
|
package com.volmit.iris.util.mantle;
|
||||||
|
|
||||||
import com.volmit.iris.Iris;
|
import com.volmit.iris.Iris;
|
||||||
|
import com.volmit.iris.engine.EnginePanic;
|
||||||
import com.volmit.iris.engine.data.cache.Cache;
|
import com.volmit.iris.engine.data.cache.Cache;
|
||||||
import com.volmit.iris.util.collection.KMap;
|
|
||||||
import com.volmit.iris.util.documentation.ChunkCoordinates;
|
import com.volmit.iris.util.documentation.ChunkCoordinates;
|
||||||
import com.volmit.iris.util.format.C;
|
import com.volmit.iris.util.format.C;
|
||||||
import com.volmit.iris.util.format.Form;
|
import com.volmit.iris.util.format.Form;
|
||||||
import com.volmit.iris.util.matter.Matter;
|
|
||||||
import com.volmit.iris.util.nbt.mca.Section;
|
|
||||||
import com.volmit.iris.util.scheduling.PrecisionStopwatch;
|
import com.volmit.iris.util.scheduling.PrecisionStopwatch;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
|
|
||||||
@ -77,7 +75,9 @@ public class TectonicPlate {
|
|||||||
this(worldHeight, din.readInt(), din.readInt());
|
this(worldHeight, din.readInt(), din.readInt());
|
||||||
for (int i = 0; i < chunks.length(); i++) {
|
for (int i = 0; i < chunks.length(); i++) {
|
||||||
if (din.readBoolean()) {
|
if (din.readBoolean()) {
|
||||||
|
Iris.addPanic("read-chunk", "Chunk[" + i + "]");
|
||||||
chunks.set(i, new MantleChunk(sectionHeight, din));
|
chunks.set(i, new MantleChunk(sectionHeight, din));
|
||||||
|
EnginePanic.saveLast();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -44,6 +44,11 @@ public class IrisMatter extends IrisRegistrant implements Matter {
|
|||||||
private final KMap<Class<?>, MatterSlice<?>> sliceMap;
|
private final KMap<Class<?>, MatterSlice<?>> sliceMap;
|
||||||
|
|
||||||
public IrisMatter(int width, int height, int depth) {
|
public IrisMatter(int width, int height, int depth) {
|
||||||
|
if(width < 1 || height < 1 || depth < 1)
|
||||||
|
{
|
||||||
|
throw new RuntimeException("Invalid Matter Size " + width + "x" + height + "x" + depth);
|
||||||
|
}
|
||||||
|
|
||||||
this.width = width;
|
this.width = width;
|
||||||
this.height = height;
|
this.height = height;
|
||||||
this.depth = depth;
|
this.depth = depth;
|
||||||
|
@ -18,6 +18,7 @@
|
|||||||
|
|
||||||
package com.volmit.iris.util.matter;
|
package com.volmit.iris.util.matter;
|
||||||
|
|
||||||
|
import com.volmit.iris.Iris;
|
||||||
import com.volmit.iris.engine.object.IrisObject;
|
import com.volmit.iris.engine.object.IrisObject;
|
||||||
import com.volmit.iris.engine.object.IrisPosition;
|
import com.volmit.iris.engine.object.IrisPosition;
|
||||||
import com.volmit.iris.util.collection.KSet;
|
import com.volmit.iris.util.collection.KSet;
|
||||||
@ -95,6 +96,10 @@ public interface Matter {
|
|||||||
return read(in, (b) -> new IrisMatter(b.getX(), b.getY(), b.getZ()));
|
return read(in, (b) -> new IrisMatter(b.getX(), b.getY(), b.getZ()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static Matter readDin(DataInputStream in) throws IOException, ClassNotFoundException {
|
||||||
|
return readDin(in, (b) -> new IrisMatter(b.getX(), b.getY(), b.getZ()));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reads the input stream into a matter object using a matter factory.
|
* Reads the input stream into a matter object using a matter factory.
|
||||||
* Does not close the input stream. Be a man, close it yourself.
|
* Does not close the input stream. Be a man, close it yourself.
|
||||||
@ -105,16 +110,26 @@ public interface Matter {
|
|||||||
* @throws IOException shit happens yo
|
* @throws IOException shit happens yo
|
||||||
*/
|
*/
|
||||||
static Matter read(InputStream in, Function<BlockPosition, Matter> matterFactory) throws IOException, ClassNotFoundException {
|
static Matter read(InputStream in, Function<BlockPosition, Matter> matterFactory) throws IOException, ClassNotFoundException {
|
||||||
DataInputStream din = new DataInputStream(in);
|
return readDin(new DataInputStream(in), matterFactory);
|
||||||
Matter matter = matterFactory.apply(new BlockPosition(
|
}
|
||||||
Varint.readUnsignedVarInt(din),
|
|
||||||
Varint.readUnsignedVarInt(din),
|
|
||||||
Varint.readUnsignedVarInt(din)));
|
|
||||||
int sliceCount = din.readByte();
|
|
||||||
matter.getHeader().read(din);
|
|
||||||
|
|
||||||
while (sliceCount-- > 0) {
|
static Matter readDin(DataInputStream din, Function<BlockPosition, Matter> matterFactory) throws IOException, ClassNotFoundException {
|
||||||
|
Matter matter = matterFactory.apply(new BlockPosition(
|
||||||
|
din.readInt(),
|
||||||
|
din.readInt(),
|
||||||
|
din.readInt()));
|
||||||
|
Iris.addPanic("read.matter.size", matter.getWidth() + "x" + matter.getHeight() + "x" + matter.getDepth());
|
||||||
|
int sliceCount = din.readByte();
|
||||||
|
Iris.addPanic("read.matter.slicecount", sliceCount + "");
|
||||||
|
|
||||||
|
matter.getHeader().read(din);
|
||||||
|
Iris.addPanic("read.matter.header", matter.getHeader().toString());
|
||||||
|
|
||||||
|
for(int i = 0; i < sliceCount; i++)
|
||||||
|
{
|
||||||
|
Iris.addPanic("read.matter.slice", i + "");
|
||||||
String cn = din.readUTF();
|
String cn = din.readUTF();
|
||||||
|
Iris.addPanic("read.matter.slice.class", cn);
|
||||||
try {
|
try {
|
||||||
Class<?> type = Class.forName(cn);
|
Class<?> type = Class.forName(cn);
|
||||||
MatterSlice<?> slice = matter.createSlice(type, matter);
|
MatterSlice<?> slice = matter.createSlice(type, matter);
|
||||||
@ -336,10 +351,6 @@ public interface Matter {
|
|||||||
Map<Class<?>, MatterSlice<?>> getSliceMap();
|
Map<Class<?>, MatterSlice<?>> getSliceMap();
|
||||||
|
|
||||||
default void write(File f) throws IOException {
|
default void write(File f) throws IOException {
|
||||||
write(f, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
default void write(File f, boolean compression) throws IOException {
|
|
||||||
OutputStream out = new FileOutputStream(f);
|
OutputStream out = new FileOutputStream(f);
|
||||||
write(out);
|
write(out);
|
||||||
out.close();
|
out.close();
|
||||||
@ -381,9 +392,9 @@ public interface Matter {
|
|||||||
|
|
||||||
default void writeDos(DataOutputStream dos) throws IOException {
|
default void writeDos(DataOutputStream dos) throws IOException {
|
||||||
trimSlices();
|
trimSlices();
|
||||||
Varint.writeUnsignedVarInt(getWidth(), dos);
|
dos.writeInt(getWidth());
|
||||||
Varint.writeUnsignedVarInt(getHeight(), dos);
|
dos.writeInt(getHeight());
|
||||||
Varint.writeUnsignedVarInt(getDepth(), dos);
|
dos.writeInt(getDepth());
|
||||||
dos.writeByte(getSliceTypes().size());
|
dos.writeByte(getSliceTypes().size());
|
||||||
getHeader().write(dos);
|
getHeader().write(dos);
|
||||||
|
|
||||||
|
@ -34,13 +34,13 @@ public class MatterHeader {
|
|||||||
|
|
||||||
public void write(DataOutputStream out) throws IOException {
|
public void write(DataOutputStream out) throws IOException {
|
||||||
out.writeUTF(author);
|
out.writeUTF(author);
|
||||||
Varint.writeUnsignedVarLong(createdAt, out);
|
out.writeLong(createdAt);
|
||||||
Varint.writeUnsignedVarInt(version, out);
|
out.writeShort(version);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void read(DataInputStream din) throws IOException {
|
public void read(DataInputStream din) throws IOException {
|
||||||
setAuthor(din.readUTF());
|
setAuthor(din.readUTF());
|
||||||
setCreatedAt(Varint.readUnsignedVarLong(din));
|
setCreatedAt(din.readLong());
|
||||||
setVersion(Varint.readUnsignedVarInt(din));
|
setVersion(din.readShort());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -19,12 +19,10 @@
|
|||||||
package com.volmit.iris.util.matter;
|
package com.volmit.iris.util.matter;
|
||||||
|
|
||||||
import com.volmit.iris.Iris;
|
import com.volmit.iris.Iris;
|
||||||
import com.volmit.iris.core.IrisSettings;
|
|
||||||
import com.volmit.iris.engine.data.cache.Cache;
|
import com.volmit.iris.engine.data.cache.Cache;
|
||||||
import com.volmit.iris.util.data.Varint;
|
import com.volmit.iris.util.data.Varint;
|
||||||
import com.volmit.iris.util.data.palette.Palette;
|
import com.volmit.iris.util.data.palette.Palette;
|
||||||
import com.volmit.iris.util.data.palette.PaletteType;
|
import com.volmit.iris.util.data.palette.PaletteType;
|
||||||
import com.volmit.iris.util.data.palette.PalettedContainer;
|
|
||||||
import com.volmit.iris.util.hunk.Hunk;
|
import com.volmit.iris.util.hunk.Hunk;
|
||||||
import com.volmit.iris.util.hunk.bits.DataContainer;
|
import com.volmit.iris.util.hunk.bits.DataContainer;
|
||||||
import com.volmit.iris.util.hunk.bits.Writable;
|
import com.volmit.iris.util.hunk.bits.Writable;
|
||||||
@ -38,8 +36,6 @@ import org.bukkit.util.BlockVector;
|
|||||||
import java.io.DataInputStream;
|
import java.io.DataInputStream;
|
||||||
import java.io.DataOutputStream;
|
import java.io.DataOutputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public interface MatterSlice<T> extends Hunk<T>, PaletteType<T>, Writable<T> {
|
public interface MatterSlice<T> extends Hunk<T>, PaletteType<T>, Writable<T> {
|
||||||
Class<T> getType();
|
Class<T> getType();
|
||||||
@ -164,8 +160,8 @@ public interface MatterSlice<T> extends Hunk<T>, PaletteType<T>, Writable<T> {
|
|||||||
|
|
||||||
default void write(DataOutputStream dos) throws IOException {
|
default void write(DataOutputStream dos) throws IOException {
|
||||||
dos.writeUTF(getType().getCanonicalName());
|
dos.writeUTF(getType().getCanonicalName());
|
||||||
if((this instanceof PaletteOrHunk f && f.isPalette()))
|
|
||||||
{
|
if ((this instanceof PaletteOrHunk f && f.isPalette())) {
|
||||||
f.palette().writeDos(dos);
|
f.palette().writeDos(dos);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -189,8 +185,7 @@ public interface MatterSlice<T> extends Hunk<T>, PaletteType<T>, Writable<T> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
default void read(DataInputStream din) throws IOException {
|
default void read(DataInputStream din) throws IOException {
|
||||||
if((this instanceof PaletteOrHunk f && f.isPalette()))
|
if ((this instanceof PaletteOrHunk f && f.isPalette())) {
|
||||||
{
|
|
||||||
f.setPalette(new DataContainer<>(din, this));
|
f.setPalette(new DataContainer<>(din, this));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -21,10 +21,10 @@ package com.volmit.iris.util.matter.slices;
|
|||||||
import com.volmit.iris.util.data.B;
|
import com.volmit.iris.util.data.B;
|
||||||
import com.volmit.iris.util.data.palette.Palette;
|
import com.volmit.iris.util.data.palette.Palette;
|
||||||
import com.volmit.iris.util.matter.Sliced;
|
import com.volmit.iris.util.matter.Sliced;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.bukkit.block.data.BlockData;
|
import org.bukkit.block.data.BlockData;
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
|
|
||||||
import java.io.DataInputStream;
|
import java.io.DataInputStream;
|
||||||
import java.io.DataOutputStream;
|
import java.io.DataOutputStream;
|
||||||
@ -44,7 +44,7 @@ public class BlockMatter extends RawMatter<BlockData> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public BlockMatter(int width, int height, int depth) {
|
public BlockMatter(int width, int height, int depth) {
|
||||||
super(width, height, depth, BlockData.class, AIR);
|
super(width, height, depth, BlockData.class);
|
||||||
registerWriter(World.class, ((w, d, x, y, z) -> w.getBlockAt(x, y, z).setBlockData(d)));
|
registerWriter(World.class, ((w, d, x, y, z) -> w.getBlockAt(x, y, z).setBlockData(d)));
|
||||||
registerReader(World.class, (w, x, y, z) -> {
|
registerReader(World.class, (w, x, y, z) -> {
|
||||||
BlockData d = w.getBlockAt(x, y, z).getBlockData();
|
BlockData d = w.getBlockAt(x, y, z).getBlockData();
|
||||||
@ -59,6 +59,6 @@ public class BlockMatter extends RawMatter<BlockData> {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BlockData readNode(DataInputStream din) throws IOException {
|
public BlockData readNode(DataInputStream din) throws IOException {
|
||||||
return B.get(din.readUTF());
|
return Bukkit.createBlockData(din.readUTF());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -20,7 +20,6 @@ package com.volmit.iris.util.matter.slices;
|
|||||||
|
|
||||||
import com.volmit.iris.util.data.palette.Palette;
|
import com.volmit.iris.util.data.palette.Palette;
|
||||||
import com.volmit.iris.util.matter.Sliced;
|
import com.volmit.iris.util.matter.Sliced;
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
|
|
||||||
import java.io.DataInputStream;
|
import java.io.DataInputStream;
|
||||||
import java.io.DataOutputStream;
|
import java.io.DataOutputStream;
|
||||||
@ -38,7 +37,7 @@ public class BooleanMatter extends RawMatter<Boolean> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public BooleanMatter(int width, int height, int depth) {
|
public BooleanMatter(int width, int height, int depth) {
|
||||||
super(width, height, depth, Boolean.class, false);
|
super(width, height, depth, Boolean.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -21,7 +21,6 @@ package com.volmit.iris.util.matter.slices;
|
|||||||
import com.volmit.iris.util.data.palette.Palette;
|
import com.volmit.iris.util.data.palette.Palette;
|
||||||
import com.volmit.iris.util.matter.MatterCavern;
|
import com.volmit.iris.util.matter.MatterCavern;
|
||||||
import com.volmit.iris.util.matter.Sliced;
|
import com.volmit.iris.util.matter.Sliced;
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
|
|
||||||
import java.io.DataInputStream;
|
import java.io.DataInputStream;
|
||||||
import java.io.DataOutputStream;
|
import java.io.DataOutputStream;
|
||||||
@ -41,7 +40,7 @@ public class CavernMatter extends RawMatter<MatterCavern> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public CavernMatter(int width, int height, int depth) {
|
public CavernMatter(int width, int height, int depth) {
|
||||||
super(width, height, depth, MatterCavern.class, EMPTY);
|
super(width, height, depth, MatterCavern.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static MatterCavern get(String customBiome, int liquid) {
|
public static MatterCavern get(String customBiome, int liquid) {
|
||||||
|
@ -33,7 +33,6 @@ import com.volmit.iris.util.nbt.tag.CompoundTag;
|
|||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.bukkit.util.BoundingBox;
|
import org.bukkit.util.BoundingBox;
|
||||||
|
|
||||||
import java.io.DataInputStream;
|
import java.io.DataInputStream;
|
||||||
@ -55,7 +54,7 @@ public class EntityMatter extends RawMatter<MatterEntityGroup> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public EntityMatter(int width, int height, int depth) {
|
public EntityMatter(int width, int height, int depth) {
|
||||||
super(width, height, depth, MatterEntityGroup.class, EMPTY);
|
super(width, height, depth, MatterEntityGroup.class);
|
||||||
registerWriter(World.class, ((w, d, x, y, z) -> {
|
registerWriter(World.class, ((w, d, x, y, z) -> {
|
||||||
for (MatterEntity i : d.getEntities()) {
|
for (MatterEntity i : d.getEntities()) {
|
||||||
Location realPosition = new Location(w, x + i.getXOff(), y + i.getYOff(), z + i.getZOff());
|
Location realPosition = new Location(w, x + i.getXOff(), y + i.getYOff(), z + i.getZOff());
|
||||||
|
@ -21,7 +21,6 @@ package com.volmit.iris.util.matter.slices;
|
|||||||
import com.volmit.iris.util.data.Varint;
|
import com.volmit.iris.util.data.Varint;
|
||||||
import com.volmit.iris.util.data.palette.Palette;
|
import com.volmit.iris.util.data.palette.Palette;
|
||||||
import com.volmit.iris.util.matter.Sliced;
|
import com.volmit.iris.util.matter.Sliced;
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
|
|
||||||
import java.io.DataInputStream;
|
import java.io.DataInputStream;
|
||||||
import java.io.DataOutputStream;
|
import java.io.DataOutputStream;
|
||||||
@ -39,7 +38,7 @@ public class IntMatter extends RawMatter<Integer> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public IntMatter(int width, int height, int depth) {
|
public IntMatter(int width, int height, int depth) {
|
||||||
super(width, height, depth, Integer.class, 0);
|
super(width, height, depth, Integer.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -21,7 +21,6 @@ package com.volmit.iris.util.matter.slices;
|
|||||||
import com.volmit.iris.util.data.Varint;
|
import com.volmit.iris.util.data.Varint;
|
||||||
import com.volmit.iris.util.data.palette.Palette;
|
import com.volmit.iris.util.data.palette.Palette;
|
||||||
import com.volmit.iris.util.matter.Sliced;
|
import com.volmit.iris.util.matter.Sliced;
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
|
|
||||||
import java.io.DataInputStream;
|
import java.io.DataInputStream;
|
||||||
import java.io.DataOutputStream;
|
import java.io.DataOutputStream;
|
||||||
@ -39,7 +38,7 @@ public class LongMatter extends RawMatter<Long> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public LongMatter(int width, int height, int depth) {
|
public LongMatter(int width, int height, int depth) {
|
||||||
super(width, height, depth, Long.class, 0L);
|
super(width, height, depth, Long.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -22,7 +22,6 @@ import com.volmit.iris.util.collection.KMap;
|
|||||||
import com.volmit.iris.util.data.palette.Palette;
|
import com.volmit.iris.util.data.palette.Palette;
|
||||||
import com.volmit.iris.util.matter.MatterMarker;
|
import com.volmit.iris.util.matter.MatterMarker;
|
||||||
import com.volmit.iris.util.matter.Sliced;
|
import com.volmit.iris.util.matter.Sliced;
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
|
|
||||||
import java.io.DataInputStream;
|
import java.io.DataInputStream;
|
||||||
import java.io.DataOutputStream;
|
import java.io.DataOutputStream;
|
||||||
@ -45,7 +44,7 @@ public class MarkerMatter extends RawMatter<MatterMarker> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public MarkerMatter(int width, int height, int depth) {
|
public MarkerMatter(int width, int height, int depth) {
|
||||||
super(width, height, depth, MatterMarker.class, NONE);
|
super(width, height, depth, MatterMarker.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -20,10 +20,7 @@ package com.volmit.iris.util.matter.slices;
|
|||||||
|
|
||||||
import com.volmit.iris.util.data.palette.Palette;
|
import com.volmit.iris.util.data.palette.Palette;
|
||||||
import com.volmit.iris.util.nbt.io.NBTUtil;
|
import com.volmit.iris.util.nbt.io.NBTUtil;
|
||||||
import com.volmit.iris.util.nbt.tag.CompoundTag;
|
|
||||||
import com.volmit.iris.util.nbt.tag.IntTag;
|
|
||||||
import com.volmit.iris.util.nbt.tag.Tag;
|
import com.volmit.iris.util.nbt.tag.Tag;
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
|
|
||||||
import java.io.DataInputStream;
|
import java.io.DataInputStream;
|
||||||
import java.io.DataOutputStream;
|
import java.io.DataOutputStream;
|
||||||
@ -31,7 +28,7 @@ import java.io.IOException;
|
|||||||
|
|
||||||
public class NBTMatter<T extends Tag<?>> extends RawMatter<T> {
|
public class NBTMatter<T extends Tag<?>> extends RawMatter<T> {
|
||||||
public NBTMatter(int width, int height, int depth, Class<T> c, T e) {
|
public NBTMatter(int width, int height, int depth, Class<T> c, T e) {
|
||||||
super(width, height, depth, c, e);
|
super(width, height, depth, c);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -19,7 +19,6 @@
|
|||||||
package com.volmit.iris.util.matter.slices;
|
package com.volmit.iris.util.matter.slices;
|
||||||
|
|
||||||
import com.volmit.iris.util.collection.KMap;
|
import com.volmit.iris.util.collection.KMap;
|
||||||
import com.volmit.iris.util.hunk.bits.Writable;
|
|
||||||
import com.volmit.iris.util.hunk.storage.MappedHunk;
|
import com.volmit.iris.util.hunk.storage.MappedHunk;
|
||||||
import com.volmit.iris.util.hunk.storage.PaletteOrHunk;
|
import com.volmit.iris.util.hunk.storage.PaletteOrHunk;
|
||||||
import com.volmit.iris.util.matter.MatterReader;
|
import com.volmit.iris.util.matter.MatterReader;
|
||||||
@ -37,8 +36,8 @@ public abstract class RawMatter<T> extends PaletteOrHunk<T> implements MatterSli
|
|||||||
@Getter
|
@Getter
|
||||||
private final Class<T> type;
|
private final Class<T> type;
|
||||||
|
|
||||||
public RawMatter(int width, int height, int depth, Class<T> type, T e) {
|
public RawMatter(int width, int height, int depth, Class<T> type) {
|
||||||
super(width, height, depth, false, () -> new MappedHunk<>(width, height, depth), e);
|
super(width, height, depth, true, () -> new MappedHunk<>(width, height, depth));
|
||||||
writers = new KMap<>();
|
writers = new KMap<>();
|
||||||
readers = new KMap<>();
|
readers = new KMap<>();
|
||||||
this.type = type;
|
this.type = type;
|
||||||
|
@ -21,7 +21,6 @@ package com.volmit.iris.util.matter.slices;
|
|||||||
import com.volmit.iris.core.loader.IrisRegistrant;
|
import com.volmit.iris.core.loader.IrisRegistrant;
|
||||||
import com.volmit.iris.util.context.IrisContext;
|
import com.volmit.iris.util.context.IrisContext;
|
||||||
import com.volmit.iris.util.data.palette.Palette;
|
import com.volmit.iris.util.data.palette.Palette;
|
||||||
import com.volmit.iris.util.matter.MatterTile;
|
|
||||||
|
|
||||||
import java.io.DataInputStream;
|
import java.io.DataInputStream;
|
||||||
import java.io.DataOutputStream;
|
import java.io.DataOutputStream;
|
||||||
@ -29,7 +28,7 @@ import java.io.IOException;
|
|||||||
|
|
||||||
public class RegistryMatter<T extends IrisRegistrant> extends RawMatter<T> {
|
public class RegistryMatter<T extends IrisRegistrant> extends RawMatter<T> {
|
||||||
public RegistryMatter(int width, int height, int depth, Class<T> c, T e) {
|
public RegistryMatter(int width, int height, int depth, Class<T> c, T e) {
|
||||||
super(width, height, depth, c, e);
|
super(width, height, depth, c);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -32,7 +32,7 @@ public class StringMatter extends RawMatter<String> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public StringMatter(int width, int height, int depth) {
|
public StringMatter(int width, int height, int depth) {
|
||||||
super(width, height, depth, String.class, "");
|
super(width, height, depth, String.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -45,7 +45,7 @@ public class TileMatter extends RawMatter<MatterTile> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public TileMatter(int width, int height, int depth) {
|
public TileMatter(int width, int height, int depth) {
|
||||||
super(width, height, depth, MatterTile.class, EMPTY);
|
super(width, height, depth, MatterTile.class);
|
||||||
registerWriter(World.class, ((w, d, x, y, z) -> INMS.get().deserializeTile(d.getTileData(), new Location(w, x, y, z))));
|
registerWriter(World.class, ((w, d, x, y, z) -> INMS.get().deserializeTile(d.getTileData(), new Location(w, x, y, z))));
|
||||||
registerReader(World.class, (w, x, y, z) -> {
|
registerReader(World.class, (w, x, y, z) -> {
|
||||||
Location l = new Location(w, x, y, z);
|
Location l = new Location(w, x, y, z);
|
||||||
|
@ -20,7 +20,6 @@ package com.volmit.iris.util.matter.slices;
|
|||||||
|
|
||||||
import com.volmit.iris.util.data.palette.GlobalPalette;
|
import com.volmit.iris.util.data.palette.GlobalPalette;
|
||||||
import com.volmit.iris.util.data.palette.Palette;
|
import com.volmit.iris.util.data.palette.Palette;
|
||||||
import com.volmit.iris.util.matter.MatterTile;
|
|
||||||
import com.volmit.iris.util.matter.MatterUpdate;
|
import com.volmit.iris.util.matter.MatterUpdate;
|
||||||
import com.volmit.iris.util.matter.Sliced;
|
import com.volmit.iris.util.matter.Sliced;
|
||||||
|
|
||||||
@ -44,7 +43,7 @@ public class UpdateMatter extends RawMatter<MatterUpdate> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public UpdateMatter(int width, int height, int depth) {
|
public UpdateMatter(int width, int height, int depth) {
|
||||||
super(width, height, depth, MatterUpdate.class, OFF);
|
super(width, height, depth, MatterUpdate.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -253,7 +253,13 @@ public class Chunk {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public CompoundTag getBlockStateAt(int blockX, int blockY, int blockZ) {
|
public CompoundTag getBlockStateAt(int blockX, int blockY, int blockZ) {
|
||||||
Section section = sections.get(MCAUtil.blockToChunk(blockY));
|
int s = MCAUtil.blockToChunk(blockY);
|
||||||
|
|
||||||
|
if (sections.length() <= s) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
Section section = sections.get(s);
|
||||||
if (section == null) {
|
if (section == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@ -274,6 +280,11 @@ public class Chunk {
|
|||||||
*/
|
*/
|
||||||
public void setBlockStateAt(int blockX, int blockY, int blockZ, CompoundTag state, boolean cleanup) {
|
public void setBlockStateAt(int blockX, int blockY, int blockZ, CompoundTag state, boolean cleanup) {
|
||||||
int sectionIndex = MCAUtil.blockToChunk(blockY);
|
int sectionIndex = MCAUtil.blockToChunk(blockY);
|
||||||
|
|
||||||
|
if (sections.length() <= sectionIndex) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
Section section = sections.get(sectionIndex);
|
Section section = sections.get(sectionIndex);
|
||||||
if (section == null) {
|
if (section == null) {
|
||||||
section = Section.newSection();
|
section = Section.newSection();
|
||||||
|
@ -18,7 +18,6 @@
|
|||||||
|
|
||||||
package com.volmit.iris.util.nbt.mca;
|
package com.volmit.iris.util.nbt.mca;
|
||||||
|
|
||||||
import com.volmit.iris.core.pregenerator.syndicate.SyndicateServer;
|
|
||||||
import com.volmit.iris.util.collection.KList;
|
import com.volmit.iris.util.collection.KList;
|
||||||
import com.volmit.iris.util.math.Position2;
|
import com.volmit.iris.util.math.Position2;
|
||||||
import com.volmit.iris.util.nbt.tag.CompoundTag;
|
import com.volmit.iris.util.nbt.tag.CompoundTag;
|
||||||
|
@ -79,8 +79,7 @@ public class MCALinearPalette<T> implements MCAPalette<T> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void read(ListTag var0) {
|
public void read(ListTag var0) {
|
||||||
for (int var1 = 0; var1 < var0.size(); var1++)
|
for (int var1 = 0; var1 < var0.size(); var1++) {
|
||||||
{
|
|
||||||
this.values[var1] = this.reader.apply((CompoundTag) var0.get(var1));
|
this.values[var1] = this.reader.apply((CompoundTag) var0.get(var1));
|
||||||
}
|
}
|
||||||
this.size = var0.size();
|
this.size = var0.size();
|
||||||
|
@ -23,6 +23,7 @@ import com.volmit.iris.core.IrisSettings;
|
|||||||
import com.volmit.iris.core.service.PreservationSVC;
|
import com.volmit.iris.core.service.PreservationSVC;
|
||||||
import com.volmit.iris.util.collection.KList;
|
import com.volmit.iris.util.collection.KList;
|
||||||
import com.volmit.iris.util.math.M;
|
import com.volmit.iris.util.math.M;
|
||||||
|
import com.volmit.iris.util.scheduling.PrecisionStopwatch;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.concurrent.Callable;
|
import java.util.concurrent.Callable;
|
||||||
@ -151,9 +152,21 @@ public class MultiBurst {
|
|||||||
public void close() {
|
public void close() {
|
||||||
if (service != null) {
|
if (service != null) {
|
||||||
service.shutdown();
|
service.shutdown();
|
||||||
|
PrecisionStopwatch p = PrecisionStopwatch.start();
|
||||||
try {
|
try {
|
||||||
while (!service.awaitTermination(10, TimeUnit.SECONDS)) {
|
while (!service.awaitTermination(1, TimeUnit.SECONDS)) {
|
||||||
Iris.info("Still waiting to shutdown burster...");
|
Iris.info("Still waiting to shutdown burster...");
|
||||||
|
if (p.getMilliseconds() > 7000) {
|
||||||
|
Iris.warn("Forcing Shutdown...");
|
||||||
|
|
||||||
|
try {
|
||||||
|
service.shutdownNow();
|
||||||
|
} catch (Throwable e) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
@ -72,8 +72,7 @@ public interface Job {
|
|||||||
}, sender.isPlayer() ? 0 : 20);
|
}, sender.isPlayer() ? 0 : 20);
|
||||||
f.whenComplete((fs, ff) -> {
|
f.whenComplete((fs, ff) -> {
|
||||||
J.car(c);
|
J.car(c);
|
||||||
if(!silentMsg)
|
if (!silentMsg) {
|
||||||
{
|
|
||||||
sender.sendMessage(C.AQUA + "Completed " + getName() + " in " + Form.duration(p.getMilliseconds(), 1));
|
sender.sendMessage(C.AQUA + "Completed " + getName() + " in " + Form.duration(p.getMilliseconds(), 1));
|
||||||
}
|
}
|
||||||
whenComplete.run();
|
whenComplete.run();
|
||||||
|
@ -288,16 +288,12 @@ public interface ProceduralStream<T> extends ProceduralLayer, Interpolated<T> {
|
|||||||
return new To3DStream<T>(this);
|
return new To3DStream<T>(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
default ProceduralStream<T> cache2D(Engine engine, int maxSize) {
|
default ProceduralStream<T> cache2D(String name, Engine engine, int size) {
|
||||||
return cache2D(engine, maxSize, false);
|
return new CachedStream2D<T>(name, engine, this, size);
|
||||||
}
|
}
|
||||||
|
|
||||||
default ProceduralStream<T> cache2D(Engine engine, int maxSize, boolean weak) {
|
default ProceduralStream<T> cache3D(String name, Engine engine, int maxSize) {
|
||||||
return new CachedStream2D<T>(engine, this, maxSize, weak);
|
return new CachedStream3D<T>(name, engine, this, maxSize);
|
||||||
}
|
|
||||||
|
|
||||||
default ProceduralStream<T> cache3D(Engine engine, int maxSize) {
|
|
||||||
return new CachedStream3D<T>(engine, this, maxSize);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
default <V> ProceduralStream<V> convert(Function<T, V> converter) {
|
default <V> ProceduralStream<V> convert(Function<T, V> converter) {
|
||||||
|
@ -18,11 +18,7 @@
|
|||||||
|
|
||||||
package com.volmit.iris.util.stream.utility;
|
package com.volmit.iris.util.stream.utility;
|
||||||
|
|
||||||
import com.github.benmanes.caffeine.cache.Caffeine;
|
|
||||||
import com.github.benmanes.caffeine.cache.LoadingCache;
|
|
||||||
import com.googlecode.concurrentlinkedhashmap.ConcurrentLinkedHashMap;
|
|
||||||
import com.volmit.iris.Iris;
|
import com.volmit.iris.Iris;
|
||||||
import com.volmit.iris.core.IrisSettings;
|
|
||||||
import com.volmit.iris.core.service.PreservationSVC;
|
import com.volmit.iris.core.service.PreservationSVC;
|
||||||
import com.volmit.iris.engine.data.cache.Cache;
|
import com.volmit.iris.engine.data.cache.Cache;
|
||||||
import com.volmit.iris.engine.framework.Engine;
|
import com.volmit.iris.engine.framework.Engine;
|
||||||
@ -36,7 +32,7 @@ public class CachedStream2D<T> extends BasicStream<T> implements ProceduralStrea
|
|||||||
private final KCache<Long, T> cache;
|
private final KCache<Long, T> cache;
|
||||||
private final Engine engine;
|
private final Engine engine;
|
||||||
|
|
||||||
public CachedStream2D(Engine engine, ProceduralStream<T> stream, int size, boolean weak) {
|
public CachedStream2D(String name, Engine engine, ProceduralStream<T> stream, int size) {
|
||||||
super();
|
super();
|
||||||
this.stream = stream;
|
this.stream = stream;
|
||||||
this.engine = engine;
|
this.engine = engine;
|
||||||
@ -56,7 +52,7 @@ public class CachedStream2D<T> extends BasicStream<T> implements ProceduralStrea
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public T get(double x, double z) {
|
public T get(double x, double z) {
|
||||||
return cache.get(Cache.key((int)x, (int)z));
|
return cache.get(Cache.key((int) x, (int) z));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -69,6 +65,11 @@ public class CachedStream2D<T> extends BasicStream<T> implements ProceduralStrea
|
|||||||
return cache.getSize();
|
return cache.getSize();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public KCache<?, ?> getRawCache() {
|
||||||
|
return cache;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public long getMaxSize() {
|
public long getMaxSize() {
|
||||||
return cache.getMaxSize();
|
return cache.getMaxSize();
|
||||||
|
@ -32,7 +32,7 @@ public class CachedStream3D<T> extends BasicStream<T> implements ProceduralStrea
|
|||||||
private final KCache<BlockPosition, T> cache;
|
private final KCache<BlockPosition, T> cache;
|
||||||
private final Engine engine;
|
private final Engine engine;
|
||||||
|
|
||||||
public CachedStream3D(Engine engine, ProceduralStream<T> stream, int size) {
|
public CachedStream3D(String name, Engine engine, ProceduralStream<T> stream, int size) {
|
||||||
super();
|
super();
|
||||||
this.stream = stream;
|
this.stream = stream;
|
||||||
this.engine = engine;
|
this.engine = engine;
|
||||||
@ -65,6 +65,11 @@ public class CachedStream3D<T> extends BasicStream<T> implements ProceduralStrea
|
|||||||
return cache.getSize();
|
return cache.getSize();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public KCache<?, ?> getRawCache() {
|
||||||
|
return cache;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public long getMaxSize() {
|
public long getMaxSize() {
|
||||||
return cache.getMaxSize();
|
return cache.getMaxSize();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user