Our own basic NBT types

This commit is contained in:
nossr50 2019-10-28 19:47:38 -07:00
parent edc8701e35
commit 2a606b1ed1
14 changed files with 378 additions and 0 deletions

View File

@ -0,0 +1,11 @@
package com.gmail.nossr50.core.nbt;
public interface NBTBase {
/**
* Get the NBTType for this NBTBase
* @return this NBTType
*/
NBTType getNBTType();
}

View File

@ -0,0 +1,28 @@
package com.gmail.nossr50.core.nbt;
public class NBTByte implements NBTBase {
private String key;
private Byte value;
@Override
public NBTType getNBTType() {
return NBTType.BYTE;
}
public String getKey() {
return key;
}
public void setKey(String key) {
this.key = key;
}
public Byte getValue() {
return value;
}
public void setValue(Byte value) {
this.value = value;
}
}

View File

@ -0,0 +1,32 @@
package com.gmail.nossr50.core.nbt;
public class NBTByteArray implements NBTBase {
private String key;
private byte[] values;
@Override
public NBTType getNBTType() {
return NBTType.BYTE_ARRAY;
}
public int getLength() {
return values.length;
}
public String getKey() {
return key;
}
public void setKey(String key) {
this.key = key;
}
public byte[] getValues() {
return values;
}
public void setValues(byte[] values) {
this.values = values;
}
}

View File

@ -0,0 +1,28 @@
package com.gmail.nossr50.core.nbt;
public class NBTDouble implements NBTBase {
private String key;
private double value;
@Override
public NBTType getNBTType() {
return NBTType.DOUBLE;
}
public String getKey() {
return key;
}
public void setKey(String key) {
this.key = key;
}
public double getValue() {
return value;
}
public void setValue(double value) {
this.value = value;
}
}

View File

@ -0,0 +1,28 @@
package com.gmail.nossr50.core.nbt;
public class NBTFloat implements NBTBase {
private String key;
private float value;
@Override
public NBTType getNBTType() {
return NBTType.FLOAT;
}
public String getKey() {
return key;
}
public void setKey(String key) {
this.key = key;
}
public float getValue() {
return value;
}
public void setValue(float value) {
this.value = value;
}
}

View File

@ -0,0 +1,32 @@
package com.gmail.nossr50.core.nbt;
public class NBTIntArray implements NBTBase {
private String key;
private int[] values;
@Override
public NBTType getNBTType() {
return NBTType.INT_ARRAY;
}
public int getLength() {
return values.length;
}
public String getKey() {
return key;
}
public void setKey(String key) {
this.key = key;
}
public int[] getValues() {
return values;
}
public void setValues(int[] values) {
this.values = values;
}
}

View File

@ -0,0 +1,28 @@
package com.gmail.nossr50.core.nbt;
public class NBTInteger implements NBTBase {
private String key;
private int value;
@Override
public NBTType getNBTType() {
return NBTType.INT;
}
public String getKey() {
return key;
}
public void setKey(String key) {
this.key = key;
}
public int getValue() {
return value;
}
public void setValue(int value) {
this.value = value;
}
}

View File

@ -0,0 +1,35 @@
package com.gmail.nossr50.core.nbt;
import java.util.List;
public class NBTList implements NBTBase {
private int length;
private String key;
private List<? extends NBTBase> values;
@Override
public NBTType getNBTType() {
return NBTType.LIST;
}
public int getLength() {
return length;
}
public String getKey() {
return key;
}
public void setKey(String key) {
this.key = key;
}
public List<? extends NBTBase> getValues() {
return values;
}
public void setValues(List<? extends NBTBase> values) {
this.values = values;
}
}

View File

@ -0,0 +1,28 @@
package com.gmail.nossr50.core.nbt;
public class NBTLong implements NBTBase {
public String key;
public long value;
public String getKey() {
return key;
}
public void setKey(String key) {
this.key = key;
}
public long getValue() {
return value;
}
public void setValue(long value) {
this.value = value;
}
@Override
public NBTType getNBTType() {
return NBTType.LONG;
}
}

View File

@ -0,0 +1,32 @@
package com.gmail.nossr50.core.nbt;
public class NBTLongArray implements NBTBase {
private String key;
private long[] values;
@Override
public NBTType getNBTType() {
return NBTType.LONG_ARRAY;
}
public int getLength() {
return values.length;
}
public String getKey() {
return key;
}
public void setKey(String key) {
this.key = key;
}
public long[] getValues() {
return values;
}
public void setValues(long[] values) {
this.values = values;
}
}

View File

@ -0,0 +1,28 @@
package com.gmail.nossr50.core.nbt;
public class NBTShort implements NBTBase {
private String key;
private short value;
@Override
public NBTType getNBTType() {
return NBTType.SHORT;
}
public String getKey() {
return key;
}
public void setKey(String key) {
this.key = key;
}
public short getValue() {
return value;
}
public void setValue(short value) {
this.value = value;
}
}

View File

@ -0,0 +1,28 @@
package com.gmail.nossr50.core.nbt;
public class NBTString implements NBTBase {
private String key;
private String value;
@Override
public NBTType getNBTType() {
return NBTType.STRING;
}
public String getKey() {
return key;
}
public void setKey(String key) {
this.key = key;
}
public String getValue() {
return value;
}
public void setValue(String value) {
this.value = value;
}
}

View File

@ -0,0 +1,18 @@
package com.gmail.nossr50.core.nbt;
import java.util.Map;
public class NBTTagCompound implements NBTBase {
private Map<String, NBTBase> tagMap;
@Override
public NBTType getNBTType() {
return NBTType.COMPOUND;
}
public NBTBase getTag(String key) {
return tagMap.get(key);
}
}

View File

@ -0,0 +1,22 @@
package com.gmail.nossr50.core.nbt;
/**
* Represents the NBT Type
* Based on NBT Structure in 1.14.4
*/
public enum NBTType {
////String[] a = new String[]{"END", "BYTE", "SHORT", "INT", "LONG", "FLOAT", "DOUBLE", "BYTE[]", "STRING", "LIST", "COMPOUND", "INT[]", "LONG[]"};
END,
BYTE,
SHORT,
INT,
LONG,
FLOAT,
DOUBLE,
BYTE_ARRAY,
STRING,
LIST,
COMPOUND,
INT_ARRAY,
LONG_ARRAY
}