Compare commits

..

22 Commits

Author SHA1 Message Date
Brian Fopiano
d11baeb08a Merge pull request #800 from VolmitSoftware/Development
V+
2022-06-03 20:23:46 -07:00
Vatuu
47d322c993 V+ 2022-06-04 05:21:55 +02:00
Vatuu
d316207a61 Added tile entity support + mantle. 2022-06-03 06:19:13 +02:00
Vatuu
e6daabbb47 Working on block entity support. 2022-06-02 10:39:28 +02:00
Vatuu
53156449f1 Made the mantle retain object placements. 2022-06-01 20:35:44 +02:00
Brian Fopiano
e3d4c32d03 Merge pull request #796 from VolmitSoftware/Development
**Changelog**

- Fixed a Memory Leak (There might be more, keep reports coming)
 - Fixed Iris wand selections (WE)
 - Added Iris Wand Worldedit compatibility [Make selection using Worldedit, then /Iris object want worldedit (/ir o w we) to then set your selection to a new iris wand]
2022-05-26 18:24:06 -07:00
Vatuu
9cd5c39bbe V+ 2022-05-27 03:17:58 +02:00
Vatuu
a1fbf25465 Please don't break or leak again. 2022-05-27 01:54:21 +02:00
Vatuu
ec74037f05 Added ability to create Iris Wand from WorldEdit selection. 2022-05-26 21:48:46 +02:00
Brian Fopiano
fff650b766 Merge pull request #795 from VolmitSoftware/Development
**Changelog:**
- Fixed Startup spam, Worldheight spam, and Entity ID spam from happening anymore
- Removes Raid Error From Villagers (Persistent raid)
- Minheight, MaxHeight, and STilt are now working as intended
- Fixed generation errors causing Holes in bedrock 
- generic math fixes internally

**This will require a world update to fix the Bedrock problems**
2022-05-21 20:26:19 -07:00
Vatuu
bae2a18e24 V+ 2022-05-22 05:18:13 +02:00
Vatuu
fd8a7ebb4c Properly fixed FAST_MAX_HEIGHT. 2022-05-22 05:08:28 +02:00
Vatuu
4a3a1491d4 Cleanup. 2022-05-22 04:25:39 +02:00
Vatuu
9aa2c5ed8a SPACE 2022-05-22 03:23:20 +02:00
Vatuu
d5699a7472 Totally didn't replace MIN_HEIGHT instead of FAST_MAX_HEIGHT 💀 2022-05-22 03:22:19 +02:00
Vatuu
df98f8f626 Added filter for duplicated entity uuid. 2022-05-22 03:07:46 +02:00
Vatuu
d37b298f07 Fixed bad math for MAX_HEIGHT and FAST_MAX_HEIGHT. 2022-05-22 03:02:50 +02:00
Vatuu
62f7fc17d1 Suppressed persistent raid error. 2022-05-21 18:41:04 +02:00
Brian Fopiano
6e4929246d Merge pull request #794 from VolmitSoftware/master
upstream merge
2022-05-20 19:48:19 -07:00
Vatuu
909461975a Chat filter. 2022-05-21 04:47:12 +02:00
DanMB
dec191e5e7 Web hate space 2022-05-19 16:23:11 -07:00
DanMB
07b0cd6f5a Img2 2022-05-19 16:20:25 -07:00
38 changed files with 285 additions and 154 deletions

View File

