mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2026-06-17 14:21:33 +00:00
+1
-1
@@ -24,7 +24,7 @@ plugins {
|
|||||||
id "de.undercouch.download" version "5.0.1"
|
id "de.undercouch.download" version "5.0.1"
|
||||||
}
|
}
|
||||||
|
|
||||||
version '2.1.2-1.18.2' // Needs to be version specific
|
version '2.1.3-1.18.2' // Needs to be version specific
|
||||||
def nmsVersion = "1.18.2"
|
def nmsVersion = "1.18.2"
|
||||||
def apiVersion = '1.18'
|
def apiVersion = '1.18'
|
||||||
def spigotJarVersion = '1.18.2-R0.1-SNAPSHOT'
|
def spigotJarVersion = '1.18.2-R0.1-SNAPSHOT'
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ import com.volmit.iris.core.link.*;
|
|||||||
import com.volmit.iris.core.loader.IrisData;
|
import com.volmit.iris.core.loader.IrisData;
|
||||||
import com.volmit.iris.core.nms.INMS;
|
import com.volmit.iris.core.nms.INMS;
|
||||||
import com.volmit.iris.core.service.StudioSVC;
|
import com.volmit.iris.core.service.StudioSVC;
|
||||||
|
import com.volmit.iris.core.tools.IrisToolbelt;
|
||||||
import com.volmit.iris.engine.EnginePanic;
|
import com.volmit.iris.engine.EnginePanic;
|
||||||
import com.volmit.iris.engine.object.IrisCompat;
|
import com.volmit.iris.engine.object.IrisCompat;
|
||||||
import com.volmit.iris.engine.object.IrisDimension;
|
import com.volmit.iris.engine.object.IrisDimension;
|
||||||
@@ -60,6 +61,7 @@ import org.bukkit.GameMode;
|
|||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.bukkit.WorldCreator;
|
import org.bukkit.WorldCreator;
|
||||||
|
import org.bukkit.block.data.BlockData;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.configuration.file.FileConfiguration;
|
import org.bukkit.configuration.file.FileConfiguration;
|
||||||
@@ -407,6 +409,8 @@ public class Iris extends VolmitPlugin implements Listener {
|
|||||||
splash();
|
splash();
|
||||||
autoStartStudio();
|
autoStartStudio();
|
||||||
checkForBukkitWorlds();
|
checkForBukkitWorlds();
|
||||||
|
IrisToolbelt.retainMantleDataForSlice(String.class.getCanonicalName());
|
||||||
|
IrisToolbelt.retainMantleDataForSlice(BlockData.class.getCanonicalName());
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -126,8 +126,8 @@ public class NMSBinding18_2 implements INMSBinding {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void deserializeTile(CompoundTag c, Location newPosition) {
|
public void deserializeTile(CompoundTag c, Location pos) {
|
||||||
((CraftWorld) newPosition.getWorld()).getHandle().getChunkAt(new BlockPos(newPosition.getBlockX(), 0, newPosition.getBlockZ())).setBlockEntityNbt(convert(c));
|
((CraftWorld) pos.getWorld()).getHandle().getChunkAt(new BlockPos(pos.getBlockX(), 0, pos.getBlockZ())).setBlockEntityNbt(convert(c));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -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.gui.components.Renderer;
|
||||||
import com.volmit.iris.core.loader.IrisData;
|
import com.volmit.iris.core.loader.IrisData;
|
||||||
import com.volmit.iris.core.loader.IrisRegistrant;
|
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.IrisComplex;
|
||||||
import com.volmit.iris.engine.data.cache.Cache;
|
import com.volmit.iris.engine.data.cache.Cache;
|
||||||
import com.volmit.iris.engine.data.chunk.TerrainChunk;
|
import com.volmit.iris.engine.data.chunk.TerrainChunk;
|
||||||
import com.volmit.iris.engine.mantle.EngineMantle;
|
import com.volmit.iris.engine.mantle.EngineMantle;
|
||||||
import com.volmit.iris.engine.object.InventorySlotType;
|
import com.volmit.iris.engine.object.*;
|
||||||
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.scripting.EngineExecutionEnvironment;
|
import com.volmit.iris.engine.scripting.EngineExecutionEnvironment;
|
||||||
import com.volmit.iris.util.collection.KList;
|
import com.volmit.iris.util.collection.KList;
|
||||||
import com.volmit.iris.util.collection.KMap;
|
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.math.RNG;
|
||||||
import com.volmit.iris.util.matter.MatterCavern;
|
import com.volmit.iris.util.matter.MatterCavern;
|
||||||
import com.volmit.iris.util.matter.MatterUpdate;
|
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.BurstExecutor;
|
||||||
import com.volmit.iris.util.parallel.MultiBurst;
|
import com.volmit.iris.util.parallel.MultiBurst;
|
||||||
import com.volmit.iris.util.scheduling.ChronoLatch;
|
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();
|
void blockUpdatedMetric();
|
||||||
|
|
||||||
@ChunkCoordinates
|
@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())
|
||||||
&& c.getWorld().isChunkLoaded(c.getX() + 1, c.getZ() - 1)
|
&& c.getWorld().isChunkLoaded(c.getX() + 1, c.getZ() - 1)
|
||||||
&& c.getWorld().isChunkLoaded(c.getX() - 1, c.getZ() + 1) && getMantle().getMantle().isLoaded(c)) {
|
&& 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(() -> {
|
getMantle().getMantle().raiseFlag(c.getX(), c.getZ(), MantleFlag.UPDATE, () -> J.s(() -> {
|
||||||
PrecisionStopwatch p = PrecisionStopwatch.start();
|
PrecisionStopwatch p = PrecisionStopwatch.start();
|
||||||
KMap<Long, Integer> updates = new KMap<>();
|
KMap<Long, Integer> updates = new KMap<>();
|
||||||
|
|||||||
@@ -38,10 +38,7 @@ import com.volmit.iris.util.hunk.Hunk;
|
|||||||
import com.volmit.iris.util.mantle.Mantle;
|
import com.volmit.iris.util.mantle.Mantle;
|
||||||
import com.volmit.iris.util.mantle.MantleChunk;
|
import com.volmit.iris.util.mantle.MantleChunk;
|
||||||
import com.volmit.iris.util.mantle.MantleFlag;
|
import com.volmit.iris.util.mantle.MantleFlag;
|
||||||
import com.volmit.iris.util.matter.Matter;
|
import com.volmit.iris.util.matter.*;
|
||||||
import com.volmit.iris.util.matter.MatterCavern;
|
|
||||||
import com.volmit.iris.util.matter.MatterFluidBody;
|
|
||||||
import com.volmit.iris.util.matter.MatterMarker;
|
|
||||||
import com.volmit.iris.util.matter.slices.UpdateMatter;
|
import com.volmit.iris.util.matter.slices.UpdateMatter;
|
||||||
import com.volmit.iris.util.parallel.BurstExecutor;
|
import com.volmit.iris.util.parallel.BurstExecutor;
|
||||||
import com.volmit.iris.util.parallel.MultiBurst;
|
import com.volmit.iris.util.parallel.MultiBurst;
|
||||||
@@ -109,17 +106,14 @@ public interface EngineMantle extends IObjectPlacer {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
default void setTile(int x, int y, int z, TileData<? extends TileState> d) {
|
default void setTile(int x, int y, int z, TileData<? extends TileState> d) {
|
||||||
// TODO SET TILE
|
getMantle().set(x, y, z, new TileWrapper(d));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
default BlockData get(int x, int y, int z) {
|
default BlockData get(int x, int y, int z) {
|
||||||
BlockData block = getMantle().get(x, y, z, BlockData.class);
|
BlockData block = getMantle().get(x, y, z, BlockData.class);
|
||||||
|
if(block == null)
|
||||||
if(block == null) {
|
|
||||||
return AIR;
|
return AIR;
|
||||||
}
|
|
||||||
|
|
||||||
return block;
|
return block;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -38,6 +38,7 @@ import lombok.EqualsAndHashCode;
|
|||||||
import lombok.NoArgsConstructor;
|
import lombok.NoArgsConstructor;
|
||||||
import lombok.experimental.Accessors;
|
import lombok.experimental.Accessors;
|
||||||
import org.bukkit.block.data.BlockData;
|
import org.bukkit.block.data.BlockData;
|
||||||
|
import org.bukkit.entity.EntityType;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
@@ -199,6 +200,19 @@ public class IrisBlockData extends IrisRegistrant {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public TileData<?> tryGetTile() {
|
||||||
|
//TODO Do like a registry thing with the tile data registry. Also update the parsing of data to include **block** entities.
|
||||||
|
if(data.containsKey("entitySpawn")) {
|
||||||
|
TileSpawner spawner = new TileSpawner();
|
||||||
|
String name = (String)data.get("entitySpawn");
|
||||||
|
if(name.contains(":"))
|
||||||
|
name = name.split(":")[1];
|
||||||
|
spawner.setEntityType(EntityType.fromName(name));
|
||||||
|
return spawner;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
private String keyify(String dat) {
|
private String keyify(String dat) {
|
||||||
if(dat.contains(":")) {
|
if(dat.contains(":")) {
|
||||||
return dat;
|
return dat;
|
||||||
|
|||||||
@@ -34,6 +34,8 @@ import lombok.NoArgsConstructor;
|
|||||||
import lombok.experimental.Accessors;
|
import lombok.experimental.Accessors;
|
||||||
import org.bukkit.block.data.BlockData;
|
import org.bukkit.block.data.BlockData;
|
||||||
|
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
@Snippet("palette")
|
@Snippet("palette")
|
||||||
@Accessors(chain = true)
|
@Accessors(chain = true)
|
||||||
@NoArgsConstructor
|
@NoArgsConstructor
|
||||||
@@ -66,6 +68,14 @@ public class IrisMaterialPalette {
|
|||||||
return getLayerGenerator(rng, rdata).fit(getBlockData(rdata), x / zoom, y / zoom, z / zoom);
|
return getLayerGenerator(rng, rdata).fit(getBlockData(rdata), x / zoom, y / zoom, z / zoom);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Optional<TileData<?>> getTile(RNG rng, double x, double y, double z, IrisData rdata) {
|
||||||
|
if(getBlockData(rdata).isEmpty())
|
||||||
|
return Optional.empty();
|
||||||
|
|
||||||
|
TileData<?> tile = getBlockData(rdata).size() == 1 ? palette.get(0).tryGetTile() : palette.getRandom(rng).tryGetTile();
|
||||||
|
return tile != null ? Optional.of(tile) : Optional.empty();
|
||||||
|
}
|
||||||
|
|
||||||
public CNG getLayerGenerator(RNG rng, IrisData rdata) {
|
public CNG getLayerGenerator(RNG rng, IrisData rdata) {
|
||||||
return layerGenerator.aquire(() ->
|
return layerGenerator.aquire(() ->
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -34,8 +34,6 @@ import com.volmit.iris.util.math.AxisAlignedBB;
|
|||||||
import com.volmit.iris.util.math.BlockPosition;
|
import com.volmit.iris.util.math.BlockPosition;
|
||||||
import com.volmit.iris.util.math.Position2;
|
import com.volmit.iris.util.math.Position2;
|
||||||
import com.volmit.iris.util.math.RNG;
|
import com.volmit.iris.util.math.RNG;
|
||||||
import com.volmit.iris.util.matter.IrisMatter;
|
|
||||||
import com.volmit.iris.util.matter.Matter;
|
|
||||||
import com.volmit.iris.util.matter.MatterMarker;
|
import com.volmit.iris.util.matter.MatterMarker;
|
||||||
import com.volmit.iris.util.parallel.BurstExecutor;
|
import com.volmit.iris.util.parallel.BurstExecutor;
|
||||||
import com.volmit.iris.util.parallel.MultiBurst;
|
import com.volmit.iris.util.parallel.MultiBurst;
|
||||||
@@ -65,11 +63,7 @@ import java.io.FileOutputStream;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.io.OutputStream;
|
import java.io.OutputStream;
|
||||||
import java.util.ArrayList;
|
import java.util.*;
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Objects;
|
|
||||||
import java.util.concurrent.atomic.AtomicInteger;
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
|
|
||||||
@@ -739,10 +733,16 @@ public class IrisObject extends IrisRegistrant {
|
|||||||
if(j.isExact() ? k.matches(data) : k.getMaterial().equals(data.getMaterial())) {
|
if(j.isExact() ? k.matches(data) : k.getMaterial().equals(data.getMaterial())) {
|
||||||
BlockData newData = j.getReplace(rng, i.getX() + x, i.getY() + y, i.getZ() + z, rdata).clone();
|
BlockData newData = j.getReplace(rng, i.getX() + x, i.getY() + y, i.getZ() + z, rdata).clone();
|
||||||
|
|
||||||
if(newData.getMaterial() == data.getMaterial()) {
|
if(newData.getMaterial() == data.getMaterial())
|
||||||
data = data.merge(newData);
|
data = data.merge(newData);
|
||||||
} else {
|
else
|
||||||
data = newData;
|
data = newData;
|
||||||
|
|
||||||
|
if(newData.getMaterial() == Material.SPAWNER) {
|
||||||
|
Optional<TileData<?>> t = j.getReplace().getTile(rng, x, y, z, rdata);
|
||||||
|
if(t.isPresent()) {
|
||||||
|
tile = t.get();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -98,7 +98,7 @@ public class TileBanner implements TileData<Banner> {
|
|||||||
|
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
@Override
|
@Override
|
||||||
public void toNBT(CompoundTag tag) {
|
public CompoundTag toNBT(CompoundTag tag) {
|
||||||
@SuppressWarnings("unchecked") ListTag<CompoundTag> listTag = (ListTag<CompoundTag>) ListTag.createUnchecked(CompoundTag.class);
|
@SuppressWarnings("unchecked") ListTag<CompoundTag> listTag = (ListTag<CompoundTag>) ListTag.createUnchecked(CompoundTag.class);
|
||||||
for(Pattern p : patterns) {
|
for(Pattern p : patterns) {
|
||||||
CompoundTag pattern = new CompoundTag();
|
CompoundTag pattern = new CompoundTag();
|
||||||
@@ -107,6 +107,7 @@ public class TileBanner implements TileData<Banner> {
|
|||||||
listTag.add(pattern);
|
listTag.add(pattern);
|
||||||
}
|
}
|
||||||
tag.put("Patterns", listTag);
|
tag.put("Patterns", listTag);
|
||||||
|
return tag;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isBanner(Material material) {
|
public boolean isBanner(Material material) {
|
||||||
|
|||||||
@@ -29,11 +29,12 @@ import org.bukkit.block.data.BlockData;
|
|||||||
import java.io.DataInputStream;
|
import java.io.DataInputStream;
|
||||||
import java.io.DataOutputStream;
|
import java.io.DataOutputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.lang.reflect.InvocationTargetException;
|
||||||
|
|
||||||
@SuppressWarnings("ALL")
|
@SuppressWarnings("ALL")
|
||||||
public interface TileData<T extends TileState> extends Cloneable {
|
public interface TileData<T extends TileState> extends Cloneable {
|
||||||
|
|
||||||
KList<TileData<? extends TileState>> registry = setup();
|
static final KList<TileData<? extends TileState>> registry = setup();
|
||||||
|
|
||||||
static KList<TileData<? extends TileState>> setup() {
|
static KList<TileData<? extends TileState>> setup() {
|
||||||
KList<TileData<? extends TileState>> registry = new KList<>();
|
KList<TileData<? extends TileState>> registry = new KList<>();
|
||||||
@@ -45,17 +46,21 @@ public interface TileData<T extends TileState> extends Cloneable {
|
|||||||
return registry;
|
return registry;
|
||||||
}
|
}
|
||||||
|
|
||||||
static TileData<? extends TileState> read(DataInputStream s) throws Throwable {
|
static TileData<? extends TileState> read(DataInputStream s) throws IOException {
|
||||||
int id = s.readShort();
|
try {
|
||||||
@SuppressWarnings("unchecked") TileData<? extends TileState> d = registry.get(id).getClass().getConstructor().newInstance();
|
int id = s.readShort();
|
||||||
d.fromBinary(s);
|
@SuppressWarnings("unchecked") TileData<? extends TileState> d = registry.get(id).getClass().getConstructor().newInstance();
|
||||||
return d;
|
d.fromBinary(s);
|
||||||
|
return d;
|
||||||
|
} catch(InvocationTargetException | InstantiationException | IllegalAccessException | NoSuchMethodException e) {
|
||||||
|
throw new IOException("Failed to create TileData instance due to missing type registrar!");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void setTileState(Block block, TileData<? extends TileState> data) {
|
static boolean setTileState(Block block, TileData<? extends TileState> data) {
|
||||||
if(data.isApplicable(block.getBlockData())) {
|
if(block.getState() instanceof TileState && data.isApplicable(block.getBlockData()))
|
||||||
data.toBukkitTry(block.getState());
|
return data.toBukkitTry(block.getState());
|
||||||
}
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
static TileData<? extends TileState> getTileState(Block block) {
|
static TileData<? extends TileState> getTileState(Block block) {
|
||||||
@@ -89,6 +94,7 @@ public interface TileData<T extends TileState> extends Cloneable {
|
|||||||
try {
|
try {
|
||||||
//noinspection unchecked
|
//noinspection unchecked
|
||||||
toBukkit((T) t);
|
toBukkit((T) t);
|
||||||
|
t.update();
|
||||||
return true;
|
return true;
|
||||||
} catch(Throwable e) {
|
} catch(Throwable e) {
|
||||||
Iris.reportError(e);
|
Iris.reportError(e);
|
||||||
@@ -111,11 +117,11 @@ public interface TileData<T extends TileState> extends Cloneable {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
TileData<T> clone();
|
CompoundTag toNBT(CompoundTag parent);
|
||||||
|
|
||||||
void toBinary(DataOutputStream out) throws IOException;
|
void toBinary(DataOutputStream out) throws IOException;
|
||||||
|
|
||||||
void toNBT(CompoundTag tag);
|
|
||||||
|
|
||||||
void fromBinary(DataInputStream in) throws IOException;
|
void fromBinary(DataInputStream in) throws IOException;
|
||||||
|
|
||||||
|
TileData<T> clone();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -98,11 +98,12 @@ public class TileSign implements TileData<Sign> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void toNBT(CompoundTag tag) {
|
public CompoundTag toNBT(CompoundTag tag) {
|
||||||
tag.putString("Text1", line1);
|
tag.putString("Text1", line1);
|
||||||
tag.putString("Text2", line2);
|
tag.putString("Text2", line2);
|
||||||
tag.putString("Text3", line3);
|
tag.putString("Text3", line3);
|
||||||
tag.putString("Text4", line4);
|
tag.putString("Text4", line4);
|
||||||
tag.putString("Color", dyeColor.name().toLowerCase());
|
tag.putString("Color", dyeColor.name().toLowerCase());
|
||||||
|
return tag;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -32,12 +32,13 @@ import java.io.IOException;
|
|||||||
|
|
||||||
@Data
|
@Data
|
||||||
public class TileSpawner implements TileData<CreatureSpawner> {
|
public class TileSpawner implements TileData<CreatureSpawner> {
|
||||||
public static final int id = 1;
|
|
||||||
private EntityType entityType;
|
|
||||||
|
|
||||||
|
public static final int id = 1;
|
||||||
|
|
||||||
|
private EntityType entityType;
|
||||||
@Override
|
@Override
|
||||||
public String getTileId() {
|
public String getTileId() {
|
||||||
return "minecraft:spawner";
|
return "minecraft:mob_spawner";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -75,7 +76,7 @@ public class TileSpawner implements TileData<CreatureSpawner> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void toNBT(CompoundTag tag) {
|
public CompoundTag toNBT(CompoundTag parent) {
|
||||||
@SuppressWarnings("unchecked") ListTag<CompoundTag> potentials = (ListTag<CompoundTag>) ListTag.createUnchecked(CompoundTag.class);
|
@SuppressWarnings("unchecked") ListTag<CompoundTag> potentials = (ListTag<CompoundTag>) ListTag.createUnchecked(CompoundTag.class);
|
||||||
CompoundTag t = new CompoundTag();
|
CompoundTag t = new CompoundTag();
|
||||||
CompoundTag ent = new CompoundTag();
|
CompoundTag ent = new CompoundTag();
|
||||||
@@ -83,6 +84,7 @@ public class TileSpawner implements TileData<CreatureSpawner> {
|
|||||||
t.put("Entity", ent);
|
t.put("Entity", ent);
|
||||||
t.putInt("Weight", 1);
|
t.putInt("Weight", 1);
|
||||||
potentials.add(t);
|
potentials.add(t);
|
||||||
tag.put("SpawnPotentials", potentials);
|
parent.put("SpawnPotentials", potentials);
|
||||||
|
return parent;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -32,7 +32,8 @@ public enum MantleFlag {
|
|||||||
INITIAL_SPAWNED_MARKER,
|
INITIAL_SPAWNED_MARKER,
|
||||||
CLEANED,
|
CLEANED,
|
||||||
PLANNED,
|
PLANNED,
|
||||||
ETCHED;
|
ETCHED,
|
||||||
|
TILE;
|
||||||
|
|
||||||
static StateList getStateList() {
|
static StateList getStateList() {
|
||||||
return new StateList(MantleFlag.values());
|
return new StateList(MantleFlag.values());
|
||||||
|
|||||||
+3
-5
@@ -18,12 +18,10 @@
|
|||||||
|
|
||||||
package com.volmit.iris.util.matter;
|
package com.volmit.iris.util.matter;
|
||||||
|
|
||||||
import com.volmit.iris.util.nbt.tag.CompoundTag;
|
import com.volmit.iris.engine.object.TileData;
|
||||||
import lombok.AllArgsConstructor;
|
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
@AllArgsConstructor
|
public class TileWrapper {
|
||||||
public class MatterTile {
|
private final TileData<?> data;
|
||||||
private final CompoundTag tileData;
|
|
||||||
}
|
}
|
||||||
@@ -33,8 +33,8 @@ public class WorldMatter {
|
|||||||
matter.slice(MatterEntityGroup.class).writeInto(at);
|
matter.slice(MatterEntityGroup.class).writeInto(at);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(matter.hasSlice(MatterTile.class)) {
|
if(matter.hasSlice(TileWrapper.class)) {
|
||||||
matter.slice(MatterTile.class).writeInto(at);
|
matter.slice(TileWrapper.class).writeInto(at);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -45,7 +45,7 @@ public class WorldMatter {
|
|||||||
s.getHeader().setAuthor(author);
|
s.getHeader().setAuthor(author);
|
||||||
s.slice(BlockData.class).readFrom(c.getLowerNE());
|
s.slice(BlockData.class).readFrom(c.getLowerNE());
|
||||||
s.slice(MatterEntityGroup.class).readFrom(c.getLowerNE());
|
s.slice(MatterEntityGroup.class).readFrom(c.getLowerNE());
|
||||||
s.slice(MatterTile.class).readFrom(c.getLowerNE());
|
s.slice(TileWrapper.class).readFrom(c.getLowerNE());
|
||||||
s.trimSlices();
|
s.trimSlices();
|
||||||
|
|
||||||
return s;
|
return s;
|
||||||
|
|||||||
@@ -18,11 +18,12 @@
|
|||||||
|
|
||||||
package com.volmit.iris.util.matter.slices;
|
package com.volmit.iris.util.matter.slices;
|
||||||
|
|
||||||
|
import com.volmit.iris.Iris;
|
||||||
import com.volmit.iris.core.nms.INMS;
|
import com.volmit.iris.core.nms.INMS;
|
||||||
|
import com.volmit.iris.engine.object.TileData;
|
||||||
import com.volmit.iris.util.data.palette.Palette;
|
import com.volmit.iris.util.data.palette.Palette;
|
||||||
import com.volmit.iris.util.matter.MatterTile;
|
|
||||||
import com.volmit.iris.util.matter.Sliced;
|
import com.volmit.iris.util.matter.Sliced;
|
||||||
import com.volmit.iris.util.nbt.io.NBTUtil;
|
import com.volmit.iris.util.matter.TileWrapper;
|
||||||
import com.volmit.iris.util.nbt.tag.CompoundTag;
|
import com.volmit.iris.util.nbt.tag.CompoundTag;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
@@ -31,43 +32,49 @@ import java.io.DataInputStream;
|
|||||||
import java.io.DataOutputStream;
|
import java.io.DataOutputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
|
@SuppressWarnings("rawtypes")
|
||||||
@Sliced
|
@Sliced
|
||||||
public class TileMatter extends RawMatter<MatterTile> {
|
public class TileMatter extends RawMatter<TileWrapper> {
|
||||||
public static final MatterTile EMPTY = new MatterTile(new CompoundTag());
|
|
||||||
|
|
||||||
public TileMatter() {
|
public TileMatter() {
|
||||||
this(1, 1, 1);
|
this(1, 1, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Palette<MatterTile> getGlobalPalette() {
|
public Palette<TileWrapper> getGlobalPalette() {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public TileMatter(int width, int height, int depth) {
|
public TileMatter(int width, int height, int depth) {
|
||||||
super(width, height, depth, MatterTile.class);
|
super(width, height, depth, TileWrapper.class);
|
||||||
registerWriter(World.class, ((w, d, x, y, z) -> INMS.get().deserializeTile(d.getTileData(), new Location(w, x, y, z))));
|
registerWriter(World.class, (w, d, x, y, z) -> {
|
||||||
|
CompoundTag tag = commonNbt(x, y, z, d.getData().getTileId());
|
||||||
|
INMS.get().deserializeTile(d.getData().toNBT(d.getData().toNBT(tag)), new Location(w, x, y, z));
|
||||||
|
Iris.warn("S: " + tag);
|
||||||
|
});
|
||||||
registerReader(World.class, (w, x, y, z) -> {
|
registerReader(World.class, (w, x, y, z) -> {
|
||||||
Location l = new Location(w, x, y, z);
|
TileData d = TileData.getTileState(w.getBlockAt(new Location(w, x, y, z)));
|
||||||
if(INMS.get().hasTile(l)) {
|
if(d == null)
|
||||||
CompoundTag tag = INMS.get().serializeTile(l);
|
return null;
|
||||||
|
return new TileWrapper(d);
|
||||||
if(tag != null) {
|
|
||||||
return new MatterTile(tag);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
public void writeNode(TileWrapper b, DataOutputStream dos) throws IOException {
|
||||||
public void writeNode(MatterTile b, DataOutputStream dos) throws IOException {
|
b.getData().toBinary(dos);
|
||||||
NBTUtil.write(b.getTileData(), dos, false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
public TileWrapper readNode(DataInputStream din) throws IOException {
|
||||||
public MatterTile readNode(DataInputStream din) throws IOException {
|
return new TileWrapper(TileData.read(din));
|
||||||
return new MatterTile((CompoundTag) NBTUtil.read(din, false).getTag());
|
}
|
||||||
|
|
||||||
|
private CompoundTag commonNbt(int x, int y, int z, String mobId) {
|
||||||
|
CompoundTag tag = new CompoundTag();
|
||||||
|
tag.putInt("x", x);
|
||||||
|
tag.putInt("y", y);
|
||||||
|
tag.putInt("z", z);
|
||||||
|
tag.putBoolean("keepPacked", false);
|
||||||
|
tag.putString("id", mobId);
|
||||||
|
return tag;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user