9
0
mirror of https://github.com/VolmitSoftware/Iris.git synced 2025-12-28 03:29:06 +00:00

Compare commits

..

13 Commits

Author SHA1 Message Date
Brian Fopiano
609104cfa8 Merge pull request #785 from VolmitSoftware/Development
Development
2022-04-16 01:23:44 -07:00
Brian Fopiano
935d11b433 V+ 2022-04-16 01:23:15 -07:00
cyberpwn
e9eeb8335d f 2022-04-14 23:58:06 -04:00
cyberpwn
4a2f42437f Mantle deletes 2022-04-14 23:47:25 -04:00
cyberpwn
51b0693c99 fix 2022-04-14 20:43:10 -04:00
cyberpwn
185b366d8d Lots of crap 2022-04-14 20:40:37 -04:00
cyberpwn
a40e533068 Revert "Drop oraxen support "
This reverts commit d315e99b63.
2022-04-14 14:32:49 -07:00
Brian Fopiano
5b3918fcb1 Merge pull request #782 from VolmitSoftware/Development
Development
2022-04-13 16:49:22 -07:00
cyberpwn
d315e99b63 Drop oraxen support 2022-04-13 19:17:25 -04:00
cyberpwn
8090ba0259 Fix object placement 2022-04-13 19:11:31 -04:00
cyberpwn
584400d011 Revert "This is to prevent warnings for weird objects, (revert)"
This reverts commit 124ad23a95.
2022-04-13 18:50:08 -04:00
cyberpwn
124ad23a95 This is to prevent warnings for weird objects, (revert) 2022-04-13 18:47:31 -04:00
cyberpwn
6b59aa38ae Allow terrain to use the world height 2022-04-13 18:46:19 -04:00
10 changed files with 158 additions and 5 deletions

View File

@@ -24,7 +24,7 @@ plugins {
id "de.undercouch.download" version "5.0.1"
}
version '2.0.4-1.18.2' // Needs to be version specific
version '2.0.5-1.18.2' // Needs to be version specific
def nmsVersion = "1.18.2"
def apiVersion = '1.18'
def spigotJarVersion = '1.18.2-R0.1-SNAPSHOT'

View File

@@ -27,6 +27,7 @@ import com.volmit.iris.core.link.OraxenLink;
import com.volmit.iris.core.loader.IrisData;
import com.volmit.iris.core.nms.INMS;
import com.volmit.iris.core.service.StudioSVC;
import com.volmit.iris.core.tools.IrisToolbelt;
import com.volmit.iris.engine.EnginePanic;
import com.volmit.iris.engine.object.IrisBiome;
import com.volmit.iris.engine.object.IrisCompat;

View File