@@ -24,7 +24,7 @@ plugins {
id "de.undercouch.download" version "5.0.1"
}
version '2.1.0-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 apiVersion = '1.18'
def spigotJarVersion = '1.18.2-R0.1-SNAPSHOT'
@@ -74,6 +74,7 @@ repositories {
}
}
maven { url "https://dl.cloudsmith.io/public/arcane/archive/maven/" }
maven { url "https://maven.enginehub.org/repo/" }
mavenCentral()
mavenLocal()
maven { url "https://jitpack.io"}
@@ -128,6 +129,7 @@ dependencies {
implementation 'io.th0rgal:oraxen:1.94.0'
implementation 'org.bukkit:craftbukkit:1.18.2-R0.1-SNAPSHOT:remapped-mojang'
implementation 'com.github.LoneDev6:api-itemsadder:3.1.0b'
implementation 'com.sk89q.worldedit:worldedit-bukkit:7.2.9'
// Shaded
implementation 'com.dfsek:Paralithic:0.4.0'

View File

@@ -28,6 +28,7 @@ import com.volmit.iris.core.link.*;
import com.volmit.iris.core.loader.IrisData;
import com.volmit.iris.core.nms.INMS;
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.object.IrisCompat;
import com.volmit.iris.engine.object.IrisDimension;
@@ -60,6 +61,7 @@ import org.bukkit.GameMode;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.WorldCreator;
import org.bukkit.block.data.BlockData;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.configuration.file.FileConfiguration;
@@ -244,12 +246,12 @@ public class Iris extends VolmitPlugin implements Listener {
return f;
}
public static void warn(String string) {
msg(C.YELLOW + string);
public static void warn(String format, Object... objs) {
msg(C.YELLOW + String.format(format, objs));
}
public static void error(String string) {
msg(C.RED + string);
public static void error(String format, Object... objs) {
msg(C.RED + String.format(format, objs));
}
public static void debug(String string) {
@@ -407,6 +409,8 @@ public class Iris extends VolmitPlugin implements Listener {
splash();
autoStartStudio();
checkForBukkitWorlds();
IrisToolbelt.retainMantleDataForSlice(String.class.getCanonicalName());
IrisToolbelt.retainMantleDataForSlice(BlockData.class.getCanonicalName());
});
}

View File

@@ -18,7 +18,9 @@
package com.volmit.iris.core.commands;
import com.mojang.datafixers.util.Pair;
import com.volmit.iris.Iris;
import com.volmit.iris.core.link.WorldEditLink;
import com.volmit.iris.core.loader.IrisData;
import com.volmit.iris.core.service.ObjectSVC;
import com.volmit.iris.core.service.StudioSVC;
@@ -41,12 +43,7 @@ import com.volmit.iris.util.format.C;
import com.volmit.iris.util.math.Direction;
import com.volmit.iris.util.math.RNG;
import com.volmit.iris.util.scheduling.Queue;
import org.bukkit.ChatColor;
import org.bukkit.HeightMap;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.World;
import org.bukkit.*;
import org.bukkit.block.Block;
import org.bukkit.block.BlockState;
import org.bukkit.block.TileState;
@@ -426,6 +423,24 @@ public class CommandObject implements DecreeExecutor {
sender().sendMessage("Reverted " + actualReverts + " pastes!");
}
@Decree(description = "Gets an object wand and grabs the current WorldEdit selection.", aliases = "we", origin = DecreeOrigin.PLAYER, studio = true)
public void we() {
if(!Bukkit.getPluginManager().isPluginEnabled("WorldEdit")) {
sender().sendMessage(C.RED + "You can't get a WorldEdit selection without WorldEdit, you know.");
return;
}
Pair<Location, Location> locs = WorldEditLink.getSelection(sender().player());
if(locs.getFirst() == null)
sender().sendMessage(C.RED + "You don't have a WorldEdit selection!");
else if(locs.getSecond() == null)
sender().sendMessage(C.RED + "You need a valid WorldRegion selection in the current world!");
else {
sender().player().getInventory().addItem(WandSVC.createWand(locs.getFirst(), locs.getSecond()));
sender().sendMessage(C.GREEN + "A fresh wand with your current WorldEdit selection on it!");
}
}
@Decree(description = "Get an object wand", sync = true)
public void wand() {
player().getInventory().addItem(WandSVC.createWand());

View File

@@ -0,0 +1,32 @@
package com.volmit.iris.core.link;
import com.mojang.datafixers.util.Pair;
import com.sk89q.worldedit.IncompleteRegionException;
import com.sk89q.worldedit.LocalSession;
import com.sk89q.worldedit.WorldEdit;
import com.sk89q.worldedit.bukkit.BukkitAdapter;
import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.regions.Region;
import com.sk89q.worldedit.session.MissingSessionException;
import org.bukkit.Location;
import org.bukkit.entity.Player;
public class WorldEditLink {
public static Pair<Location, Location> getSelection(Player p) {
LocalSession session = WorldEdit.getInstance().getSessionManager().getIfPresent(BukkitAdapter.adapt(p));
try {
if(session == null)
throw new MissingSessionException();
Region r = session.getSelection(BukkitAdapter.adapt(p.getWorld()));
BlockVector3 p1 = r.getMinimumPoint();
BlockVector3 p2 = r.getMaximumPoint();
return new Pair<>(new Location(p.getWorld(), p1.getX(), p1.getY(), p1.getZ()), new Location(p.getWorld(), p2.getX(), p2.getY(), p2.getZ()));
} catch(MissingSessionException e) {
return new Pair<>(null, new Location(null, 0, 0, 0));
} catch(IncompleteRegionException e) {
return new Pair<>(new Location(null, 0, 0, 0), null);
}
}
}

View File

@@ -126,8 +126,8 @@ public class NMSBinding18_2 implements INMSBinding {
}
@Override
public void deserializeTile(CompoundTag c, Location newPosition) {
((CraftWorld) newPosition.getWorld()).getHandle().getChunkAt(new BlockPos(newPosition.getBlockX(), 0, newPosition.getBlockZ())).setBlockEntityNbt(convert(c));
public void deserializeTile(CompoundTag c, Location pos) {
((CraftWorld) pos.getWorld()).getHandle().getChunkAt(new BlockPos(pos.getBlockX(), 0, pos.getBlockZ())).setBlockEntityNbt(convert(c));
}
@Override
@@ -416,18 +416,21 @@ public class NMSBinding18_2 implements INMSBinding {
}
private static Object fieldFor(Class<?> returns, Object in) {
for(Field i : in.getClass().getFields()) {
if(i.getType().equals(returns)) {
return fieldForClass(returns, in.getClass(), in);
}
@SuppressWarnings("unchecked")
private static <T> T fieldForClass(Class<T> returnType, Class<?> sourceType, Object in) {
for(Field i : sourceType.getFields())
if(i.getType().equals(returnType)) {
i.setAccessible(true);
try {
Iris.info("[NMS] Found " + returns.getSimpleName() + " in " + in.getClass().getSimpleName() + "." + i.getName());
return i.get(in);
Iris.info("[NMS] Found " + returnType.getSimpleName() + " in " + sourceType.getSimpleName() + "." + i.getName());
return (T)i.get(in);
} catch(IllegalAccessException e) {
e.printStackTrace();
}
}
}
return null;
}
}

View File

@@ -0,0 +1,61 @@
package com.volmit.iris.core.service;
import com.volmit.iris.util.collection.KList;
import com.volmit.iris.util.plugin.IrisService;
import org.apache.logging.log4j.Level;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Marker;
import org.apache.logging.log4j.core.Filter;
import org.apache.logging.log4j.core.LogEvent;
import org.apache.logging.log4j.core.Logger;
import org.apache.logging.log4j.message.Message;
public class LogFilterSVC implements IrisService, Filter {
private static final String HEIGHTMAP_MISMATCH = "Ignoring heightmap data for chunk";
private static final String RAID_PERSISTENCE = "Could not save data net.minecraft.world.entity.raid.PersistentRaid";
private static final String DUPLICATE_ENTITY_UUID = "UUID of added entity already exists";
private static final KList<String> FILTERS = new KList<>();
public void onEnable() {
FILTERS.add(HEIGHTMAP_MISMATCH, RAID_PERSISTENCE, DUPLICATE_ENTITY_UUID);
((Logger)LogManager.getRootLogger()).addFilter(this);
}
public void initialize() { }
public void start() { }
public void stop() { }
public void onDisable() { }
public boolean isStarted() { return true; }
public boolean isStopped() { return false; }
public State getState() {
try { return State.STARTED; }
catch (Exception var2) { return null; }
}
public Filter.Result getOnMatch() { return Result.NEUTRAL; }
public Filter.Result getOnMismatch() { return Result.NEUTRAL; }
public Result filter(LogEvent event) { return check(event.getMessage().getFormattedMessage()); }
public Result filter(Logger logger, Level level, Marker marker, Object msg, Throwable t) { return check(msg.toString()); }
public Result filter(Logger logger, Level level, Marker marker, Message msg, Throwable t) { return check(msg.getFormattedMessage()); }
public Result filter(Logger logger, Level level, Marker marker, String message, Object... params) { return check(message); }
public Result filter(Logger logger, Level level, Marker marker, String message, Object p0) { return check(message); }
public Result filter(Logger logger, Level level, Marker marker, String message, Object p0, Object p1) { return check(message); }
public Result filter(Logger logger, Level level, Marker marker, String message, Object p0, Object p1, Object p2) { return check(message); }
public Result filter(Logger logger, Level level, Marker marker, String message, Object p0, Object p1, Object p2, Object p3) { return check(message); }
public Result filter(Logger logger, Level level, Marker marker, String message, Object p0, Object p1, Object p2, Object p3, Object p4) { return check(message); }
public Result filter(Logger logger, Level level, Marker marker, String message, Object p0, Object p1, Object p2, Object p3, Object p4, Object p5) { return check(message); }
public Result filter(Logger logger, Level level, Marker marker, String message, Object p0, Object p1, Object p2, Object p3, Object p4, Object p5, Object p6) { return check(message); }
public Result filter(Logger logger, Level level, Marker marker, String message, Object p0, Object p1, Object p2, Object p3, Object p4, Object p5, Object p6, Object p7) { return check(message); }
public Result filter(Logger logger, Level level, Marker marker, String message, Object p0, Object p1, Object p2, Object p3, Object p4, Object p5, Object p6, Object p7, Object p8) { return check(message); }
public Result filter(Logger logger, Level level, Marker marker, String message, Object p0, Object p1, Object p2, Object p3, Object p4, Object p5, Object p6, Object p7, Object p8, Object p9) { return check(message); }
private Result check(String string) {
if(FILTERS.stream().anyMatch(string::contains))
return Result.DENY;
return Result.NEUTRAL;
}
}

View File

@@ -233,20 +233,17 @@ public class IrisToolbelt {
return isIrisWorld(i) && access(i).isStudio();
}
public static void retainMantleDataForSlice(String className)
{
public static void retainMantleDataForSlice(String className) {
toolbeltConfiguration.put("retain.mantle." + className, true);
}
public static <T> T getMantleData(World world, int x, int y, int z, Class<T> of)
{
public static <T> T getMantleData(World world, int x, int y, int z, Class<T> of) {
PlatformChunkGenerator e = access(world);
if(e == null) {return null;}
return e.getEngine().getMantle().getMantle().get(x, y - world.getMinHeight(), z, of);
}
public static <T> void deleteMantleData(World world, int x, int y, int z, Class<T> of)
{
public static <T> void deleteMantleData(World world, int x, int y, int z, Class<T> of) {
PlatformChunkGenerator e = access(world);
if(e == null) {return;}
e.getEngine().getMantle().getMantle().remove(x, y - world.getMinHeight(), z, of);

View File

@@ -79,7 +79,6 @@ import java.util.stream.Stream;
public class IrisWorldManager extends EngineAssignedWorldManager {
private final Looper looper;
private final int id;
private final KMap<Long, Long> chunkCooldowns;
private final KList<Runnable> updateQueue = new KList<>();
private final ChronoLatch cl;
private final ChronoLatch clw;
@@ -99,7 +98,6 @@ public class IrisWorldManager extends EngineAssignedWorldManager {
ecl = null;
cln = null;
clw = null;
chunkCooldowns = null;
looper = null;
chunkUpdater = null;
id = -1;
@@ -112,7 +110,6 @@ public class IrisWorldManager extends EngineAssignedWorldManager {
cl = new ChronoLatch(3000);
ecl = new ChronoLatch(250);
clw = new ChronoLatch(1000, true);
chunkCooldowns = new KMap<>();
id = engine.getCacheID();
energy = 25;
looper = new Looper() {
@@ -255,14 +252,6 @@ public class IrisWorldManager extends EngineAssignedWorldManager {
}
}
int chunkCooldownSeconds = 60;
for(Long i : chunkCooldowns.k()) {
if(M.ms() - chunkCooldowns.get(i) > TimeUnit.SECONDS.toMillis(chunkCooldownSeconds)) {
chunkCooldowns.remove(i);
}
}
int spawnBuffer = RNG.r.i(2, 12);
Chunk[] cc = getEngine().getWorld().realWorld().getLoadedChunks();
@@ -279,7 +268,6 @@ public class IrisWorldManager extends EngineAssignedWorldManager {
}
spawnIn(c, false);
chunkCooldowns.put(Cache.key(c), M.ms());
}
energy -= (actuallySpawned / 2D);

View File

@@ -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<>();

View File

@@ -38,10 +38,7 @@ import com.volmit.iris.util.hunk.Hunk;
import com.volmit.iris.util.mantle.Mantle;
import com.volmit.iris.util.mantle.MantleChunk;
import com.volmit.iris.util.mantle.MantleFlag;
import com.volmit.iris.util.matter.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.*;
import com.volmit.iris.util.matter.slices.UpdateMatter;
import com.volmit.iris.util.parallel.BurstExecutor;
import com.volmit.iris.util.parallel.MultiBurst;
@@ -109,17 +106,14 @@ public interface EngineMantle extends IObjectPlacer {
@Override
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
default BlockData get(int x, int y, int z) {
BlockData block = getMantle().get(x, y, z, BlockData.class);
if(block == null) {
if(block == null)
return AIR;
}
return block;
}

View File

@@ -38,6 +38,7 @@ import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;
import org.bukkit.block.data.BlockData;
import org.bukkit.entity.EntityType;
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) {
if(dat.contains(":")) {
return dat;

View File

@@ -34,6 +34,8 @@ import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;
import org.bukkit.block.data.BlockData;
import java.util.Optional;
@Snippet("palette")
@Accessors(chain = true)
@NoArgsConstructor
@@ -66,6 +68,14 @@ public class IrisMaterialPalette {
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) {
return layerGenerator.aquire(() ->
{

View File

@@ -34,8 +34,6 @@ import com.volmit.iris.util.math.AxisAlignedBB;
import com.volmit.iris.util.math.BlockPosition;
import com.volmit.iris.util.math.Position2;
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.parallel.BurstExecutor;
import com.volmit.iris.util.parallel.MultiBurst;
@@ -65,11 +63,7 @@ import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.*;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.function.Consumer;
@@ -534,41 +528,47 @@ public class IrisObject extends IrisRegistrant {
} else if(config.getMode().equals(ObjectPlaceMode.MAX_HEIGHT) || config.getMode().equals(ObjectPlaceMode.STILT)) {
BlockVector offset = new BlockVector(config.getTranslate().getX(), config.getTranslate().getY(), config.getTranslate().getZ());
BlockVector rotatedDimensions = config.getRotation().rotate(new BlockVector(getW(), getH(), getD()), spinx, spiny, spinz).clone();
for(int i = x - (rotatedDimensions.getBlockX() / 2) + offset.getBlockX(); i <= x + (rotatedDimensions.getBlockX() / 2) + offset.getBlockX(); i++) {
for(int j = z - (rotatedDimensions.getBlockZ() / 2) + offset.getBlockZ(); j <= z + (rotatedDimensions.getBlockZ() / 2) + offset.getBlockZ(); j++) {
int h = placer.getHighest(i, j, getLoader(), config.isUnderwater()) + rty;
if(placer.isCarved(i, h, j) || placer.isCarved(i, h - 1, j) || placer.isCarved(i, h - 2, j) || placer.isCarved(i, h - 3, j)) {
int xLength = (rotatedDimensions.getBlockX() / 2) + offset.getBlockX();
int minX = Math.min(x - xLength, x + xLength);
int maxX = Math.max(x - xLength, x + xLength);
int zLength = (rotatedDimensions.getBlockZ() / 2) + offset.getBlockZ();
int minZ = Math.min(z - zLength, z + zLength);
int maxZ = Math.max(z - zLength, z + zLength);
for(int i = minX; i <= maxX; i++) {
for(int ii = minZ; ii <= maxZ; ii++) {
int h = placer.getHighest(i, ii, getLoader(), config.isUnderwater()) + rty;
if(placer.isCarved(i, h, ii) || placer.isCarved(i, h - 1, ii) || placer.isCarved(i, h - 2, ii) || placer.isCarved(i, h - 3, ii)) {
bail = true;
break;
}
if(h > y) {
if(h > y)
y = h;
}
}
}
} else if(config.getMode().equals(ObjectPlaceMode.FAST_MAX_HEIGHT) || config.getMode().equals(ObjectPlaceMode.FAST_STILT)) {
BlockVector offset = new BlockVector(config.getTranslate().getX(), config.getTranslate().getY(), config.getTranslate().getZ());
BlockVector rotatedDimensions = config.getRotation().rotate(new BlockVector(getW(), getH(), getD()), spinx, spiny, spinz).clone();
for(int i = x - (rotatedDimensions.getBlockX() / 2) + offset.getBlockX(); i <= x + (rotatedDimensions.getBlockX() / 2) + offset.getBlockX(); i += (rotatedDimensions.getBlockX() / 2) + 1) {
for(int j = z - (rotatedDimensions.getBlockZ() / 2) + offset.getBlockZ(); j <= z + (rotatedDimensions.getBlockZ() / 2) + offset.getBlockZ(); j += (rotatedDimensions.getBlockZ() / 2) + 1) {
int h = placer.getHighest(i, j, getLoader(), config.isUnderwater()) + rty;
if(placer.isCarved(i, h, j) || placer.isCarved(i, h - 1, j) || placer.isCarved(i, h - 2, j) || placer.isCarved(i, h - 3, j)) {
int xRadius = (rotatedDimensions.getBlockX() / 2);
int xLength = xRadius + offset.getBlockX();
int minX = Math.min(x - xLength, x + xLength);
int maxX = Math.max(x - xLength, x + xLength);
int zRadius = (rotatedDimensions.getBlockZ() / 2);
int zLength = zRadius + offset.getBlockZ();
int minZ = Math.min(z - zLength, z + zLength);
int maxZ = Math.max(z - zLength, z + zLength);
for(int i = minX; i <= maxX; i += Math.abs(xRadius) + 1) {
for(int ii = minZ; ii <= maxZ; ii += Math.abs(zRadius) + 1) {
int h = placer.getHighest(i, ii, getLoader(), config.isUnderwater()) + rty;
if(placer.isCarved(i, h, ii) || placer.isCarved(i, h - 1, ii) || placer.isCarved(i, h - 2, ii) || placer.isCarved(i, h - 3, ii)) {
bail = true;
break;
}
if(h > y) {
if(h > y)
y = h;
}
}
}
} else if(config.getMode().equals(ObjectPlaceMode.MIN_HEIGHT)) {
y = 257;
y = rdata.getEngine().getHeight() + 1;
BlockVector offset = new BlockVector(config.getTranslate().getX(), config.getTranslate().getY(), config.getTranslate().getZ());
BlockVector rotatedDimensions = config.getRotation().rotate(new BlockVector(getW(), getH(), getD()), spinx, spiny, spinz).clone();
@@ -733,10 +733,16 @@ public class IrisObject extends IrisRegistrant {
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();
if(newData.getMaterial() == data.getMaterial()) {
if(newData.getMaterial() == data.getMaterial())
data = data.merge(newData);
} else {
else
data = newData;
if(newData.getMaterial() == Material.SPAWNER) {
Optional<TileData<?>> t = j.getReplace().getTile(rng, x, y, z, rdata);
if(t.isPresent()) {
tile = t.get();
}
}
}
}
@@ -745,6 +751,7 @@ public class IrisObject extends IrisRegistrant {
data = config.getRotation().rotate(data, spinx, spiny, spinz);
xx = x + (int) Math.round(i.getX());
int yy = y + (int) Math.round(i.getY());
zz = z + (int) Math.round(i.getZ());
@@ -787,7 +794,6 @@ public class IrisObject extends IrisRegistrant {
if(!data.getMaterial().equals(Material.AIR) && !data.getMaterial().equals(Material.CAVE_AIR)) {
placer.set(xx, yy, zz, data);
if(tile != null) {
placer.setTile(xx, yy, zz, tile);
}
@@ -852,17 +858,14 @@ public class IrisObject extends IrisRegistrant {
int yg = placer.getHighest(xx, zz, getLoader(), true);
if(config.isWaterloggable() && yg <= placer.getFluidHeight() && d instanceof Waterlogged) {
if(config.isWaterloggable() && yg <= placer.getFluidHeight() && d instanceof Waterlogged)
((Waterlogged) d).setWaterlogged(true);
}
if(yv >= 0 && config.isBottom()) {
if(yv >= 0 && config.isBottom())
y += Math.floorDiv(h, 2);
}
for(int j = lowest + y; j > yg - config.getOverStilt() - 1; j--) {
for(int j = lowest + y; j > yg - config.getOverStilt() - 1; j--)
placer.set(xx, j, zz, d);
}
}
readLock.unlock();

View File

@@ -98,7 +98,7 @@ public class TileBanner implements TileData<Banner> {
@SuppressWarnings("deprecation")
@Override
public void toNBT(CompoundTag tag) {
public CompoundTag toNBT(CompoundTag tag) {
@SuppressWarnings("unchecked") ListTag<CompoundTag> listTag = (ListTag<CompoundTag>) ListTag.createUnchecked(CompoundTag.class);
for(Pattern p : patterns) {
CompoundTag pattern = new CompoundTag();
@@ -107,6 +107,7 @@ public class TileBanner implements TileData<Banner> {
listTag.add(pattern);
}
tag.put("Patterns", listTag);
return tag;
}
public boolean isBanner(Material material) {

View File

@@ -29,11 +29,12 @@ import org.bukkit.block.data.BlockData;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import java.lang.reflect.InvocationTargetException;
@SuppressWarnings("ALL")
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() {
KList<TileData<? extends TileState>> registry = new KList<>();
@@ -45,17 +46,21 @@ public interface TileData<T extends TileState> extends Cloneable {
return registry;
}
static TileData<? extends TileState> read(DataInputStream s) throws Throwable {
int id = s.readShort();
@SuppressWarnings("unchecked") TileData<? extends TileState> d = registry.get(id).getClass().getConstructor().newInstance();
d.fromBinary(s);
return d;
static TileData<? extends TileState> read(DataInputStream s) throws IOException {
try {
int id = s.readShort();
@SuppressWarnings("unchecked") TileData<? extends TileState> d = registry.get(id).getClass().getConstructor().newInstance();
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) {
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) {
@@ -89,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);
@@ -111,11 +117,11 @@ public interface TileData<T extends TileState> extends Cloneable {
return false;
}
TileData<T> clone();
CompoundTag toNBT(CompoundTag parent);
void toBinary(DataOutputStream out) throws IOException;
void toNBT(CompoundTag tag);
void fromBinary(DataInputStream in) throws IOException;
TileData<T> clone();
}

View File

@@ -98,11 +98,12 @@ public class TileSign implements TileData<Sign> {
}
@Override
public void toNBT(CompoundTag tag) {
public CompoundTag toNBT(CompoundTag tag) {
tag.putString("Text1", line1);
tag.putString("Text2", line2);
tag.putString("Text3", line3);
tag.putString("Text4", line4);
tag.putString("Color", dyeColor.name().toLowerCase());
return tag;
}
}

View File

@@ -32,12 +32,13 @@ import java.io.IOException;
@Data
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
public String getTileId() {
return "minecraft:spawner";
return "minecraft:mob_spawner";
}
@Override
@@ -75,7 +76,7 @@ public class TileSpawner implements TileData<CreatureSpawner> {
}
@Override
public void toNBT(CompoundTag tag) {
public CompoundTag toNBT(CompoundTag parent) {
@SuppressWarnings("unchecked") ListTag<CompoundTag> potentials = (ListTag<CompoundTag>) ListTag.createUnchecked(CompoundTag.class);
CompoundTag t = new CompoundTag();
CompoundTag ent = new CompoundTag();
@@ -83,6 +84,7 @@ public class TileSpawner implements TileData<CreatureSpawner> {
t.put("Entity", ent);
t.putInt("Weight", 1);
potentials.add(t);
tag.put("SpawnPotentials", potentials);
parent.put("SpawnPotentials", potentials);
return parent;
}
}

View File

@@ -32,7 +32,8 @@ public enum MantleFlag {
INITIAL_SPAWNED_MARKER,
CLEANED,
PLANNED,
ETCHED;
ETCHED,
TILE;
static StateList getStateList() {
return new StateList(MantleFlag.values());

View File

@@ -18,12 +18,10 @@
package com.volmit.iris.util.matter;
import com.volmit.iris.util.nbt.tag.CompoundTag;
import lombok.AllArgsConstructor;
import com.volmit.iris.engine.object.TileData;
import lombok.Data;
@Data
@AllArgsConstructor
public class MatterTile {
private final CompoundTag tileData;
public class TileWrapper {
private final TileData<?> data;
}

View File

@@ -33,8 +33,8 @@ public class WorldMatter {
matter.slice(MatterEntityGroup.class).writeInto(at);
}
if(matter.hasSlice(MatterTile.class)) {
matter.slice(MatterTile.class).writeInto(at);
if(matter.hasSlice(TileWrapper.class)) {
matter.slice(TileWrapper.class).writeInto(at);
}
}
@@ -45,7 +45,7 @@ public class WorldMatter {
s.getHeader().setAuthor(author);
s.slice(BlockData.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();
return s;

View File

@@ -18,11 +18,12 @@
package com.volmit.iris.util.matter.slices;
import com.volmit.iris.Iris;
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.matter.MatterTile;
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 org.bukkit.Location;
import org.bukkit.World;
@@ -31,43 +32,49 @@ import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
@SuppressWarnings("rawtypes")
@Sliced
public class TileMatter extends RawMatter<MatterTile> {
public static final MatterTile EMPTY = new MatterTile(new CompoundTag());
public class TileMatter extends RawMatter<TileWrapper> {
public TileMatter() {
this(1, 1, 1);
}
@Override
public Palette<MatterTile> getGlobalPalette() {
public Palette<TileWrapper> getGlobalPalette() {
return null;
}
public TileMatter(int width, int height, int depth) {
super(width, height, depth, MatterTile.class);
registerWriter(World.class, ((w, d, x, y, z) -> INMS.get().deserializeTile(d.getTileData(), new Location(w, x, y, z))));
super(width, height, depth, TileWrapper.class);
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) -> {
Location l = new Location(w, x, y, z);
if(INMS.get().hasTile(l)) {
CompoundTag tag = INMS.get().serializeTile(l);
if(tag != null) {
return new MatterTile(tag);
}
}
return null;
TileData d = TileData.getTileState(w.getBlockAt(new Location(w, x, y, z)));
if(d == null)
return null;
return new TileWrapper(d);
});
}
@Override
public void writeNode(MatterTile b, DataOutputStream dos) throws IOException {
NBTUtil.write(b.getTileData(), dos, false);
public void writeNode(TileWrapper b, DataOutputStream dos) throws IOException {
b.getData().toBinary(dos);
}
@Override
public MatterTile readNode(DataInputStream din) throws IOException {
return new MatterTile((CompoundTag) NBTUtil.read(din, false).getTag());
public TileWrapper readNode(DataInputStream din) throws IOException {
return new TileWrapper(TileData.read(din));
}
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;
}
}

View File

@@ -22,4 +22,4 @@ commands:
aliases: [ ir, irs ]
api-version: ${apiversion}
hotload-dependencies: false
softdepend: [ "Oraxen", "ItemsAdder", "IrisFeller"]
softdepend: [ "Oraxen", "ItemsAdder", "IrisFeller", "WorldEdit"]

BIN
storepage/two/Footer.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 85 KiB

BIN
storepage/two/Header.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 MiB

BIN
storepage/two/Iris.xd Normal file

Binary file not shown.

BIN
storepage/two/NOTE.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 MiB

BIN
storepage/two/NOTERED.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 MiB

BIN
storepage/two/c1.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 MiB

BIN
storepage/two/c2.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.5 MiB

BIN
storepage/two/c3.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 MiB

BIN
storepage/two/c4.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.9 MiB

BIN
storepage/two/c5.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.3 MiB

BIN
storepage/two/dlshare.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 MiB

BIN
storepage/two/icard.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 MiB

BIN
storepage/two/speed.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 MiB