diff --git a/src/main/java/ninja/bytecode/iris/CommandIris.java b/src/main/java/ninja/bytecode/iris/CommandIris.java index 87949fb0a..097ca4441 100644 --- a/src/main/java/ninja/bytecode/iris/CommandIris.java +++ b/src/main/java/ninja/bytecode/iris/CommandIris.java @@ -1,14 +1,53 @@ package ninja.bytecode.iris; +import org.bukkit.Bukkit; +import org.bukkit.ChatColor; +import org.bukkit.GameMode; +import org.bukkit.Location; +import org.bukkit.World; import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; public class CommandIris implements CommandExecutor { + public void msg(CommandSender s, String msg) + { + s.sendMessage(ChatColor.DARK_PURPLE + "[" + ChatColor.GRAY + "Iris" + ChatColor.DARK_PURPLE + "]" + ChatColor.GRAY + ": " + msg); + } + @Override public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { + if(args.length == 0) + { + msg(sender, "/iris gen - Gen a new Iris World"); + msg(sender, "/ish - Iris Schematic Commands"); + } + + if(args.length > 0) + { + if(args[0].equalsIgnoreCase("gen")) + { + if(sender instanceof Player) + { + World wold = ((Player)sender).getWorld(); + World w = Iris.instance.createIrisWorld(); + ((Player)sender).teleport(new Location(w, 0, 256, 0)); + ((Player)sender).setFlying(true); + ((Player)sender).setGameMode(GameMode.CREATIVE); + wold.setAutoSave(false); + Bukkit.unloadWorld(wold, false); + } + + else + { + Iris.instance.createIrisWorld(); + } + } + } + return false; } } diff --git a/src/main/java/ninja/bytecode/iris/CommandIsh.java b/src/main/java/ninja/bytecode/iris/CommandIsh.java new file mode 100644 index 000000000..8b684312e --- /dev/null +++ b/src/main/java/ninja/bytecode/iris/CommandIsh.java @@ -0,0 +1,259 @@ +package ninja.bytecode.iris; + +import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; + +import org.bukkit.ChatColor; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.Sound; +import org.bukkit.block.Block; +import org.bukkit.command.Command; +import org.bukkit.command.CommandExecutor; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; +import org.bukkit.util.Vector; + +import ninja.bytecode.iris.schematic.Schematic; +import ninja.bytecode.iris.util.Cuboid; +import ninja.bytecode.iris.util.Cuboid.CuboidDirection; +import ninja.bytecode.iris.util.Direction; +import ninja.bytecode.iris.util.WandUtil; +import ninja.bytecode.shuriken.format.F; + +public class CommandIsh implements CommandExecutor +{ + public void msg(CommandSender s, String msg) + { + s.sendMessage(ChatColor.DARK_PURPLE + "[" + ChatColor.GRAY + "Iris" + ChatColor.DARK_PURPLE + "]" + ChatColor.GRAY + ": " + msg); + } + + @Override + public boolean onCommand(CommandSender sender, Command command, String label, String[] args) + { + if(args.length == 0) + { + msg(sender, "/ish wand - Get an Iris Wand"); + msg(sender, "/ish save - Save Schematic"); + msg(sender, "/ish load [cursor] - Paste Schematic"); + msg(sender, "/ish expand - Expand Cuboid in direction"); + msg(sender, "/ish shift - Shift Cuboid in direction"); + msg(sender, "/ish shrinkwrap - Shrink to blocks"); + msg(sender, "/ish xup - Shift up, Expand up, Contract in."); + msg(sender, "/ish xvert - Expand up, Expand down, Contract in."); + msg(sender, "/ish id - What id am i looking at"); + } + + if(args.length > 0) + { + if(sender instanceof Player) + { + Player p = (Player) sender; + if(args[0].equalsIgnoreCase("wand")) + { + p.getInventory().addItem(WandUtil.createWand()); + p.playSound(p.getLocation(), Sound.ITEM_ARMOR_EQUIP_DIAMOND, 1f, 1.55f); + } + + if(args[0].equalsIgnoreCase("id")) + { + + Block b = p.getTargetBlock(null, 64); + msg(p, b.getType().getId() + ":" + b.getData() + " (" + b.getType().toString() + ":" + b.getData() + ")"); + } + + if(args[0].equalsIgnoreCase("save")) + { + Schematic s = WandUtil.createSchematic(p.getInventory().getItemInMainHand(), p.getLocation()); + File f = new File(Iris.instance.getDataFolder(), "schematics/" + args[1] + ".ish"); + f.getParentFile().mkdirs(); + try + { + FileOutputStream fos = new FileOutputStream(f); + s.write(fos); + msg(p, "Saved " + args[1] + " (" + F.f(s.getSchematic().size()) + " Entries)"); + p.playSound(p.getLocation(), Sound.BLOCK_ENCHANTMENT_TABLE_USE, 1f, 0.45f); + } + + catch(Throwable e1) + { + e1.printStackTrace(); + } + } + + if(args[0].equalsIgnoreCase("load")) + { + Schematic s = new Schematic(1, 1, 1); + File f = new File(Iris.instance.getDataFolder(), "schematics/" + args[1] + ".ish"); + if(!f.exists()) + { + msg(p, "Not Found"); + return true; + } + + try + { + FileInputStream fin = new FileInputStream(f); + s.read(fin); + + boolean cursor = false; + for(String i : args) + { + if(i.equalsIgnoreCase("cursor")) + { + cursor = true; + break; + } + } + + Location at = p.getLocation(); + + if(cursor) + { + at = p.getTargetBlock(null, 64).getLocation(); + } + + WandUtil.pasteSchematic(s, at); + p.playSound(p.getLocation(), Sound.BLOCK_ENCHANTMENT_TABLE_USE, 1f, 1.25f); + msg(p, "Pasted " + args[1] + " (" + F.f(s.getSchematic().size()) + " Blocks Modified)"); + } + + catch(Throwable e1) + { + e1.printStackTrace(); + } + } + + if(args[0].equalsIgnoreCase("xup")) + { + Location[] b = WandUtil.getCuboid(p.getInventory().getItemInMainHand()); + b[0].add(new Vector(0, 1, 0)); + b[1].add(new Vector(0, 1, 0)); + Location a1 = b[0].clone(); + Location a2 = b[1].clone(); + Cuboid cursor = new Cuboid(a1, a2); + + while(!cursor.containsOnly(Material.AIR)) + { + a1.add(new Vector(0, 1, 0)); + a2.add(new Vector(0, 1, 0)); + cursor = new Cuboid(a1, a2); + } + + a1.add(new Vector(0, -1, 0)); + a2.add(new Vector(0, -1, 0)); + b[0] = a1; + a2 = b[1]; + cursor = new Cuboid(a1, a2); + cursor = cursor.contract(CuboidDirection.North); + cursor = cursor.contract(CuboidDirection.South); + cursor = cursor.contract(CuboidDirection.East); + cursor = cursor.contract(CuboidDirection.West); + b[0] = cursor.getLowerNE(); + b[1] = cursor.getUpperSW(); + p.getInventory().setItemInMainHand(WandUtil.createWand(b[0], b[1])); + p.updateInventory(); + p.playSound(p.getLocation(), Sound.ENTITY_ITEMFRAME_ROTATE_ITEM, 1f, 0.55f); + } + + if(args[0].equalsIgnoreCase("shrinkwrap") || args[0].equalsIgnoreCase("shrink")) + { + Location[] b = WandUtil.getCuboid(p.getInventory().getItemInMainHand()); + Location a1 = b[0].clone(); + Location a2 = b[1].clone(); + Cuboid cursor = new Cuboid(a1, a2); + cursor = cursor.contract(CuboidDirection.North); + cursor = cursor.contract(CuboidDirection.South); + cursor = cursor.contract(CuboidDirection.East); + cursor = cursor.contract(CuboidDirection.West); + cursor = cursor.contract(CuboidDirection.Up); + cursor = cursor.contract(CuboidDirection.Down); + b[0] = cursor.getLowerNE(); + b[1] = cursor.getUpperSW(); + p.getInventory().setItemInMainHand(WandUtil.createWand(b[0], b[1])); + p.updateInventory(); + p.playSound(p.getLocation(), Sound.ENTITY_ITEMFRAME_ROTATE_ITEM, 1f, 0.55f); + } + + if(args[0].equalsIgnoreCase("expand")) + { + int amt = Integer.valueOf(args[1]); + Location[] b = WandUtil.getCuboid(p.getInventory().getItemInMainHand()); + Location a1 = b[0].clone(); + Location a2 = b[1].clone(); + Cuboid cursor = new Cuboid(a1, a2); + Direction d = Direction.closest(p.getLocation().getDirection()).reverse(); + cursor = cursor.expand(d, amt); + b[0] = cursor.getLowerNE(); + b[1] = cursor.getUpperSW(); + p.getInventory().setItemInMainHand(WandUtil.createWand(b[0], b[1])); + p.updateInventory(); + p.playSound(p.getLocation(), Sound.ENTITY_ITEMFRAME_ROTATE_ITEM, 1f, 0.55f); + } + + if(args[0].equalsIgnoreCase("shift")) + { + int amt = Integer.valueOf(args[1]); + Location[] b = WandUtil.getCuboid(p.getInventory().getItemInMainHand()); + Location a1 = b[0].clone(); + Location a2 = b[1].clone(); + Direction d = Direction.closest(p.getLocation().getDirection()).reverse(); + a1.add(d.toVector().multiply(amt)); + a2.add(d.toVector().multiply(amt)); + Cuboid cursor = new Cuboid(a1, a2); + b[0] = cursor.getLowerNE(); + b[1] = cursor.getUpperSW(); + p.getInventory().setItemInMainHand(WandUtil.createWand(b[0], b[1])); + p.updateInventory(); + p.playSound(p.getLocation(), Sound.ENTITY_ITEMFRAME_ROTATE_ITEM, 1f, 0.55f); + } + + if(args[0].equalsIgnoreCase("xvert")) + { + Location[] b = WandUtil.getCuboid(p.getInventory().getItemInMainHand()); + Location a1 = b[0].clone(); + Location a2 = b[1].clone(); + Location a1x = b[0].clone(); + Location a2x = b[1].clone(); + Cuboid cursor = new Cuboid(a1, a2); + Cuboid cursorx = new Cuboid(a1, a2); + + while(!cursor.containsOnly(Material.AIR)) + { + a1.add(new Vector(0, 1, 0)); + a2.add(new Vector(0, 1, 0)); + cursor = new Cuboid(a1, a2); + } + + a1.add(new Vector(0, -1, 0)); + a2.add(new Vector(0, -1, 0)); + + while(!cursorx.containsOnly(Material.AIR)) + { + a1x.add(new Vector(0, -1, 0)); + a2x.add(new Vector(0, -1, 0)); + cursorx = new Cuboid(a1x, a2x); + } + + a1x.add(new Vector(0, 1, 0)); + a2x.add(new Vector(0, 1, 0)); + b[0] = a1; + b[1] = a2x; + cursor = new Cuboid(b[0], b[1]); + cursor = cursor.contract(CuboidDirection.North); + cursor = cursor.contract(CuboidDirection.South); + cursor = cursor.contract(CuboidDirection.East); + cursor = cursor.contract(CuboidDirection.West); + b[0] = cursor.getLowerNE(); + b[1] = cursor.getUpperSW(); + p.getInventory().setItemInMainHand(WandUtil.createWand(b[0], b[1])); + p.updateInventory(); + p.playSound(p.getLocation(), Sound.ENTITY_ITEMFRAME_ROTATE_ITEM, 1f, 0.55f); + } + } + } + + return false; + } +} diff --git a/src/main/java/ninja/bytecode/iris/Iris.java b/src/main/java/ninja/bytecode/iris/Iris.java index 9ef935e1a..bf3a96e87 100644 --- a/src/main/java/ninja/bytecode/iris/Iris.java +++ b/src/main/java/ninja/bytecode/iris/Iris.java @@ -4,15 +4,14 @@ import java.util.UUID; import java.util.function.Function; import org.bukkit.Bukkit; +import org.bukkit.Chunk; import org.bukkit.GameMode; import org.bukkit.Location; import org.bukkit.World; import org.bukkit.WorldCreator; import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; import org.bukkit.event.HandlerList; import org.bukkit.event.Listener; -import org.bukkit.event.player.PlayerCommandPreprocessEvent; import org.bukkit.generator.ChunkGenerator; import org.bukkit.plugin.Plugin; import org.bukkit.plugin.java.JavaPlugin; @@ -28,6 +27,7 @@ import ninja.bytecode.shuriken.execution.TaskExecutor; public class Iris extends JavaPlugin implements Listener { + public static GSet refresh = new GSet<>(); public static Profiler profiler; public static TaskExecutor genPool; public static IrisGenerator gen; @@ -45,6 +45,8 @@ public class Iris extends JavaPlugin implements Listener gen = new IrisGenerator(); genPool = new TaskExecutor(getTC(), settings.performance.threadPriority, "Iris Generator"); getServer().getPluginManager().registerEvents((Listener) this, this); + getCommand("iris").setExecutor(new CommandIris()); + getCommand("ish").setExecutor(new CommandIsh()); new WandManager(); // Debug world regens @@ -117,23 +119,7 @@ public class Iris extends JavaPlugin implements Listener return new IrisGenerator(); } - @EventHandler - public void on(PlayerCommandPreprocessEvent e) - { - if(e.getMessage().toLowerCase().equals("/iris gen")) - { - e.setCancelled(true); - World wold = e.getPlayer().getWorld(); - World w = createIrisWorld(); - e.getPlayer().teleport(new Location(w, 0, 256, 0)); - e.getPlayer().setFlying(true); - e.getPlayer().setGameMode(GameMode.CREATIVE); - wold.setAutoSave(false); - Bukkit.unloadWorld(wold, false); - } - } - - private World createIrisWorld() + public World createIrisWorld() { World ww = Bukkit.createWorld(new WorldCreator("iris-worlds/" + UUID.randomUUID().toString()).generator(new IrisGenerator()).seed(5944323)); ww.setSpawnFlags(false, false); diff --git a/src/main/java/ninja/bytecode/iris/WandManager.java b/src/main/java/ninja/bytecode/iris/WandManager.java index 5da76a45b..84c5ef616 100644 --- a/src/main/java/ninja/bytecode/iris/WandManager.java +++ b/src/main/java/ninja/bytecode/iris/WandManager.java @@ -1,31 +1,26 @@ package ninja.bytecode.iris; import java.awt.Color; -import java.io.File; -import java.io.FileInputStream; -import java.io.FileOutputStream; import org.bukkit.Bukkit; +import org.bukkit.Chunk; import org.bukkit.Location; -import org.bukkit.Material; +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.PlayerCommandPreprocessEvent; import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.inventory.EquipmentSlot; import org.bukkit.util.Vector; -import ninja.bytecode.iris.schematic.Schematic; -import ninja.bytecode.iris.util.Cuboid; -import ninja.bytecode.iris.util.Cuboid.CuboidDirection; import ninja.bytecode.iris.util.ParticleEffect; import ninja.bytecode.iris.util.ParticleRedstone; import ninja.bytecode.iris.util.WandUtil; public class WandManager implements Listener { + @SuppressWarnings("deprecation") public WandManager() { Bukkit.getPluginManager().registerEvents(this, Iris.instance); @@ -35,219 +30,104 @@ public class WandManager implements Listener { tick(i); } - }, 0, 4); + + for(Chunk i : Iris.refresh) + { + i.getWorld().refreshChunk(i.getX(), i.getZ()); + } + + Iris.refresh.clear(); + }, 0, 2); } @EventHandler public void tick(Player p) { - if(WandUtil.isWand(p.getInventory().getItemInMainHand())) + try { - Location[] d = WandUtil.getCuboid(p.getInventory().getItemInMainHand()); - ParticleEffect.CRIT_MAGIC.display(0.1f, 1, d[0].clone().add(0.5, 0.5, 0.5).clone().add(Vector.getRandom().subtract(Vector.getRandom()).normalize().clone().multiply(0.65)), p); - ParticleEffect.CRIT.display(0.1f, 1, d[1].clone().add(0.5, 0.5, 0.5).clone().add(Vector.getRandom().subtract(Vector.getRandom()).normalize().clone().multiply(0.65)), p); - - if(!d[0].getWorld().equals(d[1].getWorld())) + if(WandUtil.isWand(p.getInventory().getItemInMainHand())) { - return; - } + Location[] d = WandUtil.getCuboid(p.getInventory().getItemInMainHand()); + ParticleEffect.CRIT_MAGIC.display(0.1f, 1, d[0].clone().add(0.5, 0.5, 0.5).clone().add(Vector.getRandom().subtract(Vector.getRandom()).normalize().clone().multiply(0.65)), p); + ParticleEffect.CRIT.display(0.1f, 1, d[1].clone().add(0.5, 0.5, 0.5).clone().add(Vector.getRandom().subtract(Vector.getRandom()).normalize().clone().multiply(0.65)), p); - if(d[0].distanceSquared(d[1]) > 64 * 64) - { - return; - } - - int minx = Math.min(d[0].getBlockX(), d[1].getBlockX()); - int miny = Math.min(d[0].getBlockY(), d[1].getBlockY()); - int minz = Math.min(d[0].getBlockZ(), d[1].getBlockZ()); - int maxx = Math.max(d[0].getBlockX(), d[1].getBlockX()); - int maxy = Math.max(d[0].getBlockY(), d[1].getBlockY()); - int maxz = Math.max(d[0].getBlockZ(), d[1].getBlockZ()); - - for(double j = minx - 1; j < maxx + 1; j += 0.25) - { - for(double k = miny - 1; k < maxy + 1; k += 0.25) + if(!d[0].getWorld().equals(d[1].getWorld())) { - for(double l = minz - 1; l < maxz + 1; l += 0.25) + return; + } + + if(d[0].distanceSquared(d[1]) > 64 * 64) + { + return; + } + + int minx = Math.min(d[0].getBlockX(), d[1].getBlockX()); + int miny = Math.min(d[0].getBlockY(), d[1].getBlockY()); + int minz = Math.min(d[0].getBlockZ(), d[1].getBlockZ()); + int maxx = Math.max(d[0].getBlockX(), d[1].getBlockX()); + int maxy = Math.max(d[0].getBlockY(), d[1].getBlockY()); + int maxz = Math.max(d[0].getBlockZ(), d[1].getBlockZ()); + + for(double j = minx - 1; j < maxx + 1; j += 0.25) + { + for(double k = miny - 1; k < maxy + 1; k += 0.25) { - boolean jj = j == minx || j == maxx; - boolean kk = k == miny || k == maxy; - boolean ll = l == minz || l == maxz; - double aa = j; - double bb = k; - double cc = l; - - if((jj && kk) || (jj && ll) || (ll && kk)) + for(double l = minz - 1; l < maxz + 1; l += 0.25) { - Vector push = new Vector(0, 0, 0); + boolean jj = j == minx || j == maxx; + boolean kk = k == miny || k == maxy; + boolean ll = l == minz || l == maxz; + double aa = j; + double bb = k; + double cc = l; - if(j == minx) + if((jj && kk) || (jj && ll) || (ll && kk)) { - push.add(new Vector(-0.55, 0, 0)); - } + Vector push = new Vector(0, 0, 0); - if(k == miny) - { - push.add(new Vector(0, -0.55, 0)); - } + if(j == minx) + { + push.add(new Vector(-0.55, 0, 0)); + } - if(l == minz) - { - push.add(new Vector(0, 0, -0.55)); - } + if(k == miny) + { + push.add(new Vector(0, -0.55, 0)); + } - if(j == maxx) - { - push.add(new Vector(0.55, 0, 0)); - } + if(l == minz) + { + push.add(new Vector(0, 0, -0.55)); + } - if(k == maxy) - { - push.add(new Vector(0, 0.55, 0)); - } + if(j == maxx) + { + push.add(new Vector(0.55, 0, 0)); + } - if(l == maxz) - { - push.add(new Vector(0, 0, 0.55)); - } + if(k == maxy) + { + push.add(new Vector(0, 0.55, 0)); + } - Location lv = new Location(d[0].getWorld(), aa, bb, cc).clone().add(0.5, 0.5, 0.5).clone().add(push); - int color = Color.getHSBColor((float) (0.5f + (Math.sin((aa + bb + cc + (p.getTicksLived() / 2)) / 20f) / 2)), 1, 1).getRGB(); - new ParticleRedstone().setColor(new Color(color)).play(lv, p); + if(l == maxz) + { + push.add(new Vector(0, 0, 0.55)); + } + + Location lv = new Location(d[0].getWorld(), aa, bb, cc).clone().add(0.5, 0.5, 0.5).clone().add(push); + int color = Color.getHSBColor((float) (0.5f + (Math.sin((aa + bb + cc + (p.getTicksLived() / 2)) / 20f) / 2)), 1, 1).getRGB(); + new ParticleRedstone().setColor(new Color(color)).play(lv, p); + } } } } } } - } - - @EventHandler - public void on(PlayerCommandPreprocessEvent e) - { - if(e.getMessage().startsWith("/isave ")) - { - e.setCancelled(true); - Schematic s = WandUtil.createSchematic(e.getPlayer().getInventory().getItemInMainHand(), e.getPlayer().getLocation()); - File f = new File(Iris.instance.getDataFolder(), "schematics/" + e.getMessage().split("\\Q \\E")[1] + ".ish"); - f.getParentFile().mkdirs(); - try - { - FileOutputStream fos = new FileOutputStream(f); - s.write(fos); - e.getPlayer().sendMessage("Done!"); - } - - catch(Throwable e1) - { - e1.printStackTrace(); - } - } - - if(e.getMessage().startsWith("/iload ")) - { - e.setCancelled(true); - Schematic s = new Schematic(1, 1, 1); - File f = new File(Iris.instance.getDataFolder(), "schematics/" + e.getMessage().split("\\Q \\E")[1] + ".ish"); - if(!f.exists()) - { - e.getPlayer().sendMessage("Not Found"); - return; - } - - try - { - FileInputStream fin = new FileInputStream(f); - s.read(fin); - WandUtil.pasteSchematic(s, e.getPlayer().getLocation()); - e.getPlayer().sendMessage("Done!"); - } - - catch(Throwable e1) - { - e1.printStackTrace(); - } - } - if(e.getMessage().startsWith("/iup")) + catch(Throwable e) { - e.setCancelled(true); - Location[] b = WandUtil.getCuboid(e.getPlayer().getInventory().getItemInMainHand()); - b[0].add(new Vector(0, 1, 0)); - b[1].add(new Vector(0, 1, 0)); - Location a1 = b[0].clone(); - Location a2 = b[1].clone(); - Cuboid cursor = new Cuboid(a1, a2); - - while(!cursor.containsOnly(Material.AIR)) - { - a1.add(new Vector(0, 1, 0)); - a2.add(new Vector(0, 1, 0)); - cursor = new Cuboid(a1, a2); - } - a1.add(new Vector(0, -1, 0)); - a2.add(new Vector(0, -1, 0)); - b[0] = a1; - a2 = b[1]; - cursor = new Cuboid(a1, a2); - cursor = cursor.contract(CuboidDirection.North); - cursor = cursor.contract(CuboidDirection.South); - cursor = cursor.contract(CuboidDirection.East); - cursor = cursor.contract(CuboidDirection.West); - b[0] = cursor.getLowerNE(); - b[1] = cursor.getUpperSW(); - e.getPlayer().getInventory().setItemInMainHand(WandUtil.createWand(b[0], b[1])); - e.getPlayer().updateInventory(); - } - - if(e.getMessage().startsWith("/ivert")) - { - e.setCancelled(true); - Location[] b = WandUtil.getCuboid(e.getPlayer().getInventory().getItemInMainHand()); - - Location a1 = b[0].clone(); - Location a2 = b[1].clone(); - Location a1x = b[0].clone(); - Location a2x = b[1].clone(); - Cuboid cursor = new Cuboid(a1, a2); - Cuboid cursorx = new Cuboid(a1, a2); - - while(!cursor.containsOnly(Material.AIR)) - { - a1.add(new Vector(0, 1, 0)); - a2.add(new Vector(0, 1, 0)); - cursor = new Cuboid(a1, a2); - } - - a1.add(new Vector(0, -1, 0)); - a2.add(new Vector(0, -1, 0)); - - while(!cursorx.containsOnly(Material.AIR)) - { - a1x.add(new Vector(0, -1, 0)); - a2x.add(new Vector(0, -1, 0)); - cursorx = new Cuboid(a1x, a2x); - } - - a1x.add(new Vector(0, 1, 0)); - a2x.add(new Vector(0, 1, 0)); - b[0] = a1; - b[1] = a2x; - cursor = new Cuboid(b[0], b[1]); - cursor = cursor.contract(CuboidDirection.North); - cursor = cursor.contract(CuboidDirection.South); - cursor = cursor.contract(CuboidDirection.East); - cursor = cursor.contract(CuboidDirection.West); - b[0] = cursor.getLowerNE(); - b[1] = cursor.getUpperSW(); - e.getPlayer().getInventory().setItemInMainHand(WandUtil.createWand(b[0], b[1])); - e.getPlayer().updateInventory(); - } - - if(e.getMessage().equals("/iris wand")) - { - e.setCancelled(true); - e.getPlayer().getInventory().addItem(WandUtil.createWand()); } } @@ -260,7 +140,7 @@ public class WandManager implements Listener { e.setCancelled(true); e.getPlayer().getInventory().setItemInMainHand(WandUtil.update(true, e.getClickedBlock().getLocation(), e.getPlayer().getInventory().getItemInMainHand())); - + e.getPlayer().playSound(e.getClickedBlock().getLocation(), Sound.BLOCK_END_PORTAL_FRAME_FILL, 1f, 0.67f); e.getPlayer().updateInventory(); } @@ -268,7 +148,7 @@ public class WandManager implements Listener { e.setCancelled(true); e.getPlayer().getInventory().setItemInMainHand(WandUtil.update(false, e.getClickedBlock().getLocation(), e.getPlayer().getInventory().getItemInMainHand())); - + e.getPlayer().playSound(e.getClickedBlock().getLocation(), Sound.BLOCK_END_PORTAL_FRAME_FILL, 1f, 1.17f); e.getPlayer().updateInventory(); } } diff --git a/src/main/java/ninja/bytecode/iris/generator/IrisGenerator.java b/src/main/java/ninja/bytecode/iris/generator/IrisGenerator.java index 74aafada7..352b15813 100644 --- a/src/main/java/ninja/bytecode/iris/generator/IrisGenerator.java +++ b/src/main/java/ninja/bytecode/iris/generator/IrisGenerator.java @@ -233,17 +233,7 @@ public class IrisGenerator extends ParallelChunkGenerator p.add(new BiomeBiasSchematicPopulator(i.getSchematicGroups().get(j), i, gs.getSchematics().toArray(new Schematic[gs.size()]))); } } - - p.add(new BlockPopulator() - { - @SuppressWarnings("deprecation") - @Override - public void populate(World world, Random random, Chunk source) - { - Bukkit.getScheduler().scheduleSyncDelayedTask(Iris.instance, () -> world.refreshChunk(source.getX(), source.getZ()), 50); - } - }); - + L.i("Initialized " + b + " Biomes with " + p.size() + " Populators using " + sch + " Schematics"); } diff --git a/src/main/java/ninja/bytecode/iris/schematic/Schematic.java b/src/main/java/ninja/bytecode/iris/schematic/Schematic.java index 7a0212796..16675c756 100644 --- a/src/main/java/ninja/bytecode/iris/schematic/Schematic.java +++ b/src/main/java/ninja/bytecode/iris/schematic/Schematic.java @@ -14,6 +14,7 @@ import org.bukkit.Material; import org.bukkit.World; import org.bukkit.util.BlockVector; +import ninja.bytecode.iris.Iris; import ninja.bytecode.iris.util.Catalyst12; import ninja.bytecode.iris.util.MB; import ninja.bytecode.shuriken.collections.GMap; @@ -137,9 +138,15 @@ public class Schematic s.put(b); } + public int sh(int g) + { + int m = (g / 2); + return g % 2 == 0 ? m : m + 1; + } + public void place(World source, int wx, int wy, int wz) { - Location start = new Location(source, wx, wy, wz).clone().add(w / 2, centeredHeight ? 0 : -(h / 2), d / 2); + Location start = new Location(source, wx, wy, wz).clone().add(sh(w), sh(h) + 1, sh(d)); for(BlockVector i : getSchematic().k()) { @@ -153,6 +160,7 @@ public class Schematic try { + Iris.refresh.add(f.getChunk()); Catalyst12.setBlock(source, f.getBlockX(), f.getBlockY(), f.getBlockZ(), b); } diff --git a/src/main/java/ninja/bytecode/iris/util/Cuboid.java b/src/main/java/ninja/bytecode/iris/util/Cuboid.java index d7d18ab5e..017b202e6 100644 --- a/src/main/java/ninja/bytecode/iris/util/Cuboid.java +++ b/src/main/java/ninja/bytecode/iris/util/Cuboid.java @@ -422,6 +422,17 @@ public class Cuboid implements Iterable, Cloneable, ConfigurationSerializ } } + public Cuboid expand(Direction dir, int amount) + { + int ax = dir.toVector().getBlockX() == 1 ? amount : 0; + int sx = dir.toVector().getBlockX() == -1 ? -amount : 0; + int ay = dir.toVector().getBlockY() == 1 ? amount : 0; + int sy = dir.toVector().getBlockY() == -1 ? -amount : 0; + int az = dir.toVector().getBlockZ() == 1 ? amount : 0; + int sz = dir.toVector().getBlockZ() == -1 ? -amount : 0; + return new Cuboid(worldName, x1 + sx, y1 + sy, z1 + sz, x2 + ax, y2 + ay, z2 + az); + } + /** * Shift the Cuboid in the given direction by the given amount. * diff --git a/src/main/java/ninja/bytecode/iris/util/Direction.java b/src/main/java/ninja/bytecode/iris/util/Direction.java index 52b22e640..790098c92 100644 --- a/src/main/java/ninja/bytecode/iris/util/Direction.java +++ b/src/main/java/ninja/bytecode/iris/util/Direction.java @@ -62,7 +62,7 @@ public enum Direction for(Direction i : values()) { Vector x = i.toVector(); - double g = x.distance(v); + double g = x.dot(v); if(g < m) { diff --git a/src/main/java/ninja/bytecode/iris/util/WandUtil.java b/src/main/java/ninja/bytecode/iris/util/WandUtil.java index 287338da8..09cca3b29 100644 --- a/src/main/java/ninja/bytecode/iris/util/WandUtil.java +++ b/src/main/java/ninja/bytecode/iris/util/WandUtil.java @@ -15,7 +15,6 @@ import org.bukkit.util.BlockVector; import ninja.bytecode.iris.schematic.Schematic; import ninja.bytecode.shuriken.collections.GList; -import ninja.bytecode.shuriken.logging.L; public class WandUtil { @@ -108,6 +107,11 @@ public class WandUtil Location[] f = getCuboid(item); Location other = left ? f[1] : f[0]; + if(other != null && !other.getWorld().getName().equals(a.getWorld().getName())) + { + other = null; + } + return createWand(left ? a : other, left ? other : a); } diff --git a/src/main/resources/objects/tree/birch/small/birch1.ish b/src/main/resources/objects/tree/birch/small/birch1.ish new file mode 100644 index 000000000..7a8e2863a Binary files /dev/null and b/src/main/resources/objects/tree/birch/small/birch1.ish differ diff --git a/src/main/resources/objects/tree/birch/small/birch10.ish b/src/main/resources/objects/tree/birch/small/birch10.ish new file mode 100644 index 000000000..f5b6da952 Binary files /dev/null and b/src/main/resources/objects/tree/birch/small/birch10.ish differ diff --git a/src/main/resources/objects/tree/birch/small/birch11.ish b/src/main/resources/objects/tree/birch/small/birch11.ish new file mode 100644 index 000000000..ce63063ce Binary files /dev/null and b/src/main/resources/objects/tree/birch/small/birch11.ish differ diff --git a/src/main/resources/objects/tree/birch/small/birch12.ish b/src/main/resources/objects/tree/birch/small/birch12.ish new file mode 100644 index 000000000..aa354e29f Binary files /dev/null and b/src/main/resources/objects/tree/birch/small/birch12.ish differ diff --git a/src/main/resources/objects/tree/birch/small/birch13.ish b/src/main/resources/objects/tree/birch/small/birch13.ish new file mode 100644 index 000000000..8b8b956ea Binary files /dev/null and b/src/main/resources/objects/tree/birch/small/birch13.ish differ diff --git a/src/main/resources/objects/tree/birch/small/birch14.ish b/src/main/resources/objects/tree/birch/small/birch14.ish new file mode 100644 index 000000000..ae54318e8 Binary files /dev/null and b/src/main/resources/objects/tree/birch/small/birch14.ish differ diff --git a/src/main/resources/objects/tree/birch/small/birch15.ish b/src/main/resources/objects/tree/birch/small/birch15.ish new file mode 100644 index 000000000..d20e5bc67 Binary files /dev/null and b/src/main/resources/objects/tree/birch/small/birch15.ish differ diff --git a/src/main/resources/objects/tree/birch/small/birch2.ish b/src/main/resources/objects/tree/birch/small/birch2.ish new file mode 100644 index 000000000..58625d1a9 Binary files /dev/null and b/src/main/resources/objects/tree/birch/small/birch2.ish differ diff --git a/src/main/resources/objects/tree/birch/small/birch3.ish b/src/main/resources/objects/tree/birch/small/birch3.ish new file mode 100644 index 000000000..920b548b5 Binary files /dev/null and b/src/main/resources/objects/tree/birch/small/birch3.ish differ diff --git a/src/main/resources/objects/tree/birch/small/birch4.ish b/src/main/resources/objects/tree/birch/small/birch4.ish new file mode 100644 index 000000000..a367b45ed Binary files /dev/null and b/src/main/resources/objects/tree/birch/small/birch4.ish differ diff --git a/src/main/resources/objects/tree/birch/small/birch5.ish b/src/main/resources/objects/tree/birch/small/birch5.ish new file mode 100644 index 000000000..38f4d6e3f Binary files /dev/null and b/src/main/resources/objects/tree/birch/small/birch5.ish differ diff --git a/src/main/resources/objects/tree/birch/small/birch6.ish b/src/main/resources/objects/tree/birch/small/birch6.ish new file mode 100644 index 000000000..f75ebbcc4 Binary files /dev/null and b/src/main/resources/objects/tree/birch/small/birch6.ish differ diff --git a/src/main/resources/objects/tree/birch/small/birch7.ish b/src/main/resources/objects/tree/birch/small/birch7.ish new file mode 100644 index 000000000..402c63909 Binary files /dev/null and b/src/main/resources/objects/tree/birch/small/birch7.ish differ diff --git a/src/main/resources/objects/tree/birch/small/birch8.ish b/src/main/resources/objects/tree/birch/small/birch8.ish new file mode 100644 index 000000000..7bc0ccc23 Binary files /dev/null and b/src/main/resources/objects/tree/birch/small/birch8.ish differ diff --git a/src/main/resources/objects/tree/birch/small/birch9.ish b/src/main/resources/objects/tree/birch/small/birch9.ish new file mode 100644 index 000000000..cf1a54734 Binary files /dev/null and b/src/main/resources/objects/tree/birch/small/birch9.ish differ diff --git a/src/main/resources/objects/tree/oak/small/oak1.ish b/src/main/resources/objects/tree/oak/small/oak1.ish new file mode 100644 index 000000000..cebafc048 Binary files /dev/null and b/src/main/resources/objects/tree/oak/small/oak1.ish differ diff --git a/src/main/resources/objects/tree/oak/small/oak10.ish b/src/main/resources/objects/tree/oak/small/oak10.ish new file mode 100644 index 000000000..0c35fb273 Binary files /dev/null and b/src/main/resources/objects/tree/oak/small/oak10.ish differ diff --git a/src/main/resources/objects/tree/oak/small/oak11.ish b/src/main/resources/objects/tree/oak/small/oak11.ish new file mode 100644 index 000000000..ca667c63d Binary files /dev/null and b/src/main/resources/objects/tree/oak/small/oak11.ish differ diff --git a/src/main/resources/objects/tree/oak/small/oak12.ish b/src/main/resources/objects/tree/oak/small/oak12.ish new file mode 100644 index 000000000..dc2e60d83 Binary files /dev/null and b/src/main/resources/objects/tree/oak/small/oak12.ish differ diff --git a/src/main/resources/objects/tree/oak/small/oak13.ish b/src/main/resources/objects/tree/oak/small/oak13.ish new file mode 100644 index 000000000..93b886ccb Binary files /dev/null and b/src/main/resources/objects/tree/oak/small/oak13.ish differ diff --git a/src/main/resources/objects/tree/oak/small/oak14.ish b/src/main/resources/objects/tree/oak/small/oak14.ish new file mode 100644 index 000000000..eb8ed7124 Binary files /dev/null and b/src/main/resources/objects/tree/oak/small/oak14.ish differ diff --git a/src/main/resources/objects/tree/oak/small/oak15.ish b/src/main/resources/objects/tree/oak/small/oak15.ish new file mode 100644 index 000000000..93b886ccb Binary files /dev/null and b/src/main/resources/objects/tree/oak/small/oak15.ish differ diff --git a/src/main/resources/objects/tree/oak/small/oak2.ish b/src/main/resources/objects/tree/oak/small/oak2.ish new file mode 100644 index 000000000..296b4f33c Binary files /dev/null and b/src/main/resources/objects/tree/oak/small/oak2.ish differ diff --git a/src/main/resources/objects/tree/oak/small/oak3.ish b/src/main/resources/objects/tree/oak/small/oak3.ish new file mode 100644 index 000000000..be13af323 Binary files /dev/null and b/src/main/resources/objects/tree/oak/small/oak3.ish differ diff --git a/src/main/resources/objects/tree/oak/small/oak4.ish b/src/main/resources/objects/tree/oak/small/oak4.ish new file mode 100644 index 000000000..e364ed875 Binary files /dev/null and b/src/main/resources/objects/tree/oak/small/oak4.ish differ diff --git a/src/main/resources/objects/tree/oak/small/oak5.ish b/src/main/resources/objects/tree/oak/small/oak5.ish new file mode 100644 index 000000000..ba19ab1e5 Binary files /dev/null and b/src/main/resources/objects/tree/oak/small/oak5.ish differ diff --git a/src/main/resources/objects/tree/oak/small/oak6.ish b/src/main/resources/objects/tree/oak/small/oak6.ish new file mode 100644 index 000000000..8dc79530e Binary files /dev/null and b/src/main/resources/objects/tree/oak/small/oak6.ish differ diff --git a/src/main/resources/objects/tree/oak/small/oak7.ish b/src/main/resources/objects/tree/oak/small/oak7.ish new file mode 100644 index 000000000..52666cb86 Binary files /dev/null and b/src/main/resources/objects/tree/oak/small/oak7.ish differ diff --git a/src/main/resources/objects/tree/oak/small/oak8.ish b/src/main/resources/objects/tree/oak/small/oak8.ish new file mode 100644 index 000000000..706e021d9 Binary files /dev/null and b/src/main/resources/objects/tree/oak/small/oak8.ish differ diff --git a/src/main/resources/objects/tree/oak/small/oak9.ish b/src/main/resources/objects/tree/oak/small/oak9.ish new file mode 100644 index 000000000..70182d017 Binary files /dev/null and b/src/main/resources/objects/tree/oak/small/oak9.ish differ diff --git a/src/main/resources/objects/tree/spruce/small/spruce1.ish b/src/main/resources/objects/tree/spruce/small/spruce1.ish new file mode 100644 index 000000000..f4bcf7ab6 Binary files /dev/null and b/src/main/resources/objects/tree/spruce/small/spruce1.ish differ diff --git a/src/main/resources/objects/tree/spruce/small/spruce10.ish b/src/main/resources/objects/tree/spruce/small/spruce10.ish new file mode 100644 index 000000000..14fe2ff83 Binary files /dev/null and b/src/main/resources/objects/tree/spruce/small/spruce10.ish differ diff --git a/src/main/resources/objects/tree/spruce/small/spruce11.ish b/src/main/resources/objects/tree/spruce/small/spruce11.ish new file mode 100644 index 000000000..ccfa712fb Binary files /dev/null and b/src/main/resources/objects/tree/spruce/small/spruce11.ish differ diff --git a/src/main/resources/objects/tree/spruce/small/spruce12.ish b/src/main/resources/objects/tree/spruce/small/spruce12.ish new file mode 100644 index 000000000..59b67b8aa Binary files /dev/null and b/src/main/resources/objects/tree/spruce/small/spruce12.ish differ diff --git a/src/main/resources/objects/tree/spruce/small/spruce13.ish b/src/main/resources/objects/tree/spruce/small/spruce13.ish new file mode 100644 index 000000000..a235f0394 Binary files /dev/null and b/src/main/resources/objects/tree/spruce/small/spruce13.ish differ diff --git a/src/main/resources/objects/tree/spruce/small/spruce2.ish b/src/main/resources/objects/tree/spruce/small/spruce2.ish new file mode 100644 index 000000000..2ac0969fb Binary files /dev/null and b/src/main/resources/objects/tree/spruce/small/spruce2.ish differ diff --git a/src/main/resources/objects/tree/spruce/small/spruce3.ish b/src/main/resources/objects/tree/spruce/small/spruce3.ish new file mode 100644 index 000000000..409fa7a87 Binary files /dev/null and b/src/main/resources/objects/tree/spruce/small/spruce3.ish differ diff --git a/src/main/resources/objects/tree/spruce/small/spruce4.ish b/src/main/resources/objects/tree/spruce/small/spruce4.ish new file mode 100644 index 000000000..7fa1e8ba8 Binary files /dev/null and b/src/main/resources/objects/tree/spruce/small/spruce4.ish differ diff --git a/src/main/resources/objects/tree/spruce/small/spruce5.ish b/src/main/resources/objects/tree/spruce/small/spruce5.ish new file mode 100644 index 000000000..6c757ca6a Binary files /dev/null and b/src/main/resources/objects/tree/spruce/small/spruce5.ish differ diff --git a/src/main/resources/objects/tree/spruce/small/spruce6.ish b/src/main/resources/objects/tree/spruce/small/spruce6.ish new file mode 100644 index 000000000..26937cea2 Binary files /dev/null and b/src/main/resources/objects/tree/spruce/small/spruce6.ish differ diff --git a/src/main/resources/objects/tree/spruce/small/spruce7.ish b/src/main/resources/objects/tree/spruce/small/spruce7.ish new file mode 100644 index 000000000..ef502ecee Binary files /dev/null and b/src/main/resources/objects/tree/spruce/small/spruce7.ish differ diff --git a/src/main/resources/objects/tree/spruce/small/spruce8.ish b/src/main/resources/objects/tree/spruce/small/spruce8.ish new file mode 100644 index 000000000..6dab9c6da Binary files /dev/null and b/src/main/resources/objects/tree/spruce/small/spruce8.ish differ diff --git a/src/main/resources/objects/tree/spruce/small/spruce9.ish b/src/main/resources/objects/tree/spruce/small/spruce9.ish new file mode 100644 index 000000000..c01f988e7 Binary files /dev/null and b/src/main/resources/objects/tree/spruce/small/spruce9.ish differ diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index 9c9773c6f..08edf6cb4 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -1,3 +1,6 @@ name: ${project.name} version: ${project.version} -main: ninja.bytecode.iris.Iris \ No newline at end of file +main: ninja.bytecode.iris.Iris +commands: + iris: + ish: \ No newline at end of file