mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2025-12-28 11:39:07 +00:00
Compare commits
10 Commits
feat/folia
...
3.7.11-1.2
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e1ec6b7827 | ||
|
|
f94292fdac | ||
|
|
7d153bf985 | ||
|
|
f85f15ed02 | ||
|
|
867686eced | ||
|
|
9d796bd2a0 | ||
|
|
1a9a5d80ad | ||
|
|
c5c7f9bdc5 | ||
|
|
01a421b732 | ||
|
|
ae92bcf194 |
@@ -24,7 +24,7 @@ import kotlin.system.exitProcess
|
||||
|
||||
buildscript {
|
||||
repositories.maven("https://jitpack.io")
|
||||
dependencies.classpath("com.github.VolmitSoftware:NMSTools:c5cbc46ce6")
|
||||
dependencies.classpath("com.github.VolmitSoftware:NMSTools:c88961416f")
|
||||
}
|
||||
|
||||
plugins {
|
||||
@@ -36,7 +36,7 @@ plugins {
|
||||
}
|
||||
|
||||
group = "com.volmit"
|
||||
version = "3.7.2-1.20.1-1.21.8"
|
||||
version = "3.7.11-1.20.1-1.21.8"
|
||||
|
||||
apply<ApiGenerator>()
|
||||
|
||||
@@ -65,7 +65,7 @@ val color = "truecolor"
|
||||
val errorReporting = findProperty("errorReporting") as Boolean? ?: false
|
||||
|
||||
val nmsBindings = mapOf(
|
||||
"v1_21_R5" to "1.21.7-R0.1-SNAPSHOT",
|
||||
"v1_21_R5" to "1.21.8-R0.1-SNAPSHOT",
|
||||
"v1_21_R4" to "1.21.5-R0.1-SNAPSHOT",
|
||||
"v1_21_R3" to "1.21.4-R0.1-SNAPSHOT",
|
||||
"v1_21_R2" to "1.21.3-R0.1-SNAPSHOT",
|
||||
@@ -81,10 +81,6 @@ nmsBindings.forEach { key, value ->
|
||||
apply<JavaPlugin>()
|
||||
apply<NMSToolsPlugin>()
|
||||
|
||||
repositories {
|
||||
maven("https://libraries.minecraft.net")
|
||||
}
|
||||
|
||||
extensions.configure(NMSToolsExtension::class) {
|
||||
jvm = jvmVersion.getOrDefault(key, 21)
|
||||
version = value
|
||||
|
||||
@@ -35,7 +35,7 @@ import java.io.File;
|
||||
|
||||
@Data
|
||||
public abstract class IrisRegistrant {
|
||||
@Desc("Preprocess this object in-memory when it's loaded, run scripts using the variable 'Iris.getPreprocessorObject()' and modify properties about this object before it's used.")
|
||||
@Desc("Preprocess this object in-memory when it's loaded, run scripts using the variable 'object' and modify properties about this object before it's used.\nFile extension: .prox.kts")
|
||||
@RegistryListResource(IrisScript.class)
|
||||
@ArrayType(min = 1, type = String.class)
|
||||
private KList<String> preprocessors = new KList<>();
|
||||
|
||||
@@ -1,9 +1,12 @@
|
||||
package com.volmit.iris.core.scripting.environment;
|
||||
|
||||
import com.volmit.iris.core.loader.IrisRegistrant;
|
||||
import com.volmit.iris.core.scripting.func.UpdateExecutor;
|
||||
import com.volmit.iris.core.scripting.kotlin.environment.IrisExecutionEnvironment;
|
||||
import com.volmit.iris.engine.framework.Engine;
|
||||
import com.volmit.iris.util.mantle.MantleChunk;
|
||||
import lombok.NonNull;
|
||||
import org.bukkit.Chunk;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
@@ -22,4 +25,6 @@ public interface EngineEnvironment extends PackEnvironment {
|
||||
void postSpawnMob(@NonNull String script, @NonNull Location location, @NonNull Entity mob);
|
||||
|
||||
void preprocessObject(@NonNull String script, @NonNull IrisRegistrant object);
|
||||
|
||||
void updateChunk(@NonNull String script, @NonNull MantleChunk mantleChunk, @NonNull Chunk chunk, @NonNull UpdateExecutor executor);
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package com.volmit.iris.core.scripting.func;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
@FunctionalInterface
|
||||
public interface UpdateExecutor {
|
||||
|
||||
@NotNull Runnable wrap(int delay, @NotNull Runnable runnable);
|
||||
|
||||
@NotNull
|
||||
default Runnable wrap(@NotNull Runnable runnable) {
|
||||
return wrap(1, runnable);
|
||||
}
|
||||
|
||||
default void execute(@NotNull Runnable runnable) {
|
||||
execute(1, runnable);
|
||||
}
|
||||
|
||||
default void execute(int delay, @NotNull Runnable runnable) {
|
||||
wrap(delay, runnable).run();
|
||||
}
|
||||
}
|
||||
@@ -89,7 +89,7 @@ public class IrisConverter {
|
||||
for (int h = 0; h < objH; h++) {
|
||||
for (int d = 0; d < objD; d++) {
|
||||
for (int w = 0; w < objW; w++) {
|
||||
BlockData bd = blockmap.get((int) originalBlockArray[v.get()]);
|
||||
BlockData bd = blockmap.get(Byte.toUnsignedInt(originalBlockArray[v.get()]));
|
||||
if (!bd.getMaterial().isAir()) {
|
||||
object.setUnsigned(w, h, d, bd);
|
||||
}
|
||||
|
||||
@@ -294,7 +294,7 @@ public interface Engine extends DataProvider, Fallible, LootProvider, BlockUpdat
|
||||
|
||||
var chunk = mantle.getChunk(c).use();
|
||||
try {
|
||||
Semaphore semaphore = new Semaphore(3);
|
||||
Semaphore semaphore = new Semaphore(1024);
|
||||
chunk.raiseFlag(MantleFlag.ETCHED, () -> {
|
||||
chunk.raiseFlagUnchecked(MantleFlag.TILE, run(semaphore, () -> {
|
||||
chunk.iterate(TileWrapper.class, (x, y, z, v) -> {
|
||||
@@ -355,8 +355,18 @@ public interface Engine extends DataProvider, Fallible, LootProvider, BlockUpdat
|
||||
}, RNG.r.i(1, 20))); //Why is there a random delay here?
|
||||
});
|
||||
|
||||
chunk.raiseFlagUnchecked(MantleFlag.SCRIPT, () -> {
|
||||
var scripts = getDimension().getChunkUpdateScripts();
|
||||
if (scripts == null || scripts.isEmpty())
|
||||
return;
|
||||
|
||||
for (var script : scripts) {
|
||||
getExecution().updateChunk(script, chunk, c, (delay, task) -> run(semaphore, task, delay));
|
||||
}
|
||||
});
|
||||
|
||||
try {
|
||||
semaphore.acquire(3);
|
||||
semaphore.acquire(1024);
|
||||
} catch (InterruptedException ignored) {}
|
||||
} finally {
|
||||
chunk.release();
|
||||
@@ -365,8 +375,11 @@ public interface Engine extends DataProvider, Fallible, LootProvider, BlockUpdat
|
||||
|
||||
private static Runnable run(Semaphore semaphore, Runnable runnable, int delay) {
|
||||
return () -> {
|
||||
if (!semaphore.tryAcquire())
|
||||
return;
|
||||
try {
|
||||
semaphore.acquire();
|
||||
} catch (InterruptedException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
J.s(() -> {
|
||||
try {
|
||||
|
||||
@@ -249,14 +249,18 @@ public class IrisDimension extends IrisRegistrant {
|
||||
@Desc("A list of globally applied pre-processors")
|
||||
@ArrayType(type = IrisPreProcessors.class)
|
||||
private KList<IrisPreProcessors> globalPreProcessors = new KList<>();
|
||||
@Desc("A list of scripts executed on engine setup")
|
||||
@Desc("A list of scripts executed on engine setup\nFile extension: .engine.kts")
|
||||
@RegistryListResource(IrisScript.class)
|
||||
@ArrayType(type = String.class, min = 1)
|
||||
private KList<String> engineScripts = new KList<>();
|
||||
@Desc("A list of scripts executed on data setup")
|
||||
@Desc("A list of scripts executed on data setup\nFile extension: .data.kts")
|
||||
@RegistryListResource(IrisScript.class)
|
||||
@ArrayType(type = String.class, min = 1)
|
||||
private KList<String> dataScripts = new KList<>();
|
||||
@Desc("A list of scripts executed on chunk update\nFile extension: .update.kts")
|
||||
@RegistryListResource(IrisScript.class)
|
||||
@ArrayType(type = String.class, min = 1)
|
||||
private KList<String> chunkUpdateScripts = new KList<>();
|
||||
@Desc("Use legacy rarity instead of modern one\nWARNING: Changing this may break expressions and image maps")
|
||||
private boolean legacyRarity = true;
|
||||
|
||||
|
||||
@@ -39,7 +39,7 @@ public class IrisDimensionMode {
|
||||
private IrisDimensionModeType type = IrisDimensionModeType.OVERWORLD;
|
||||
|
||||
@RegistryListResource(IrisScript.class)
|
||||
@Desc("The script to create the dimension mode instead of using provided types")
|
||||
@Desc("The script to create the dimension mode instead of using provided types\nFile extension: .engine.kts")
|
||||
private String script;
|
||||
|
||||
public EngineMode create(Engine engine) {
|
||||
|
||||
@@ -166,12 +166,12 @@ public class IrisEntity extends IrisRegistrant {
|
||||
@Desc("Set to true if you want to apply all of the settings here to the mob, even though an external plugin has already done so. Scripts are always applied.")
|
||||
private boolean applySettingsToCustomMobAnyways = false;
|
||||
|
||||
@Desc("Set the entity type to UNKNOWN, then define a script here which ends with the entity variable (the result). You can use Iris.getLocation() to find the target location. You can spawn any entity this way.")
|
||||
@Desc("Set the entity type to UNKNOWN, then define a script here which ends with the entity variable (the result). You can use location to find the target location. You can spawn any entity this way.\nFile extension: .spawn.kts")
|
||||
@RegistryListResource(IrisScript.class)
|
||||
private String spawnerScript = "";
|
||||
|
||||
@ArrayType(min = 1, type = String.class)
|
||||
@Desc("Set the entity type to UNKNOWN, then define a script here. You can use Iris.getLocation() to find the target location. You can spawn any entity this way.")
|
||||
@Desc("Executed post spawn you can modify the entity however you want with it\nFile extension: .postspawn.kts")
|
||||
@RegistryListResource(IrisScript.class)
|
||||
private KList<String> postSpawnScripts = new KList<>();
|
||||
|
||||
|
||||
@@ -58,7 +58,7 @@ public class IrisGeneratorStyle {
|
||||
private String expression = null;
|
||||
@Desc("Use an Image map instead of a generated value")
|
||||
private IrisImageMap imageMap = null;
|
||||
@Desc("Instead of using the style property, use a custom noise generator to represent this style.")
|
||||
@Desc("Instead of using the style property, use a custom noise generator to represent this style.\nFile extension: .noise.kts")
|
||||
@RegistryListResource(IrisScript.class)
|
||||
private String script = null;
|
||||
@MinNumber(0.00001)
|
||||
|
||||
@@ -33,10 +33,7 @@ import com.volmit.iris.util.data.IrisCustomData;
|
||||
import com.volmit.iris.util.format.Form;
|
||||
import com.volmit.iris.util.interpolation.IrisInterpolation;
|
||||
import com.volmit.iris.util.json.JSONObject;
|
||||
import com.volmit.iris.util.math.AxisAlignedBB;
|
||||
import com.volmit.iris.util.math.BlockPosition;
|
||||
import com.volmit.iris.util.math.Position2;
|
||||
import com.volmit.iris.util.math.RNG;
|
||||
import com.volmit.iris.util.math.*;
|
||||
import com.volmit.iris.util.matter.MatterMarker;
|
||||
import com.volmit.iris.util.parallel.BurstExecutor;
|
||||
import com.volmit.iris.util.parallel.MultiBurst;
|
||||
@@ -84,8 +81,8 @@ public class IrisObject extends IrisRegistrant {
|
||||
protected transient IrisLock lock = new IrisLock("Preloadcache");
|
||||
@Setter
|
||||
protected transient AtomicCache<AxisAlignedBB> aabb = new AtomicCache<>();
|
||||
private KMap<BlockVector, BlockData> blocks;
|
||||
private KMap<BlockVector, TileData> states;
|
||||
private KMap<Vector3i, BlockData> blocks;
|
||||
private KMap<Vector3i, TileData> states;
|
||||
@Getter
|
||||
@Setter
|
||||
private int w;
|
||||
@@ -97,7 +94,7 @@ public class IrisObject extends IrisRegistrant {
|
||||
private int h;
|
||||
@Getter
|
||||
@Setter
|
||||
private transient BlockVector center;
|
||||
private transient Vector3i center;
|
||||
|
||||
public IrisObject(int w, int h, int d) {
|
||||
blocks = new KMap<>();
|
||||
@@ -105,7 +102,7 @@ public class IrisObject extends IrisRegistrant {
|
||||
this.w = w;
|
||||
this.h = h;
|
||||
this.d = d;
|
||||
center = new BlockVector(w / 2, h / 2, d / 2);
|
||||
center = new Vector3i(w / 2, h / 2, d / 2);
|
||||
}
|
||||
|
||||
public IrisObject() {
|
||||
@@ -193,7 +190,7 @@ public class IrisObject extends IrisRegistrant {
|
||||
int end = Integer.MIN_VALUE;
|
||||
|
||||
for (int ray = min.getBlockX(); ray <= max.getBlockX(); ray++) {
|
||||
if (getBlocks().containsKey(new BlockVector(ray, finalRayY, rayZ))) {
|
||||
if (getBlocks().containsKey(new Vector3i(ray, finalRayY, rayZ))) {
|
||||
start = Math.min(ray, start);
|
||||
end = Math.max(ray, end);
|
||||
}
|
||||
@@ -201,7 +198,7 @@ public class IrisObject extends IrisRegistrant {
|
||||
|
||||
if (start != Integer.MAX_VALUE && end != Integer.MIN_VALUE) {
|
||||
for (int i = start; i <= end; i++) {
|
||||
BlockVector v = new BlockVector(i, finalRayY, rayZ);
|
||||
Vector3i v = new Vector3i(i, finalRayY, rayZ);
|
||||
|
||||
if (!B.isAir(getBlocks().get(v))) {
|
||||
getBlocks().computeIfAbsent(v, (vv) -> vair);
|
||||
@@ -222,7 +219,7 @@ public class IrisObject extends IrisRegistrant {
|
||||
int end = Integer.MIN_VALUE;
|
||||
|
||||
for (int ray = min.getBlockY(); ray <= max.getBlockY(); ray++) {
|
||||
if (getBlocks().containsKey(new BlockVector(finalRayX, ray, rayZ))) {
|
||||
if (getBlocks().containsKey(new Vector3i(finalRayX, ray, rayZ))) {
|
||||
start = Math.min(ray, start);
|
||||
end = Math.max(ray, end);
|
||||
}
|
||||
@@ -230,7 +227,7 @@ public class IrisObject extends IrisRegistrant {
|
||||
|
||||
if (start != Integer.MAX_VALUE && end != Integer.MIN_VALUE) {
|
||||
for (int i = start; i <= end; i++) {
|
||||
BlockVector v = new BlockVector(finalRayX, i, rayZ);
|
||||
Vector3i v = new Vector3i(finalRayX, i, rayZ);
|
||||
|
||||
if (!B.isAir(getBlocks().get(v))) {
|
||||
getBlocks().computeIfAbsent(v, (vv) -> vair);
|
||||
@@ -251,7 +248,7 @@ public class IrisObject extends IrisRegistrant {
|
||||
int end = Integer.MIN_VALUE;
|
||||
|
||||
for (int ray = min.getBlockZ(); ray <= max.getBlockZ(); ray++) {
|
||||
if (getBlocks().containsKey(new BlockVector(finalRayX, rayY, ray))) {
|
||||
if (getBlocks().containsKey(new Vector3i(finalRayX, rayY, ray))) {
|
||||
start = Math.min(ray, start);
|
||||
end = Math.max(ray, end);
|
||||
}
|
||||
@@ -259,7 +256,7 @@ public class IrisObject extends IrisRegistrant {
|
||||
|
||||
if (start != Integer.MAX_VALUE && end != Integer.MIN_VALUE) {
|
||||
for (int i = start; i <= end; i++) {
|
||||
BlockVector v = new BlockVector(finalRayX, rayY, i);
|
||||
Vector3i v = new Vector3i(finalRayX, rayY, i);
|
||||
|
||||
if (!B.isAir(getBlocks().get(v))) {
|
||||
getBlocks().computeIfAbsent(v, (vv) -> vair);
|
||||
@@ -284,11 +281,11 @@ public class IrisObject extends IrisRegistrant {
|
||||
o.setLoadFile(getLoadFile());
|
||||
o.setCenter(getCenter().clone());
|
||||
|
||||
for (BlockVector i : getBlocks().keySet()) {
|
||||
for (Vector3i i : getBlocks().keySet()) {
|
||||
o.getBlocks().put(i.clone(), Objects.requireNonNull(getBlocks().get(i)).clone());
|
||||
}
|
||||
|
||||
for (BlockVector i : getStates().keySet()) {
|
||||
for (Vector3i i : getStates().keySet()) {
|
||||
o.getStates().put(i.clone(), Objects.requireNonNull(getStates().get(i)).clone());
|
||||
}
|
||||
|
||||
@@ -300,18 +297,18 @@ public class IrisObject extends IrisRegistrant {
|
||||
this.w = din.readInt();
|
||||
this.h = din.readInt();
|
||||
this.d = din.readInt();
|
||||
center = new BlockVector(w / 2, h / 2, d / 2);
|
||||
center = new Vector3i(w / 2, h / 2, d / 2);
|
||||
int s = din.readInt();
|
||||
|
||||
for (int i = 0; i < s; i++) {
|
||||
getBlocks().put(new BlockVector(din.readShort(), din.readShort(), din.readShort()), B.get(din.readUTF()));
|
||||
getBlocks().put(new Vector3i(din.readShort(), din.readShort(), din.readShort()), B.get(din.readUTF()));
|
||||
}
|
||||
|
||||
try {
|
||||
int size = din.readInt();
|
||||
|
||||
for (int i = 0; i < size; i++) {
|
||||
getStates().put(new BlockVector(din.readShort(), din.readShort(), din.readShort()), TileData.read(din));
|
||||
getStates().put(new Vector3i(din.readShort(), din.readShort(), din.readShort()), TileData.read(din));
|
||||
}
|
||||
} catch (Throwable e) {
|
||||
Iris.reportError(e);
|
||||
@@ -327,7 +324,7 @@ public class IrisObject extends IrisRegistrant {
|
||||
if (!din.readUTF().equals("Iris V2 IOB;")) {
|
||||
return;
|
||||
}
|
||||
center = new BlockVector(w / 2, h / 2, d / 2);
|
||||
center = new Vector3i(w / 2, h / 2, d / 2);
|
||||
int s = din.readShort();
|
||||
int i;
|
||||
KList<String> palette = new KList<>();
|
||||
@@ -339,13 +336,13 @@ public class IrisObject extends IrisRegistrant {
|
||||
s = din.readInt();
|
||||
|
||||
for (i = 0; i < s; i++) {
|
||||
getBlocks().put(new BlockVector(din.readShort(), din.readShort(), din.readShort()), B.get(palette.get(din.readShort())));
|
||||
getBlocks().put(new Vector3i(din.readShort(), din.readShort(), din.readShort()), B.get(palette.get(din.readShort())));
|
||||
}
|
||||
|
||||
s = din.readInt();
|
||||
|
||||
for (i = 0; i < s; i++) {
|
||||
getStates().put(new BlockVector(din.readShort(), din.readShort(), din.readShort()), TileData.read(din));
|
||||
getStates().put(new Vector3i(din.readShort(), din.readShort(), din.readShort()), TileData.read(din));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -369,7 +366,7 @@ public class IrisObject extends IrisRegistrant {
|
||||
|
||||
dos.writeInt(getBlocks().size());
|
||||
|
||||
for (BlockVector i : getBlocks().keySet()) {
|
||||
for (Vector3i i : getBlocks().keySet()) {
|
||||
dos.writeShort(i.getBlockX());
|
||||
dos.writeShort(i.getBlockY());
|
||||
dos.writeShort(i.getBlockZ());
|
||||
@@ -377,7 +374,7 @@ public class IrisObject extends IrisRegistrant {
|
||||
}
|
||||
|
||||
dos.writeInt(getStates().size());
|
||||
for (BlockVector i : getStates().keySet()) {
|
||||
for (Vector3i i : getStates().keySet()) {
|
||||
dos.writeShort(i.getBlockX());
|
||||
dos.writeShort(i.getBlockY());
|
||||
dos.writeShort(i.getBlockZ());
|
||||
@@ -423,7 +420,7 @@ public class IrisObject extends IrisRegistrant {
|
||||
|
||||
dos.writeInt(getBlocks().size());
|
||||
|
||||
for (BlockVector i : getBlocks().keySet()) {
|
||||
for (Vector3i i : getBlocks().keySet()) {
|
||||
dos.writeShort(i.getBlockX());
|
||||
dos.writeShort(i.getBlockY());
|
||||
dos.writeShort(i.getBlockZ());
|
||||
@@ -432,7 +429,7 @@ public class IrisObject extends IrisRegistrant {
|
||||
}
|
||||
|
||||
dos.writeInt(getStates().size());
|
||||
for (BlockVector i : getStates().keySet()) {
|
||||
for (Vector3i i : getStates().keySet()) {
|
||||
dos.writeShort(i.getBlockX());
|
||||
dos.writeShort(i.getBlockY());
|
||||
dos.writeShort(i.getBlockZ());
|
||||
@@ -517,40 +514,40 @@ public class IrisObject extends IrisRegistrant {
|
||||
w = max.getBlockX() - min.getBlockX() + 1;
|
||||
h = max.getBlockY() - min.getBlockY() + 1;
|
||||
d = max.getBlockZ() - min.getBlockZ() + 1;
|
||||
center = new BlockVector(w / 2, h / 2, d / 2);
|
||||
center = new Vector3i(w / 2, h / 2, d / 2);
|
||||
}
|
||||
|
||||
public void clean() {
|
||||
KMap<BlockVector, BlockData> d = new KMap<>();
|
||||
KMap<Vector3i, BlockData> d = new KMap<>();
|
||||
|
||||
for (BlockVector i : getBlocks().keySet()) {
|
||||
d.put(new BlockVector(i.getBlockX(), i.getBlockY(), i.getBlockZ()), Objects.requireNonNull(getBlocks().get(i)));
|
||||
for (Vector3i i : getBlocks().keySet()) {
|
||||
d.put(new Vector3i(i.getBlockX(), i.getBlockY(), i.getBlockZ()), Objects.requireNonNull(getBlocks().get(i)));
|
||||
}
|
||||
|
||||
KMap<BlockVector, TileData> dx = new KMap<>();
|
||||
KMap<Vector3i, TileData> dx = new KMap<>();
|
||||
|
||||
for (BlockVector i : getBlocks().keySet()) {
|
||||
d.put(new BlockVector(i.getBlockX(), i.getBlockY(), i.getBlockZ()), Objects.requireNonNull(getBlocks().get(i)));
|
||||
for (Vector3i i : getBlocks().keySet()) {
|
||||
d.put(new Vector3i(i.getBlockX(), i.getBlockY(), i.getBlockZ()), Objects.requireNonNull(getBlocks().get(i)));
|
||||
}
|
||||
|
||||
for (BlockVector i : getStates().keySet()) {
|
||||
dx.put(new BlockVector(i.getBlockX(), i.getBlockY(), i.getBlockZ()), Objects.requireNonNull(getStates().get(i)));
|
||||
for (Vector3i i : getStates().keySet()) {
|
||||
dx.put(new Vector3i(i.getBlockX(), i.getBlockY(), i.getBlockZ()), Objects.requireNonNull(getStates().get(i)));
|
||||
}
|
||||
|
||||
blocks = d;
|
||||
states = dx;
|
||||
}
|
||||
|
||||
public BlockVector getSigned(int x, int y, int z) {
|
||||
public Vector3i getSigned(int x, int y, int z) {
|
||||
if (x >= w || y >= h || z >= d) {
|
||||
throw new RuntimeException(x + " " + y + " " + z + " exceeds limit of " + w + " " + h + " " + d);
|
||||
}
|
||||
|
||||
return new BlockVector(x, y, z).subtract(center).toBlockVector();
|
||||
return (Vector3i) new Vector3i(x, y, z).subtract(center);
|
||||
}
|
||||
|
||||
public void setUnsigned(int x, int y, int z, BlockData block) {
|
||||
BlockVector v = getSigned(x, y, z);
|
||||
Vector3i v = getSigned(x, y, z);
|
||||
|
||||
if (block == null) {
|
||||
getBlocks().remove(v);
|
||||
@@ -561,7 +558,7 @@ public class IrisObject extends IrisRegistrant {
|
||||
}
|
||||
|
||||
public void setUnsigned(int x, int y, int z, Block block, boolean legacy) {
|
||||
BlockVector v = getSigned(x, y, z);
|
||||
Vector3i v = getSigned(x, y, z);
|
||||
|
||||
if (block == null) {
|
||||
getBlocks().remove(v);
|
||||
@@ -878,7 +875,7 @@ public class IrisObject extends IrisRegistrant {
|
||||
|
||||
int max = j.getMaximumMarkers();
|
||||
|
||||
for (BlockVector i : getBlocks().k().shuffle()) {
|
||||
for (Vector3i i : getBlocks().k().shuffle()) {
|
||||
if (max <= 0) {
|
||||
break;
|
||||
}
|
||||
@@ -891,8 +888,8 @@ public class IrisObject extends IrisRegistrant {
|
||||
}
|
||||
|
||||
if (j.isExact() ? k.matches(data) : k.getMaterial().equals(data.getMaterial())) {
|
||||
boolean a = !blocks.containsKey(new BlockVector(i.clone().add(new BlockVector(0, 1, 0))));
|
||||
boolean fff = !blocks.containsKey(new BlockVector(i.clone().add(new BlockVector(0, 2, 0))));
|
||||
boolean a = !blocks.containsKey((Vector3i) i.clone().add(new BlockVector(0, 1, 0)));
|
||||
boolean fff = !blocks.containsKey((Vector3i) i.clone().add(new BlockVector(0, 2, 0)));
|
||||
|
||||
if (!marker.isEmptyAbove() || (a && fff)) {
|
||||
markers.put(i, j.getMarker());
|
||||
@@ -904,12 +901,13 @@ public class IrisObject extends IrisRegistrant {
|
||||
}
|
||||
}
|
||||
|
||||
for (BlockVector g : getBlocks().keySet()) {
|
||||
for (var entry : getBlocks().entrySet()) {
|
||||
var g = entry.getKey();
|
||||
BlockData d;
|
||||
TileData tile = null;
|
||||
|
||||
try {
|
||||
d = getBlocks().get(g);
|
||||
d = entry.getValue();
|
||||
tile = getStates().get(g);
|
||||
} catch (Throwable e) {
|
||||
Iris.reportError(e);
|
||||
@@ -1028,7 +1026,7 @@ public class IrisObject extends IrisRegistrant {
|
||||
if (stilting) {
|
||||
readLock.lock();
|
||||
IrisStiltSettings settings = config.getStiltSettings();
|
||||
for (BlockVector g : getBlocks().keySet()) {
|
||||
for (Vector3i g : getBlocks().keySet()) {
|
||||
BlockData d;
|
||||
|
||||
if (settings == null || settings.getPalette() == null) {
|
||||
@@ -1140,17 +1138,16 @@ public class IrisObject extends IrisRegistrant {
|
||||
}
|
||||
|
||||
public void rotate(IrisObjectRotation r, int spinx, int spiny, int spinz) {
|
||||
KMap<BlockVector, BlockData> d = new KMap<>();
|
||||
KMap<Vector3i, BlockData> d = new KMap<>();
|
||||
|
||||
for (BlockVector i : getBlocks().keySet()) {
|
||||
d.put(r.rotate(i.clone(), spinx, spiny, spinz), r.rotate(getBlocks().get(i).clone(),
|
||||
spinx, spiny, spinz));
|
||||
for (Vector3i i : getBlocks().keySet()) {
|
||||
d.put(new Vector3i(r.rotate(i, spinx, spiny, spinz)), r.rotate(getBlocks().get(i).clone(), spinx, spiny, spinz));
|
||||
}
|
||||
|
||||
KMap<BlockVector, TileData> dx = new KMap<>();
|
||||
KMap<Vector3i, TileData> dx = new KMap<>();
|
||||
|
||||
for (BlockVector i : getStates().keySet()) {
|
||||
dx.put(r.rotate(i.clone(), spinx, spiny, spinz), getStates().get(i));
|
||||
for (Vector3i i : getStates().keySet()) {
|
||||
dx.put(new Vector3i(r.rotate(i, spinx, spiny, spinz)), getStates().get(i));
|
||||
}
|
||||
|
||||
blocks = d;
|
||||
@@ -1159,7 +1156,7 @@ public class IrisObject extends IrisRegistrant {
|
||||
}
|
||||
|
||||
public void place(Location at) {
|
||||
for (BlockVector i : getBlocks().keySet()) {
|
||||
for (Vector3i i : getBlocks().keySet()) {
|
||||
Block b = at.clone().add(0, getCenter().getY(), 0).add(i).getBlock();
|
||||
b.setBlockData(Objects.requireNonNull(getBlocks().get(i)), false);
|
||||
|
||||
@@ -1171,7 +1168,7 @@ public class IrisObject extends IrisRegistrant {
|
||||
}
|
||||
|
||||
public void placeCenterY(Location at) {
|
||||
for (BlockVector i : getBlocks().keySet()) {
|
||||
for (Vector3i i : getBlocks().keySet()) {
|
||||
Block b = at.clone().add(getCenter().getX(), getCenter().getY(), getCenter().getZ()).add(i).getBlock();
|
||||
b.setBlockData(Objects.requireNonNull(getBlocks().get(i)), false);
|
||||
|
||||
@@ -1181,11 +1178,11 @@ public class IrisObject extends IrisRegistrant {
|
||||
}
|
||||
}
|
||||
|
||||
public synchronized KMap<BlockVector, BlockData> getBlocks() {
|
||||
public synchronized KMap<Vector3i, BlockData> getBlocks() {
|
||||
return blocks;
|
||||
}
|
||||
|
||||
public synchronized KMap<BlockVector, TileData> getStates() {
|
||||
public synchronized KMap<Vector3i, TileData> getStates() {
|
||||
return states;
|
||||
}
|
||||
|
||||
@@ -1219,7 +1216,7 @@ public class IrisObject extends IrisRegistrant {
|
||||
|
||||
IrisObject oo = new IrisObject((int) Math.ceil((w * scale) + (scale * 2)), (int) Math.ceil((h * scale) + (scale * 2)), (int) Math.ceil((d * scale) + (scale * 2)));
|
||||
|
||||
for (Map.Entry<BlockVector, BlockData> entry : blocks.entrySet()) {
|
||||
for (Map.Entry<Vector3i, BlockData> entry : blocks.entrySet()) {
|
||||
BlockData bd = entry.getValue();
|
||||
placeBlock.put(entry.getKey().clone().add(HALF).subtract(center)
|
||||
.multiply(scale).add(sm1).toBlockVector(), bd);
|
||||
@@ -1229,7 +1226,7 @@ public class IrisObject extends IrisRegistrant {
|
||||
BlockVector v = entry.getKey();
|
||||
if (scale > 1) {
|
||||
for (BlockVector vec : blocksBetweenTwoPoints(v.clone().add(center), v.clone().add(center).add(sm1))) {
|
||||
oo.getBlocks().put(vec, entry.getValue());
|
||||
oo.getBlocks().put(new Vector3i(vec), entry.getValue());
|
||||
}
|
||||
} else {
|
||||
oo.setUnsigned(v.getBlockX(), v.getBlockY(), v.getBlockZ(), entry.getValue());
|
||||
@@ -1248,8 +1245,8 @@ public class IrisObject extends IrisRegistrant {
|
||||
}
|
||||
|
||||
public void trilinear(int rad) {
|
||||
KMap<BlockVector, BlockData> v = getBlocks().copy();
|
||||
KMap<BlockVector, BlockData> b = new KMap<>();
|
||||
KMap<Vector3i, BlockData> v = getBlocks().copy();
|
||||
KMap<Vector3i, BlockData> b = new KMap<>();
|
||||
BlockVector min = getAABB().minbv();
|
||||
BlockVector max = getAABB().maxbv();
|
||||
|
||||
@@ -1257,7 +1254,7 @@ public class IrisObject extends IrisRegistrant {
|
||||
for (int y = min.getBlockY(); y <= max.getBlockY(); y++) {
|
||||
for (int z = min.getBlockZ(); z <= max.getBlockZ(); z++) {
|
||||
if (IrisInterpolation.getTrilinear(x, y, z, rad, (xx, yy, zz) -> {
|
||||
BlockData data = v.get(new BlockVector((int) xx, (int) yy, (int) zz));
|
||||
BlockData data = v.get(new Vector3i((int) xx, (int) yy, (int) zz));
|
||||
|
||||
if (data == null || data.getMaterial().isAir()) {
|
||||
return 0;
|
||||
@@ -1265,9 +1262,9 @@ public class IrisObject extends IrisRegistrant {
|
||||
|
||||
return 1;
|
||||
}) >= 0.5) {
|
||||
b.put(new BlockVector(x, y, z), nearestBlockData(x, y, z));
|
||||
b.put(new Vector3i(x, y, z), nearestBlockData(x, y, z));
|
||||
} else {
|
||||
b.put(new BlockVector(x, y, z), AIR);
|
||||
b.put(new Vector3i(x, y, z), AIR);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1277,8 +1274,8 @@ public class IrisObject extends IrisRegistrant {
|
||||
}
|
||||
|
||||
public void tricubic(int rad) {
|
||||
KMap<BlockVector, BlockData> v = getBlocks().copy();
|
||||
KMap<BlockVector, BlockData> b = new KMap<>();
|
||||
KMap<Vector3i, BlockData> v = getBlocks().copy();
|
||||
KMap<Vector3i, BlockData> b = new KMap<>();
|
||||
BlockVector min = getAABB().minbv();
|
||||
BlockVector max = getAABB().maxbv();
|
||||
|
||||
@@ -1286,7 +1283,7 @@ public class IrisObject extends IrisRegistrant {
|
||||
for (int y = min.getBlockY(); y <= max.getBlockY(); y++) {
|
||||
for (int z = min.getBlockZ(); z <= max.getBlockZ(); z++) {
|
||||
if (IrisInterpolation.getTricubic(x, y, z, rad, (xx, yy, zz) -> {
|
||||
BlockData data = v.get(new BlockVector((int) xx, (int) yy, (int) zz));
|
||||
BlockData data = v.get(new Vector3i((int) xx, (int) yy, (int) zz));
|
||||
|
||||
if (data == null || data.getMaterial().isAir()) {
|
||||
return 0;
|
||||
@@ -1294,9 +1291,9 @@ public class IrisObject extends IrisRegistrant {
|
||||
|
||||
return 1;
|
||||
}) >= 0.5) {
|
||||
b.put(new BlockVector(x, y, z), nearestBlockData(x, y, z));
|
||||
b.put(new Vector3i(x, y, z), nearestBlockData(x, y, z));
|
||||
} else {
|
||||
b.put(new BlockVector(x, y, z), AIR);
|
||||
b.put(new Vector3i(x, y, z), AIR);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1310,8 +1307,8 @@ public class IrisObject extends IrisRegistrant {
|
||||
}
|
||||
|
||||
public void trihermite(int rad, double tension, double bias) {
|
||||
KMap<BlockVector, BlockData> v = getBlocks().copy();
|
||||
KMap<BlockVector, BlockData> b = new KMap<>();
|
||||
KMap<Vector3i, BlockData> v = getBlocks().copy();
|
||||
KMap<Vector3i, BlockData> b = new KMap<>();
|
||||
BlockVector min = getAABB().minbv();
|
||||
BlockVector max = getAABB().maxbv();
|
||||
|
||||
@@ -1319,7 +1316,7 @@ public class IrisObject extends IrisRegistrant {
|
||||
for (int y = min.getBlockY(); y <= max.getBlockY(); y++) {
|
||||
for (int z = min.getBlockZ(); z <= max.getBlockZ(); z++) {
|
||||
if (IrisInterpolation.getTrihermite(x, y, z, rad, (xx, yy, zz) -> {
|
||||
BlockData data = v.get(new BlockVector((int) xx, (int) yy, (int) zz));
|
||||
BlockData data = v.get(new Vector3i((int) xx, (int) yy, (int) zz));
|
||||
|
||||
if (data == null || data.getMaterial().isAir()) {
|
||||
return 0;
|
||||
@@ -1327,9 +1324,9 @@ public class IrisObject extends IrisRegistrant {
|
||||
|
||||
return 1;
|
||||
}, tension, bias) >= 0.5) {
|
||||
b.put(new BlockVector(x, y, z), nearestBlockData(x, y, z));
|
||||
b.put(new Vector3i(x, y, z), nearestBlockData(x, y, z));
|
||||
} else {
|
||||
b.put(new BlockVector(x, y, z), AIR);
|
||||
b.put(new Vector3i(x, y, z), AIR);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1348,7 +1345,7 @@ public class IrisObject extends IrisRegistrant {
|
||||
|
||||
double d = Double.MAX_VALUE;
|
||||
|
||||
for (Map.Entry<BlockVector, BlockData> entry : blocks.entrySet()) {
|
||||
for (Map.Entry<Vector3i, BlockData> entry : blocks.entrySet()) {
|
||||
BlockData dat = entry.getValue();
|
||||
|
||||
if (dat.getMaterial().isAir()) {
|
||||
|
||||
@@ -18,7 +18,7 @@ public class IrisPreProcessors {
|
||||
private String type = "dimension";
|
||||
|
||||
@Required
|
||||
@Desc("The preprocessor scripts")
|
||||
@Desc("The preprocessor scripts\nFile extension: .proc.kts")
|
||||
@RegistryListResource(IrisScript.class)
|
||||
@ArrayType(type = String.class, min = 1)
|
||||
private KList<String> scripts = new KList<>();
|
||||
|
||||
@@ -84,7 +84,7 @@ public class MantleChunk {
|
||||
public MantleChunk(int version, int sectionHeight, CountingDataInputStream din) throws IOException {
|
||||
this(sectionHeight, din.readByte(), din.readByte());
|
||||
int s = din.readByte();
|
||||
int l = version < 0 ? MantleFlag.RESERVED_FLAGS : Varint.readUnsignedVarInt(din);
|
||||
int l = version < 0 ? 16 : Varint.readUnsignedVarInt(din);
|
||||
|
||||
if (version >= 1) {
|
||||
for (int i = 0; i < l;) {
|
||||
@@ -176,14 +176,26 @@ public class MantleChunk {
|
||||
if (guard != null && isFlagged(guard)) return;
|
||||
synchronized (flagLocks[flag.ordinal()]) {
|
||||
if (flags.compareAndSet(flag.ordinal(), false, true)) {
|
||||
r.run();
|
||||
try {
|
||||
r.run();
|
||||
} catch (RuntimeException | Error e) {
|
||||
flags.set(flag.ordinal(), false);
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void raiseFlagUnchecked(MantleFlag flag, Runnable r) {
|
||||
if (closed.get()) throw new IllegalStateException("Chunk is closed!");
|
||||
if (flags.compareAndSet(flag.ordinal(), false, true)) r.run();
|
||||
if (flags.compareAndSet(flag.ordinal(), false, true)) {
|
||||
try {
|
||||
r.run();
|
||||
} catch (RuntimeException | Error e) {
|
||||
flags.set(flag.ordinal(), false);
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isFlagged(MantleFlag flag) {
|
||||
|
||||
@@ -40,6 +40,7 @@ public sealed interface MantleFlag permits CustomFlag, ReservedFlag {
|
||||
MantleFlag CUSTOM = ReservedFlag.CUSTOM;
|
||||
MantleFlag DISCOVERED = ReservedFlag.DISCOVERED;
|
||||
MantleFlag CUSTOM_ACTIVE = ReservedFlag.CUSTOM_ACTIVE;
|
||||
MantleFlag SCRIPT = ReservedFlag.SCRIPT;
|
||||
|
||||
int RESERVED_FLAGS = ReservedFlag.values().length;
|
||||
|
||||
|
||||
@@ -16,7 +16,8 @@ public enum ReservedFlag implements MantleFlag {
|
||||
TILE,
|
||||
CUSTOM,
|
||||
DISCOVERED,
|
||||
CUSTOM_ACTIVE;
|
||||
CUSTOM_ACTIVE,
|
||||
SCRIPT;
|
||||
|
||||
@Override
|
||||
public boolean isCustom() {
|
||||
|
||||
26
core/src/main/java/com/volmit/iris/util/math/Vector3i.java
Normal file
26
core/src/main/java/com/volmit/iris/util/math/Vector3i.java
Normal file
@@ -0,0 +1,26 @@
|
||||
package com.volmit.iris.util.math;
|
||||
|
||||
import org.bukkit.util.BlockVector;
|
||||
import org.bukkit.util.Vector;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class Vector3i extends BlockVector {
|
||||
public Vector3i(int x, int y, int z) {
|
||||
super(x, y, z);
|
||||
}
|
||||
|
||||
public Vector3i(Vector vec) {
|
||||
super(vec);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Vector3i clone() {
|
||||
return (Vector3i) super.clone();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return (((int) x & 0x3FF) << 2) | (((int) y & 0x3FF) << 1) | ((int) z & 0x3FF);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package com.volmit.iris.core.scripting.kotlin.base
|
||||
|
||||
import com.volmit.iris.core.scripting.func.UpdateExecutor
|
||||
import com.volmit.iris.util.mantle.MantleChunk
|
||||
import org.bukkit.Chunk
|
||||
import kotlin.script.experimental.annotations.KotlinScript
|
||||
import kotlin.script.experimental.api.ScriptCompilationConfiguration
|
||||
import kotlin.script.experimental.api.providedProperties
|
||||
|
||||
@KotlinScript(fileExtension = "update.kts", compilationConfiguration = ChunkUpdateScriptDefinition::class)
|
||||
abstract class ChunkUpdateScript
|
||||
|
||||
object ChunkUpdateScriptDefinition : ScriptCompilationConfiguration(listOf(EngineScriptDefinition), {
|
||||
providedProperties(
|
||||
"mantleChunk" to MantleChunk::class,
|
||||
"chunk" to Chunk::class,
|
||||
"executor" to UpdateExecutor::class
|
||||
)
|
||||
}) {
|
||||
private fun readResolve(): Any = MobSpawningScriptDefinition
|
||||
}
|
||||
@@ -3,11 +3,15 @@ package com.volmit.iris.core.scripting.kotlin.environment
|
||||
import com.volmit.iris.core.loader.IrisRegistrant
|
||||
import com.volmit.iris.core.scripting.environment.EngineEnvironment
|
||||
import com.volmit.iris.core.scripting.func.BiomeLookup
|
||||
import com.volmit.iris.core.scripting.func.UpdateExecutor
|
||||
import com.volmit.iris.core.scripting.kotlin.base.ChunkUpdateScript
|
||||
import com.volmit.iris.core.scripting.kotlin.base.EngineScript
|
||||
import com.volmit.iris.core.scripting.kotlin.base.MobSpawningScript
|
||||
import com.volmit.iris.core.scripting.kotlin.base.PostMobSpawningScript
|
||||
import com.volmit.iris.core.scripting.kotlin.base.PreprocessorScript
|
||||
import com.volmit.iris.engine.framework.Engine
|
||||
import com.volmit.iris.util.mantle.MantleChunk
|
||||
import org.bukkit.Chunk
|
||||
import org.bukkit.Location
|
||||
import org.bukkit.entity.Entity
|
||||
|
||||
@@ -31,6 +35,9 @@ data class IrisExecutionEnvironment(
|
||||
override fun preprocessObject(script: String, `object`: IrisRegistrant) =
|
||||
execute(script, PreprocessorScript::class.java, engine.parameters("object" to `object`))
|
||||
|
||||
override fun updateChunk(script: String, mantleChunk: MantleChunk, chunk: Chunk, executor: UpdateExecutor) =
|
||||
execute(script, ChunkUpdateScript::class.java, engine.parameters("mantleChunk" to mantleChunk, "chunk" to chunk, "executor" to executor))
|
||||
|
||||
private fun Engine.parameters(vararg values: Pair<String, Any?>): Map<String, Any?> {
|
||||
return mapOf(
|
||||
"data" to data,
|
||||
|
||||
@@ -23,6 +23,7 @@ rootProject.name = "Iris"
|
||||
|
||||
include(":core", ":core:agent")
|
||||
include(
|
||||
":nms:v1_21_R6",
|
||||
":nms:v1_21_R5",
|
||||
":nms:v1_21_R4",
|
||||
":nms:v1_21_R3",
|
||||
|
||||
Reference in New Issue
Block a user