9
0
mirror of https://github.com/VolmitSoftware/Iris.git synced 2026-01-06 15:51:30 +00:00

Compare commits

..

22 Commits

Author SHA1 Message Date
Brian Fopiano
f5c64c7480 Merge pull request #960 from CocoTheOwner/render-continent
Continent (i.e. heightmap + ocean/land division) render
2023-02-15 14:47:14 -08:00
Brian Fopiano
085f63a915 Merge pull request #961 from CocoTheOwner/slopes-rotation
Implements slope rotation
2023-02-15 14:46:48 -08:00
Brian Fopiano
3e022e1931 Merge pull request #954 from CocoTheOwner/slopes
Slope condition
2023-02-15 14:46:28 -08:00
Brian Fopiano
0dba3725ae Merge pull request #953 from CocoTheOwner/mm-set-stuff
MM should set its own stuff
2023-02-15 14:44:42 -08:00
Brian Fopiano
8bb409df4e Merge pull request #952 from CocoTheOwner/fix-image-math
Fix image mapping math
2023-02-15 14:44:09 -08:00
Brian Fopiano
603168a147 Merge pull request #951 from CocoTheOwner/fix-decree-conv
Actually check for origin on command invoke
2023-02-15 14:42:57 -08:00
Sjoerd van de Goor
2a95edd860 further documentation and cleaner code 2023-02-15 14:14:26 +01:00
Sjoerd van de Goor
e94406fb45 Implement rotation, remove precise rotation. 2023-02-15 14:05:34 +01:00
Sjoerd van de Goor
e5a7b5d0c6 Reformulate todo 2023-02-15 13:12:34 +01:00
Sjoerd van de Goor
d6f816fe2f Flipped water / land 2023-02-15 13:00:13 +01:00
Sjoerd van de Goor
c15d4a349f map to 255 range 2023-02-15 12:55:43 +01:00
Sjoerd van de Goor
3ce832583c Continent (i.e. heightmap + ocean/land division) render 2023-02-15 12:49:20 +01:00
Sjoerd van de Goor
5514fd2645 Proper ordering 2023-02-08 01:51:39 +01:00
Sjoerd van de Goor
66d07dcaca Revert "Slope condition"
This reverts commit d4c0e07b1d.
2023-02-08 01:35:18 +01:00
Sjoerd van de Goor
c1cf8e88ee That is pretty necessary 2023-02-08 01:33:31 +01:00
Sjoerd van de Goor
684bd739b9 Slope rotation (unfinished) 2023-02-08 01:30:12 +01:00
Sjoerd van de Goor
d4c0e07b1d Slope condition 2023-02-08 01:29:30 +01:00
Sjoerd van de Goor
a6ea6fcfb2 better 2023-02-07 17:39:44 +01:00
Sjoerd van de Goor
c366ec0c40 MM should set its own stuff 2023-02-07 17:26:06 +01:00
CocoTheOwner
8d715e2e4e x != z 2023-02-06 15:43:27 +01:00
CocoTheOwner
dea3ec80ac Fix image mapping math
Fixes snippet code, prevents an NPE, fixes centered for coordinateScale scaled image noises, fixes tiling on negative numbers (-1 % 2 = -1, a free fuck you from java)
2023-02-06 15:39:28 +01:00
CocoTheOwner
4053f05ba9 Actually check for origin on command invoke 2023-02-06 14:58:17 +01:00
7 changed files with 74 additions and 14 deletions

View File

@@ -49,6 +49,14 @@ public class IrisRenderer {
colorFunction = (x, z) -> renderer.getComplex().getCaveBiomeStream().get(x, z).getColor(renderer, currentType).getRGB();
case HEIGHT ->
colorFunction = (x, z) -> Color.getHSBColor(renderer.getComplex().getHeightStream().get(x, z).floatValue(), 100, 100).getRGB();
case CONTINENT -> {
double fluidHeight = renderer.getComplex().getFluidHeight();
int deltaHeight = renderer.getMaxHeight() - renderer.getMinHeight();
colorFunction = (x, z) -> {
double h = renderer.getComplex().getHeightStream().get(x, z);
return new Color((int) (h * 255d / deltaHeight), 128, h > fluidHeight ? 0 : 255).getRGB();
};
}
}
double x, z;

View File

@@ -19,5 +19,5 @@
package com.volmit.iris.core.gui.components;
public enum RenderType {
BIOME, BIOME_LAND, BIOME_SEA, REGION, CAVE_LAND, HEIGHT, OBJECT_LOAD, DECORATOR_LOAD, LAYER_LOAD
BIOME, BIOME_LAND, BIOME_SEA, REGION, CAVE_LAND, HEIGHT, OBJECT_LOAD, DECORATOR_LOAD, CONTINENT, LAYER_LOAD
}

View File

@@ -154,6 +154,9 @@ public class IrisEntity extends IrisRegistrant {
@Desc("Create a mob from another plugin, such as Mythic Mobs. Should be in the format of a namespace of PluginName:MobName")
private String specialType = "";
@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.")
@RegistryListResource(IrisScript.class)
private String spawnerScript = "";
@@ -211,6 +214,10 @@ public class IrisEntity extends IrisRegistrant {
}
}
if (isSpecialType() && !applySettingsToCustomMobAnyways) {
return ee;
}
if (ee == null) {
return null;
}

View File

