This commit is contained in:
Daniel Mills 2020-12-23 19:47:30 -05:00
parent 89e1af456f
commit 5487cd7858
12 changed files with 694 additions and 154 deletions

View File

@ -14,6 +14,9 @@ public class CommandIris extends MortarCommand
@Command @Command
private CommandIrisStudio studio; private CommandIrisStudio studio;
@Command
private CommandIrisJigsaw jigsaw;
@Command @Command
private CommandIrisStructure structure; private CommandIrisStructure structure;

View File

@ -0,0 +1,57 @@
package com.volmit.iris.manager.command;
import com.volmit.iris.Iris;
import com.volmit.iris.IrisSettings;
import com.volmit.iris.util.Command;
import com.volmit.iris.util.KList;
import com.volmit.iris.util.MortarCommand;
import com.volmit.iris.util.MortarSender;
public class CommandIrisJigsaw extends MortarCommand
{
@Command
private CommandIrisJigsawNew create;
@Command
private CommandIrisJigsawEdit edit;
@Command
private CommandIrisJigsawSave save;
public CommandIrisJigsaw()
{
super("jigsaw", "jig", "jsw");
requiresPermission(Iris.perm);
setCategory("Jigsaw");
setDescription("Iris jigsaw commands");
}
@Override
public void addTabOptions(MortarSender sender, String[] args, KList<String> list) {
}
@Override
public boolean handle(MortarSender sender, String[] args)
{
if(!IrisSettings.get().isStudio())
{
sender.sendMessage("To use Iris Studio Jigsaw, please enable studio in Iris/settings.json");
return true;
}
if(!sender.isPlayer())
{
sender.sendMessage("Ingame only");
return true;
}
printHelp(sender);
return true;
}
@Override
protected String getArgsUsage()
{
return "";
}
}

View File

@ -0,0 +1,61 @@
package com.volmit.iris.manager.command;
import com.volmit.iris.Iris;
import com.volmit.iris.IrisSettings;
import com.volmit.iris.manager.IrisDataManager;
import com.volmit.iris.manager.edit.JigsawEditor;
import com.volmit.iris.object.IrisStructurePiece;
import com.volmit.iris.util.KList;
import com.volmit.iris.util.MortarCommand;
import com.volmit.iris.util.MortarSender;
import java.io.File;
public class CommandIrisJigsawEdit extends MortarCommand
{
public CommandIrisJigsawEdit()
{
super("edit", "e", "*");
requiresPermission(Iris.perm);
setCategory("Jigsaw");
setDescription("Create a new jigsaw piece");
}
@Override
public void addTabOptions(MortarSender sender, String[] args, KList<String> list) {
}
@Override
public boolean handle(MortarSender sender, String[] args)
{
if(!IrisSettings.get().isStudio())
{
sender.sendMessage("To use Iris Studio Jigsaw, please enable studio in Iris/settings.json");
return true;
}
if(!sender.isPlayer())
{
sender.sendMessage("Ingame only");
return true;
}
IrisStructurePiece piece = IrisDataManager.loadAnyStructurePiece(args[0]);
if(piece != null)
{
File dest = piece.getLoadFile();
new JigsawEditor(sender.player(), piece, IrisDataManager.loadAnyObject(piece.getObject()), dest);
}
return true;
}
@Override
protected String getArgsUsage()
{
return "<name>";
}
}

View File

@ -0,0 +1,65 @@
package com.volmit.iris.manager.command;
import com.volmit.iris.Iris;
import com.volmit.iris.IrisSettings;
import com.volmit.iris.manager.IrisDataManager;
import com.volmit.iris.manager.edit.JigsawEditor;
import com.volmit.iris.object.IrisObject;
import com.volmit.iris.util.KList;
import com.volmit.iris.util.MortarCommand;
import com.volmit.iris.util.MortarSender;
import java.io.File;
public class CommandIrisJigsawNew extends MortarCommand
{
public CommandIrisJigsawNew()
{
super("create", "new", "+");
requiresPermission(Iris.perm);
setCategory("Jigsaw");
setDescription("Create a new jigsaw piece");
}
@Override
public void addTabOptions(MortarSender sender, String[] args, KList<String> list) {
}
@Override
public boolean handle(MortarSender sender, String[] args)
{
if(!IrisSettings.get().isStudio())
{
sender.sendMessage("To use Iris Studio Jigsaw, please enable studio in Iris/settings.json");
return true;
}
if(!sender.isPlayer())
{
sender.sendMessage("Ingame only");
return true;
}
if(args.length != 3)
{
sender.sendMessage(getArgsUsage());
return true;
}
IrisObject object = IrisDataManager.loadAnyObject(args[2]);
File dest = Iris.instance.getDataFile("packs", args[1], "structure-pieces", args[0] + ".json");
new JigsawEditor(sender.player(), null, object, dest);
sender.sendMessage("* Right Click blocks to make them connectors");
sender.sendMessage("* Right Click connectors to orient them");
sender.sendMessage("* Shift + Right Click connectors to remove them");
sender.sendMessage("Remember to use /iris jigsaw save");
return true;
}
@Override
protected String getArgsUsage()
{
return "<name> <project> <object>";
}
}

View File

@ -0,0 +1,57 @@
package com.volmit.iris.manager.command;
import com.volmit.iris.Iris;
import com.volmit.iris.IrisSettings;
import com.volmit.iris.manager.edit.JigsawEditor;
import com.volmit.iris.util.KList;
import com.volmit.iris.util.MortarCommand;
import com.volmit.iris.util.MortarSender;
public class CommandIrisJigsawSave extends MortarCommand
{
public CommandIrisJigsawSave()
{
super("save");
requiresPermission(Iris.perm);
setCategory("Jigsaw");
setDescription("Save a currently open piece");
}
@Override
public void addTabOptions(MortarSender sender, String[] args, KList<String> list) {
}
@Override
public boolean handle(MortarSender sender, String[] args)
{
if(!IrisSettings.get().isStudio())
{
sender.sendMessage("To use Iris Studio Jigsaw, please enable studio in Iris/settings.json");
return true;
}
if(!sender.isPlayer())
{
sender.sendMessage("Ingame only");
return true;
}
JigsawEditor editor = JigsawEditor.editors.get(sender.player());
if(editor == null)
{
sender.sendMessage("You don't have any pieces open to save!");
return true;
}
editor.close();
return true;
}
@Override
protected String getArgsUsage()
{
return "";
}
}

View File

