From fd561cd45dd061ec9ad98f6adcb6d0e81121fae2 Mon Sep 17 00:00:00 2001 From: Daniel Mills Date: Mon, 20 Jan 2020 01:53:43 -0500 Subject: [PATCH] Fixes --- .../java/ninja/bytecode/iris/CommandIris.java | 36 +++++++++++++++++++ .../iris/controller/PackController.java | 10 +++--- .../iris/generator/IrisGenerator.java | 5 +++ .../genobject/GenObjectDecorator.java | 20 +++++++++++ 4 files changed, 67 insertions(+), 4 deletions(-) diff --git a/src/main/java/ninja/bytecode/iris/CommandIris.java b/src/main/java/ninja/bytecode/iris/CommandIris.java index 6f90cbff6..f8ad216a7 100644 --- a/src/main/java/ninja/bytecode/iris/CommandIris.java +++ b/src/main/java/ninja/bytecode/iris/CommandIris.java @@ -2,6 +2,7 @@ package ninja.bytecode.iris; import org.bukkit.ChatColor; import org.bukkit.Chunk; +import org.bukkit.Location; import org.bukkit.World; import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; @@ -12,6 +13,7 @@ import mortar.api.nms.NMP; import mortar.util.text.C; import ninja.bytecode.iris.controller.TimingsController; import ninja.bytecode.iris.generator.IrisGenerator; +import ninja.bytecode.iris.generator.genobject.PlacedObject; import ninja.bytecode.iris.pack.IrisBiome; import ninja.bytecode.iris.util.BiomeLayer; import ninja.bytecode.shuriken.format.F; @@ -86,6 +88,40 @@ public class CommandIris implements CommandExecutor } } + if(args[0].equalsIgnoreCase("otp")) + { + if(sender instanceof Player) + { + Player p = (Player) sender; + World w = p.getWorld(); + + if(w.getGenerator() instanceof IrisGenerator) + { + if(args.length >= 2) + { + PlacedObject o = ((IrisGenerator) w.getGenerator()).randomObject(args[1]); + + if(o != null) + { + Location l = new Location(w, o.getX(), o.getY(), o.getZ()); + p.teleport(l); + msg(p, "Found " + C.DARK_GREEN + o.getF().replace(":", "/" + C.WHITE)); + } + + else + { + msg(p, "Found Nothing"); + } + } + + else + { + msg(p, "/iris otp "); + } + } + } + } + if(args[0].equalsIgnoreCase("rtp")) { if(sender instanceof Player) diff --git a/src/main/java/ninja/bytecode/iris/controller/PackController.java b/src/main/java/ninja/bytecode/iris/controller/PackController.java index 01fc7717e..736f8fad9 100644 --- a/src/main/java/ninja/bytecode/iris/controller/PackController.java +++ b/src/main/java/ninja/bytecode/iris/controller/PackController.java @@ -103,7 +103,7 @@ public class PackController implements IrisController } L.v(ChatColor.LIGHT_PURPLE + "Processing Content"); - + for(GenObjectGroup i : genObjectGroups.v()) { i.processVariants(); @@ -129,6 +129,8 @@ public class PackController implements IrisController GenObjectGroup ggx = genObjectGroups.get(k).copy("-snowy-" + j.getSnow()); ggx.applySnowFilter((int) (j.getSnow() * 4)); d.registerObject(ggx); + j.getSchematicGroups().put(ggx.getName(), j.getSchematicGroups().get(k)); + j.getSchematicGroups().remove(k); } } } @@ -285,17 +287,17 @@ public class PackController implements IrisController { i.dispose(); } - + for(IrisDimension i : dimensions.values()) { i.dispose(); } - + for(CompiledDimension i : compiledDimensions.values()) { i.dispose(); } - + compiledDimensions.clear(); dimensions.clear(); biomes.clear(); diff --git a/src/main/java/ninja/bytecode/iris/generator/IrisGenerator.java b/src/main/java/ninja/bytecode/iris/generator/IrisGenerator.java index 71b45275f..24bd8dde3 100644 --- a/src/main/java/ninja/bytecode/iris/generator/IrisGenerator.java +++ b/src/main/java/ninja/bytecode/iris/generator/IrisGenerator.java @@ -434,4 +434,9 @@ public class IrisGenerator extends ParallelChunkGenerator return f; } + + public PlacedObject randomObject(String string) + { + return god.randomObject(string); + } } \ No newline at end of file diff --git a/src/main/java/ninja/bytecode/iris/generator/genobject/GenObjectDecorator.java b/src/main/java/ninja/bytecode/iris/generator/genobject/GenObjectDecorator.java index 0f2d4ad91..f6ecc1f2d 100644 --- a/src/main/java/ninja/bytecode/iris/generator/genobject/GenObjectDecorator.java +++ b/src/main/java/ninja/bytecode/iris/generator/genobject/GenObjectDecorator.java @@ -248,4 +248,24 @@ public class GenObjectDecorator extends BlockPopulator { return placeHistory; } + + public PlacedObject randomObject(String string) + { + GList v = new GList<>(); + + for(PlacedObject i : placeHistory) + { + if(i.getF().toLowerCase().replaceAll("\\Q:\\E", "/").startsWith(string.toLowerCase())) + { + v.add(i); + } + } + + if(v.isEmpty()) + { + return null; + } + + return v.getRandom(); + } }