From 930469a006429ce0c152bfb1924f4481288ffd90 Mon Sep 17 00:00:00 2001 From: cyberpwn Date: Sat, 11 Sep 2021 12:00:04 -0400 Subject: [PATCH] Matter placer --- .../engine/object/IrisMatterPlacement.java | 38 ++++++++++++ .../com/volmit/iris/util/mantle/Mantle.java | 11 ++++ .../volmit/iris/util/matter/MatterPlacer.java | 60 +++++++++++++++++++ 3 files changed, 109 insertions(+) create mode 100644 src/main/java/com/volmit/iris/engine/object/IrisMatterPlacement.java create mode 100644 src/main/java/com/volmit/iris/util/matter/MatterPlacer.java diff --git a/src/main/java/com/volmit/iris/engine/object/IrisMatterPlacement.java b/src/main/java/com/volmit/iris/engine/object/IrisMatterPlacement.java new file mode 100644 index 000000000..4bf4fcf66 --- /dev/null +++ b/src/main/java/com/volmit/iris/engine/object/IrisMatterPlacement.java @@ -0,0 +1,38 @@ +/* + * 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 . + */ + +package com.volmit.iris.engine.object; + +import com.volmit.iris.engine.object.annotations.Desc; +import com.volmit.iris.engine.object.annotations.Snippet; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.NoArgsConstructor; +import lombok.experimental.Accessors; + +@Snippet("matter-placer") +@EqualsAndHashCode() +@Accessors(chain = true) +@NoArgsConstructor +@AllArgsConstructor +@Desc("Represents an iris object placer. It places objects.") +@Data +public class IrisMatterPlacement { + +} diff --git a/src/main/java/com/volmit/iris/util/mantle/Mantle.java b/src/main/java/com/volmit/iris/util/mantle/Mantle.java index 2ee288565..1cb977f76 100644 --- a/src/main/java/com/volmit/iris/util/mantle/Mantle.java +++ b/src/main/java/com/volmit/iris/util/mantle/Mantle.java @@ -31,8 +31,10 @@ import com.volmit.iris.util.documentation.RegionCoordinates; import com.volmit.iris.util.format.C; import com.volmit.iris.util.format.Form; import com.volmit.iris.util.function.Consumer4; +import com.volmit.iris.util.math.AxisAlignedBB; import com.volmit.iris.util.math.M; import com.volmit.iris.util.matter.Matter; +import com.volmit.iris.util.matter.MatterSlice; import com.volmit.iris.util.parallel.BurstExecutor; import com.volmit.iris.util.parallel.HyperLock; import com.volmit.iris.util.parallel.MultiBurst; @@ -504,4 +506,13 @@ public class Mantle { public int getLoadedRegionCount() { return loadedRegions.size(); } + + public void set(int x, int y, int z, MatterSlice slice) { + if(slice.isEmpty()) + { + return; + } + + slice.iterateSync((xx,yy,zz,t) -> set(x+xx,y+yy,z+zz,t)); + } } diff --git a/src/main/java/com/volmit/iris/util/matter/MatterPlacer.java b/src/main/java/com/volmit/iris/util/matter/MatterPlacer.java new file mode 100644 index 000000000..ea436ac4d --- /dev/null +++ b/src/main/java/com/volmit/iris/util/matter/MatterPlacer.java @@ -0,0 +1,60 @@ +/* + * 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 . + */ + +package com.volmit.iris.util.matter; + +import com.volmit.iris.util.mantle.Mantle; + +public interface MatterPlacer { + int getHeight(int x, int z, boolean ignoreFluid); + + Mantle getMantle(); + + default void set(int x, int y, int z, T t) + { + getMantle().set(x,y,z,t); + } + + default T get(int x, int y, int z, Class t) + { + return getMantle().get(x, y, z, t); + } + + default void set(int x, int y, int z, Matter matter) + { + for(MatterSlice i : matter.getSliceMap().values()) + { + set(x, y, z, i); + } + } + + default void set(int x, int y, int z, MatterSlice slice) + { + getMantle().set(x, y, z, slice); + } + + default int getHeight(int x, int z) + { + return getHeight(x, z, true); + } + + default int getHeightOrFluid(int x, int z) + { + return getHeight(x, z, false); + } +}