change compressed data tree ids and clean up
This commit is contained in:
parent
6c55d59f1f
commit
f76d3c8b89
33 changed files with 633 additions and 682 deletions
|
@ -28,8 +28,6 @@ import common.item.Item;
|
||||||
import common.item.ItemStack;
|
import common.item.ItemStack;
|
||||||
import common.model.ParticleType;
|
import common.model.ParticleType;
|
||||||
import common.rng.Random;
|
import common.rng.Random;
|
||||||
import common.tags.TagDoubleList;
|
|
||||||
import common.tags.TagFloatList;
|
|
||||||
import common.tags.TagObject;
|
import common.tags.TagObject;
|
||||||
import common.util.BlockPos;
|
import common.util.BlockPos;
|
||||||
import common.util.BoundingBox;
|
import common.util.BoundingBox;
|
||||||
|
@ -1496,10 +1494,15 @@ public abstract class Entity
|
||||||
// if(this.tag != null) {
|
// if(this.tag != null) {
|
||||||
// tagCompund.setString("ObjectTag", this.tag);
|
// tagCompund.setString("ObjectTag", this.tag);
|
||||||
// }
|
// }
|
||||||
|
|
||||||
tag.setDoubleList("Pos", this.newDoubleList(this.posX, this.posY, this.posZ));
|
tag.setDouble("PosX", this.posX);
|
||||||
tag.setDoubleList("Motion", this.newDoubleList(this.motionX, this.motionY, this.motionZ));
|
tag.setDouble("PosY", this.posY);
|
||||||
tag.setFloatList("Rotation", this.newFloatList(this.rotYaw, this.rotPitch));
|
tag.setDouble("PosZ", this.posZ);
|
||||||
|
tag.setDouble("MotionX", this.motionX);
|
||||||
|
tag.setDouble("MotionY", this.motionY);
|
||||||
|
tag.setDouble("MotionZ", this.motionZ);
|
||||||
|
tag.setFloat("Yaw", this.rotYaw);
|
||||||
|
tag.setFloat("Pitch", this.rotPitch);
|
||||||
tag.setFloat("FallDistance", this.fallDistance);
|
tag.setFloat("FallDistance", this.fallDistance);
|
||||||
tag.setShort("Fire", (short)this.fire);
|
tag.setShort("Fire", (short)this.fire);
|
||||||
// tagCompund.setShort("Air", (short)this.getAir());
|
// tagCompund.setShort("Air", (short)this.getAir());
|
||||||
|
@ -1543,12 +1546,9 @@ public abstract class Entity
|
||||||
// this.setPersistentId(tagCompund.getLong("PersistID"));
|
// this.setPersistentId(tagCompund.getLong("PersistID"));
|
||||||
// this.setTag(tagCompund.getString("ObjectTag"));
|
// this.setTag(tagCompund.getString("ObjectTag"));
|
||||||
|
|
||||||
TagDoubleList pos = tag.getDoubleList("Pos");
|
this.motionX = tag.getDouble("MotionX");
|
||||||
TagDoubleList motion = tag.getDoubleList("Motion");
|
this.motionY = tag.getDouble("MotionY");
|
||||||
TagFloatList rotation = tag.getFloatList("Rotation");
|
this.motionZ = tag.getDouble("MotionZ");
|
||||||
this.motionX = motion.get(0);
|
|
||||||
this.motionY = motion.get(1);
|
|
||||||
this.motionZ = motion.get(2);
|
|
||||||
|
|
||||||
if (Math.abs(this.motionX) > 10.0D)
|
if (Math.abs(this.motionX) > 10.0D)
|
||||||
{
|
{
|
||||||
|
@ -1565,11 +1565,11 @@ public abstract class Entity
|
||||||
this.motionZ = 0.0D;
|
this.motionZ = 0.0D;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.prevX = this.lastTickPosX = this.posX = pos.get(0);
|
this.prevX = this.lastTickPosX = this.posX = tag.getDouble("PosX");
|
||||||
this.prevY = this.lastTickPosY = this.posY = pos.get(1);
|
this.prevY = this.lastTickPosY = this.posY = tag.getDouble("PosY");
|
||||||
this.prevZ = this.lastTickPosZ = this.posZ = pos.get(2);
|
this.prevZ = this.lastTickPosZ = this.posZ = tag.getDouble("PosZ");
|
||||||
this.prevYaw = this.rotYaw = rotation.get(0);
|
this.prevYaw = this.rotYaw = tag.getFloat("Yaw");
|
||||||
this.prevPitch = this.rotPitch = rotation.get(1);
|
this.prevPitch = this.rotPitch = tag.getFloat("Pitch");
|
||||||
this.setRotationYawHead(this.rotYaw);
|
this.setRotationYawHead(this.rotYaw);
|
||||||
this.setRenderYawOffset(this.rotYaw);
|
this.setRenderYawOffset(this.rotYaw);
|
||||||
this.fallDistance = tag.getFloat("FallDistance");
|
this.fallDistance = tag.getFloat("FallDistance");
|
||||||
|
@ -1625,36 +1625,6 @@ public abstract class Entity
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* creates a list from the array of doubles passed to this function
|
|
||||||
*/
|
|
||||||
protected TagDoubleList newDoubleList(double... numbers)
|
|
||||||
{
|
|
||||||
TagDoubleList list = new TagDoubleList();
|
|
||||||
|
|
||||||
for (double d0 : numbers)
|
|
||||||
{
|
|
||||||
list.add(d0);
|
|
||||||
}
|
|
||||||
|
|
||||||
return list;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns a new list filled with the specified floats
|
|
||||||
*/
|
|
||||||
protected TagFloatList newFloatList(float... numbers)
|
|
||||||
{
|
|
||||||
TagFloatList list = new TagFloatList();
|
|
||||||
|
|
||||||
for (float f : numbers)
|
|
||||||
{
|
|
||||||
list.add(f);
|
|
||||||
}
|
|
||||||
|
|
||||||
return list;
|
|
||||||
}
|
|
||||||
|
|
||||||
public EntityItem dropItem(Item itemIn, int size)
|
public EntityItem dropItem(Item itemIn, int size)
|
||||||
{
|
{
|
||||||
return this.dropItemWithOffset(itemIn, size, 0.0F);
|
return this.dropItemWithOffset(itemIn, size, 0.0F);
|
||||||
|
|
|
@ -153,11 +153,7 @@ public class EntityWolf extends EntityTameable
|
||||||
{
|
{
|
||||||
super.readEntity(tagCompund);
|
super.readEntity(tagCompund);
|
||||||
this.setAngry(tagCompund.getBool("Angry"));
|
this.setAngry(tagCompund.getBool("Angry"));
|
||||||
|
this.setCollarColor(DyeColor.byDyeDamage(tagCompund.getByte("CollarColor")));
|
||||||
if (tagCompund.hasByte("CollarColor"))
|
|
||||||
{
|
|
||||||
this.setCollarColor(DyeColor.byDyeDamage(tagCompund.getByte("CollarColor")));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -483,7 +483,7 @@ public class EntityArrow extends Entity implements IProjectile, IObjectData
|
||||||
}
|
}
|
||||||
tagCompound.setByte("inData", (byte)this.inData);
|
tagCompound.setByte("inData", (byte)this.inData);
|
||||||
tagCompound.setByte("shake", (byte)this.arrowShake);
|
tagCompound.setByte("shake", (byte)this.arrowShake);
|
||||||
tagCompound.setByte("inGround", (byte)(this.inGround ? 1 : 0));
|
tagCompound.setBool("inGround", this.inGround);
|
||||||
tagCompound.setByte("pickup", (byte)this.canBePickedUp);
|
tagCompound.setByte("pickup", (byte)this.canBePickedUp);
|
||||||
tagCompound.setDouble("damage", this.damage);
|
tagCompound.setDouble("damage", this.damage);
|
||||||
}
|
}
|
||||||
|
@ -509,7 +509,7 @@ public class EntityArrow extends Entity implements IProjectile, IObjectData
|
||||||
|
|
||||||
this.inData = tagCompund.getByte("inData") & 255;
|
this.inData = tagCompund.getByte("inData") & 255;
|
||||||
this.arrowShake = tagCompund.getByte("shake") & 255;
|
this.arrowShake = tagCompund.getByte("shake") & 255;
|
||||||
this.inGround = tagCompund.getByte("inGround") == 1;
|
this.inGround = tagCompund.getBool("inGround");
|
||||||
|
|
||||||
this.damage = tagCompund.getDouble("damage");
|
this.damage = tagCompund.getDouble("damage");
|
||||||
|
|
||||||
|
|
|
@ -527,7 +527,7 @@ public class EntityHook extends Entity implements IObjectData
|
||||||
tagCompound.setString("inTile", id == null ? "" : id.toString());
|
tagCompound.setString("inTile", id == null ? "" : id.toString());
|
||||||
}
|
}
|
||||||
tagCompound.setByte("shake", (byte)this.shake);
|
tagCompound.setByte("shake", (byte)this.shake);
|
||||||
tagCompound.setByte("inGround", (byte)(this.inGround ? 1 : 0));
|
tagCompound.setBool("inGround", this.inGround);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -549,7 +549,7 @@ public class EntityHook extends Entity implements IObjectData
|
||||||
}
|
}
|
||||||
|
|
||||||
this.shake = tagCompund.getByte("shake") & 255;
|
this.shake = tagCompund.getByte("shake") & 255;
|
||||||
this.inGround = tagCompund.getByte("inGround") == 1;
|
this.inGround = tagCompund.getBool("inGround");
|
||||||
}
|
}
|
||||||
|
|
||||||
public int handleHookRetraction()
|
public int handleHookRetraction()
|
||||||
|
|
|
@ -9,7 +9,6 @@ import common.entity.EntityType;
|
||||||
import common.entity.types.EntityLiving;
|
import common.entity.types.EntityLiving;
|
||||||
import common.init.BlockRegistry;
|
import common.init.BlockRegistry;
|
||||||
import common.model.ParticleType;
|
import common.model.ParticleType;
|
||||||
import common.tags.TagDoubleList;
|
|
||||||
import common.tags.TagObject;
|
import common.tags.TagObject;
|
||||||
import common.util.BlockPos;
|
import common.util.BlockPos;
|
||||||
import common.util.BoundingBox;
|
import common.util.BoundingBox;
|
||||||
|
@ -259,10 +258,14 @@ public abstract class EntityProjectile extends Entity
|
||||||
tagCompound.setShort("xTile", (short)this.xTile);
|
tagCompound.setShort("xTile", (short)this.xTile);
|
||||||
tagCompound.setShort("yTile", (short)this.yTile);
|
tagCompound.setShort("yTile", (short)this.yTile);
|
||||||
tagCompound.setShort("zTile", (short)this.zTile);
|
tagCompound.setShort("zTile", (short)this.zTile);
|
||||||
String resourcelocation = BlockRegistry.REGISTRY.getNameForObject(this.inTile);
|
if(this.inTile != null) {
|
||||||
tagCompound.setString("inTile", resourcelocation == null ? "" : resourcelocation.toString());
|
String id = BlockRegistry.REGISTRY.getNameForObject(this.inTile);
|
||||||
tagCompound.setByte("inGround", (byte)(this.inGround ? 1 : 0));
|
tagCompound.setString("inTile", id == null ? "" : id.toString());
|
||||||
tagCompound.setDoubleList("direction", this.newDoubleList(this.motionX, this.motionY, this.motionZ));
|
}
|
||||||
|
tagCompound.setBool("inGround", this.inGround);
|
||||||
|
tagCompound.setDouble("dirX", this.motionX);
|
||||||
|
tagCompound.setDouble("dirY", this.motionY);
|
||||||
|
tagCompound.setDouble("dirZ", this.motionZ);
|
||||||
tagCompound.setInt("Age", this.age);
|
tagCompound.setInt("Age", this.age);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -281,17 +284,16 @@ public abstract class EntityProjectile extends Entity
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
this.inTile = BlockRegistry.getBlockById(tagCompund.getByte("inTile") & 255);
|
this.inTile = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.inGround = tagCompund.getByte("inGround") == 1;
|
this.inGround = tagCompund.getBool("inGround");
|
||||||
|
|
||||||
if (tagCompund.hasDoubleList("direction"))
|
if (tagCompund.hasDouble("dirX") && tagCompund.hasDouble("dirY") && tagCompund.hasDouble("dirZ"))
|
||||||
{
|
{
|
||||||
TagDoubleList nbttaglist = tagCompund.getDoubleList("direction");
|
this.motionX = tagCompund.getDouble("dirX");
|
||||||
this.motionX = nbttaglist.get(0);
|
this.motionY = tagCompund.getDouble("dirY");
|
||||||
this.motionY = nbttaglist.get(1);
|
this.motionZ = tagCompund.getDouble("dirZ");
|
||||||
this.motionZ = nbttaglist.get(2);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
@ -313,7 +313,7 @@ public abstract class EntityThrowable extends Entity implements IProjectile
|
||||||
tagCompound.setString("inTile", id == null ? "" : id.toString());
|
tagCompound.setString("inTile", id == null ? "" : id.toString());
|
||||||
}
|
}
|
||||||
tagCompound.setByte("shake", (byte)this.throwableShake);
|
tagCompound.setByte("shake", (byte)this.throwableShake);
|
||||||
tagCompound.setByte("inGround", (byte)(this.inGround ? 1 : 0));
|
tagCompound.setBool("inGround", this.inGround);
|
||||||
|
|
||||||
// if ((this.throwerName == null || this.throwerName.length() == 0) && this.thrower.isPlayer())
|
// if ((this.throwerName == null || this.throwerName.length() == 0) && this.thrower.isPlayer())
|
||||||
// {
|
// {
|
||||||
|
@ -342,7 +342,7 @@ public abstract class EntityThrowable extends Entity implements IProjectile
|
||||||
}
|
}
|
||||||
|
|
||||||
this.throwableShake = tagCompund.getByte("shake") & 255;
|
this.throwableShake = tagCompund.getByte("shake") & 255;
|
||||||
this.inGround = tagCompund.getByte("inGround") == 1;
|
this.inGround = tagCompund.getBool("inGround");
|
||||||
// this.thrower = null;
|
// this.thrower = null;
|
||||||
// this.throwerName = tagCompund.getString("ownerName");
|
// this.throwerName = tagCompund.getString("ownerName");
|
||||||
//
|
//
|
||||||
|
|
|
@ -5,56 +5,17 @@ import java.io.DataOutput;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
public abstract class Tag {
|
public abstract class Tag {
|
||||||
protected static Tag createNewByType(byte id) {
|
|
||||||
switch(id) {
|
|
||||||
case 0:
|
|
||||||
return new TagNull();
|
|
||||||
case 1:
|
|
||||||
return new TagByte();
|
|
||||||
case 2:
|
|
||||||
return new TagShort();
|
|
||||||
case 3:
|
|
||||||
return new TagInt();
|
|
||||||
case 4:
|
|
||||||
return new TagLong();
|
|
||||||
case 5:
|
|
||||||
return new TagFloat();
|
|
||||||
case 6:
|
|
||||||
return new TagDouble();
|
|
||||||
case 7:
|
|
||||||
return new TagByteArray();
|
|
||||||
case 8:
|
|
||||||
return new TagString();
|
|
||||||
case 9:
|
|
||||||
return new TagStringList();
|
|
||||||
case 10:
|
|
||||||
return new TagObject();
|
|
||||||
case 11:
|
|
||||||
return new TagIntArray();
|
|
||||||
case 12:
|
|
||||||
return new TagObjectList();
|
|
||||||
case 13:
|
|
||||||
return new TagFloatList();
|
|
||||||
case 14:
|
|
||||||
return new TagDoubleList();
|
|
||||||
case 15:
|
|
||||||
return new TagIntArrayList();
|
|
||||||
default:
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
abstract void write(DataOutput output) throws IOException;
|
abstract void write(DataOutput output) throws IOException;
|
||||||
abstract void read(DataInput input, int depth, SizeTracker tracker) throws IOException;
|
abstract void read(DataInput input, int depth, SizeTracker tracker) throws IOException;
|
||||||
public abstract String toString();
|
public abstract String toString();
|
||||||
protected abstract byte getId();
|
protected abstract TagType getType();
|
||||||
public abstract Tag copy();
|
public abstract Tag copy();
|
||||||
|
|
||||||
public boolean equals(Object other) {
|
public boolean equals(Object other) {
|
||||||
return other instanceof Tag && this.getId() == ((Tag)other).getId();
|
return other instanceof Tag && this.getType() == ((Tag)other).getType();
|
||||||
}
|
}
|
||||||
|
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
return this.getId();
|
return this.getType().getId();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
49
common/src/main/java/common/tags/TagBool.java
Normal file
49
common/src/main/java/common/tags/TagBool.java
Normal file
|
@ -0,0 +1,49 @@
|
||||||
|
package common.tags;
|
||||||
|
|
||||||
|
import java.io.DataInput;
|
||||||
|
import java.io.DataOutput;
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
class TagBool extends Tag {
|
||||||
|
private boolean data;
|
||||||
|
|
||||||
|
TagBool() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public TagBool(boolean data) {
|
||||||
|
this.data = data;
|
||||||
|
}
|
||||||
|
|
||||||
|
void write(DataOutput output) throws IOException {
|
||||||
|
output.writeBoolean(this.data);
|
||||||
|
}
|
||||||
|
|
||||||
|
void read(DataInput input, int depth, SizeTracker tracker) throws IOException {
|
||||||
|
tracker.read(9);
|
||||||
|
this.data = input.readBoolean();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected TagType getType() {
|
||||||
|
return TagType.BOOLEAN;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String toString() {
|
||||||
|
return "" + this.data;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Tag copy() {
|
||||||
|
return new TagBool(this.data);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean equals(Object other) {
|
||||||
|
return super.equals(other) && this.data == ((TagBool)other).data;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int hashCode() {
|
||||||
|
return super.hashCode() ^ (this.data ? 1 : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean getBool() {
|
||||||
|
return this.data;
|
||||||
|
}
|
||||||
|
}
|
|
@ -4,65 +4,46 @@ import java.io.DataInput;
|
||||||
import java.io.DataOutput;
|
import java.io.DataOutput;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
class TagByte extends Tag
|
class TagByte extends Tag {
|
||||||
{
|
private byte data;
|
||||||
private byte data;
|
|
||||||
|
|
||||||
TagByte()
|
TagByte() {
|
||||||
{
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public TagByte(byte data)
|
public TagByte(byte data) {
|
||||||
{
|
this.data = data;
|
||||||
this.data = data;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
void write(DataOutput output) throws IOException
|
void write(DataOutput output) throws IOException {
|
||||||
{
|
output.writeByte(this.data);
|
||||||
output.writeByte(this.data);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
void read(DataInput input, int depth, SizeTracker sizeTracker) throws IOException
|
void read(DataInput input, int depth, SizeTracker tracker) throws IOException {
|
||||||
{
|
tracker.read(9);
|
||||||
sizeTracker.read(9);
|
this.data = input.readByte();
|
||||||
this.data = input.readByte();
|
}
|
||||||
}
|
|
||||||
|
|
||||||
protected byte getId()
|
protected TagType getType() {
|
||||||
{
|
return TagType.BYTE;
|
||||||
return (byte)1;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public String toString()
|
public String toString() {
|
||||||
{
|
return "" + this.data + "b";
|
||||||
return "" + this.data + "b";
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public Tag copy()
|
public Tag copy() {
|
||||||
{
|
return new TagByte(this.data);
|
||||||
return new TagByte(this.data);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public boolean equals(Object other)
|
public boolean equals(Object other) {
|
||||||
{
|
return super.equals(other) && this.data == ((TagByte)other).data;
|
||||||
if (super.equals(other))
|
}
|
||||||
{
|
|
||||||
TagByte tag = (TagByte)other;
|
|
||||||
return this.data == tag.data;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public int hashCode()
|
public int hashCode() {
|
||||||
{
|
return super.hashCode() ^ this.data;
|
||||||
return super.hashCode() ^ this.data;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public byte getByte()
|
public byte getByte() {
|
||||||
{
|
return this.data;
|
||||||
return this.data;
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,8 +28,8 @@ class TagByteArray extends Tag {
|
||||||
input.readFully(this.data);
|
input.readFully(this.data);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected byte getId() {
|
protected TagType getType() {
|
||||||
return (byte)7;
|
return TagType.BYTE_ARRAY;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String toString() {
|
public String toString() {
|
||||||
|
|
49
common/src/main/java/common/tags/TagChar.java
Normal file
49
common/src/main/java/common/tags/TagChar.java
Normal file
|
@ -0,0 +1,49 @@
|
||||||
|
package common.tags;
|
||||||
|
|
||||||
|
import java.io.DataInput;
|
||||||
|
import java.io.DataOutput;
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
class TagChar extends Tag {
|
||||||
|
private char data;
|
||||||
|
|
||||||
|
TagChar() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public TagChar(char data) {
|
||||||
|
this.data = data;
|
||||||
|
}
|
||||||
|
|
||||||
|
void write(DataOutput output) throws IOException {
|
||||||
|
output.writeChar(this.data);
|
||||||
|
}
|
||||||
|
|
||||||
|
void read(DataInput input, int depth, SizeTracker tracker) throws IOException {
|
||||||
|
tracker.read(10);
|
||||||
|
this.data = input.readChar();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected TagType getType() {
|
||||||
|
return TagType.CHAR;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String toString() {
|
||||||
|
return String.format(Character.isLetterOrDigit(this.data) ? "'%c'" : (this.data >= 256 ? "'\\u%04x'" : "'\\x%02x'"), this.data);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Tag copy() {
|
||||||
|
return new TagChar(this.data);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean equals(Object other) {
|
||||||
|
return super.equals(other) && this.data == ((TagChar)other).data;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int hashCode() {
|
||||||
|
return super.hashCode() ^ this.data;
|
||||||
|
}
|
||||||
|
|
||||||
|
public char getChar() {
|
||||||
|
return this.data;
|
||||||
|
}
|
||||||
|
}
|
|
@ -4,66 +4,47 @@ import java.io.DataInput;
|
||||||
import java.io.DataOutput;
|
import java.io.DataOutput;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
class TagDouble extends Tag
|
class TagDouble extends Tag {
|
||||||
{
|
private double data;
|
||||||
private double data;
|
|
||||||
|
|
||||||
TagDouble()
|
TagDouble() {
|
||||||
{
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public TagDouble(double data)
|
public TagDouble(double data) {
|
||||||
{
|
this.data = data;
|
||||||
this.data = data;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
void write(DataOutput output) throws IOException
|
void write(DataOutput output) throws IOException {
|
||||||
{
|
output.writeDouble(this.data);
|
||||||
output.writeDouble(this.data);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
void read(DataInput input, int depth, SizeTracker sizeTracker) throws IOException
|
void read(DataInput input, int depth, SizeTracker tracker) throws IOException {
|
||||||
{
|
tracker.read(16);
|
||||||
sizeTracker.read(16);
|
this.data = input.readDouble();
|
||||||
this.data = input.readDouble();
|
}
|
||||||
}
|
|
||||||
|
|
||||||
protected byte getId()
|
protected TagType getType() {
|
||||||
{
|
return TagType.DOUBLE;
|
||||||
return (byte)6;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public String toString()
|
public String toString() {
|
||||||
{
|
return "" + this.data + "d";
|
||||||
return "" + this.data + "d";
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public Tag copy()
|
public Tag copy() {
|
||||||
{
|
return new TagDouble(this.data);
|
||||||
return new TagDouble(this.data);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public boolean equals(Object other)
|
public boolean equals(Object other) {
|
||||||
{
|
return super.equals(other) && this.data == ((TagDouble)other).data;
|
||||||
if (super.equals(other))
|
}
|
||||||
{
|
|
||||||
TagDouble tag = (TagDouble)other;
|
|
||||||
return this.data == tag.data;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public int hashCode()
|
public int hashCode() {
|
||||||
{
|
long l = Double.doubleToLongBits(this.data);
|
||||||
long i = Double.doubleToLongBits(this.data);
|
return super.hashCode() ^ (int)(l ^ l >>> 32);
|
||||||
return super.hashCode() ^ (int)(i ^ i >>> 32);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public double getDouble()
|
public double getDouble() {
|
||||||
{
|
return this.data;
|
||||||
return this.data;
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,27 +0,0 @@
|
||||||
package common.tags;
|
|
||||||
|
|
||||||
public class TagDoubleList extends TagList<TagDouble> {
|
|
||||||
protected byte getId() {
|
|
||||||
return 14;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected byte getType() {
|
|
||||||
return 6;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected TagList<TagDouble> createInstance() {
|
|
||||||
return new TagDoubleList();
|
|
||||||
}
|
|
||||||
|
|
||||||
protected TagDouble getDefault() {
|
|
||||||
return new TagDouble(0.0);
|
|
||||||
}
|
|
||||||
|
|
||||||
public double get(int index) {
|
|
||||||
return this.getElem(index).getDouble();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void add(double value) {
|
|
||||||
this.addElem(new TagDouble(value));
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -4,65 +4,46 @@ import java.io.DataInput;
|
||||||
import java.io.DataOutput;
|
import java.io.DataOutput;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
class TagFloat extends Tag
|
class TagFloat extends Tag {
|
||||||
{
|
private float data;
|
||||||
private float data;
|
|
||||||
|
|
||||||
TagFloat()
|
TagFloat() {
|
||||||
{
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public TagFloat(float data)
|
public TagFloat(float data) {
|
||||||
{
|
this.data = data;
|
||||||
this.data = data;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
void write(DataOutput output) throws IOException
|
void write(DataOutput output) throws IOException {
|
||||||
{
|
output.writeFloat(this.data);
|
||||||
output.writeFloat(this.data);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
void read(DataInput input, int depth, SizeTracker sizeTracker) throws IOException
|
void read(DataInput input, int depth, SizeTracker tracker) throws IOException {
|
||||||
{
|
tracker.read(12);
|
||||||
sizeTracker.read(12);
|
this.data = input.readFloat();
|
||||||
this.data = input.readFloat();
|
}
|
||||||
}
|
|
||||||
|
|
||||||
protected byte getId()
|
protected TagType getType() {
|
||||||
{
|
return TagType.FLOAT;
|
||||||
return (byte)5;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public String toString()
|
public String toString() {
|
||||||
{
|
return "" + this.data + "f";
|
||||||
return "" + this.data + "f";
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public Tag copy()
|
public Tag copy() {
|
||||||
{
|
return new TagFloat(this.data);
|
||||||
return new TagFloat(this.data);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public boolean equals(Object other)
|
public boolean equals(Object other) {
|
||||||
{
|
return super.equals(other) && this.data == ((TagFloat)other).data;
|
||||||
if (super.equals(other))
|
}
|
||||||
{
|
|
||||||
TagFloat tag = (TagFloat)other;
|
|
||||||
return this.data == tag.data;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public int hashCode()
|
public int hashCode() {
|
||||||
{
|
return super.hashCode() ^ Float.floatToIntBits(this.data);
|
||||||
return super.hashCode() ^ Float.floatToIntBits(this.data);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public float getFloat()
|
public float getFloat() {
|
||||||
{
|
return this.data;
|
||||||
return this.data;
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,27 +0,0 @@
|
||||||
package common.tags;
|
|
||||||
|
|
||||||
public class TagFloatList extends TagList<TagFloat> {
|
|
||||||
protected byte getId() {
|
|
||||||
return 13;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected byte getType() {
|
|
||||||
return 5;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected TagList<TagFloat> createInstance() {
|
|
||||||
return new TagFloatList();
|
|
||||||
}
|
|
||||||
|
|
||||||
protected TagFloat getDefault() {
|
|
||||||
return new TagFloat(0.0f);
|
|
||||||
}
|
|
||||||
|
|
||||||
public float get(int index) {
|
|
||||||
return this.getElem(index).getFloat();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void add(float value) {
|
|
||||||
this.addElem(new TagFloat(value));
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -4,65 +4,46 @@ import java.io.DataInput;
|
||||||
import java.io.DataOutput;
|
import java.io.DataOutput;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
class TagInt extends Tag
|
class TagInt extends Tag {
|
||||||
{
|
private int data;
|
||||||
private int data;
|
|
||||||
|
|
||||||
TagInt()
|
TagInt() {
|
||||||
{
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public TagInt(int data)
|
public TagInt(int data) {
|
||||||
{
|
this.data = data;
|
||||||
this.data = data;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
void write(DataOutput output) throws IOException
|
void write(DataOutput output) throws IOException {
|
||||||
{
|
output.writeInt(this.data);
|
||||||
output.writeInt(this.data);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
void read(DataInput input, int depth, SizeTracker sizeTracker) throws IOException
|
void read(DataInput input, int depth, SizeTracker tracker) throws IOException {
|
||||||
{
|
tracker.read(12);
|
||||||
sizeTracker.read(12);
|
this.data = input.readInt();
|
||||||
this.data = input.readInt();
|
}
|
||||||
}
|
|
||||||
|
|
||||||
protected byte getId()
|
protected TagType getType() {
|
||||||
{
|
return TagType.INT;
|
||||||
return (byte)3;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public String toString()
|
public String toString() {
|
||||||
{
|
return "" + this.data;
|
||||||
return "" + this.data;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public Tag copy()
|
public Tag copy() {
|
||||||
{
|
return new TagInt(this.data);
|
||||||
return new TagInt(this.data);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public boolean equals(Object other)
|
public boolean equals(Object other) {
|
||||||
{
|
return super.equals(other) && this.data == ((TagInt)other).data;
|
||||||
if (super.equals(other))
|
}
|
||||||
{
|
|
||||||
TagInt tag = (TagInt)other;
|
|
||||||
return this.data == tag.data;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public int hashCode()
|
public int hashCode() {
|
||||||
{
|
return super.hashCode() ^ this.data;
|
||||||
return super.hashCode() ^ this.data;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public int getInt()
|
public int getInt() {
|
||||||
{
|
return this.data;
|
||||||
return this.data;
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,8 +32,8 @@ class TagIntArray extends Tag {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected byte getId() {
|
protected TagType getType() {
|
||||||
return (byte)11;
|
return TagType.INT_ARRAY;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String toString() {
|
public String toString() {
|
||||||
|
|
|
@ -1,27 +0,0 @@
|
||||||
package common.tags;
|
|
||||||
|
|
||||||
public class TagIntArrayList extends TagList<TagIntArray> {
|
|
||||||
protected byte getId() {
|
|
||||||
return 15;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected byte getType() {
|
|
||||||
return 11;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected TagList<TagIntArray> createInstance() {
|
|
||||||
return new TagIntArrayList();
|
|
||||||
}
|
|
||||||
|
|
||||||
protected TagIntArray getDefault() {
|
|
||||||
return new TagIntArray(new int[0]);
|
|
||||||
}
|
|
||||||
|
|
||||||
public int[] get(int index) {
|
|
||||||
return this.getElem(index).getIntArray();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void add(int[] value) {
|
|
||||||
this.addElem(new TagIntArray(value));
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -420,17 +420,11 @@ public class TagInterpreter
|
||||||
{
|
{
|
||||||
Tag tag = any.parse();
|
Tag tag = any.parse();
|
||||||
if(list == null) {
|
if(list == null) {
|
||||||
switch(tag.getId()) {
|
switch(tag.getType()) {
|
||||||
case 8:
|
case STRING_LIST:
|
||||||
list = new TagStringList();
|
list = new TagStringList();
|
||||||
case 10:
|
case OBJECT_LIST:
|
||||||
list = new TagObjectList();
|
list = new TagObjectList();
|
||||||
case 5:
|
|
||||||
list = new TagFloatList();
|
|
||||||
case 6:
|
|
||||||
list = new TagDoubleList();
|
|
||||||
case 11:
|
|
||||||
list = new TagIntArrayList();
|
|
||||||
default:
|
default:
|
||||||
throw new TagException("Type cannot be put in a list: " + any.json);
|
throw new TagException("Type cannot be put in a list: " + any.json);
|
||||||
}
|
}
|
||||||
|
@ -501,7 +495,7 @@ public class TagInterpreter
|
||||||
|
|
||||||
if (this.jsonValue.equalsIgnoreCase("true") || this.jsonValue.equalsIgnoreCase("false"))
|
if (this.jsonValue.equalsIgnoreCase("true") || this.jsonValue.equalsIgnoreCase("false"))
|
||||||
{
|
{
|
||||||
return new TagByte((byte)(Boolean.parseBoolean(this.jsonValue) ? 1 : 0));
|
return new TagBool(Boolean.parseBoolean(this.jsonValue));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (NumberFormatException var6)
|
catch (NumberFormatException var6)
|
||||||
|
@ -533,6 +527,29 @@ public class TagInterpreter
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
if (this.jsonValue.startsWith("'") && this.jsonValue.endsWith("'"))
|
||||||
|
{
|
||||||
|
String s = this.jsonValue.substring(1, this.jsonValue.length() - 1);
|
||||||
|
if(s.length() == 1 && s.charAt(0) != '\\') {
|
||||||
|
return new TagChar(s.charAt(0));
|
||||||
|
}
|
||||||
|
else if(s.length() == 2 && s.charAt(0) == '\\') {
|
||||||
|
switch(s.charAt(1)) {
|
||||||
|
case '\\':
|
||||||
|
return new TagChar('\\');
|
||||||
|
case 'n':
|
||||||
|
return new TagChar('\n');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if((s.length() == 4 && s.startsWith("\\x")) || (s.length() == 6 && s.startsWith("\\u"))) {
|
||||||
|
try {
|
||||||
|
return new TagChar((char)Integer.parseUnsignedInt(s.substring(2), 16));
|
||||||
|
}
|
||||||
|
catch(NumberFormatException e) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (this.jsonValue.startsWith("\"") && this.jsonValue.endsWith("\""))
|
if (this.jsonValue.startsWith("\"") && this.jsonValue.endsWith("\""))
|
||||||
{
|
{
|
||||||
this.jsonValue = this.jsonValue.substring(1, this.jsonValue.length() - 1);
|
this.jsonValue = this.jsonValue.substring(1, this.jsonValue.length() - 1);
|
||||||
|
|
|
@ -27,14 +27,14 @@ abstract class TagList<K extends Tag> extends Tag {
|
||||||
tracker.read(4 * len);
|
tracker.read(4 * len);
|
||||||
this.list = new ArrayList<K>(len);
|
this.list = new ArrayList<K>(len);
|
||||||
for(int z = 0; z < len; z++) {
|
for(int z = 0; z < len; z++) {
|
||||||
K tag = (K)Tag.createNewByType(this.getType());
|
K tag = (K)this.getElemType().createTag();
|
||||||
tag.read(input, depth + 1, tracker);
|
tag.read(input, depth + 1, tracker);
|
||||||
this.list.add(tag);
|
this.list.add(tag);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected abstract byte getId();
|
protected abstract TagType getType();
|
||||||
protected abstract byte getType();
|
protected abstract TagType getElemType();
|
||||||
protected abstract TagList<K> createInstance();
|
protected abstract TagList<K> createInstance();
|
||||||
protected abstract K getDefault();
|
protected abstract K getDefault();
|
||||||
|
|
||||||
|
|
|
@ -4,65 +4,46 @@ import java.io.DataInput;
|
||||||
import java.io.DataOutput;
|
import java.io.DataOutput;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
class TagLong extends Tag
|
class TagLong extends Tag {
|
||||||
{
|
private long data;
|
||||||
private long data;
|
|
||||||
|
|
||||||
TagLong()
|
TagLong() {
|
||||||
{
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public TagLong(long data)
|
public TagLong(long data) {
|
||||||
{
|
this.data = data;
|
||||||
this.data = data;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
void write(DataOutput output) throws IOException
|
void write(DataOutput output) throws IOException {
|
||||||
{
|
output.writeLong(this.data);
|
||||||
output.writeLong(this.data);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
void read(DataInput input, int depth, SizeTracker sizeTracker) throws IOException
|
void read(DataInput input, int depth, SizeTracker tracker) throws IOException {
|
||||||
{
|
tracker.read(16);
|
||||||
sizeTracker.read(16);
|
this.data = input.readLong();
|
||||||
this.data = input.readLong();
|
}
|
||||||
}
|
|
||||||
|
|
||||||
protected byte getId()
|
protected TagType getType() {
|
||||||
{
|
return TagType.LONG;
|
||||||
return (byte)4;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public String toString()
|
public String toString() {
|
||||||
{
|
return "" + this.data + "L";
|
||||||
return "" + this.data + "L";
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public Tag copy()
|
public Tag copy() {
|
||||||
{
|
return new TagLong(this.data);
|
||||||
return new TagLong(this.data);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public boolean equals(Object other)
|
public boolean equals(Object other) {
|
||||||
{
|
return super.equals(other) && this.data == ((TagLong)other).data;
|
||||||
if (super.equals(other))
|
}
|
||||||
{
|
|
||||||
TagLong tag = (TagLong)other;
|
|
||||||
return this.data == tag.data;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public int hashCode()
|
public int hashCode() {
|
||||||
{
|
return super.hashCode() ^ (int)(this.data ^ this.data >>> 32);
|
||||||
return super.hashCode() ^ (int)(this.data ^ this.data >>> 32);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public long getLong()
|
public long getLong() {
|
||||||
{
|
return this.data;
|
||||||
return this.data;
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,8 +12,8 @@ class TagNull extends Tag {
|
||||||
void write(DataOutput output) throws IOException {
|
void write(DataOutput output) throws IOException {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected byte getId() {
|
protected TagType getType() {
|
||||||
return (byte)0;
|
return TagType.NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String toString() {
|
public String toString() {
|
||||||
|
|
|
@ -16,8 +16,8 @@ public class TagObject extends Tag {
|
||||||
void write(DataOutput output) throws IOException {
|
void write(DataOutput output) throws IOException {
|
||||||
for(String key : this.tags.keySet()) {
|
for(String key : this.tags.keySet()) {
|
||||||
Tag tag = this.tags.get(key);
|
Tag tag = this.tags.get(key);
|
||||||
output.writeByte(tag.getId());
|
output.writeByte(tag.getType().getId());
|
||||||
if(tag.getId() != 0) {
|
if(tag.getType() != TagType.NULL) {
|
||||||
output.writeUTF(key);
|
output.writeUTF(key);
|
||||||
tag.write(output);
|
tag.write(output);
|
||||||
}
|
}
|
||||||
|
@ -34,7 +34,7 @@ public class TagObject extends Tag {
|
||||||
while((id = input.readByte()) != 0) {
|
while((id = input.readByte()) != 0) {
|
||||||
String key = input.readUTF();
|
String key = input.readUTF();
|
||||||
tracker.read(28 + 2 * key.length());
|
tracker.read(28 + 2 * key.length());
|
||||||
Tag tag = Tag.createNewByType(id);
|
Tag tag = TagType.create(id);
|
||||||
tag.read(input, depth + 1, tracker);
|
tag.read(input, depth + 1, tracker);
|
||||||
if(this.tags.put(key, tag) != null)
|
if(this.tags.put(key, tag) != null)
|
||||||
tracker.read(36);
|
tracker.read(36);
|
||||||
|
@ -45,8 +45,8 @@ public class TagObject extends Tag {
|
||||||
return this.tags.keySet();
|
return this.tags.keySet();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected byte getId() {
|
protected TagType getType() {
|
||||||
return (byte)10;
|
return TagType.OBJECT;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void set(String key, Tag value) {
|
public void set(String key, Tag value) {
|
||||||
|
@ -57,26 +57,18 @@ public class TagObject extends Tag {
|
||||||
this.tags.put(key, value);
|
this.tags.put(key, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setFloatList(String key, TagFloatList value) {
|
|
||||||
this.tags.put(key, value);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setDoubleList(String key, TagDoubleList value) {
|
|
||||||
this.tags.put(key, value);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setStringList(String key, TagStringList value) {
|
public void setStringList(String key, TagStringList value) {
|
||||||
this.tags.put(key, value);
|
this.tags.put(key, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setIntArrayList(String key, TagIntArrayList value) {
|
|
||||||
this.tags.put(key, value);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setObjectList(String key, TagObjectList value) {
|
public void setObjectList(String key, TagObjectList value) {
|
||||||
this.tags.put(key, value);
|
this.tags.put(key, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setBool(String key, boolean value) {
|
||||||
|
this.tags.put(key, new TagBool(value));
|
||||||
|
}
|
||||||
|
|
||||||
public void setByte(String key, byte value) {
|
public void setByte(String key, byte value) {
|
||||||
this.tags.put(key, new TagByte(value));
|
this.tags.put(key, new TagByte(value));
|
||||||
}
|
}
|
||||||
|
@ -85,6 +77,10 @@ public class TagObject extends Tag {
|
||||||
this.tags.put(key, new TagShort(value));
|
this.tags.put(key, new TagShort(value));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setChar(String key, char value) {
|
||||||
|
this.tags.put(key, new TagChar(value));
|
||||||
|
}
|
||||||
|
|
||||||
public void setInt(String key, int value) {
|
public void setInt(String key, int value) {
|
||||||
this.tags.put(key, new TagInt(value));
|
this.tags.put(key, new TagInt(value));
|
||||||
}
|
}
|
||||||
|
@ -113,145 +109,125 @@ public class TagObject extends Tag {
|
||||||
this.tags.put(key, new TagIntArray(value));
|
this.tags.put(key, new TagIntArray(value));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setBool(String key, boolean value) {
|
|
||||||
this.setByte(key, (byte)(value ? 1 : 0));
|
|
||||||
}
|
|
||||||
|
|
||||||
public Tag get(String key) {
|
public Tag get(String key) {
|
||||||
return this.tags.get(key);
|
return this.tags.get(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean has(String key, int type) {
|
private boolean has(String key, TagType type) {
|
||||||
Tag tag = this.tags.get(key);
|
Tag tag = this.tags.get(key);
|
||||||
return tag != null && tag.getId() == type;
|
return tag != null && tag.getType() == type;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasBool(String key) {
|
public boolean hasBool(String key) {
|
||||||
return this.hasByte(key);
|
return this.has(key, TagType.BOOLEAN);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasByte(String key) {
|
public boolean hasByte(String key) {
|
||||||
return this.has(key, 1);
|
return this.has(key, TagType.BYTE);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasShort(String key) {
|
public boolean hasShort(String key) {
|
||||||
return this.has(key, 2);
|
return this.has(key, TagType.SHORT);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean hasChar(String key) {
|
||||||
|
return this.has(key, TagType.CHAR);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasInt(String key) {
|
public boolean hasInt(String key) {
|
||||||
return this.has(key, 3);
|
return this.has(key, TagType.INT);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasLong(String key) {
|
public boolean hasLong(String key) {
|
||||||
return this.has(key, 4);
|
return this.has(key, TagType.LONG);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasFloat(String key) {
|
public boolean hasFloat(String key) {
|
||||||
return this.has(key, 5);
|
return this.has(key, TagType.FLOAT);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasDouble(String key) {
|
public boolean hasDouble(String key) {
|
||||||
return this.has(key, 6);
|
return this.has(key, TagType.DOUBLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasString(String key) {
|
public boolean hasString(String key) {
|
||||||
return this.has(key, 8);
|
return this.has(key, TagType.STRING);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasByteArray(String key) {
|
public boolean hasByteArray(String key) {
|
||||||
return this.has(key, 7);
|
return this.has(key, TagType.BYTE_ARRAY);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasIntArray(String key) {
|
public boolean hasIntArray(String key) {
|
||||||
return this.has(key, 11);
|
return this.has(key, TagType.INT_ARRAY);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasObject(String key) {
|
public boolean hasObject(String key) {
|
||||||
return this.has(key, 10);
|
return this.has(key, TagType.OBJECT);
|
||||||
}
|
|
||||||
|
|
||||||
public boolean hasFloatList(String key) {
|
|
||||||
return this.has(key, 13);
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean hasDoubleList(String key) {
|
|
||||||
return this.has(key, 14);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasStringList(String key) {
|
public boolean hasStringList(String key) {
|
||||||
return this.has(key, 9);
|
return this.has(key, TagType.STRING_LIST);
|
||||||
}
|
|
||||||
|
|
||||||
public boolean hasIntArrayList(String key) {
|
|
||||||
return this.has(key, 15);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasObjectList(String key) {
|
public boolean hasObjectList(String key) {
|
||||||
return this.has(key, 12);
|
return this.has(key, TagType.OBJECT_LIST);
|
||||||
}
|
|
||||||
|
|
||||||
public byte getByte(String key) {
|
|
||||||
return !this.has(key, 1) ? 0 : ((TagByte)this.tags.get(key)).getByte();
|
|
||||||
}
|
|
||||||
|
|
||||||
public short getShort(String key) {
|
|
||||||
return !this.has(key, 2) ? 0 : ((TagShort)this.tags.get(key)).getShort();
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getInt(String key) {
|
|
||||||
return !this.has(key, 3) ? 0 : ((TagInt)this.tags.get(key)).getInt();
|
|
||||||
}
|
|
||||||
|
|
||||||
public long getLong(String key) {
|
|
||||||
return !this.has(key, 4) ? 0L : ((TagLong)this.tags.get(key)).getLong();
|
|
||||||
}
|
|
||||||
|
|
||||||
public float getFloat(String key) {
|
|
||||||
return !this.has(key, 5) ? 0.0F : ((TagFloat)this.tags.get(key)).getFloat();
|
|
||||||
}
|
|
||||||
|
|
||||||
public double getDouble(String key) {
|
|
||||||
return !this.has(key, 6) ? 0.0D : ((TagDouble)this.tags.get(key)).getDouble();
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getString(String key) {
|
|
||||||
return !this.has(key, 8) ? "" : ((TagString)this.tags.get(key)).getString();
|
|
||||||
}
|
|
||||||
|
|
||||||
public byte[] getByteArray(String key) {
|
|
||||||
return !this.has(key, 7) ? new byte[0] : ((TagByteArray)this.tags.get(key)).getByteArray();
|
|
||||||
}
|
|
||||||
|
|
||||||
public int[] getIntArray(String key) {
|
|
||||||
return !this.has(key, 11) ? new int[0] : ((TagIntArray)this.tags.get(key)).getIntArray();
|
|
||||||
}
|
|
||||||
|
|
||||||
public TagObject getObject(String key) {
|
|
||||||
return !this.has(key, 10) ? new TagObject() : (TagObject)this.tags.get(key);
|
|
||||||
}
|
|
||||||
|
|
||||||
public TagFloatList getFloatList(String key) {
|
|
||||||
return !this.has(key, 13) ? new TagFloatList() : (TagFloatList)this.tags.get(key);
|
|
||||||
}
|
|
||||||
|
|
||||||
public TagDoubleList getDoubleList(String key) {
|
|
||||||
return !this.has(key, 14) ? new TagDoubleList() : (TagDoubleList)this.tags.get(key);
|
|
||||||
}
|
|
||||||
|
|
||||||
public TagStringList getStringList(String key) {
|
|
||||||
return !this.has(key, 9) ? new TagStringList() : (TagStringList)this.tags.get(key);
|
|
||||||
}
|
|
||||||
|
|
||||||
public TagIntArrayList getIntArrayList(String key) {
|
|
||||||
return !this.has(key, 15) ? new TagIntArrayList() : (TagIntArrayList)this.tags.get(key);
|
|
||||||
}
|
|
||||||
|
|
||||||
public TagObjectList getObjectList(String key) {
|
|
||||||
return !this.has(key, 12) ? new TagObjectList() : (TagObjectList)this.tags.get(key);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean getBool(String key) {
|
public boolean getBool(String key) {
|
||||||
return this.getByte(key) != 0;
|
return !this.has(key, TagType.BOOLEAN) ? false : ((TagBool)this.tags.get(key)).getBool();
|
||||||
|
}
|
||||||
|
|
||||||
|
public byte getByte(String key) {
|
||||||
|
return !this.has(key, TagType.BYTE) ? 0 : ((TagByte)this.tags.get(key)).getByte();
|
||||||
|
}
|
||||||
|
|
||||||
|
public short getShort(String key) {
|
||||||
|
return !this.has(key, TagType.SHORT) ? 0 : ((TagShort)this.tags.get(key)).getShort();
|
||||||
|
}
|
||||||
|
|
||||||
|
public char getChar(String key) {
|
||||||
|
return !this.has(key, TagType.CHAR) ? 0 : ((TagChar)this.tags.get(key)).getChar();
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getInt(String key) {
|
||||||
|
return !this.has(key, TagType.INT) ? 0 : ((TagInt)this.tags.get(key)).getInt();
|
||||||
|
}
|
||||||
|
|
||||||
|
public long getLong(String key) {
|
||||||
|
return !this.has(key, TagType.LONG) ? 0L : ((TagLong)this.tags.get(key)).getLong();
|
||||||
|
}
|
||||||
|
|
||||||
|
public float getFloat(String key) {
|
||||||
|
return !this.has(key, TagType.FLOAT) ? 0.0F : ((TagFloat)this.tags.get(key)).getFloat();
|
||||||
|
}
|
||||||
|
|
||||||
|
public double getDouble(String key) {
|
||||||
|
return !this.has(key, TagType.DOUBLE) ? 0.0D : ((TagDouble)this.tags.get(key)).getDouble();
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getString(String key) {
|
||||||
|
return !this.has(key, TagType.STRING) ? "" : ((TagString)this.tags.get(key)).getString();
|
||||||
|
}
|
||||||
|
|
||||||
|
public byte[] getByteArray(String key) {
|
||||||
|
return !this.has(key, TagType.BYTE_ARRAY) ? new byte[0] : ((TagByteArray)this.tags.get(key)).getByteArray();
|
||||||
|
}
|
||||||
|
|
||||||
|
public int[] getIntArray(String key) {
|
||||||
|
return !this.has(key, TagType.INT_ARRAY) ? new int[0] : ((TagIntArray)this.tags.get(key)).getIntArray();
|
||||||
|
}
|
||||||
|
|
||||||
|
public TagObject getObject(String key) {
|
||||||
|
return !this.has(key, TagType.OBJECT) ? new TagObject() : (TagObject)this.tags.get(key);
|
||||||
|
}
|
||||||
|
|
||||||
|
public TagStringList getStringList(String key) {
|
||||||
|
return !this.has(key, TagType.STRING_LIST) ? new TagStringList() : (TagStringList)this.tags.get(key);
|
||||||
|
}
|
||||||
|
|
||||||
|
public TagObjectList getObjectList(String key) {
|
||||||
|
return !this.has(key, TagType.OBJECT_LIST) ? new TagObjectList() : (TagObjectList)this.tags.get(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void remove(String key) {
|
public void remove(String key) {
|
||||||
|
@ -296,8 +272,8 @@ public class TagObject extends Tag {
|
||||||
public void merge(TagObject other) {
|
public void merge(TagObject other) {
|
||||||
for(String key : other.tags.keySet()) {
|
for(String key : other.tags.keySet()) {
|
||||||
Tag tag = other.tags.get(key);
|
Tag tag = other.tags.get(key);
|
||||||
if(tag.getId() == 10) {
|
if(tag.getType() == TagType.OBJECT) {
|
||||||
if(this.has(key, 10)) {
|
if(this.has(key, TagType.OBJECT)) {
|
||||||
TagObject comp = this.getObject(key);
|
TagObject comp = this.getObject(key);
|
||||||
comp.merge((TagObject)tag);
|
comp.merge((TagObject)tag);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
package common.tags;
|
package common.tags;
|
||||||
|
|
||||||
public class TagObjectList extends TagList<TagObject> {
|
public class TagObjectList extends TagList<TagObject> {
|
||||||
protected byte getId() {
|
protected TagType getType() {
|
||||||
return 12;
|
return TagType.OBJECT_LIST;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected byte getType() {
|
protected TagType getElemType() {
|
||||||
return 10;
|
return TagType.OBJECT;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected TagList<TagObject> createInstance() {
|
protected TagList<TagObject> createInstance() {
|
||||||
|
|
|
@ -4,65 +4,46 @@ import java.io.DataInput;
|
||||||
import java.io.DataOutput;
|
import java.io.DataOutput;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
class TagShort extends Tag
|
class TagShort extends Tag {
|
||||||
{
|
private short data;
|
||||||
private short data;
|
|
||||||
|
|
||||||
public TagShort()
|
TagShort() {
|
||||||
{
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public TagShort(short data)
|
public TagShort(short data) {
|
||||||
{
|
this.data = data;
|
||||||
this.data = data;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
void write(DataOutput output) throws IOException
|
void write(DataOutput output) throws IOException {
|
||||||
{
|
output.writeShort(this.data);
|
||||||
output.writeShort(this.data);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
void read(DataInput input, int depth, SizeTracker sizeTracker) throws IOException
|
void read(DataInput input, int depth, SizeTracker tracker) throws IOException {
|
||||||
{
|
tracker.read(10);
|
||||||
sizeTracker.read(10);
|
this.data = input.readShort();
|
||||||
this.data = input.readShort();
|
}
|
||||||
}
|
|
||||||
|
|
||||||
protected byte getId()
|
protected TagType getType() {
|
||||||
{
|
return TagType.SHORT;
|
||||||
return (byte)2;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public String toString()
|
public String toString() {
|
||||||
{
|
return "" + this.data + "s";
|
||||||
return "" + this.data + "s";
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public Tag copy()
|
public Tag copy() {
|
||||||
{
|
return new TagShort(this.data);
|
||||||
return new TagShort(this.data);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public boolean equals(Object other)
|
public boolean equals(Object other) {
|
||||||
{
|
return super.equals(other) && this.data == ((TagShort)other).data;
|
||||||
if (super.equals(other))
|
}
|
||||||
{
|
|
||||||
TagShort tag = (TagShort)other;
|
|
||||||
return this.data == tag.data;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public int hashCode()
|
public int hashCode() {
|
||||||
{
|
return super.hashCode() ^ this.data;
|
||||||
return super.hashCode() ^ this.data;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public short getShort()
|
public short getShort() {
|
||||||
{
|
return this.data;
|
||||||
return this.data;
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,7 +7,7 @@ import java.io.IOException;
|
||||||
class TagString extends Tag {
|
class TagString extends Tag {
|
||||||
private String data;
|
private String data;
|
||||||
|
|
||||||
public TagString() {
|
TagString() {
|
||||||
this.data = "";
|
this.data = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -27,8 +27,8 @@ class TagString extends Tag {
|
||||||
tracker.read(2 * this.data.length());
|
tracker.read(2 * this.data.length());
|
||||||
}
|
}
|
||||||
|
|
||||||
protected byte getId() {
|
protected TagType getType() {
|
||||||
return (byte)8;
|
return TagType.STRING;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String toString() {
|
public String toString() {
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
package common.tags;
|
package common.tags;
|
||||||
|
|
||||||
public class TagStringList extends TagList<TagString> {
|
public class TagStringList extends TagList<TagString> {
|
||||||
protected byte getId() {
|
protected TagType getType() {
|
||||||
return 9;
|
return TagType.STRING_LIST;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected byte getType() {
|
protected TagType getElemType() {
|
||||||
return 8;
|
return TagType.STRING;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected TagList<TagString> createInstance() {
|
protected TagList<TagString> createInstance() {
|
||||||
|
|
125
common/src/main/java/common/tags/TagType.java
Normal file
125
common/src/main/java/common/tags/TagType.java
Normal file
|
@ -0,0 +1,125 @@
|
||||||
|
package common.tags;
|
||||||
|
|
||||||
|
import java.io.DataInput;
|
||||||
|
import java.io.DataOutput;
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
public enum TagType {
|
||||||
|
NULL { // 0
|
||||||
|
public Tag createTag() {
|
||||||
|
return new TagNull();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
OBJECT { // 1
|
||||||
|
public Tag createTag() {
|
||||||
|
return new TagObject();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
BOOLEAN { // 2
|
||||||
|
public Tag createTag() {
|
||||||
|
return new TagBool();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
BYTE { // 3
|
||||||
|
public Tag createTag() {
|
||||||
|
return new TagByte();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
SHORT { // 4
|
||||||
|
public Tag createTag() {
|
||||||
|
return new TagShort();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
CHAR { // 5
|
||||||
|
public Tag createTag() {
|
||||||
|
return new TagChar();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
INT { // 6
|
||||||
|
public Tag createTag() {
|
||||||
|
return new TagInt();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
LONG { // 7
|
||||||
|
public Tag createTag() {
|
||||||
|
return new TagLong();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
FLOAT { // 8
|
||||||
|
public Tag createTag() {
|
||||||
|
return new TagFloat();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
DOUBLE { // 9
|
||||||
|
public Tag createTag() {
|
||||||
|
return new TagDouble();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
STRING { // 10
|
||||||
|
public Tag createTag() {
|
||||||
|
return new TagString();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
OBJECT_LIST { // 11
|
||||||
|
public Tag createTag() {
|
||||||
|
return new TagObjectList();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
BYTE_ARRAY { // 12
|
||||||
|
public Tag createTag() {
|
||||||
|
return new TagByteArray();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
INT_ARRAY { // 13
|
||||||
|
public Tag createTag() {
|
||||||
|
return new TagIntArray();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
STRING_LIST { // 14
|
||||||
|
public Tag createTag() {
|
||||||
|
return new TagStringList();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
private static final TagType[] TYPES;
|
||||||
|
|
||||||
|
private final byte id;
|
||||||
|
|
||||||
|
static {
|
||||||
|
TYPES = values();
|
||||||
|
}
|
||||||
|
|
||||||
|
static Tag create(byte id) {
|
||||||
|
return id >= 0 && id < TYPES.length ? TYPES[id].createTag() : new Tag() {
|
||||||
|
void write(DataOutput output) throws IOException {
|
||||||
|
throw new IOException("Kann keinen ungültigen Tag mit ID #" + id + " schreiben");
|
||||||
|
}
|
||||||
|
|
||||||
|
void read(DataInput input, int depth, SizeTracker tracker) throws IOException {
|
||||||
|
throw new IOException("Kann keinen ungültigen Tag mit ID #" + id + " lesen");
|
||||||
|
}
|
||||||
|
|
||||||
|
public String toString() {
|
||||||
|
return "<invalid>";
|
||||||
|
}
|
||||||
|
|
||||||
|
protected TagType getType() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Tag copy() {
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
private TagType() {
|
||||||
|
this.id = (byte)this.ordinal();
|
||||||
|
}
|
||||||
|
|
||||||
|
public abstract Tag createTag();
|
||||||
|
|
||||||
|
public byte getId() {
|
||||||
|
return this.id;
|
||||||
|
}
|
||||||
|
}
|
|
@ -80,8 +80,6 @@ import common.packet.SPacketSkin;
|
||||||
import common.packet.SPacketTimeUpdate;
|
import common.packet.SPacketTimeUpdate;
|
||||||
import common.packet.SPacketWorld;
|
import common.packet.SPacketWorld;
|
||||||
import common.potion.PotionEffect;
|
import common.potion.PotionEffect;
|
||||||
import common.tags.TagDoubleList;
|
|
||||||
import common.tags.TagFloatList;
|
|
||||||
import common.tags.TagLoader;
|
import common.tags.TagLoader;
|
||||||
import common.tags.TagObject;
|
import common.tags.TagObject;
|
||||||
import common.util.BlockPos;
|
import common.util.BlockPos;
|
||||||
|
@ -329,13 +327,11 @@ public final class Server implements IThreadListener {
|
||||||
TagObject tag = this.loadPlayerData(user);
|
TagObject tag = this.loadPlayerData(user);
|
||||||
if(tag == null)
|
if(tag == null)
|
||||||
return null;
|
return null;
|
||||||
TagDoubleList pos = tag.getDoubleList("Pos");
|
double posX = tag.getDouble("PosX");
|
||||||
TagFloatList rot = tag.getFloatList("Rotation");
|
double posY = tag.getDouble("PosY");
|
||||||
double posX = pos.get(0);
|
double posZ = tag.getDouble("PosZ");
|
||||||
double posY = pos.get(1);
|
float rotYaw = tag.getFloat("Yaw");
|
||||||
double posZ = pos.get(2);
|
float rotPitch = tag.getFloat("Pitch");
|
||||||
float rotYaw = rot.get(0);
|
|
||||||
float rotPitch = rot.get(1);
|
|
||||||
int dimension = tag.getInt("Dimension");
|
int dimension = tag.getInt("Dimension");
|
||||||
return new Position(posX, posY, posZ, rotYaw, rotPitch, dimension);
|
return new Position(posX, posY, posZ, rotYaw, rotPitch, dimension);
|
||||||
}
|
}
|
||||||
|
|
|
@ -101,7 +101,6 @@ import common.packet.CPacketAction.Action;
|
||||||
import common.packet.SPacketMessage.Type;
|
import common.packet.SPacketMessage.Type;
|
||||||
import common.potion.Potion;
|
import common.potion.Potion;
|
||||||
import common.potion.PotionEffect;
|
import common.potion.PotionEffect;
|
||||||
import common.tags.TagDoubleList;
|
|
||||||
import common.tags.TagObject;
|
import common.tags.TagObject;
|
||||||
import common.tags.TagObjectList;
|
import common.tags.TagObjectList;
|
||||||
import common.tileentity.IInteractionObject;
|
import common.tileentity.IInteractionObject;
|
||||||
|
@ -1636,10 +1635,9 @@ public class Player extends NetHandler implements ICrafting, Executor, IPlayer
|
||||||
if(info != null && info.isEmpty())
|
if(info != null && info.isEmpty())
|
||||||
info = null;
|
info = null;
|
||||||
Alignment align = Alignment.getByName(tag.getString("Align"));
|
Alignment align = Alignment.getByName(tag.getString("Align"));
|
||||||
TagDoubleList position = tag.getDoubleList("Pos");
|
|
||||||
Dimension dimension = UniverseRegistry.getDimension(tag.getInt("Dimension"));
|
Dimension dimension = UniverseRegistry.getDimension(tag.getInt("Dimension"));
|
||||||
String dim = dimension == null ? "???" : dimension.getFormattedName(false);
|
String dim = dimension == null ? "???" : dimension.getFormattedName(false);
|
||||||
BlockPos pos = new BlockPos(position.get(0), position.get(1), position.get(2));
|
BlockPos pos = new BlockPos(tag.getDouble("PosX"), tag.getDouble("PosY"), tag.getDouble("PosZ"));
|
||||||
String type = EntityRegistry.getEntityName(tag.getString("id"));
|
String type = EntityRegistry.getEntityName(tag.getString("id"));
|
||||||
int level = tag.getInt("XpLevel");
|
int level = tag.getInt("XpLevel");
|
||||||
return new PlayerCharacter(name, info, align, dim, pos, type, level);
|
return new PlayerCharacter(name, info, align, dim, pos, type, level);
|
||||||
|
|
|
@ -68,8 +68,6 @@ import common.init.TileRegistry;
|
||||||
import common.init.UniverseRegistry;
|
import common.init.UniverseRegistry;
|
||||||
import common.log.Log;
|
import common.log.Log;
|
||||||
import common.rng.Random;
|
import common.rng.Random;
|
||||||
import common.tags.TagDoubleList;
|
|
||||||
import common.tags.TagFloatList;
|
|
||||||
import common.tags.TagLoader;
|
import common.tags.TagLoader;
|
||||||
import common.tags.TagObject;
|
import common.tags.TagObject;
|
||||||
import common.tags.TagObjectList;
|
import common.tags.TagObjectList;
|
||||||
|
@ -997,22 +995,6 @@ public abstract class Converter {
|
||||||
return idx >= 0 ? name.substring(idx + 1) : name; // save compat
|
return idx >= 0 ? name.substring(idx + 1) : name; // save compat
|
||||||
}
|
}
|
||||||
|
|
||||||
private static TagFloatList getList(float[] values) {
|
|
||||||
TagFloatList nlist = new TagFloatList();
|
|
||||||
for(int z = 0; z < values.length; z++) {
|
|
||||||
nlist.add(values[z]);
|
|
||||||
}
|
|
||||||
return nlist;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static TagDoubleList getList(double[] values) {
|
|
||||||
TagDoubleList nlist = new TagDoubleList();
|
|
||||||
for(int z = 0; z < values.length; z++) {
|
|
||||||
nlist.add(values[z]);
|
|
||||||
}
|
|
||||||
return nlist;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static TagObject convertChunkData(NbtTag tag, boolean legacy) {
|
private static TagObject convertChunkData(NbtTag tag, boolean legacy) {
|
||||||
TagObject ntag = new TagObject();
|
TagObject ntag = new TagObject();
|
||||||
tag = tag.getTag("Level");
|
tag = tag.getTag("Level");
|
||||||
|
@ -1092,9 +1074,14 @@ public abstract class Converter {
|
||||||
if(pos.length != 3 || motion.length != 3 || rotation.length != 2)
|
if(pos.length != 3 || motion.length != 3 || rotation.length != 2)
|
||||||
continue;
|
continue;
|
||||||
boolean ground = ent.getByte("OnGround") != 0;
|
boolean ground = ent.getByte("OnGround") != 0;
|
||||||
nent.setDoubleList("Pos", getList(pos));
|
nent.setDouble("PosX", pos[0]);
|
||||||
nent.setDoubleList("Motion", getList(motion));
|
nent.setDouble("PosY", pos[1]);
|
||||||
nent.setFloatList("Rotation", getList(rotation));
|
nent.setDouble("PosZ", pos[2]);
|
||||||
|
nent.setDouble("MotionX", motion[0]);
|
||||||
|
nent.setDouble("MotionY", motion[1]);
|
||||||
|
nent.setDouble("MotionZ", motion[2]);
|
||||||
|
nent.setFloat("Yaw", rotation[0]);
|
||||||
|
nent.setFloat("Pitch", rotation[1]);
|
||||||
nent.setBool("OnGround", ground);
|
nent.setBool("OnGround", ground);
|
||||||
nent.setInt("Dimension", 1);
|
nent.setInt("Dimension", 1);
|
||||||
nent.setString("id", mapped);
|
nent.setString("id", mapped);
|
||||||
|
@ -1123,6 +1110,7 @@ public abstract class Converter {
|
||||||
entities = new TagObjectList();
|
entities = new TagObjectList();
|
||||||
for(NbtTag sect : sects) {
|
for(NbtTag sect : sects) {
|
||||||
TagObject nsect = new TagObject();
|
TagObject nsect = new TagObject();
|
||||||
|
nsect.setInt("Y", sect.getByte("Y"));
|
||||||
byte[] blocks = sect.getByteArray("Blocks");
|
byte[] blocks = sect.getByteArray("Blocks");
|
||||||
NibbleArray data = new NibbleArray(sect.getByteArray("Data"));
|
NibbleArray data = new NibbleArray(sect.getByteArray("Data"));
|
||||||
byte[] add = sect.getByteArray("Add");
|
byte[] add = sect.getByteArray("Add");
|
||||||
|
|
|
@ -41,6 +41,16 @@ public class StructureBoundingBox
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public StructureBoundingBox(int[] coords, int offset)
|
||||||
|
{
|
||||||
|
this.minX = coords[offset + 0];
|
||||||
|
this.minY = coords[offset + 1];
|
||||||
|
this.minZ = coords[offset + 2];
|
||||||
|
this.maxX = coords[offset + 3];
|
||||||
|
this.maxY = coords[offset + 4];
|
||||||
|
this.maxZ = coords[offset + 5];
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* returns a new StructureBoundingBox with MAX values
|
* returns a new StructureBoundingBox with MAX values
|
||||||
*/
|
*/
|
||||||
|
@ -212,4 +222,14 @@ public class StructureBoundingBox
|
||||||
{
|
{
|
||||||
return new int[] {this.minX, this.minY, this.minZ, this.maxX, this.maxY, this.maxZ};
|
return new int[] {this.minX, this.minY, this.minZ, this.maxX, this.maxY, this.maxZ};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void toIntArray(int[] data, int offset)
|
||||||
|
{
|
||||||
|
data[offset + 0] = this.minX;
|
||||||
|
data[offset + 1] = this.minY;
|
||||||
|
data[offset + 2] = this.minZ;
|
||||||
|
data[offset + 3] = this.maxX;
|
||||||
|
data[offset + 4] = this.maxY;
|
||||||
|
data[offset + 5] = this.maxZ;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,7 +9,6 @@ import common.init.Items;
|
||||||
import common.item.RngLoot;
|
import common.item.RngLoot;
|
||||||
import common.rng.Random;
|
import common.rng.Random;
|
||||||
import common.rng.WeightedList;
|
import common.rng.WeightedList;
|
||||||
import common.tags.TagIntArrayList;
|
|
||||||
import common.tags.TagObject;
|
import common.tags.TagObject;
|
||||||
import common.tileentity.TileEntity;
|
import common.tileentity.TileEntity;
|
||||||
import common.tileentity.TileEntityMobSpawner;
|
import common.tileentity.TileEntityMobSpawner;
|
||||||
|
@ -712,23 +711,23 @@ public class StructureMineshaft
|
||||||
|
|
||||||
protected void writeTags(TagObject tag)
|
protected void writeTags(TagObject tag)
|
||||||
{
|
{
|
||||||
TagIntArrayList list = new TagIntArrayList();
|
int[] rooms = new int[this.roomsLinkedToTheRoom.size() * 6];
|
||||||
|
|
||||||
for (StructureBoundingBox bb : this.roomsLinkedToTheRoom)
|
for (int z = 0; z < rooms.length / 6; z++)
|
||||||
{
|
{
|
||||||
list.add(bb.toIntArray());
|
this.roomsLinkedToTheRoom.get(z).toIntArray(rooms, z * 6);
|
||||||
}
|
}
|
||||||
|
|
||||||
tag.setIntArrayList("Entrances", list);
|
tag.setIntArray("Entrances", rooms);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void readTags(TagObject tag)
|
protected void readTags(TagObject tag)
|
||||||
{
|
{
|
||||||
TagIntArrayList list = tag.getIntArrayList("Entrances");
|
int[] rooms = tag.getIntArray("Entrances");
|
||||||
|
|
||||||
for (int i = 0; i < list.size(); ++i)
|
for (int z = 0; z < rooms.length / 6; z++)
|
||||||
{
|
{
|
||||||
this.roomsLinkedToTheRoom.add(new StructureBoundingBox(list.get(i)));
|
this.roomsLinkedToTheRoom.add(new StructureBoundingBox(rooms, z * 6));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue