mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2026-05-19 08:00:18 +00:00
Commands and objects
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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 <name> - Save Schematic");
|
||||
msg(sender, "/ish load <name> [cursor] - Paste Schematic");
|
||||
msg(sender, "/ish expand <amount> - Expand Cuboid in direction");
|
||||
msg(sender, "/ish shift <amount> - 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;
|
||||
}
|
||||
}
|
||||
@@ -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<Chunk> 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);
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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");
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -422,6 +422,17 @@ public class Cuboid implements Iterable<Block>, 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.
|
||||
*
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -1,3 +1,6 @@
|
||||
name: ${project.name}
|
||||
version: ${project.version}
|
||||
main: ninja.bytecode.iris.Iris
|
||||
main: ninja.bytecode.iris.Iris
|
||||
commands:
|
||||
iris:
|
||||
ish:
|
||||
Reference in New Issue
Block a user