mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2025-07-18 18:23:06 +00:00
Fixes
This commit is contained in:
parent
72d4c7eb40
commit
6c28e270d2
@ -31,6 +31,7 @@ import org.bukkit.util.Vector;
|
|||||||
import com.google.gson.Gson;
|
import com.google.gson.Gson;
|
||||||
|
|
||||||
import ninja.bytecode.iris.generator.IrisChunkGenerator;
|
import ninja.bytecode.iris.generator.IrisChunkGenerator;
|
||||||
|
import ninja.bytecode.iris.legacy.GenObject;
|
||||||
import ninja.bytecode.iris.object.IrisBiome;
|
import ninja.bytecode.iris.object.IrisBiome;
|
||||||
import ninja.bytecode.iris.object.IrisDimension;
|
import ninja.bytecode.iris.object.IrisDimension;
|
||||||
import ninja.bytecode.iris.object.IrisObject;
|
import ninja.bytecode.iris.object.IrisObject;
|
||||||
@ -52,6 +53,8 @@ import ninja.bytecode.iris.wand.WandController;
|
|||||||
import ninja.bytecode.shuriken.collections.KList;
|
import ninja.bytecode.shuriken.collections.KList;
|
||||||
import ninja.bytecode.shuriken.collections.KMap;
|
import ninja.bytecode.shuriken.collections.KMap;
|
||||||
import ninja.bytecode.shuriken.execution.J;
|
import ninja.bytecode.shuriken.execution.J;
|
||||||
|
import ninja.bytecode.shuriken.execution.TaskExecutor;
|
||||||
|
import ninja.bytecode.shuriken.execution.TaskExecutor.TaskGroup;
|
||||||
import ninja.bytecode.shuriken.format.Form;
|
import ninja.bytecode.shuriken.format.Form;
|
||||||
import ninja.bytecode.shuriken.json.JSONException;
|
import ninja.bytecode.shuriken.json.JSONException;
|
||||||
import ninja.bytecode.shuriken.json.JSONObject;
|
import ninja.bytecode.shuriken.json.JSONObject;
|
||||||
@ -216,6 +219,52 @@ public class Iris extends JavaPlugin implements BoardProvider
|
|||||||
|
|
||||||
if(args.length >= 1)
|
if(args.length >= 1)
|
||||||
{
|
{
|
||||||
|
if(args[0].equalsIgnoreCase("convert") && args.length == 1)
|
||||||
|
{
|
||||||
|
File folder = new File(getDataFolder(), "convert");
|
||||||
|
|
||||||
|
if(folder.exists() && folder.isDirectory())
|
||||||
|
{
|
||||||
|
KList<File> objects = new KList<>();
|
||||||
|
lookForObjects(folder, objects);
|
||||||
|
TaskExecutor tx = new TaskExecutor(32, Thread.MIN_PRIORITY, "Iris Converter");
|
||||||
|
TaskGroup g = tx.startWork();
|
||||||
|
info("Converting " + Form.f(objects.size()) + " Objects");
|
||||||
|
O<Integer> max = new O<Integer>().set(objects.size());
|
||||||
|
O<Integer> at = new O<Integer>().set(0);
|
||||||
|
for(File i : objects)
|
||||||
|
{
|
||||||
|
g.queue(() ->
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
IrisObject o = GenObject.loadAsModern(i);
|
||||||
|
File ff = new File(i.getParentFile(), o.getLoadKey() + ".iob");
|
||||||
|
|
||||||
|
o.write(new File(i.getParentFile(), o.getLoadKey() + ".iob"));
|
||||||
|
|
||||||
|
Iris.info("Converting [" + at.get() + " of " + max.get() + "]: " + i.getName() + " to " + ff.getName());
|
||||||
|
}
|
||||||
|
|
||||||
|
catch(Throwable e)
|
||||||
|
{
|
||||||
|
e.printStackTrace();
|
||||||
|
error("Failed to convert " + i.getName());
|
||||||
|
}
|
||||||
|
|
||||||
|
i.delete();
|
||||||
|
at.set(at.get() + 1);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
J.a(() ->
|
||||||
|
{
|
||||||
|
g.execute();
|
||||||
|
Iris.info("Done!");
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if(args[0].equalsIgnoreCase("goto") && args.length == 2)
|
if(args[0].equalsIgnoreCase("goto") && args.length == 2)
|
||||||
{
|
{
|
||||||
if(sender instanceof Player)
|
if(sender instanceof Player)
|
||||||
@ -667,6 +716,25 @@ public class Iris extends JavaPlugin implements BoardProvider
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void lookForObjects(File folder, KList<File> objects)
|
||||||
|
{
|
||||||
|
if(folder.isDirectory())
|
||||||
|
{
|
||||||
|
for(File i : folder.listFiles())
|
||||||
|
{
|
||||||
|
if(i.isDirectory())
|
||||||
|
{
|
||||||
|
lookForObjects(i, objects);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(i.getName().endsWith(".ish"))
|
||||||
|
{
|
||||||
|
objects.add(i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void imsg(CommandSender s, String msg)
|
public void imsg(CommandSender s, String msg)
|
||||||
{
|
{
|
||||||
s.sendMessage(ChatColor.GREEN + "[" + ChatColor.DARK_GRAY + "Iris" + ChatColor.GREEN + "]" + ChatColor.GRAY + ": " + msg);
|
s.sendMessage(ChatColor.GREEN + "[" + ChatColor.DARK_GRAY + "Iris" + ChatColor.GREEN + "]" + ChatColor.GRAY + ": " + msg);
|
||||||
|
547
src/main/java/ninja/bytecode/iris/legacy/GenObject.java
Normal file
547
src/main/java/ninja/bytecode/iris/legacy/GenObject.java
Normal file
@ -0,0 +1,547 @@
|
|||||||
|
package ninja.bytecode.iris.legacy;
|
||||||
|
|
||||||
|
import java.io.DataInputStream;
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.FileInputStream;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.util.function.Consumer;
|
||||||
|
import java.util.function.Supplier;
|
||||||
|
import java.util.zip.GZIPInputStream;
|
||||||
|
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.block.BlockFace;
|
||||||
|
import org.bukkit.block.data.BlockData;
|
||||||
|
import org.bukkit.material.Directional;
|
||||||
|
import org.bukkit.material.Ladder;
|
||||||
|
import org.bukkit.material.MaterialData;
|
||||||
|
import org.bukkit.material.Stairs;
|
||||||
|
import org.bukkit.material.Vine;
|
||||||
|
import org.bukkit.util.BlockVector;
|
||||||
|
import org.bukkit.util.Vector;
|
||||||
|
|
||||||
|
import ninja.bytecode.iris.Iris;
|
||||||
|
import ninja.bytecode.iris.object.IrisObject;
|
||||||
|
import ninja.bytecode.iris.util.Direction;
|
||||||
|
import ninja.bytecode.iris.util.VectorMath;
|
||||||
|
import ninja.bytecode.shuriken.collections.KList;
|
||||||
|
import ninja.bytecode.shuriken.collections.KMap;
|
||||||
|
import ninja.bytecode.shuriken.execution.J;
|
||||||
|
import ninja.bytecode.shuriken.logging.L;
|
||||||
|
|
||||||
|
public class GenObject
|
||||||
|
{
|
||||||
|
public static IDLibrary lib = new IDLibrary();
|
||||||
|
private boolean centeredHeight;
|
||||||
|
private int w;
|
||||||
|
private int h;
|
||||||
|
private int d;
|
||||||
|
private int failures;
|
||||||
|
private int successes;
|
||||||
|
private boolean gravity;
|
||||||
|
private String name = "?";
|
||||||
|
private KMap<SBlockVector, BlockData> s;
|
||||||
|
private KMap<SChunkVectorShort, SBlockVector> slopeCache;
|
||||||
|
private KMap<SChunkVectorShort, SBlockVector> gravityCache;
|
||||||
|
private BlockVector mount;
|
||||||
|
private int maxslope;
|
||||||
|
private int baseslope;
|
||||||
|
private boolean hydrophilic;
|
||||||
|
private boolean submerged;
|
||||||
|
private int mountHeight;
|
||||||
|
private BlockVector shift;
|
||||||
|
|
||||||
|
public GenObject(int w, int h, int d)
|
||||||
|
{
|
||||||
|
this.w = w;
|
||||||
|
this.h = h;
|
||||||
|
this.d = d;
|
||||||
|
shift = new BlockVector();
|
||||||
|
s = new KMap<>();
|
||||||
|
centeredHeight = false;
|
||||||
|
gravity = false;
|
||||||
|
maxslope = -1;
|
||||||
|
baseslope = 0;
|
||||||
|
hydrophilic = false;
|
||||||
|
submerged = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void recalculateMountShift()
|
||||||
|
{
|
||||||
|
int ly = Integer.MAX_VALUE;
|
||||||
|
|
||||||
|
for(SBlockVector i : s.keySet())
|
||||||
|
{
|
||||||
|
if(i.getY() < ly)
|
||||||
|
{
|
||||||
|
ly = (int) i.getY();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
KList<SBlockVector> fmount = new KList<>();
|
||||||
|
|
||||||
|
for(SBlockVector i : s.keySet())
|
||||||
|
{
|
||||||
|
if(i.getY() == ly)
|
||||||
|
{
|
||||||
|
fmount.add(i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
double avx[] = new double[fmount.size()];
|
||||||
|
double avy[] = new double[fmount.size()];
|
||||||
|
double avz[] = new double[fmount.size()];
|
||||||
|
int c = 0;
|
||||||
|
|
||||||
|
for(SBlockVector i : fmount)
|
||||||
|
{
|
||||||
|
avx[c] = i.getX();
|
||||||
|
avy[c] = i.getY();
|
||||||
|
avz[c] = i.getZ();
|
||||||
|
c++;
|
||||||
|
}
|
||||||
|
|
||||||
|
mountHeight = avg(avy);
|
||||||
|
mount = new BlockVector(0, 0, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
private KMap<SChunkVectorShort, SBlockVector> getSlopeCache()
|
||||||
|
{
|
||||||
|
if(slopeCache == null)
|
||||||
|
{
|
||||||
|
computeSlopeCache();
|
||||||
|
}
|
||||||
|
|
||||||
|
return slopeCache;
|
||||||
|
}
|
||||||
|
|
||||||
|
private KMap<SChunkVectorShort, SBlockVector> getGravityCache()
|
||||||
|
{
|
||||||
|
if(gravityCache == null)
|
||||||
|
{
|
||||||
|
computeGravityCache();
|
||||||
|
}
|
||||||
|
|
||||||
|
return gravityCache;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void computeGravityCache()
|
||||||
|
{
|
||||||
|
gravityCache = new KMap<>();
|
||||||
|
|
||||||
|
for(SBlockVector i : s.keySet())
|
||||||
|
{
|
||||||
|
SChunkVectorShort v = new SChunkVectorShort(i.getX(), i.getZ());
|
||||||
|
|
||||||
|
if(!gravityCache.containsKey(v) || gravityCache.get(v).getY() > i.getY())
|
||||||
|
{
|
||||||
|
gravityCache.put(v, i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void computeSlopeCache()
|
||||||
|
{
|
||||||
|
slopeCache = new KMap<>();
|
||||||
|
int low = Integer.MAX_VALUE;
|
||||||
|
|
||||||
|
for(SBlockVector i : s.keySet())
|
||||||
|
{
|
||||||
|
SChunkVectorShort v = new SChunkVectorShort(i.getX(), i.getZ());
|
||||||
|
|
||||||
|
if(!slopeCache.containsKey(v) || slopeCache.get(v).getY() > i.getY())
|
||||||
|
{
|
||||||
|
slopeCache.put(v, i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for(SChunkVectorShort i : slopeCache.keySet())
|
||||||
|
{
|
||||||
|
int f = (int) slopeCache.get(i).getY();
|
||||||
|
|
||||||
|
if(f < low)
|
||||||
|
{
|
||||||
|
low = f;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for(SChunkVectorShort i : slopeCache.k())
|
||||||
|
{
|
||||||
|
int f = (int) slopeCache.get(i).getY();
|
||||||
|
|
||||||
|
if(f > low - baseslope)
|
||||||
|
{
|
||||||
|
slopeCache.remove(i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private int avg(double[] v)
|
||||||
|
{
|
||||||
|
double g = 0;
|
||||||
|
|
||||||
|
for(int i = 0; i < v.length; i++)
|
||||||
|
{
|
||||||
|
g += v[i];
|
||||||
|
}
|
||||||
|
|
||||||
|
return (int) Math.round(g / (double) v.length);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCenteredHeight()
|
||||||
|
{
|
||||||
|
this.centeredHeight = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getW()
|
||||||
|
{
|
||||||
|
return w;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getH()
|
||||||
|
{
|
||||||
|
return h;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getD()
|
||||||
|
{
|
||||||
|
return d;
|
||||||
|
}
|
||||||
|
|
||||||
|
public KMap<SBlockVector, BlockData> getSchematic()
|
||||||
|
{
|
||||||
|
return s;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getWidth()
|
||||||
|
{
|
||||||
|
return w;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getDepth()
|
||||||
|
{
|
||||||
|
return d;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void read(InputStream in, boolean gzip) throws IOException
|
||||||
|
{
|
||||||
|
@SuppressWarnings("resource")
|
||||||
|
GZIPInputStream gzi = gzip ? new GZIPInputStream(in) : null;
|
||||||
|
DataInputStream din = new DataInputStream(gzip ? gzi : in);
|
||||||
|
readDirect(din);
|
||||||
|
din.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("deprecation")
|
||||||
|
public void readDirect(DataInputStream din) throws IOException
|
||||||
|
{
|
||||||
|
w = din.readInt();
|
||||||
|
h = din.readInt();
|
||||||
|
d = din.readInt();
|
||||||
|
int l = din.readInt();
|
||||||
|
clear();
|
||||||
|
|
||||||
|
for(int i = 0; i < l; i++)
|
||||||
|
{
|
||||||
|
SBlockVector v = new SBlockVector(din.readInt(), din.readInt(), din.readInt());
|
||||||
|
int id = din.readInt();
|
||||||
|
byte dat = (byte) din.readInt();
|
||||||
|
Material mat = IDLibrary.getMaterial(id);
|
||||||
|
BlockData data = Bukkit.getUnsafe().fromLegacy(Bukkit.getUnsafe().toLegacy(mat), dat);
|
||||||
|
|
||||||
|
if(data != null)
|
||||||
|
{
|
||||||
|
s.put(v, data);
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
{
|
||||||
|
throw new RuntimeException("Failed to convert");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public BlockData get(int x, int y, int z)
|
||||||
|
{
|
||||||
|
return s.get(new SBlockVector(x, y, z));
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean has(int x, int y, int z)
|
||||||
|
{
|
||||||
|
return s.containsKey(new SBlockVector(x, y, z));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void put(int x, int y, int z, BlockData mb)
|
||||||
|
{
|
||||||
|
s.put(new SBlockVector(x, y, z), mb);
|
||||||
|
}
|
||||||
|
|
||||||
|
public GenObject copy()
|
||||||
|
{
|
||||||
|
GenObject s = new GenObject(w, h, d);
|
||||||
|
s.fill(this.s);
|
||||||
|
s.centeredHeight = centeredHeight;
|
||||||
|
s.name = name;
|
||||||
|
return s;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void clear()
|
||||||
|
{
|
||||||
|
s.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void fill(KMap<SBlockVector, BlockData> b)
|
||||||
|
{
|
||||||
|
clear();
|
||||||
|
s.putAll(b);
|
||||||
|
}
|
||||||
|
|
||||||
|
public int sh(int g)
|
||||||
|
{
|
||||||
|
int m = (g / 2);
|
||||||
|
return g % 2 == 0 ? m : m + 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static GenObject load(InputStream in) throws IOException
|
||||||
|
{
|
||||||
|
GenObject s = new GenObject(1, 1, 1);
|
||||||
|
s.read(in, true);
|
||||||
|
|
||||||
|
return s;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static IrisObject loadAsModern(File f) throws IOException
|
||||||
|
{
|
||||||
|
GenObject legacy = new GenObject(1, 1, 1);
|
||||||
|
legacy.name = f.getName().replaceAll("\\Q.ish\\E", "");
|
||||||
|
FileInputStream fin = new FileInputStream(f);
|
||||||
|
legacy.read(fin, true);
|
||||||
|
|
||||||
|
IrisObject object = new IrisObject(legacy.w, legacy.h, legacy.d);
|
||||||
|
object.setLoadKey(legacy.name);
|
||||||
|
|
||||||
|
for(SBlockVector i : legacy.s.k())
|
||||||
|
{
|
||||||
|
object.getBlocks().put(new BlockVector(i.getX(), i.getY(), i.getZ()), legacy.s.get(i));
|
||||||
|
}
|
||||||
|
|
||||||
|
return object;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static GenObject load(File f) throws IOException
|
||||||
|
{
|
||||||
|
GenObject s = new GenObject(1, 1, 1);
|
||||||
|
s.name = f.getName().replaceAll("\\Q.ish\\E", "");
|
||||||
|
FileInputStream fin = new FileInputStream(f);
|
||||||
|
s.read(fin, true);
|
||||||
|
|
||||||
|
return s;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getName()
|
||||||
|
{
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setName(String name)
|
||||||
|
{
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
private byte toGlazedTCDir(BlockFace b)
|
||||||
|
{
|
||||||
|
switch(b)
|
||||||
|
{
|
||||||
|
case NORTH:
|
||||||
|
return 0;
|
||||||
|
case EAST:
|
||||||
|
return 1;
|
||||||
|
case SOUTH:
|
||||||
|
return 2;
|
||||||
|
case WEST:
|
||||||
|
return 3;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
private BlockFace getGlazedTCDir(byte d2)
|
||||||
|
{
|
||||||
|
switch(d2)
|
||||||
|
{
|
||||||
|
case 0:
|
||||||
|
return BlockFace.NORTH;
|
||||||
|
case 1:
|
||||||
|
return BlockFace.EAST;
|
||||||
|
case 2:
|
||||||
|
return BlockFace.SOUTH;
|
||||||
|
case 3:
|
||||||
|
return BlockFace.WEST;
|
||||||
|
}
|
||||||
|
|
||||||
|
return BlockFace.NORTH;
|
||||||
|
}
|
||||||
|
|
||||||
|
private BlockFace rotate(Direction from, Direction to, BlockFace face)
|
||||||
|
{
|
||||||
|
return Direction.getDirection(from.angle(Direction.getDirection(face).toVector(), to)).getFace();
|
||||||
|
}
|
||||||
|
|
||||||
|
public double getSuccess()
|
||||||
|
{
|
||||||
|
return (double) successes / ((double) successes + (double) failures);
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getFailures()
|
||||||
|
{
|
||||||
|
return failures;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getSuccesses()
|
||||||
|
{
|
||||||
|
return successes;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getPlaces()
|
||||||
|
{
|
||||||
|
return successes + failures;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void dispose()
|
||||||
|
{
|
||||||
|
s.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setGravity(boolean gravity)
|
||||||
|
{
|
||||||
|
this.gravity = gravity;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setShift(int x, int y, int z)
|
||||||
|
{
|
||||||
|
shift = new BlockVector(x, y, z);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isCenteredHeight()
|
||||||
|
{
|
||||||
|
return centeredHeight;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isGravity()
|
||||||
|
{
|
||||||
|
return gravity;
|
||||||
|
}
|
||||||
|
|
||||||
|
public BlockVector getMount()
|
||||||
|
{
|
||||||
|
return mount;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getMaxslope()
|
||||||
|
{
|
||||||
|
return maxslope;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getBaseslope()
|
||||||
|
{
|
||||||
|
return baseslope;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isHydrophilic()
|
||||||
|
{
|
||||||
|
return hydrophilic;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isSubmerged()
|
||||||
|
{
|
||||||
|
return submerged;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getMountHeight()
|
||||||
|
{
|
||||||
|
return mountHeight;
|
||||||
|
}
|
||||||
|
|
||||||
|
public BlockVector getShift()
|
||||||
|
{
|
||||||
|
return shift;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCenteredHeight(boolean centeredHeight)
|
||||||
|
{
|
||||||
|
this.centeredHeight = centeredHeight;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setW(int w)
|
||||||
|
{
|
||||||
|
this.w = w;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setH(int h)
|
||||||
|
{
|
||||||
|
this.h = h;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setD(int d)
|
||||||
|
{
|
||||||
|
this.d = d;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFailures(int failures)
|
||||||
|
{
|
||||||
|
this.failures = failures;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSuccesses(int successes)
|
||||||
|
{
|
||||||
|
this.successes = successes;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSlopeCache(KMap<SChunkVectorShort, SBlockVector> slopeCache)
|
||||||
|
{
|
||||||
|
this.slopeCache = slopeCache;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setGravityCache(KMap<SChunkVectorShort, SBlockVector> gravityCache)
|
||||||
|
{
|
||||||
|
this.gravityCache = gravityCache;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMount(BlockVector mount)
|
||||||
|
{
|
||||||
|
this.mount = mount;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMaxslope(int maxslope)
|
||||||
|
{
|
||||||
|
this.maxslope = maxslope;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setBaseslope(int baseslope)
|
||||||
|
{
|
||||||
|
this.baseslope = baseslope;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setHydrophilic(boolean hydrophilic)
|
||||||
|
{
|
||||||
|
this.hydrophilic = hydrophilic;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSubmerged(boolean submerged)
|
||||||
|
{
|
||||||
|
this.submerged = submerged;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMountHeight(int mountHeight)
|
||||||
|
{
|
||||||
|
this.mountHeight = mountHeight;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setShift(BlockVector shift)
|
||||||
|
{
|
||||||
|
this.shift = shift;
|
||||||
|
}
|
||||||
|
}
|
276
src/main/java/ninja/bytecode/iris/legacy/IDLibrary.java
Normal file
276
src/main/java/ninja/bytecode/iris/legacy/IDLibrary.java
Normal file
@ -0,0 +1,276 @@
|
|||||||
|
//
|
||||||
|
// Decompiled by Procyon v0.5.36
|
||||||
|
//
|
||||||
|
|
||||||
|
package ninja.bytecode.iris.legacy;
|
||||||
|
|
||||||
|
import java.util.EnumSet;
|
||||||
|
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
import org.bukkit.material.MaterialData;
|
||||||
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
|
||||||
|
public class IDLibrary
|
||||||
|
{
|
||||||
|
public static final String SEPARATOR = ":";
|
||||||
|
private static final String Spawn_Egg_Id = "383";
|
||||||
|
private static final int Spawn_Egg_Id_I = Integer.parseInt("383");
|
||||||
|
private static final IDList List = new IDList();
|
||||||
|
|
||||||
|
public static boolean isInt(final String ID)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
Integer.parseInt(ID);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
catch(Exception e)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static boolean isLegacy()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
Material.valueOf("CONDUIT");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
catch(Exception e)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Material getMaterial(String ID)
|
||||||
|
{
|
||||||
|
if(isLegacy())
|
||||||
|
{
|
||||||
|
final ItemStack IS = getItemStack(ID);
|
||||||
|
return (IS == null) ? null : IS.getType();
|
||||||
|
}
|
||||||
|
ID = ID.replace(" ", "").toUpperCase();
|
||||||
|
Material t = List.getMaterial(ID.contains(":") ? ID : (String.valueOf(ID) + ":" + "0"));
|
||||||
|
if(t != null)
|
||||||
|
{
|
||||||
|
return t;
|
||||||
|
}
|
||||||
|
try
|
||||||
|
{
|
||||||
|
t = Material.valueOf(ID);
|
||||||
|
if(List.getIDData(t) != null)
|
||||||
|
{
|
||||||
|
return t;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch(Exception ex)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
if(ID.startsWith("383"))
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
if(!ID.contains(":") && !isInt(ID))
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
t = Material.valueOf(ID);
|
||||||
|
if(t != null)
|
||||||
|
{
|
||||||
|
return t;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch(Exception ex2)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(ID.contains(":"))
|
||||||
|
{
|
||||||
|
final String[] IDs = ID.split(":");
|
||||||
|
try
|
||||||
|
{
|
||||||
|
return getMaterial(Integer.parseInt(IDs[0]), Byte.parseByte(IDs[1]));
|
||||||
|
}
|
||||||
|
catch(Exception e)
|
||||||
|
{
|
||||||
|
final Material m = Material.getMaterial("LEGACY_" + IDs[0], false);
|
||||||
|
try
|
||||||
|
{
|
||||||
|
return (m == null) ? m : getMaterial(m.getId(), Byte.parseByte(IDs[1]));
|
||||||
|
}
|
||||||
|
catch(Exception e2)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
try
|
||||||
|
{
|
||||||
|
return getMaterial(Integer.parseInt(ID));
|
||||||
|
}
|
||||||
|
catch(Exception e3)
|
||||||
|
{
|
||||||
|
final Material i = Material.getMaterial("LEGACY_" + ID, false);
|
||||||
|
return (i == null) ? i : getMaterial(i.getId(), (byte) 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Material getMaterial(final int ID)
|
||||||
|
{
|
||||||
|
return getMaterial(ID, (byte) 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Material getMaterial(final int ID, final byte Data)
|
||||||
|
{
|
||||||
|
for(final Material i : EnumSet.allOf(Material.class))
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if(i.getId() == ID)
|
||||||
|
{
|
||||||
|
final Material m = Bukkit.getUnsafe().fromLegacy(new MaterialData(i, Data));
|
||||||
|
return ((m == Material.AIR && (ID != 0 || Data != 0)) || (Data != 0 && m == Bukkit.getUnsafe().fromLegacy(new MaterialData(i, (byte) 0)))) ? List.getMaterial(String.valueOf(ID) + ":" + Data) : m;
|
||||||
|
}
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
catch(IllegalArgumentException ex)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ItemStack getItemStack(String ID)
|
||||||
|
{
|
||||||
|
if(isLegacy())
|
||||||
|
{
|
||||||
|
final ItemStack IS = null;
|
||||||
|
ID = ID.replace(" ", "").toUpperCase();
|
||||||
|
if(!ID.contains(":"))
|
||||||
|
{
|
||||||
|
ID = String.valueOf(ID) + ":" + "0";
|
||||||
|
}
|
||||||
|
final String[] I = ID.split(":");
|
||||||
|
int id = 0;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
id = Integer.parseInt(I[0]);
|
||||||
|
}
|
||||||
|
catch(NumberFormatException e)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
id = Material.valueOf(I[0]).getId();
|
||||||
|
}
|
||||||
|
catch(IllegalArgumentException e2)
|
||||||
|
{
|
||||||
|
return IS;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
try
|
||||||
|
{
|
||||||
|
for(final Material i : EnumSet.allOf(Material.class))
|
||||||
|
{
|
||||||
|
if(i.getId() == id)
|
||||||
|
{
|
||||||
|
return new ItemStack(i, 1, (short) Integer.parseInt(I[1]));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch(Exception ex)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
return IS;
|
||||||
|
}
|
||||||
|
final Material M = getMaterial(ID);
|
||||||
|
return (M == null) ? null : new ItemStack(getMaterial(ID), 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String getIDData(final Material M)
|
||||||
|
{
|
||||||
|
final byte d = getData(M);
|
||||||
|
return String.valueOf(getID(M)) + ((d == 0) ? "" : (":" + d));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static int getID(final Material M)
|
||||||
|
{
|
||||||
|
if(isLegacy())
|
||||||
|
{
|
||||||
|
M.getId();
|
||||||
|
}
|
||||||
|
final int d = List.getID(M);
|
||||||
|
if(d != -1)
|
||||||
|
{
|
||||||
|
return d;
|
||||||
|
}
|
||||||
|
final int i = Bukkit.getUnsafe().toLegacy(M).getId();
|
||||||
|
return (i != Spawn_Egg_Id_I && (i != 0 || (i == 0 && M == Material.AIR))) ? i : 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static byte getData(final Material M)
|
||||||
|
{
|
||||||
|
if(isLegacy())
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
final byte d = List.getData(M);
|
||||||
|
if(d != -1)
|
||||||
|
{
|
||||||
|
return d;
|
||||||
|
}
|
||||||
|
final int i = Bukkit.getUnsafe().toLegacy(M).getId();
|
||||||
|
return (byte) ((i != Spawn_Egg_Id_I && (i != 0 || (i == 0 && M == Material.AIR))) ? getData(M, i, Bukkit.getUnsafe().toLegacy(M)) : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static byte getData(final Material M, final int ID, final Material O)
|
||||||
|
{
|
||||||
|
for(final Material i : EnumSet.allOf(Material.class))
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if(i.getId() != ID)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
for(byte i2 = 0; i2 <= 15; ++i2)
|
||||||
|
{
|
||||||
|
if(M.equals((Object) Bukkit.getUnsafe().fromLegacy(new MaterialData(i, i2))))
|
||||||
|
{
|
||||||
|
return i2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch(IllegalArgumentException ex)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String getIDData(final ItemStack IS)
|
||||||
|
{
|
||||||
|
final byte d = getData(IS);
|
||||||
|
return String.valueOf(getID(IS)) + ((d == 0) ? "" : (":" + d));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static int getID(final ItemStack IS)
|
||||||
|
{
|
||||||
|
if(!isLegacy())
|
||||||
|
{
|
||||||
|
return getID(IS.getType());
|
||||||
|
}
|
||||||
|
return IS.getType().getId();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static byte getData(final ItemStack IS)
|
||||||
|
{
|
||||||
|
if(!isLegacy())
|
||||||
|
{
|
||||||
|
return getData(IS.getType());
|
||||||
|
}
|
||||||
|
return IS.getData().getData();
|
||||||
|
}
|
||||||
|
}
|
3003
src/main/java/ninja/bytecode/iris/legacy/IDList.java
Normal file
3003
src/main/java/ninja/bytecode/iris/legacy/IDList.java
Normal file
File diff suppressed because it is too large
Load Diff
103
src/main/java/ninja/bytecode/iris/legacy/MB.java
Normal file
103
src/main/java/ninja/bytecode/iris/legacy/MB.java
Normal file
@ -0,0 +1,103 @@
|
|||||||
|
package ninja.bytecode.iris.legacy;
|
||||||
|
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.Material;
|
||||||
|
|
||||||
|
public class MB
|
||||||
|
{
|
||||||
|
public final Material material;
|
||||||
|
public final byte data;
|
||||||
|
|
||||||
|
@SuppressWarnings("deprecation")
|
||||||
|
public static MB of(String dat)
|
||||||
|
{
|
||||||
|
String material = dat;
|
||||||
|
byte data = 0;
|
||||||
|
|
||||||
|
if(dat.contains(":"))
|
||||||
|
{
|
||||||
|
material = dat.split("\\Q:\\E")[0];
|
||||||
|
data = Integer.valueOf(dat.split("\\Q:\\E")[1]).byteValue();
|
||||||
|
}
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
return new MB(Material.getMaterial("LEGACY_" + Integer.valueOf(material)), data);
|
||||||
|
}
|
||||||
|
|
||||||
|
catch(Throwable e)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
return new MB(Material.getMaterial(material), data);
|
||||||
|
}
|
||||||
|
|
||||||
|
catch(Throwable e)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
return MB.of(Material.AIR);
|
||||||
|
}
|
||||||
|
|
||||||
|
public String toString()
|
||||||
|
{
|
||||||
|
if(data == 0)
|
||||||
|
{
|
||||||
|
return material.name();
|
||||||
|
}
|
||||||
|
|
||||||
|
return material.name() + ":" + data;
|
||||||
|
}
|
||||||
|
|
||||||
|
public MB(Material material, int data)
|
||||||
|
{
|
||||||
|
this.material = material;
|
||||||
|
this.data = (byte) data;
|
||||||
|
}
|
||||||
|
|
||||||
|
public MB(Material material)
|
||||||
|
{
|
||||||
|
this(material, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static MB of(Material f)
|
||||||
|
{
|
||||||
|
return new MB(f);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static MB of(Material f, int a)
|
||||||
|
{
|
||||||
|
return new MB(f, a);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode()
|
||||||
|
{
|
||||||
|
final int prime = 31;
|
||||||
|
int result = 1;
|
||||||
|
result = prime * result + data;
|
||||||
|
result = prime * result + ((material == null) ? 0 : material.hashCode());
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object obj)
|
||||||
|
{
|
||||||
|
if(this == obj)
|
||||||
|
return true;
|
||||||
|
if(obj == null)
|
||||||
|
return false;
|
||||||
|
if(getClass() != obj.getClass())
|
||||||
|
return false;
|
||||||
|
MB other = (MB) obj;
|
||||||
|
if(data != other.data)
|
||||||
|
return false;
|
||||||
|
if(material != other.material)
|
||||||
|
return false;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
169
src/main/java/ninja/bytecode/iris/legacy/SBlockVector.java
Normal file
169
src/main/java/ninja/bytecode/iris/legacy/SBlockVector.java
Normal file
@ -0,0 +1,169 @@
|
|||||||
|
package ninja.bytecode.iris.legacy;
|
||||||
|
|
||||||
|
import org.bukkit.configuration.serialization.SerializableAs;
|
||||||
|
import org.bukkit.util.BlockVector;
|
||||||
|
import org.bukkit.util.Vector;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A vector with a hash function that floors the X, Y, Z components, a la
|
||||||
|
* BlockVector in WorldEdit. BlockVectors can be used in hash sets and hash
|
||||||
|
* maps. Be aware that BlockVectors are mutable, but it is important that
|
||||||
|
* BlockVectors are never changed once put into a hash set or hash map.
|
||||||
|
*/
|
||||||
|
@SerializableAs("BlockVector")
|
||||||
|
public class SBlockVector
|
||||||
|
{
|
||||||
|
private short x;
|
||||||
|
private short y;
|
||||||
|
private short z;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Construct the vector with all components as 0.
|
||||||
|
*/
|
||||||
|
public SBlockVector()
|
||||||
|
{
|
||||||
|
this.x = 0;
|
||||||
|
this.y = 0;
|
||||||
|
this.z = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Construct the vector with another vector.
|
||||||
|
*
|
||||||
|
* @param vec
|
||||||
|
* The other vector.
|
||||||
|
*/
|
||||||
|
public SBlockVector(Vector vec)
|
||||||
|
{
|
||||||
|
this.x = (short) vec.getX();
|
||||||
|
this.y = (short) vec.getY();
|
||||||
|
this.z = (short) vec.getZ();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Construct the vector with provided integer components.
|
||||||
|
*
|
||||||
|
* @param x
|
||||||
|
* X component
|
||||||
|
* @param y
|
||||||
|
* Y component
|
||||||
|
* @param z
|
||||||
|
* Z component
|
||||||
|
*/
|
||||||
|
public SBlockVector(int x, int y, int z)
|
||||||
|
{
|
||||||
|
this.x = (short) x;
|
||||||
|
this.y = (short) y;
|
||||||
|
this.z = (short) z;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Construct the vector with provided double components.
|
||||||
|
*
|
||||||
|
* @param x
|
||||||
|
* X component
|
||||||
|
* @param y
|
||||||
|
* Y component
|
||||||
|
* @param z
|
||||||
|
* Z component
|
||||||
|
*/
|
||||||
|
public SBlockVector(double x, double y, double z)
|
||||||
|
{
|
||||||
|
this.x = (short) x;
|
||||||
|
this.y = (short) y;
|
||||||
|
this.z = (short) z;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Construct the vector with provided float components.
|
||||||
|
*
|
||||||
|
* @param x
|
||||||
|
* X component
|
||||||
|
* @param y
|
||||||
|
* Y component
|
||||||
|
* @param z
|
||||||
|
* Z component
|
||||||
|
*/
|
||||||
|
public SBlockVector(float x, float y, float z)
|
||||||
|
{
|
||||||
|
this.x = (short) x;
|
||||||
|
this.y = (short) y;
|
||||||
|
this.z = (short) z;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get a new block vector.
|
||||||
|
*
|
||||||
|
* @return vector
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public SBlockVector clone()
|
||||||
|
{
|
||||||
|
return new SBlockVector(x, y, z);
|
||||||
|
}
|
||||||
|
|
||||||
|
public double getX()
|
||||||
|
{
|
||||||
|
return x;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setX(double x)
|
||||||
|
{
|
||||||
|
this.x = (short) x;
|
||||||
|
}
|
||||||
|
|
||||||
|
public double getY()
|
||||||
|
{
|
||||||
|
return y;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setY(double y)
|
||||||
|
{
|
||||||
|
this.y = (short) y;
|
||||||
|
}
|
||||||
|
|
||||||
|
public double getZ()
|
||||||
|
{
|
||||||
|
return z;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setZ(double z)
|
||||||
|
{
|
||||||
|
this.z = (short) z;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode()
|
||||||
|
{
|
||||||
|
final int prime = 31;
|
||||||
|
int result = 1;
|
||||||
|
result = prime * result + x;
|
||||||
|
result = prime * result + y;
|
||||||
|
result = prime * result + z;
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object obj)
|
||||||
|
{
|
||||||
|
if(this == obj)
|
||||||
|
return true;
|
||||||
|
if(obj == null)
|
||||||
|
return false;
|
||||||
|
if(getClass() != obj.getClass())
|
||||||
|
return false;
|
||||||
|
SBlockVector other = (SBlockVector) obj;
|
||||||
|
if(x != other.x)
|
||||||
|
return false;
|
||||||
|
if(y != other.y)
|
||||||
|
return false;
|
||||||
|
if(z != other.z)
|
||||||
|
return false;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public BlockVector toBlockVector()
|
||||||
|
{
|
||||||
|
return new BlockVector(x, y, z);
|
||||||
|
}
|
||||||
|
}
|
76
src/main/java/ninja/bytecode/iris/legacy/SChunkVector.java
Normal file
76
src/main/java/ninja/bytecode/iris/legacy/SChunkVector.java
Normal file
@ -0,0 +1,76 @@
|
|||||||
|
package ninja.bytecode.iris.legacy;
|
||||||
|
|
||||||
|
public class SChunkVector
|
||||||
|
{
|
||||||
|
private byte x;
|
||||||
|
private byte z;
|
||||||
|
|
||||||
|
public SChunkVector(int x, int z)
|
||||||
|
{
|
||||||
|
this.x = (byte) (x);
|
||||||
|
this.z = (byte) (z);
|
||||||
|
}
|
||||||
|
|
||||||
|
public SChunkVector(byte x, byte z)
|
||||||
|
{
|
||||||
|
this.x = x;
|
||||||
|
this.z = z;
|
||||||
|
}
|
||||||
|
|
||||||
|
public SChunkVector(double x, double z)
|
||||||
|
{
|
||||||
|
this((int) Math.round(x), (int) Math.round(z));
|
||||||
|
}
|
||||||
|
|
||||||
|
public SChunkVector()
|
||||||
|
{
|
||||||
|
this((byte) 0, (byte) 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getX()
|
||||||
|
{
|
||||||
|
return x;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setX(int x)
|
||||||
|
{
|
||||||
|
this.x = (byte) x;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getZ()
|
||||||
|
{
|
||||||
|
return z;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setZ(int z)
|
||||||
|
{
|
||||||
|
this.z = (byte) z;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode()
|
||||||
|
{
|
||||||
|
final int prime = 31;
|
||||||
|
int result = 1;
|
||||||
|
result = prime * result + x;
|
||||||
|
result = prime * result + z;
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object obj)
|
||||||
|
{
|
||||||
|
if(this == obj)
|
||||||
|
return true;
|
||||||
|
if(obj == null)
|
||||||
|
return false;
|
||||||
|
if(getClass() != obj.getClass())
|
||||||
|
return false;
|
||||||
|
SChunkVector other = (SChunkVector) obj;
|
||||||
|
if(x != other.x)
|
||||||
|
return false;
|
||||||
|
if(z != other.z)
|
||||||
|
return false;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,72 @@
|
|||||||
|
package ninja.bytecode.iris.legacy;
|
||||||
|
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
|
public class SChunkVectorShort
|
||||||
|
{
|
||||||
|
private short x;
|
||||||
|
private short z;
|
||||||
|
|
||||||
|
public SChunkVectorShort(int x, int z)
|
||||||
|
{
|
||||||
|
this.x = (short) (x);
|
||||||
|
this.z = (short) (z);
|
||||||
|
}
|
||||||
|
|
||||||
|
public SChunkVectorShort(short x, short z)
|
||||||
|
{
|
||||||
|
this.x = x;
|
||||||
|
this.z = z;
|
||||||
|
}
|
||||||
|
|
||||||
|
public SChunkVectorShort(double x, double z)
|
||||||
|
{
|
||||||
|
this((int) Math.round(x), (int) Math.round(z));
|
||||||
|
}
|
||||||
|
|
||||||
|
public SChunkVectorShort()
|
||||||
|
{
|
||||||
|
this((short) 0, (short) 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getX()
|
||||||
|
{
|
||||||
|
return x;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setX(int x)
|
||||||
|
{
|
||||||
|
this.x = (short) x;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getZ()
|
||||||
|
{
|
||||||
|
return z;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setZ(int z)
|
||||||
|
{
|
||||||
|
this.z = (short) z;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode()
|
||||||
|
{
|
||||||
|
return Objects.hash(x, z);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object obj)
|
||||||
|
{
|
||||||
|
if(this == obj)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if(!(obj instanceof SChunkVectorShort))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
SChunkVectorShort other = (SChunkVectorShort) obj;
|
||||||
|
return x == other.x && z == other.z;
|
||||||
|
}
|
||||||
|
}
|
61
src/main/java/ninja/bytecode/iris/legacy/SMCAVector.java
Normal file
61
src/main/java/ninja/bytecode/iris/legacy/SMCAVector.java
Normal file
@ -0,0 +1,61 @@
|
|||||||
|
package ninja.bytecode.iris.legacy;
|
||||||
|
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
|
public class SMCAVector
|
||||||
|
{
|
||||||
|
private int x;
|
||||||
|
private int z;
|
||||||
|
|
||||||
|
public SMCAVector(int x, int z)
|
||||||
|
{
|
||||||
|
this.x = x;
|
||||||
|
this.z = z;
|
||||||
|
}
|
||||||
|
|
||||||
|
public SMCAVector()
|
||||||
|
{
|
||||||
|
this(0, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getX()
|
||||||
|
{
|
||||||
|
return x;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setX(int x)
|
||||||
|
{
|
||||||
|
this.x = x;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getZ()
|
||||||
|
{
|
||||||
|
return z;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setZ(int z)
|
||||||
|
{
|
||||||
|
this.z = z;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode()
|
||||||
|
{
|
||||||
|
return Objects.hash(x, z);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object obj)
|
||||||
|
{
|
||||||
|
if(this == obj)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if(!(obj instanceof SMCAVector))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
SMCAVector other = (SMCAVector) obj;
|
||||||
|
return x == other.x && z == other.z;
|
||||||
|
}
|
||||||
|
}
|
19
src/main/java/ninja/bytecode/iris/legacy/SuperUnsafe.java
Normal file
19
src/main/java/ninja/bytecode/iris/legacy/SuperUnsafe.java
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
package ninja.bytecode.iris.legacy;
|
||||||
|
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.block.data.BlockData;
|
||||||
|
|
||||||
|
@SuppressWarnings("deprecation")
|
||||||
|
public class SuperUnsafe
|
||||||
|
{
|
||||||
|
public static Material getMaterial(String material, byte d)
|
||||||
|
{
|
||||||
|
return Bukkit.getUnsafe().getMaterial(material, d);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static BlockData getBlockData(String material, byte d)
|
||||||
|
{
|
||||||
|
return Bukkit.getUnsafe().fromLegacy(Bukkit.getUnsafe().toLegacy(getMaterial(material, d)), d);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,6 @@
|
|||||||
|
package ninja.bytecode.iris.util;
|
||||||
|
|
||||||
|
public class ObjectConverter
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user