mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2026-04-24 00:47:31 +00:00
Mantle Impl
This commit is contained in:
38
src/main/java/com/volmit/iris/engine/IrisEngineMantle.java
Normal file
38
src/main/java/com/volmit/iris/engine/IrisEngineMantle.java
Normal file
@@ -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 <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
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());
|
||||||
|
}
|
||||||
|
}
|
||||||
147
src/main/java/com/volmit/iris/engine/mantle/EngineMantle.java
Normal file
147
src/main/java/com/volmit/iris/engine/mantle/EngineMantle.java
Normal file
@@ -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 <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
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<? extends TileState> 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();
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user