mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2025-07-04 00:46:08 +00:00
mid save
This commit is contained in:
parent
76365e7875
commit
c35366caa4
@ -91,6 +91,7 @@ import java.io.*;
|
|||||||
import java.lang.annotation.Annotation;
|
import java.lang.annotation.Annotation;
|
||||||
import java.lang.management.ManagementFactory;
|
import java.lang.management.ManagementFactory;
|
||||||
import java.lang.management.OperatingSystemMXBean;
|
import java.lang.management.OperatingSystemMXBean;
|
||||||
|
import java.lang.management.ThreadMXBean;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@ -811,6 +812,22 @@ public class Iris extends VolmitPlugin implements Listener {
|
|||||||
Iris.info("Server type & version: " + C.RED + Bukkit.getVersion());
|
Iris.info("Server type & version: " + C.RED + Bukkit.getVersion());
|
||||||
} else { Iris.info("Server type & version: " + Bukkit.getVersion()); }
|
} else { Iris.info("Server type & version: " + Bukkit.getVersion()); }
|
||||||
Iris.info("Java: " + getJava());
|
Iris.info("Java: " + getJava());
|
||||||
|
try {
|
||||||
|
if (getCPUModel().contains("Intel")) {
|
||||||
|
Iris.info("Server Cpu: " + C.BLUE + getCPUModel());
|
||||||
|
}
|
||||||
|
if (getCPUModel().contains("Ryzen")) {
|
||||||
|
Iris.info("Server Cpu: " + C.RED + getCPUModel());
|
||||||
|
}
|
||||||
|
if (!getCPUModel().contains("Ryzen") && !getCPUModel().contains("Intel")) {
|
||||||
|
Iris.info("Server Cpu: " + C.GRAY + getCPUModel());
|
||||||
|
}
|
||||||
|
|
||||||
|
} catch (Exception e){
|
||||||
|
Iris.info("Server Cpu: " + C.DARK_RED + "Failed");
|
||||||
|
}
|
||||||
|
|
||||||
|
Iris.info("Threads: " + C.GRAY + Runtime.getRuntime().availableProcessors());
|
||||||
if (!instance.getServer().getVersion().contains("Purpur")) {
|
if (!instance.getServer().getVersion().contains("Purpur")) {
|
||||||
if (instance.getServer().getVersion().contains("Spigot") && instance.getServer().getVersion().contains("Bukkit")) {
|
if (instance.getServer().getVersion().contains("Spigot") && instance.getServer().getVersion().contains("Bukkit")) {
|
||||||
Iris.info(C.RED + " Iris requires paper or above to function properly..");
|
Iris.info(C.RED + " Iris requires paper or above to function properly..");
|
||||||
|
@ -99,6 +99,10 @@ public interface INMSBinding {
|
|||||||
|
|
||||||
int countCustomBiomes();
|
int countCustomBiomes();
|
||||||
|
|
||||||
|
default boolean setBlock(World world, int x, int y, int z, BlockData data, int flag, int updateDepth) {
|
||||||
|
throw new UnsupportedOperationException();
|
||||||
|
}
|
||||||
|
|
||||||
void forceBiomeInto(int x, int y, int z, Object somethingVeryDirty, ChunkGenerator.BiomeGrid chunk);
|
void forceBiomeInto(int x, int y, int z, Object somethingVeryDirty, ChunkGenerator.BiomeGrid chunk);
|
||||||
|
|
||||||
default boolean supportsDataPacks() {
|
default boolean supportsDataPacks() {
|
||||||
|
@ -57,30 +57,29 @@ public class IrisTerrainNormalActuator extends EngineAssignedActuator<BlockData>
|
|||||||
public IrisTerrainNormalActuator(Engine engine) {
|
public IrisTerrainNormalActuator(Engine engine) {
|
||||||
super(engine, "Terrain");
|
super(engine, "Terrain");
|
||||||
rng = new RNG(engine.getSeedManager().getTerrain());
|
rng = new RNG(engine.getSeedManager().getTerrain());
|
||||||
boolean debug = getDimension().getMerger().isDatapackMode();
|
// todo: for v4
|
||||||
if (!getDimension().getMerger().getGenerator().isBlank()) {
|
// boolean debug = getDimension().getMerger().isDatapackMode();
|
||||||
try {
|
// if (!getDimension().getMerger().getGenerator().isBlank()) {
|
||||||
if (!getDimension().getMerger().isDatapackMode()) {
|
// try {
|
||||||
this.memoryWorld = INMS.get().createMemoryWorld(new WorldCreator("terrain").generator(getEngine().getDimension().getMerger().getGenerator()));
|
// if (!getDimension().getMerger().isDatapackMode()) {
|
||||||
} else {
|
// this.memoryWorld = INMS.get().createMemoryWorld(new WorldCreator("terrain").generator(getEngine().getDimension().getMerger().getGenerator()));
|
||||||
String test = getDimension().getMerger().getGenerator().toLowerCase();
|
// } else {
|
||||||
this.memoryWorld = INMS.get().createMemoryWorld(NamespacedKey.minecraft(test), new WorldCreator("terrain"));
|
// String test = getDimension().getMerger().getGenerator().toLowerCase();
|
||||||
}
|
// this.memoryWorld = INMS.get().createMemoryWorld(NamespacedKey.minecraft(test), new WorldCreator("terrain"));
|
||||||
} catch (Exception e) {
|
// }
|
||||||
e.printStackTrace();
|
// } catch (Exception e) {
|
||||||
}
|
// e.printStackTrace();
|
||||||
}
|
// }
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
@BlockCoordinates
|
@BlockCoordinates
|
||||||
@Override
|
@Override
|
||||||
public void onActuate(int x, int z, Hunk<BlockData> h, boolean multicore, ChunkContext context) {
|
public void onActuate(int x, int z, Hunk<BlockData> h, boolean multicore, ChunkContext context) {
|
||||||
try {
|
try {
|
||||||
|
|
||||||
PrecisionStopwatch p = PrecisionStopwatch.start();
|
PrecisionStopwatch p = PrecisionStopwatch.start();
|
||||||
AtomicReference<Hunk<BlockData>> hm = new AtomicReference<>();
|
AtomicReference<Hunk<BlockData>> hm = new AtomicReference<>();
|
||||||
if (memoryWorld != null) {
|
if (memoryWorld != null) {
|
||||||
|
|
||||||
PaperLib.getChunkAtAsync(memoryWorld.getBukkit(), x, z, true).thenAccept((i) -> {
|
PaperLib.getChunkAtAsync(memoryWorld.getBukkit(), x, z, true).thenAccept((i) -> {
|
||||||
hm.set(toHunk(memoryWorld.getChunkData(x, z)));
|
hm.set(toHunk(memoryWorld.getChunkData(x, z)));
|
||||||
}).get();
|
}).get();
|
||||||
@ -176,11 +175,6 @@ public class IrisTerrainNormalActuator extends EngineAssignedActuator<BlockData>
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Merger DEV CODE
|
|
||||||
if (hm != null) {
|
|
||||||
h.set(xf, i, zf, hm.get(xf, i, zf));
|
|
||||||
}
|
|
||||||
|
|
||||||
BlockData ore = biome.generateOres(realX, i, realZ, rng, getData());
|
BlockData ore = biome.generateOres(realX, i, realZ, rng, getData());
|
||||||
ore = ore == null ? region.generateOres(realX, i, realZ, rng, getData()) : ore;
|
ore = ore == null ? region.generateOres(realX, i, realZ, rng, getData()) : ore;
|
||||||
ore = ore == null ? getDimension().generateOres(realX, i, realZ, rng, getData()) : ore;
|
ore = ore == null ? getDimension().generateOres(realX, i, realZ, rng, getData()) : ore;
|
||||||
|
@ -144,8 +144,10 @@ public class IrisDimension extends IrisRegistrant {
|
|||||||
@RegistryListResource(IrisJigsawStructure.class)
|
@RegistryListResource(IrisJigsawStructure.class)
|
||||||
@Desc("If defined, Iris will place the given jigsaw structure where minecraft should place the overworld stronghold.")
|
@Desc("If defined, Iris will place the given jigsaw structure where minecraft should place the overworld stronghold.")
|
||||||
private String stronghold;
|
private String stronghold;
|
||||||
@Desc("Iris merger")
|
// @Desc("Iris merger") V4 Feature
|
||||||
private IrisMerger merger = new IrisMerger();
|
// private IrisMerger merger = new IrisMerger();
|
||||||
|
@Desc("Cheap temp solution till v4 arrives")
|
||||||
|
private boolean vanillaUnderground = true;
|
||||||
@Desc("If set to true, Iris will remove chunks to allow visualizing cross sections of chunks easily")
|
@Desc("If set to true, Iris will remove chunks to allow visualizing cross sections of chunks easily")
|
||||||
private boolean debugChunkCrossSections = false;
|
private boolean debugChunkCrossSections = false;
|
||||||
@Desc("Vertically split up the biome palettes with 3 air blocks in between to visualize them")
|
@Desc("Vertically split up the biome palettes with 3 air blocks in between to visualize them")
|
||||||
|
@ -20,6 +20,7 @@ package com.volmit.iris.engine.platform;
|
|||||||
|
|
||||||
import com.volmit.iris.Iris;
|
import com.volmit.iris.Iris;
|
||||||
import com.volmit.iris.core.loader.IrisData;
|
import com.volmit.iris.core.loader.IrisData;
|
||||||
|
import com.volmit.iris.core.nms.IMemoryWorld;
|
||||||
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.IrisEngine;
|
import com.volmit.iris.engine.IrisEngine;
|
||||||
@ -32,23 +33,31 @@ import com.volmit.iris.engine.object.StudioMode;
|
|||||||
import com.volmit.iris.engine.platform.studio.StudioGenerator;
|
import com.volmit.iris.engine.platform.studio.StudioGenerator;
|
||||||
import com.volmit.iris.util.collection.KList;
|
import com.volmit.iris.util.collection.KList;
|
||||||
import com.volmit.iris.util.data.IrisBiomeStorage;
|
import com.volmit.iris.util.data.IrisBiomeStorage;
|
||||||
|
import com.volmit.iris.util.format.Form;
|
||||||
import com.volmit.iris.util.hunk.Hunk;
|
import com.volmit.iris.util.hunk.Hunk;
|
||||||
import com.volmit.iris.util.hunk.view.BiomeGridHunkHolder;
|
import com.volmit.iris.util.hunk.view.BiomeGridHunkHolder;
|
||||||
import com.volmit.iris.util.hunk.view.ChunkDataHunkHolder;
|
import com.volmit.iris.util.hunk.view.ChunkDataHunkHolder;
|
||||||
import com.volmit.iris.util.io.ReactiveFolder;
|
import com.volmit.iris.util.io.ReactiveFolder;
|
||||||
|
import com.volmit.iris.util.math.RollingSequence;
|
||||||
|
import com.volmit.iris.util.misc.E;
|
||||||
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 com.volmit.iris.util.scheduling.Looper;
|
||||||
|
import com.volmit.iris.util.scheduling.PrecisionStopwatch;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.EqualsAndHashCode;
|
import lombok.EqualsAndHashCode;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
|
import org.apache.commons.lang3.Functions;
|
||||||
|
import org.apache.commons.lang3.function.Failable;
|
||||||
import org.bukkit.*;
|
import org.bukkit.*;
|
||||||
import org.bukkit.block.Biome;
|
import org.bukkit.block.Biome;
|
||||||
import org.bukkit.block.data.BlockData;
|
import org.bukkit.block.data.BlockData;
|
||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.EventPriority;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
|
import org.bukkit.event.world.ChunkLoadEvent;
|
||||||
import org.bukkit.event.world.WorldInitEvent;
|
import org.bukkit.event.world.WorldInitEvent;
|
||||||
import org.bukkit.generator.BiomeProvider;
|
import org.bukkit.generator.BiomeProvider;
|
||||||
import org.bukkit.generator.BlockPopulator;
|
import org.bukkit.generator.BlockPopulator;
|
||||||
@ -83,10 +92,12 @@ public class BukkitChunkGenerator extends ChunkGenerator implements PlatformChun
|
|||||||
private final KList<BlockPopulator> populators;
|
private final KList<BlockPopulator> populators;
|
||||||
private final ChronoLatch hotloadChecker;
|
private final ChronoLatch hotloadChecker;
|
||||||
private final AtomicBoolean setup;
|
private final AtomicBoolean setup;
|
||||||
|
private IMemoryWorld memoryWorld;
|
||||||
private final boolean studio;
|
private final boolean studio;
|
||||||
private final AtomicInteger a = new AtomicInteger(0);
|
private final AtomicInteger a = new AtomicInteger(0);
|
||||||
private final CompletableFuture<Integer> spawnChunks = new CompletableFuture<>();
|
private final CompletableFuture<Integer> spawnChunks = new CompletableFuture<>();
|
||||||
private final boolean smartVanillaHeight;
|
private final boolean smartVanillaHeight;
|
||||||
|
private RollingSequence mergeDuration;
|
||||||
private Engine engine;
|
private Engine engine;
|
||||||
private Looper hotloader;
|
private Looper hotloader;
|
||||||
private StudioMode lastMode;
|
private StudioMode lastMode;
|
||||||
@ -103,6 +114,14 @@ public class BukkitChunkGenerator extends ChunkGenerator implements PlatformChun
|
|||||||
populators = new KList<>();
|
populators = new KList<>();
|
||||||
loadLock = new Semaphore(LOAD_LOCKS);
|
loadLock = new Semaphore(LOAD_LOCKS);
|
||||||
this.world = world;
|
this.world = world;
|
||||||
|
this.mergeDuration = new RollingSequence(20);
|
||||||
|
try {
|
||||||
|
this.memoryWorld = INMS.get().createMemoryWorld(NamespacedKey.minecraft("overworld"), new WorldCreator("terrain"));
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
//this.memoryWorld = engine.getDimension().isVanillaUnderground() ? Failable.get(() -> INMS.get().createMemoryWorld(NamespacedKey.minecraft("overworld"), new WorldCreator("terrain"))) : null;
|
||||||
this.hotloadChecker = new ChronoLatch(1000, false);
|
this.hotloadChecker = new ChronoLatch(1000, false);
|
||||||
this.studio = studio;
|
this.studio = studio;
|
||||||
this.dataLocation = dataLocation;
|
this.dataLocation = dataLocation;
|
||||||
@ -362,8 +381,12 @@ public class BukkitChunkGenerator extends ChunkGenerator implements PlatformChun
|
|||||||
getEngine().generate(x << 4, z << 4, blocks, biomes, false);
|
getEngine().generate(x << 4, z << 4, blocks, biomes, false);
|
||||||
blocks.apply();
|
blocks.apply();
|
||||||
biomes.apply();
|
biomes.apply();
|
||||||
|
J.s(() -> {
|
||||||
|
//generateVanillaUnderground(x,z, blocks);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Iris.info("dev");
|
||||||
Iris.debug("Generated " + x + " " + z);
|
Iris.debug("Generated " + x + " " + z);
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
Iris.error("======================================");
|
Iris.error("======================================");
|
||||||
@ -379,6 +402,50 @@ public class BukkitChunkGenerator extends ChunkGenerator implements PlatformChun
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
private void onChunkGeneration(ChunkLoadEvent event) {
|
||||||
|
if(!event.isNewChunk() || !engine.getWorld().realWorld().equals(event.getWorld()) || !engine.getDimension().isVanillaUnderground()) return;
|
||||||
|
generateVanillaUnderground(event.getChunk().getX(), event.getChunk().getZ());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
|
private void generateVanillaUnderground(int x, int z) {
|
||||||
|
if (memoryWorld == null || engine.getWorld() == null)
|
||||||
|
throw new NullPointerException();
|
||||||
|
PrecisionStopwatch p = PrecisionStopwatch.start();
|
||||||
|
Hunk<BlockData> vh = toHunk(memoryWorld.getChunkData(x, z));
|
||||||
|
int totalHeight = memoryWorld.getBukkit().getMaxHeight() - memoryWorld.getBukkit().getMinHeight();
|
||||||
|
int minHeight = memoryWorld.getBukkit().getMinHeight();
|
||||||
|
|
||||||
|
for (int xx = 0; xx < 16; xx++) {
|
||||||
|
for (int zz = 0; zz < 16; zz++) {
|
||||||
|
for (int y = 0; y < totalHeight; y++) {
|
||||||
|
if (y < engine.getHeight(x * 16 + xx, z * 16 + zz, false) - 10) {
|
||||||
|
BlockData blockData = vh.get(xx, y, zz);
|
||||||
|
if (blockData != null) {
|
||||||
|
INMS.get().setBlock(world.realWorld(), x * 16 + xx, y - minHeight , z * 16 + zz, blockData, 1042, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
mergeDuration.put(p.getMilliseconds());
|
||||||
|
Iris.info("Vanilla merge average in: " + Form.duration(mergeDuration.getAverage(), 8));
|
||||||
|
}
|
||||||
|
|
||||||
|
private Hunk<BlockData> toHunk(ChunkGenerator.ChunkData data) {
|
||||||
|
Hunk<BlockData> h = Hunk.newArrayHunk(16, memoryWorld.getBukkit().getMaxHeight() - memoryWorld.getBukkit().getMinHeight(), 16);
|
||||||
|
for (int x = 0; x < 16; x++) {
|
||||||
|
for (int z = 0; z < 16; z++) {
|
||||||
|
for (int y = 0; y < memoryWorld.getBukkit().getMaxHeight() - memoryWorld.getBukkit().getMinHeight(); y++) {
|
||||||
|
BlockData block = data.getBlockData(x, y, z);
|
||||||
|
h.set(x, y, z, block);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return h;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getBaseHeight(@NotNull WorldInfo worldInfo, @NotNull Random random, int x, int z, @NotNull HeightMap heightMap) {
|
public int getBaseHeight(@NotNull WorldInfo worldInfo, @NotNull Random random, int x, int z, @NotNull HeightMap heightMap) {
|
||||||
return 4;
|
return 4;
|
||||||
|
@ -20,9 +20,11 @@ import net.minecraft.nbt.*;
|
|||||||
import net.minecraft.nbt.Tag;
|
import net.minecraft.nbt.Tag;
|
||||||
import net.minecraft.server.commands.data.BlockDataAccessor;
|
import net.minecraft.server.commands.data.BlockDataAccessor;
|
||||||
import net.minecraft.tags.TagKey;
|
import net.minecraft.tags.TagKey;
|
||||||
|
import net.minecraft.util.datafix.fixes.BlockStateData;
|
||||||
import net.minecraft.world.level.DataPackConfig;
|
import net.minecraft.world.level.DataPackConfig;
|
||||||
import net.minecraft.world.level.LevelReader;
|
import net.minecraft.world.level.LevelReader;
|
||||||
import net.minecraft.world.level.block.EntityBlock;
|
import net.minecraft.world.level.block.EntityBlock;
|
||||||
|
import net.minecraft.world.level.chunk.LevelChunkSection;
|
||||||
import org.bukkit.*;
|
import org.bukkit.*;
|
||||||
import org.bukkit.block.Biome;
|
import org.bukkit.block.Biome;
|
||||||
import org.bukkit.block.data.BlockData;
|
import org.bukkit.block.data.BlockData;
|
||||||
@ -634,6 +636,13 @@ public class NMSBinding implements INMSBinding {
|
|||||||
return registry.getHolderOrThrow(ResourceKey.create(Registries.BIOME, CraftNamespacedKey.toMinecraft(biome.getKey())));
|
return registry.getHolderOrThrow(ResourceKey.create(Registries.BIOME, CraftNamespacedKey.toMinecraft(biome.getKey())));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean setBlock(World world, int x, int y, int z, BlockData data, int flag, int updateDepth) {
|
||||||
|
var level = ((CraftWorld) world).getHandle();
|
||||||
|
var blockData = ((CraftBlockData) data).getState();
|
||||||
|
return level.setBlock(new BlockPos(x, y, z), blockData, flag, updateDepth);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BlockData getBlockData(CompoundTag tag) {
|
public BlockData getBlockData(CompoundTag tag) {
|
||||||
if (tag == null) {
|
if (tag == null) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user