@@ -32,7 +32,7 @@ import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;
@Snippet("carving")
@Snippet("image-map")
@Accessors(chain = true)
@NoArgsConstructor
@AllArgsConstructor
@@ -68,6 +68,7 @@ public class IrisImageMap {
IrisImage i = imageCache.aquire(() -> data.getImageLoader().load(image));
if (i == null) {
Iris.error("NULL IMAGE FOR " + image);
return 0;
}
return IrisInterpolation.getNoise(interpolationMethod, x, z, coordinateScale, (xx, zz) -> rawNoise(i, xx, zz));
@@ -76,11 +77,27 @@ public class IrisImageMap {
private double rawNoise(IrisImage i, double x, double z) {
x /= coordinateScale;
z /= coordinateScale;
x = isCentered() ? x + ((i.getWidth() / 2D) * coordinateScale) : x;
z = isCentered() ? z + ((i.getHeight() / 2D) * coordinateScale) : z;
x = isTiled() ? x % i.getWidth() : x;
z = isTiled() ? z % i.getHeight() : z;
// X and Z are now scaled to the image
// Add half the image width & height if centered
if (isCentered()) {
x += i.getWidth() / 2D;
z += i.getHeight() / 2D;
}
// If tiled modulo over width and height
if (isTiled()) {
x = x % i.getWidth();
x = x < 0 ? x + i.getWidth() : x; // Fix java's negative modulo shit
z = z % i.getHeight();
z = z < 0 ? z + i.getHeight() : z; // Fix java's negative modulo shit
}
// Retrieve value from image
double v = i.getValue(getChannel(), (int) x, (int) z);
// Return value, or 1 - value if inverted (value is in double set [0, 1] so this will return [0, 1])
return isInverted() ? 1D - v : v;
}
}

View File

@@ -30,16 +30,14 @@ import com.volmit.iris.util.data.B;
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;
import com.volmit.iris.util.plugin.VolmitSender;
import com.volmit.iris.util.scheduling.IrisLock;
import com.volmit.iris.util.scheduling.PrecisionStopwatch;
import com.volmit.iris.util.stream.ProceduralStream;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.Setter;
@@ -496,6 +494,30 @@ public class IrisObject extends IrisRegistrant {
public int place(int x, int yv, int z, IObjectPlacer oplacer, IrisObjectPlacement config, RNG rng, BiConsumer<BlockPosition, BlockData> listener, CarveResult c, IrisData rdata) {
IObjectPlacer placer = (config.getHeightmap() != null) ? new HeightmapObjectPlacer(oplacer.getEngine() == null ? IrisContext.get().getEngine() : oplacer.getEngine(), rng, x, yv, z, config, oplacer) : oplacer;
// Rotation calculation
int slopeRotationY = 0;
ProceduralStream<Double> heightStream = rdata.getEngine().getComplex().getHeightStream();
if (config.isRotateTowardsSlope()) {
// Whichever side of the rectangle that bounds the object is lowest is the 'direction' of the slope (simply said).
double hNorth = heightStream.get(x, z + ((float)d) / 2);
double hEast = heightStream.get(x + ((float)w) / 2, z);
double hSouth = heightStream.get(x, z - ((float)d) / 2);
double hWest = heightStream.get(x - ((float)w) / 2, z);
double min = Math.min(Math.min(hNorth, hEast), Math.min(hSouth, hWest));
if (min == hNorth) {
slopeRotationY = 0;
} else if (min == hEast) {
slopeRotationY = 90;
} else if (min == hSouth) {
slopeRotationY = 180;
} else if (min == hWest) {
slopeRotationY = 270;
}
}
double newRotation = config.getRotation().getYAxis().getMin() + slopeRotationY;
config.getRotation().setYAxis(new IrisAxisRotationClamp(true, false, newRotation, newRotation, 360));
config.getRotation().setEnabled(true);
if (config.isSmartBore()) {
ensureSmartBored(placer.isDebugSmartBore());
}

View File

@@ -62,6 +62,9 @@ public class IrisObjectPlacement {
private double snow = 0;
@Desc("Whether or not this object can be targeted by a dolphin.")
private boolean isDolphinTarget = false;
@Desc("Set to true to add the rotation of the direction of the slope of the terrain (wherever the slope is going down) to the y-axis rotation of the object." +
"Rounded to 90 degrees. Adds the *min* rotation of the y axis as well (to still allow you to rotate objects nicely). Discards *max* and *interval* on *yaxis*")
private boolean rotateTowardsSlope = false;
@MinNumber(0)
@MaxNumber(1)
@Desc("The chance for this to place in a chunk. If you need multiple per chunk, set this to 1 and use density.")

View File

@@ -23,10 +23,7 @@ import com.volmit.iris.core.IrisSettings;
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.decree.DecreeContext;
import com.volmit.iris.util.decree.DecreeContextHandler;
import com.volmit.iris.util.decree.DecreeNode;
import com.volmit.iris.util.decree.DecreeParameter;
import com.volmit.iris.util.decree.*;
import com.volmit.iris.util.decree.annotations.Decree;
import com.volmit.iris.util.decree.exceptions.DecreeParsingException;
import com.volmit.iris.util.format.C;
@@ -381,6 +378,12 @@ public class VirtualDecreeCommand {
return false;
}
DecreeOrigin origin = type.getDeclaredAnnotation(Decree.class).origin();
if (origin.validFor(sender)) {
sender.sendMessage(C.RED + "This command has to be sent from another origin: " + C.GOLD + origin);
return false;
}
Iris.debug("@ " + getPath() + " with " + args.toString(", "));
if (isNode()) {
Iris.debug("Invoke " + getPath() + "(" + args.toString(",") + ") at ");