mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2025-12-26 02:29:14 +00:00
Added tile entity support + mantle.
This commit is contained in:
@@ -24,25 +24,12 @@ import com.volmit.iris.core.gui.components.RenderType;
|
||||
import com.volmit.iris.core.gui.components.Renderer;
|
||||
import com.volmit.iris.core.loader.IrisData;
|
||||
import com.volmit.iris.core.loader.IrisRegistrant;
|
||||
import com.volmit.iris.core.nms.INMS;
|
||||
import com.volmit.iris.engine.IrisComplex;
|
||||
import com.volmit.iris.engine.data.cache.Cache;
|
||||
import com.volmit.iris.engine.data.chunk.TerrainChunk;
|
||||
import com.volmit.iris.engine.mantle.EngineMantle;
|
||||
import com.volmit.iris.engine.object.InventorySlotType;
|
||||
import com.volmit.iris.engine.object.IrisBiome;
|
||||
import com.volmit.iris.engine.object.IrisColor;
|
||||
import com.volmit.iris.engine.object.IrisDimension;
|
||||
import com.volmit.iris.engine.object.IrisEngineData;
|
||||
import com.volmit.iris.engine.object.IrisJigsawStructure;
|
||||
import com.volmit.iris.engine.object.IrisJigsawStructurePlacement;
|
||||
import com.volmit.iris.engine.object.IrisLootMode;
|
||||
import com.volmit.iris.engine.object.IrisLootReference;
|
||||
import com.volmit.iris.engine.object.IrisLootTable;
|
||||
import com.volmit.iris.engine.object.IrisObject;
|
||||
import com.volmit.iris.engine.object.IrisObjectPlacement;
|
||||
import com.volmit.iris.engine.object.IrisPosition;
|
||||
import com.volmit.iris.engine.object.IrisRegion;
|
||||
import com.volmit.iris.engine.object.IrisWorld;
|
||||
import com.volmit.iris.engine.object.*;
|
||||
import com.volmit.iris.engine.scripting.EngineExecutionEnvironment;
|
||||
import com.volmit.iris.util.collection.KList;
|
||||
import com.volmit.iris.util.collection.KMap;
|
||||
@@ -61,6 +48,7 @@ import com.volmit.iris.util.math.Position2;
|
||||
import com.volmit.iris.util.math.RNG;
|
||||
import com.volmit.iris.util.matter.MatterCavern;
|
||||
import com.volmit.iris.util.matter.MatterUpdate;
|
||||
import com.volmit.iris.util.matter.TileWrapper;
|
||||
import com.volmit.iris.util.parallel.BurstExecutor;
|
||||
import com.volmit.iris.util.parallel.MultiBurst;
|
||||
import com.volmit.iris.util.scheduling.ChronoLatch;
|
||||
@@ -262,11 +250,6 @@ public interface Engine extends DataProvider, Fallible, LootProvider, BlockUpdat
|
||||
}
|
||||
}
|
||||
|
||||
@ChunkCoordinates
|
||||
default void placeTiles(Chunk c) {
|
||||
|
||||
}
|
||||
|
||||
void blockUpdatedMetric();
|
||||
|
||||
@ChunkCoordinates
|
||||
@@ -280,6 +263,15 @@ public interface Engine extends DataProvider, Fallible, LootProvider, BlockUpdat
|
||||
&& c.getWorld().isChunkLoaded(c.getX() - 1, c.getZ())
|
||||
&& c.getWorld().isChunkLoaded(c.getX() + 1, c.getZ() - 1)
|
||||
&& c.getWorld().isChunkLoaded(c.getX() - 1, c.getZ() + 1) && getMantle().getMantle().isLoaded(c)) {
|
||||
|
||||
getMantle().getMantle().raiseFlag(c.getX(), c.getZ(), MantleFlag.TILE, () -> J.s(() -> {
|
||||
getMantle().getMantle().iterateChunk(c.getX(), c.getZ(), TileWrapper.class, (x, y, z, tile) -> {
|
||||
int betterY = y + getWorld().minHeight();
|
||||
if(!TileData.setTileState(c.getBlock(x, betterY, z), tile.getData()))
|
||||
Iris.warn("Failed to set tile entity data at [%d %d %d | %s] for tile %s!", x, betterY ,z, c.getBlock(x, betterY, z).getBlockData().getMaterial().getKey(), tile.getData().getTileId());
|
||||
});
|
||||
}));
|
||||
|
||||
getMantle().getMantle().raiseFlag(c.getX(), c.getZ(), MantleFlag.UPDATE, () -> J.s(() -> {
|
||||
PrecisionStopwatch p = PrecisionStopwatch.start();
|
||||
KMap<Long, Integer> updates = new KMap<>();
|
||||
|
||||
@@ -57,10 +57,10 @@ public interface TileData<T extends TileState> extends Cloneable {
|
||||
}
|
||||
}
|
||||
|
||||
static void setTileState(Block block, TileData<? extends TileState> data) {
|
||||
if(data.isApplicable(block.getBlockData())) {
|
||||
data.toBukkitTry(block.getState());
|
||||
}
|
||||
static boolean setTileState(Block block, TileData<? extends TileState> data) {
|
||||
if(block.getState() instanceof TileState && data.isApplicable(block.getBlockData()))
|
||||
return data.toBukkitTry(block.getState());
|
||||
return false;
|
||||
}
|
||||
|
||||
static TileData<? extends TileState> getTileState(Block block) {
|
||||
@@ -94,6 +94,7 @@ public interface TileData<T extends TileState> extends Cloneable {
|
||||
try {
|
||||
//noinspection unchecked
|
||||
toBukkit((T) t);
|
||||
t.update();
|
||||
return true;
|
||||
} catch(Throwable e) {
|
||||
Iris.reportError(e);
|
||||
|
||||
@@ -32,7 +32,8 @@ public enum MantleFlag {
|
||||
INITIAL_SPAWNED_MARKER,
|
||||
CLEANED,
|
||||
PLANNED,
|
||||
ETCHED;
|
||||
ETCHED,
|
||||
TILE;
|
||||
|
||||
static StateList getStateList() {
|
||||
return new StateList(MantleFlag.values());
|
||||
|
||||
Reference in New Issue
Block a user