@ -2,6 +2,7 @@ package com.volmit.iris.manager.edit;
import com.volmit.iris.util.J; import com.volmit.iris.util.J;
import com.volmit.iris.scaffold.parallel.MultiBurst; import com.volmit.iris.scaffold.parallel.MultiBurst;
import com.volmit.iris.util.SR;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import org.bukkit.block.data.BlockData; import org.bukkit.block.data.BlockData;
@ -20,6 +21,48 @@ public class BlockSignal {
of(block, 100); of(block, 100);
} }
public static Runnable forever(Block block)
{
Location tg = block.getLocation().clone().add(0.5, 0, 0.5).clone();
FallingBlock e = block.getWorld().spawnFallingBlock(tg.clone(), block.getBlockData());
e.setGravity(false);
e.setInvulnerable(true);
e.setGlowing(true);
e.teleport(tg.clone());
e.setDropItem(false);
e.setHurtEntities(false);
e.setSilent(true);
e.setTicksLived(1);
e.setVelocity(new Vector(0, 0, 0));
new SR(20) {
@Override
public void run() {
if(e.isDead())
{
cancel();
return;
}
e.setTicksLived(1);
e.teleport(tg.clone());
e.setVelocity(new Vector(0, 0, 0));
}
};
return () -> {
e.remove();
BlockData type = block.getBlockData();
MultiBurst.burst.lazy(() -> {
for(Player i : block.getWorld().getPlayers())
{
i.sendBlockChange(block.getLocation(), block.getBlockData());
}
});
};
}
public BlockSignal(Block block, int ticks) public BlockSignal(Block block, int ticks)
{ {
Location tg = block.getLocation().clone().add(0.5, 0, 0.5).clone(); Location tg = block.getLocation().clone().add(0.5, 0, 0.5).clone();

View File

@ -0,0 +1,193 @@
package com.volmit.iris.manager.edit;
import com.google.gson.Gson;
import com.volmit.iris.Iris;
import com.volmit.iris.object.*;
import com.volmit.iris.util.*;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.Particle;
import org.bukkit.Sound;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.block.Action;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.player.PlayerMoveEvent;
import org.bukkit.util.Vector;
import java.io.File;
import java.io.IOException;
public class JigsawEditor implements Listener {
public static final KMap<Player, JigsawEditor> editors = new KMap<>();
private final Player player;
private final IrisObject object;
private final File targetSaveLocation;
private final IrisStructurePiece piece;
private final Location origin;
private final Cuboid cuboid;
private final int ticker;
private Location target;
private final KMap<IrisPosition, Runnable> falling = new KMap<>();
private final ChronoLatch cl = new ChronoLatch(100);
public JigsawEditor(Player player, IrisStructurePiece piece, IrisObject object, File saveLocation)
{
if(editors.containsKey(player))
{
editors.get(player).close();
}
editors.put(player, this);
this.object = object;
this.player = player;
origin = player.getLocation().clone().add(0, 7, 0);
target = origin;
this.targetSaveLocation = saveLocation;
this.piece = piece == null ? new IrisStructurePiece() : piece;
this.piece.setObject(object.getLoadKey());
cuboid = new Cuboid(origin.clone(), origin.clone().add(object.getW()-1, object.getH()-1, object.getD()-1));
ticker = J.sr(this::onTick, 0);
object.placeCenterY(origin);
Iris.instance.registerListener(this);
}
@EventHandler
public void on(PlayerMoveEvent e)
{
if(e.getPlayer().equals(player))
{
try
{
target = player.getTargetBlockExact(7).getLocation();
}
catch(Throwable ex)
{
target = player.getLocation();
return;
}
if(cuboid.contains(target))
{
for(IrisPosition i : falling.k())
{
Location at = origin.clone().add(new Vector(i.getX()+1, i.getY()+1, i.getZ()+1)).getBlock().getLocation();
if(at.equals(target))
{
falling.remove(i).run();
}
}
}
}
}
@EventHandler
public void on(PlayerInteractEvent e)
{
if(e.getAction().equals(Action.RIGHT_CLICK_BLOCK))
{
if(e.getClickedBlock() != null && cuboid.contains(e.getClickedBlock().getLocation()) && e.getPlayer().equals(player))
{
Vector v = e.getClickedBlock().getLocation().clone().subtract(origin.clone()).toVector();
IrisPosition pos = new IrisPosition(v.getBlockX(), v.getBlockY(), v.getBlockZ());
IrisStructurePieceConnector connector = null;
for(IrisStructurePieceConnector i : piece.getConnectors())
{
if(i.getPosition().equals(pos))
{
connector = i;
break;
}
}
if(!player.isSneaking() && connector == null)
{
connector = new IrisStructurePieceConnector();
connector.setDirection(IrisDirection.getDirection(e.getBlockFace()));
connector.setPosition(pos);
piece.getConnectors().add(connector);
player.playSound(e.getClickedBlock().getLocation(), Sound.ENTITY_ITEM_FRAME_ADD_ITEM, 1f, 1f);
}
else if(player.isSneaking() && connector != null)
{
piece.getConnectors().remove(connector);
player.playSound(e.getClickedBlock().getLocation(), Sound.ENTITY_ITEM_FRAME_REMOVE_ITEM, 1f, 1f);
}
else if(connector != null && !player.isSneaking())
{
connector.setDirection(IrisDirection.getDirection(e.getBlockFace()));
player.playSound(e.getClickedBlock().getLocation(), Sound.ENTITY_ITEM_FRAME_ROTATE_ITEM, 1f, 1f);
}
}
}
}
public void close()
{
J.car(ticker);
Iris.instance.unregisterListener(this);
object.unplaceCenterY(origin);
editors.remove(player);
falling.v().forEach(Runnable::run);
try {
IO.writeAll(targetSaveLocation, new JSONObject(new Gson().toJson(piece)).toString(4));
} catch (IOException e) {
e.printStackTrace();
}
}
public void onTick()
{
if(cl.flip())
{
Iris.wand.draw(cuboid, player);
f: for(IrisPosition i : falling.k())
{
for(IrisStructurePieceConnector j : piece.getConnectors())
{
if(j.getPosition().equals(i))
{
continue f;
}
}
falling.remove(i).run();
}
for(IrisStructurePieceConnector i : piece.getConnectors())
{
IrisPosition pos = i.getPosition();
Location at = origin.clone().add(new Vector(pos.getX()+1, pos.getY()+1, pos.getZ()+1));
Vector dir = i.getDirection().toVector().clone();
for(int ix = 0; ix < RNG.r.i(1, 3); ix++)
{
at.getWorld().spawnParticle(Particle.SOUL_FIRE_FLAME, at.clone().getBlock().getLocation().add(0.25, 0.25, 0.25).add(RNG.r.d(0.5), RNG.r.d(0.5), RNG.r.d(0.5)), 0, dir.getX(), dir.getY(), dir.getZ(), 0.092 + RNG.r.d(-0.03, 0.08));
}
if(at.getBlock().getLocation().equals(target))
{
continue;
}
if(!falling.containsKey(pos))
{
if(at.getBlock().getType().isAir())
{
at.getBlock().setType(Material.STONE);
}
falling.put(pos, BlockSignal.forever(at.getBlock()));
}
}
}
}
}

View File

@ -1,15 +1,11 @@
package com.volmit.iris.object; package com.volmit.iris.object;
import java.io.DataInputStream; import com.volmit.iris.Iris;
import java.io.DataOutputStream; import com.volmit.iris.manager.IrisDataManager;
import java.io.File; import com.volmit.iris.util.*;
import java.io.FileInputStream; import lombok.Data;
import java.io.FileOutputStream; import lombok.EqualsAndHashCode;
import java.io.IOException; import lombok.experimental.Accessors;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.function.Consumer;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.block.data.BlockData; import org.bukkit.block.data.BlockData;
@ -17,20 +13,8 @@ import org.bukkit.block.data.Waterlogged;
import org.bukkit.block.data.type.Leaves; import org.bukkit.block.data.type.Leaves;
import org.bukkit.util.BlockVector; import org.bukkit.util.BlockVector;
import com.volmit.iris.Iris; import java.io.*;
import com.volmit.iris.manager.IrisDataManager; import java.util.function.Consumer;
import com.volmit.iris.util.B;
import com.volmit.iris.util.BlockPosition;
import com.volmit.iris.util.CarveResult;
import com.volmit.iris.util.ChunkPosition;
import com.volmit.iris.util.IObjectPlacer;
import com.volmit.iris.util.IrisLock;
import com.volmit.iris.util.KMap;
import com.volmit.iris.util.RNG;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
@Accessors(chain = true) @Accessors(chain = true)
@Data @Data
@ -672,4 +656,30 @@ public class IrisObject extends IrisRegistrant
at.clone().add(0, getCenter().getY(), 0).add(i).getBlock().setBlockData(blocks.get(i), false); at.clone().add(0, getCenter().getY(), 0).add(i).getBlock().setBlockData(blocks.get(i), false);
} }
} }
public void placeCenterY(Location at)
{
if(shitty)
{
return;
}
for(BlockVector i : blocks.keySet())
{
at.clone().add(getCenter().getX(), getCenter().getY(), getCenter().getZ()).add(i).getBlock().setBlockData(blocks.get(i), false);
}
}
public void unplaceCenterY(Location at)
{
if(shitty)
{
return;
}
for(BlockVector i : blocks.keySet())
{
at.clone().add(getCenter().getX(), getCenter().getY(), getCenter().getZ()).add(i).getBlock().setBlockData(Material.AIR.createBlockData(), false);
}
}
} }

