From 956958fa0e68bd3cc56252f4bb3d1bb718482f6b Mon Sep 17 00:00:00 2001 From: Daniel Mills Date: Sat, 7 Aug 2021 08:34:45 -0400 Subject: [PATCH] Mantle Impl --- .../volmit/iris/engine/IrisEngineMantle.java | 38 +++++ .../iris/engine/mantle/EngineMantle.java | 147 ++++++++++++++++++ 2 files changed, 185 insertions(+) create mode 100644 src/main/java/com/volmit/iris/engine/IrisEngineMantle.java create mode 100644 src/main/java/com/volmit/iris/engine/mantle/EngineMantle.java diff --git a/src/main/java/com/volmit/iris/engine/IrisEngineMantle.java b/src/main/java/com/volmit/iris/engine/IrisEngineMantle.java new file mode 100644 index 000000000..f9f0994c3 --- /dev/null +++ b/src/main/java/com/volmit/iris/engine/IrisEngineMantle.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; + +import com.volmit.iris.engine.framework.Engine; +import com.volmit.iris.engine.mantle.EngineMantle; +import com.volmit.iris.util.mantle.Mantle; +import lombok.Data; + +import java.io.File; + +@Data +public class IrisEngineMantle implements EngineMantle { + private final Engine engine; + private final Mantle mantle; + + public IrisEngineMantle(Engine engine) + { + this.engine = engine; + this.mantle = new Mantle(new File(engine.getWorld().worldFolder(), "mantle/" + engine.getIndex()), engine.getTarget().getHeight()); + } +} diff --git a/src/main/java/com/volmit/iris/engine/mantle/EngineMantle.java b/src/main/java/com/volmit/iris/engine/mantle/EngineMantle.java new file mode 100644 index 000000000..97e55341c --- /dev/null +++ b/src/main/java/com/volmit/iris/engine/mantle/EngineMantle.java @@ -0,0 +1,147 @@ +/* + * 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.mantle; + +import com.volmit.iris.Iris; +import com.volmit.iris.core.project.loader.IrisData; +import com.volmit.iris.engine.IrisComplex; +import com.volmit.iris.engine.framework.Engine; +import com.volmit.iris.engine.framework.EngineComponent; +import com.volmit.iris.engine.framework.EngineFramework; +import com.volmit.iris.engine.framework.EngineTarget; +import com.volmit.iris.engine.object.common.IObjectPlacer; +import com.volmit.iris.engine.object.dimensional.IrisDimension; +import com.volmit.iris.engine.object.tile.TileData; +import com.volmit.iris.engine.parallax.ParallaxAccess; +import com.volmit.iris.util.data.B; +import com.volmit.iris.util.mantle.Mantle; +import org.bukkit.block.TileState; +import org.bukkit.block.data.BlockData; + +public interface EngineMantle extends IObjectPlacer +{ + BlockData AIR = B.get("AIR"); + + Mantle getMantle(); + + Engine getEngine(); + + default int getHighest(int x, int z) { + return getHighest(x, z, getData()); + } + + default int getHighest(int x, int z, boolean ignoreFluid) { + return getHighest(x, z, getData(), ignoreFluid); + } + + @Override + default int getHighest(int x, int z, IrisData data) { + return getHighest(x, z, data, false); + } + + @Override + default int getHighest(int x, int z, IrisData data, boolean ignoreFluid) { + return ignoreFluid ? trueHeight(x, z) : Math.max(trueHeight(x, z), getEngine().getDimension().getFluidHeight()); + } + + default int trueHeight(int x, int z) { + return getComplex().getTrueHeightStream().get(x, z); + } + + @Override + default void set(int x, int y, int z, BlockData d) { + getMantle().set(x,y,z,d == null ? AIR : d); + } + + @Override + default void setTile(int x, int y, int z, TileData d) { + // TODO SET TILE + Iris.warn("Unable to set tile data in mantles yet."); + } + + @Override + default BlockData get(int x, int y, int z) { + BlockData block = getMantle().get(x,y,z,BlockData.class); + + if (block == null) { + return AIR; + } + + return block; + } + + @Override + default boolean isPreventingDecay() { + return getEngine().getDimension().isPreventLeafDecay(); + } + + @Override + default boolean isSolid(int x, int y, int z) { + return B.isSolid(get(x, y, z)); + } + + @Override + default boolean isUnderwater(int x, int z) { + return getHighest(x, z, true) <= getFluidHeight(); + } + + @Override + default int getFluidHeight() { + return getEngine().getDimension().getFluidHeight(); + } + + @Override + default boolean isDebugSmartBore() { + return getEngine().getDimension().isDebugSmartBore(); + } + + default void trim(long dur) + { + getMantle().trim(dur); + } + + default IrisData getData() { + return getEngine().getData(); + } + + default ParallaxAccess getParallax() { + return getEngine().getParallax(); + } + + default EngineTarget getTarget() { + return getEngine().getTarget(); + } + + default IrisDimension getDimension() { + return getEngine().getDimension(); + } + + default EngineFramework getFramework() { + return getEngine().getFramework(); + } + + default IrisComplex getComplex() { + return getFramework().getComplex(); + } + + default void close() + { + getMantle().close(); + } +}