@@ -327,7 +327,11 @@ public class CommandObject implements DecreeExecutor {
Map<Block, BlockData> futureChanges = new HashMap<>();
o = o.scaled(scale, IrisObjectPlacementScaleInterpolator.TRICUBIC);
if(scale != 1)
{
o = o.scaled(scale, IrisObjectPlacementScaleInterpolator.TRICUBIC);
}
o.place(block.getBlockX(), block.getBlockY() + (int) o.getCenter().getY(), block.getBlockZ(), createPlacer(block.getWorld(), futureChanges), placement, new RNG(), null);
Iris.service(ObjectSVC.class).addChanges(futureChanges);

View File

@@ -32,15 +32,21 @@ import com.volmit.iris.engine.platform.PlatformChunkGenerator;
import com.volmit.iris.util.plugin.VolmitSender;
import org.bukkit.Bukkit;
import org.bukkit.World;
import org.bukkit.block.data.BlockData;
import org.bukkit.entity.Player;
import java.io.File;
import java.lang.reflect.Method;
import java.util.HashMap;
import java.util.Map;
/**
* Something you really want to wear if working on Iris. Shit gets pretty hectic down there.
* Hope you packed snacks & road sodas.
*/
public class IrisToolbelt {
public static Map<String, Boolean> toolbeltConfiguration = new HashMap<>();
/**
* Will find / download / search for the dimension or return null
* <p>
@@ -210,4 +216,64 @@ public class IrisToolbelt {
public static boolean isStudio(World i) {
return isIrisWorld(i) && access(i).isStudio();
}
public static void retainMantleDataForSlice(String className)
{
toolbeltConfiguration.put("retain.mantle." + className, true);
}
public static <T> T getMantleData(World world, int x, int y, int z, Class<T> of)
{
PlatformChunkGenerator e = access(world);
if(e == null) {return null;}
return e.getEngine().getMantle().getMantle().get(x, y - world.getMinHeight(), z, of);
}
public static <T> void deleteMantleData(World world, int x, int y, int z, Class<T> of)
{
PlatformChunkGenerator e = access(world);
if(e == null) {return;}
e.getEngine().getMantle().getMantle().remove(x, y - world.getMinHeight(), z, of);
}
/////////////////// REFLECTIVE METHODS //////////////////////////
// Copy this stuff to your project, it's safe to use with a
// bukkit api only.
/////////////////////////////////////////////////////////////////
public static void setup() throws Throwable {
Method m = Class.forName("com.volmit.iris.core.tools.IrisToolbelt").getDeclaredMethod("retainMantleDataForSlice", String.class);
m.invoke(null, String.class.getCanonicalName());
m.invoke(null, BlockData.class.getCanonicalName());
}
public static boolean hasMantleObject(World world, int x, int y, int z) {
return getMantleIdentity(world, x, y, z) != -1;
}
public static void deleteMantleBlock(World world, int x, int y, int z) {
try {
Method m = Class.forName("com.volmit.iris.core.tools.IrisToolbelt").getDeclaredMethod("deleteMantleData", World.class, int.class, int.class, int.class, Class.class);
m.invoke(null, world, x, y, z, BlockData.class);
m.invoke(null, world, x, y, z, String.class);
} catch(Throwable ignored) {}
}
public static BlockData getMantleBlock(World world, int x, int y, int z) {
try {
Method m = Class.forName("com.volmit.iris.core.tools.IrisToolbelt").getDeclaredMethod("getMantleData", World.class, int.class, int.class, int.class, Class.class);
BlockData s = (BlockData) m.invoke(null, world, x, y, z, BlockData.class);
if(s != null) {return s;}
} catch(Throwable ignored) {}
return null;
}
public static int getMantleIdentity(World world, int x, int y, int z) {
try {
Method m = Class.forName("com.volmit.iris.core.tools.IrisToolbelt").getDeclaredMethod("getMantleData", World.class, int.class, int.class, int.class, Class.class);
String s = (String) m.invoke(null, world, x, y, z, String.class);
if(s != null) {return Integer.parseInt(s.split("\\Q@\\E")[1]);}
} catch(Throwable ignored) {}
return -1;
}
}

View File

@@ -336,8 +336,7 @@ public class IrisComplex implements DataProvider {
}
private double getHeight(Engine engine, IrisBiome b, double x, double z, long seed) {
return Math.min(engine.getWorld().maxHeight(),
Math.max(getInterpolatedHeight(engine, x, z, seed) + fluidHeight + overlayStream.get(x, z), engine.getWorld().minHeight()));
return Math.max(Math.min(getInterpolatedHeight(engine, x, z, seed) + fluidHeight + overlayStream.get(x, z), engine.getHeight()), 0);
}
private void registerGenerator(IrisGenerator cachedGenerator) {

View File

@@ -24,6 +24,7 @@ import com.volmit.iris.core.loader.IrisData;
import com.volmit.iris.engine.data.cache.Cache;
import com.volmit.iris.engine.framework.Engine;
import com.volmit.iris.engine.object.IObjectPlacer;
import com.volmit.iris.engine.object.IrisGeneratorStyle;
import com.volmit.iris.engine.object.IrisPosition;
import com.volmit.iris.engine.object.TileData;
import com.volmit.iris.util.collection.KMap;
@@ -31,6 +32,7 @@ import com.volmit.iris.util.collection.KSet;
import com.volmit.iris.util.function.Function3;
import com.volmit.iris.util.mantle.Mantle;
import com.volmit.iris.util.mantle.MantleChunk;
import com.volmit.iris.util.math.RNG;
import com.volmit.iris.util.matter.Matter;
import lombok.Data;
import org.bukkit.block.TileState;
@@ -121,6 +123,13 @@ public class MantleWriter implements IObjectPlacer {
return (x * x) + (z * z);
}
public <T> void setDataWarped(int x, int y, int z, T t, RNG rng, IrisData data, IrisGeneratorStyle style)
{
setData((int)Math.round(style.warp(rng, data, x, x, y, -z)),
(int)Math.round(style.warp(rng, data, y, z, -x, y)),
(int)Math.round(style.warp(rng, data, z, -y, z, x)), t);
}
public <T> void setData(int x, int y, int z, T t) {
if(t == null) {
return;
@@ -233,6 +242,10 @@ public class MantleWriter implements IObjectPlacer {
setElipsoidFunction(cx, cy, cz, rx, ry, rz, fill, (a, b, c) -> data);
}
public <T> void setElipsoidWarped(int cx, int cy, int cz, double rx, double ry, double rz, boolean fill, T data, RNG rng, IrisData idata, IrisGeneratorStyle style) {
setElipsoidFunctionWarped(cx, cy, cz, rx, ry, rz, fill, (a, b, c) -> data, rng, idata, style);
}
/**
* Set an elipsoid into the mantle
*
@@ -312,6 +325,63 @@ public class MantleWriter implements IObjectPlacer {
}
}
public <T> void setElipsoidFunctionWarped(int cx, int cy, int cz, double rx, double ry, double rz, boolean fill, Function3<Integer, Integer, Integer, T> data, RNG rng, IrisData idata, IrisGeneratorStyle style) {
rx += 0.5;
ry += 0.5;
rz += 0.5;
final double invRadiusX = 1 / rx;
final double invRadiusY = 1 / ry;
final double invRadiusZ = 1 / rz;
final int ceilRadiusX = (int) Math.ceil(rx);
final int ceilRadiusY = (int) Math.ceil(ry);
final int ceilRadiusZ = (int) Math.ceil(rz);
double nextXn = 0;
forX:
for(int x = 0; x <= ceilRadiusX; ++x) {
final double xn = nextXn;
nextXn = (x + 1) * invRadiusX;
double nextYn = 0;
forY:
for(int y = 0; y <= ceilRadiusY; ++y) {
final double yn = nextYn;
nextYn = (y + 1) * invRadiusY;
double nextZn = 0;
for(int z = 0; z <= ceilRadiusZ; ++z) {
final double zn = nextZn;
nextZn = (z + 1) * invRadiusZ;
double distanceSq = lengthSq(xn, yn, zn);
if(distanceSq > 1) {
if(z == 0) {
if(y == 0) {
break forX;
}
break forY;
}
break;
}
if(!fill) {
if(lengthSq(nextXn, yn, zn) <= 1 && lengthSq(xn, nextYn, zn) <= 1 && lengthSq(xn, yn, nextZn) <= 1) {
continue;
}
}
setDataWarped(x + cx, y + cy, z + cz, data.apply(x + cx, y + cy, z + cz), rng, idata, style);
setDataWarped(-x + cx, y + cy, z + cz, data.apply(-x + cx, y + cy, z + cz), rng, idata, style);
setDataWarped(x + cx, -y + cy, z + cz, data.apply(x + cx, -y + cy, z + cz), rng, idata, style);
setDataWarped(x + cx, y + cy, -z + cz, data.apply(x + cx, y + cy, -z + cz), rng, idata, style);
setDataWarped(-x + cx, y + cy, -z + cz, data.apply(-x + cx, y + cy, -z + cz), rng, idata, style);
setDataWarped(-x + cx, -y + cy, z + cz, data.apply(-x + cx, -y + cy, z + cz), rng, idata, style);
setDataWarped(x + cx, -y + cy, -z + cz, data.apply(x + cx, -y + cy, -z + cz), rng, idata, style);
setDataWarped(-x + cx, y + cy, -z + cz, data.apply(-x + cx, y + cy, -z + cz), rng, idata, style);
setDataWarped(-x + cx, -y + cy, -z + cz, data.apply(-x + cx, -y + cy, -z + cz), rng, idata, style);
}
}
}
}
/**
* Set a cuboid of data in the mantle
*

View File

@@ -128,6 +128,11 @@ public class IrisGeneratorStyle {
return cng;
}
public double warp(RNG rng, IrisData data, double value, double... coords)
{
return create(rng, data).noise(coords) + value;
}
public CNG create(RNG rng, IrisData data) {
return cng.aquire(() -> createNoCache(rng, data));
}

View File

@@ -20,6 +20,7 @@ package com.volmit.iris.util.mantle;
import com.volmit.iris.Iris;
import com.volmit.iris.core.IrisSettings;
import com.volmit.iris.core.tools.IrisToolbelt;
import com.volmit.iris.engine.data.cache.Cache;
import com.volmit.iris.engine.framework.Engine;
import com.volmit.iris.engine.mantle.EngineMantle;
@@ -570,6 +571,11 @@ public class Mantle {
}
public void deleteChunkSlice(int x, int z, Class<?> c) {
if(!IrisToolbelt.toolbeltConfiguration.isEmpty() && IrisToolbelt.toolbeltConfiguration.getOrDefault("retain.mantle." + c.getCanonicalName(), false))
{
return;
}
getChunk(x, z).deleteSlices(c);
}

View File

@@ -31,7 +31,8 @@ public enum MantleFlag {
FLUID_BODIES,
INITIAL_SPAWNED_MARKER,
CLEANED,
PLANNED;
PLANNED,
ETCHED;
static StateList getStateList() {
return new StateList(MantleFlag.values());

View File

@@ -29,6 +29,7 @@ import java.io.IOException;
@Sliced
public class CavernMatter extends RawMatter<MatterCavern> {
public static final MatterCavern EMPTY = new MatterCavern(false, "", (byte) 0);
public static final MatterCavern BASIC = new MatterCavern(true, "", (byte) 0);
public CavernMatter() {
this(1, 1, 1);