View File

@ -1,20 +1,20 @@
package com.volmit.iris.object; package com.volmit.iris.object;
import com.volmit.iris.scaffold.cache.AtomicCache;
import com.volmit.iris.generator.noise.CNG;
import com.volmit.iris.scaffold.data.DataProvider; import com.volmit.iris.scaffold.data.DataProvider;
import com.volmit.iris.util.*; import com.volmit.iris.util.*;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.Data; import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor; import lombok.NoArgsConstructor;
import lombok.experimental.Accessors; import lombok.experimental.Accessors;
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true) @Accessors(chain = true)
@NoArgsConstructor @NoArgsConstructor
@AllArgsConstructor @AllArgsConstructor
@Desc("Represents an iris object placer. It places objects.") @Desc("Represents an iris object placer. It places objects.")
@Data @Data
public class IrisObjectPlacement public class IrisObjectPlacement extends IrisObjectPlacementOptions
{ {
@RegistryListObject @RegistryListObject
@Required @Required
@ -23,118 +23,6 @@ public class IrisObjectPlacement
@Desc("List of objects to place") @Desc("List of objects to place")
private KList<String> place = new KList<>(); private KList<String> place = new KList<>();
@DontObfuscate
@Desc("If the place mode is set to CENTER_HEIGHT_RIGID and you have an X/Z translation, Turning on translate center will also translate the center height check.")
private boolean translateCenter = false;
@DontObfuscate
@Desc("The placement mode")
private ObjectPlaceMode mode = ObjectPlaceMode.CENTER_HEIGHT;
@ArrayType(min = 1, type = IrisObjectReplace.class)
@DontObfuscate
@Desc("Find and replace blocks")
private KList<IrisObjectReplace> edit = new KList<>();
@DontObfuscate
@Desc("Translate this object's placement")
private IrisObjectTranslate translate = new IrisObjectTranslate();
@DontObfuscate
@Desc("Rotate this objects placement")
private IrisObjectRotation rotation = new IrisObjectRotation();
@DontObfuscate
@Desc("Limit the max height or min height of placement.")
private IrisObjectLimit clamp = new IrisObjectLimit();
@MinNumber(0)
@MaxNumber(1)
@DontObfuscate
@Desc("The maximum layer level of a snow filter overtop of this placement. Set to 0 to disable. Max of 1.")
private double snow = 0;
@Required
@MinNumber(0)
@MaxNumber(1)
@DontObfuscate
@Desc("The chance for this to place in a chunk. If you need multiple per chunk, set this to 1 and use density.")
private double chance = 1;
@MinNumber(1)
@DontObfuscate
@Desc("If the chance check passes, place this many in a single chunk")
private int density = 1;
@MaxNumber(64)
@MinNumber(0)
@DontObfuscate
@Desc("If the place mode is set to stilt, you can over-stilt it even further into the ground. Especially useful when using fast stilt due to inaccuracies.")
private int overStilt = 0;
@MaxNumber(64)
@MinNumber(0)
@DontObfuscate
@Desc("When boar is enabled, expand max-y of the cuboid it removes")
private int boarExtendMaxY = 0;
@MaxNumber(64)
@MinNumber(0)
@DontObfuscate
@Desc("When boar is enabled, lower min-y of the cuboid it removes")
private int boarExtendMinY = 0;
@DontObfuscate
@Desc("If set to true, objects will place on the terrain height, ignoring the water surface.")
private boolean underwater = false;
@DontObfuscate
@Desc("If set to true, objects will place in carvings (such as underground) or under an overhang.")
private CarvingMode carvingSupport = CarvingMode.SURFACE_ONLY;
@DontObfuscate
@Desc("If set to true, Iris will try to fill the insides of 'rooms' and 'pockets' where air should fit based off of raytrace checks. This prevents a village house placing in an area where a tree already exists, and instead replaces the parts of the tree where the interior of the structure is. \n\nThis operation does not affect warmed-up generation speed however it does slow down loading objects.")
private boolean smartBore = false;
@DontObfuscate
@Desc("If set to true, Blocks placed underwater that could be waterlogged are waterlogged.")
private boolean waterloggable = false;
@DontObfuscate
@Desc("If set to true, objects will place on the fluid height level Such as boats.")
private boolean onwater = false;
@DontObfuscate
@Desc("If set to true, this object will only place parts of itself where blocks already exist. Warning: Melding is very performance intensive!")
private boolean meld = false;
@DontObfuscate
@Desc("If set to true, this object will place from the ground up instead of height checks when not y locked to the surface. This is not compatable with X and Z axis rotations (it may look off)")
private boolean bottom = false;
@DontObfuscate
@Desc("If set to true, air will be placed before the schematic places.")
private boolean bore = false;
@DontObfuscate
@Desc("Use a generator to warp the field of coordinates. Using simplex for example would make a square placement warp like a flag")
private IrisGeneratorStyle warp = new IrisGeneratorStyle(NoiseStyle.FLAT);
private final transient AtomicCache<CNG> surfaceWarp = new AtomicCache<>();
public CNG getSurfaceWarp(RNG rng)
{
return surfaceWarp.aquire(() ->
{
return getWarp().create(rng);
});
}
public double warp(RNG rng, double x, double y, double z)
{
return getSurfaceWarp(rng).fitDouble(-(getWarp().getMultiplier() / 2D), (getWarp().getMultiplier() / 2D), x, y, z);
}
public IrisObject getSchematic(DataProvider g, RNG random) public IrisObject getSchematic(DataProvider g, RNG random)
{ {
if(place.isEmpty()) if(place.isEmpty())
@ -144,19 +32,4 @@ public class IrisObjectPlacement
return g.getData().getObjectLoader().load(place.get(random.nextInt(place.size()))); return g.getData().getObjectLoader().load(place.get(random.nextInt(place.size())));
} }
public int getTriesForChunk(RNG random)
{
if(chance <= 0)
{
return 0;
}
if(chance >= 1 || random.nextDouble() < chance)
{
return density;
}
return 0;
}
} }

View File

@ -0,0 +1,170 @@
package com.volmit.iris.object;
import com.volmit.iris.generator.noise.CNG;
import com.volmit.iris.scaffold.cache.AtomicCache;
import com.volmit.iris.util.*;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;
@Accessors(chain = true)
@NoArgsConstructor
@AllArgsConstructor
@Desc("Represents an iris object placer. It places objects.")
@Data
public class IrisObjectPlacementOptions
{
@Desc("Rotate this objects placement")
private IrisObjectRotation rotation = new IrisObjectRotation();
@DontObfuscate
@Desc("Limit the max height or min height of placement.")
private IrisObjectLimit clamp = new IrisObjectLimit();
@MinNumber(0)
@MaxNumber(1)
@DontObfuscate
@Desc("The maximum layer level of a snow filter overtop of this placement. Set to 0 to disable. Max of 1.")
private double snow = 0;
@Required
@MinNumber(0)
@MaxNumber(1)
@DontObfuscate
@Desc("The chance for this to place in a chunk. If you need multiple per chunk, set this to 1 and use density.")
private double chance = 1;
@MinNumber(1)
@DontObfuscate
@Desc("If the chance check passes, place this many in a single chunk")
private int density = 1;
@MaxNumber(64)
@MinNumber(0)
@DontObfuscate
@Desc("If the place mode is set to stilt, you can over-stilt it even further into the ground. Especially useful when using fast stilt due to inaccuracies.")
private int overStilt = 0;
@MaxNumber(64)
@MinNumber(0)
@DontObfuscate
@Desc("When boar is enabled, expand max-y of the cuboid it removes")
private int boarExtendMaxY = 0;
@MaxNumber(64)
@MinNumber(0)
@DontObfuscate
@Desc("When boar is enabled, lower min-y of the cuboid it removes")
private int boarExtendMinY = 0;
@DontObfuscate
@Desc("If set to true, objects will place on the terrain height, ignoring the water surface.")
private boolean underwater = false;
@DontObfuscate
@Desc("If set to true, objects will place in carvings (such as underground) or under an overhang.")
private CarvingMode carvingSupport = CarvingMode.SURFACE_ONLY;
@DontObfuscate
@Desc("If set to true, Iris will try to fill the insides of 'rooms' and 'pockets' where air should fit based off of raytrace checks. This prevents a village house placing in an area where a tree already exists, and instead replaces the parts of the tree where the interior of the structure is. \n\nThis operation does not affect warmed-up generation speed however it does slow down loading objects.")
private boolean smartBore = false;
@DontObfuscate
@Desc("If set to true, Blocks placed underwater that could be waterlogged are waterlogged.")
private boolean waterloggable = false;
@DontObfuscate
@Desc("If set to true, objects will place on the fluid height level Such as boats.")
private boolean onwater = false;
@DontObfuscate
@Desc("If set to true, this object will only place parts of itself where blocks already exist. Warning: Melding is very performance intensive!")
private boolean meld = false;
@DontObfuscate
@Desc("If set to true, this object will place from the ground up instead of height checks when not y locked to the surface. This is not compatable with X and Z axis rotations (it may look off)")
private boolean bottom = false;
@DontObfuscate
@Desc("If set to true, air will be placed before the schematic places.")
private boolean bore = false;
@DontObfuscate
@Desc("Use a generator to warp the field of coordinates. Using simplex for example would make a square placement warp like a flag")
private IrisGeneratorStyle warp = new IrisGeneratorStyle(NoiseStyle.FLAT);
@DontObfuscate
@Desc("If the place mode is set to CENTER_HEIGHT_RIGID and you have an X/Z translation, Turning on translate center will also translate the center height check.")
private boolean translateCenter = false;
@DontObfuscate
@Desc("The placement mode")
private ObjectPlaceMode mode = ObjectPlaceMode.CENTER_HEIGHT;
@ArrayType(min = 1, type = IrisObjectReplace.class)
@DontObfuscate
@Desc("Find and replace blocks")
private KList<IrisObjectReplace> edit = new KList<>();
@DontObfuscate
@Desc("Translate this object's placement")
private IrisObjectTranslate translate = new IrisObjectTranslate();
public IrisObjectPlacement toPlacement(String... place)
{
IrisObjectPlacement p = new IrisObjectPlacement();
p.setPlace(new KList<>(place));
p.setTranslateCenter(translateCenter);
p.setMode(mode);
p.setEdit(edit);
p.setTranslate(translate);
p.setWarp(warp);
p.setBore(bore);
p.setMeld(meld);
p.setWaterloggable(waterloggable);
p.setOnwater(onwater);
p.setSmartBore(smartBore);
p.setCarvingSupport(carvingSupport);
p.setUnderwater(underwater);
p.setBoarExtendMaxY(boarExtendMaxY);
p.setBoarExtendMinY(boarExtendMinY);
p.setOverStilt(overStilt);
p.setDensity(density);
p.setChance(chance);
p.setSnow(snow);
p.setClamp(clamp);
p.setRotation(rotation);
return p;
}
private final transient AtomicCache<CNG> surfaceWarp = new AtomicCache<>();
public CNG getSurfaceWarp(RNG rng)
{
return surfaceWarp.aquire(() ->
{
return getWarp().create(rng);
});
}
public double warp(RNG rng, double x, double y, double z)
{
return getSurfaceWarp(rng).fitDouble(-(getWarp().getMultiplier() / 2D), (getWarp().getMultiplier() / 2D), x, y, z);
}
public int getTriesForChunk(RNG random)
{
if(chance <= 0)
{
return 0;
}
if(chance >= 1 || random.nextDouble() < chance)
{
return density;
}
return 0;
}
}

View File

@ -22,6 +22,10 @@ public class IrisStructurePiece extends IrisRegistrant
@Desc("The object this piece represents") @Desc("The object this piece represents")
private String object = ""; private String object = "";
@DontObfuscate
@Desc("Options for placement")
private IrisObjectPlacementOptions placementOptions = new IrisObjectPlacementOptions();
@Required @Required
@DontObfuscate @DontObfuscate
@ArrayType(type = IrisStructurePieceConnector.class, min = 1) @ArrayType(type = IrisStructurePieceConnector.class, min = 1)

View File

@ -27,6 +27,10 @@ public class IrisStructurePieceConnector
@Desc("Rotates the placed piece on this connector. If rotation is enabled, this connector will effectivley rotate, if this connector is facing the Z direction, then the connected piece would rotate in the X,Y direction in 90 degree segments.") @Desc("Rotates the placed piece on this connector. If rotation is enabled, this connector will effectivley rotate, if this connector is facing the Z direction, then the connected piece would rotate in the X,Y direction in 90 degree segments.")
private boolean rotateConnector = false; private boolean rotateConnector = false;
@DontObfuscate
@Desc("If set to true, this connector is allowed to place pieces inside of it's own piece. For example if you are adding a light post, or house on top of a path piece, you would set this to true to allow the piece to collide with the path bounding box.")
private boolean innerConnector = false;
@DontObfuscate @DontObfuscate
@Desc("The relative position this connector is located at for connecting to other pieces") @Desc("The relative position this connector is located at for connecting to other pieces")
@Required @Required