decompile with cfr

This commit is contained in:
Merith-TK 2022-08-09 23:01:55 -07:00
commit 7d26cb34a1
1987 changed files with 238867 additions and 0 deletions

View file

@ -0,0 +1,27 @@
/*
* Decompiled with CFR 0.152.
*/
package com.evilco.mc.nbt.error;
import java.io.IOException;
public class TagNotFoundException
extends IOException {
private static final long serialVersionUID = -4631008535746749103L;
public TagNotFoundException() {
super("The tag does not exist");
}
public TagNotFoundException(String message) {
super(message);
}
public TagNotFoundException(Throwable cause) {
super(cause);
}
public TagNotFoundException(String message, Throwable cause) {
super(message, cause);
}
}

View file

@ -0,0 +1,27 @@
/*
* Decompiled with CFR 0.152.
*/
package com.evilco.mc.nbt.error;
import java.io.IOException;
public class UnexpectedTagTypeException
extends IOException {
private static final long serialVersionUID = -6604963428978583800L;
public UnexpectedTagTypeException() {
super("The tag is not of the expected type");
}
public UnexpectedTagTypeException(String message) {
super(message);
}
public UnexpectedTagTypeException(Throwable cause) {
super(cause);
}
public UnexpectedTagTypeException(String message, Throwable cause) {
super(message, cause);
}
}

View file

@ -0,0 +1,46 @@
/*
* Decompiled with CFR 0.152.
*/
package com.evilco.mc.nbt.stream;
import com.evilco.mc.nbt.tag.ITag;
import com.evilco.mc.nbt.tag.TagType;
import java.io.DataInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.lang.reflect.Constructor;
public class NbtInputStream
extends DataInputStream {
public NbtInputStream(InputStream in) {
super(in);
}
public ITag readTag() throws IOException {
byte type = this.readByte();
TagType tagType = TagType.valueOf(type);
if (tagType == null) {
throw new IOException("Invalid NBT tag: Found unknown tag type " + type + ".");
}
if (tagType == TagType.END) {
return null;
}
return this.readTag(tagType, false);
}
public ITag readTag(TagType type, boolean anonymous) throws IOException {
Constructor<? extends ITag> constructor = null;
try {
constructor = type.tagType.getConstructor(NbtInputStream.class, Boolean.TYPE);
}
catch (NoSuchMethodException ex) {
throw new IOException("Invalid NBT implementation state: Type " + type.tagType.getName() + " has no de-serialization constructor.");
}
try {
return constructor.newInstance(this, anonymous);
}
catch (Exception ex) {
throw new IOException("Invalid NBT implementation state: Type " + type.tagType.getName() + " in (" + this.getClass().getName() + ") has no valid constructor: " + ex.getMessage(), ex);
}
}
}

View file

@ -0,0 +1,21 @@
/*
* Decompiled with CFR 0.152.
*/
package com.evilco.mc.nbt.stream;
import com.evilco.mc.nbt.tag.ITag;
import java.io.DataOutputStream;
import java.io.IOException;
import java.io.OutputStream;
public class NbtOutputStream
extends DataOutputStream {
public NbtOutputStream(OutputStream out) {
super(out);
}
public void write(ITag tag) throws IOException {
this.writeByte(tag.getTagID());
tag.write(this, false);
}
}

View file

@ -0,0 +1,86 @@
/*
* Decompiled with CFR 0.152.
*/
package com.evilco.mc.nbt.tag;
import com.evilco.mc.nbt.stream.NbtInputStream;
import com.evilco.mc.nbt.stream.NbtOutputStream;
import com.evilco.mc.nbt.tag.IAnonymousTagContainer;
import com.evilco.mc.nbt.tag.INamedTagContainer;
import com.evilco.mc.nbt.tag.ITag;
import com.evilco.mc.nbt.tag.ITagContainer;
import com.google.common.base.Preconditions;
import java.io.IOException;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
public abstract class AbstractTag
implements ITag {
protected String name;
protected ITagContainer parent = null;
public AbstractTag(@Nonnull String name) {
this.setName(name);
}
public AbstractTag(@Nonnull NbtInputStream inputStream, boolean anonymous) throws IOException {
Preconditions.checkNotNull(inputStream, "inputStream");
if (!anonymous) {
short nameSize = inputStream.readShort();
byte[] nameBytes = new byte[nameSize];
inputStream.readFully(nameBytes);
this.setName(new String(nameBytes, STRING_CHARSET));
}
}
@Override
public String getName() {
return this.name;
}
@Override
public byte[] getNameBytes() {
return this.name.getBytes(STRING_CHARSET);
}
@Override
public ITagContainer getParent() {
return this.parent;
}
@Override
public abstract byte getTagID();
@Override
public void setName(@Nonnull String name) {
Preconditions.checkNotNull(name, "name");
if (this.getParent() != null) {
this.getParent().removeTag(this);
}
this.name = name;
if (this.getParent() != null) {
if (this.getParent() instanceof IAnonymousTagContainer) {
((IAnonymousTagContainer)this.getParent()).addTag(this);
} else {
((INamedTagContainer)this.getParent()).setTag(this);
}
}
}
@Override
public void setParent(@Nullable ITagContainer parent) {
if (this.getParent() != null) {
this.getParent().removeTag(this);
}
this.parent = parent;
}
@Override
public void write(NbtOutputStream outputStream, boolean anonymous) throws IOException {
if (!anonymous) {
byte[] name = this.getNameBytes();
outputStream.writeShort(name.length);
outputStream.write(name);
}
}
}

View file

@ -0,0 +1,21 @@
/*
* Decompiled with CFR 0.152.
*/
package com.evilco.mc.nbt.tag;
import com.evilco.mc.nbt.error.UnexpectedTagTypeException;
import com.evilco.mc.nbt.tag.ITag;
import com.evilco.mc.nbt.tag.ITagContainer;
import java.util.List;
import javax.annotation.Nonnull;
public interface IAnonymousTagContainer
extends ITagContainer {
public void addTag(@Nonnull ITag var1);
public List<ITag> getTags();
public <T extends ITag> List<T> getTags(Class<T> var1) throws UnexpectedTagTypeException;
public void setTag(int var1, @Nonnull ITag var2);
}

View file

@ -0,0 +1,24 @@
/*
* Decompiled with CFR 0.152.
*/
package com.evilco.mc.nbt.tag;
import com.evilco.mc.nbt.error.TagNotFoundException;
import com.evilco.mc.nbt.error.UnexpectedTagTypeException;
import com.evilco.mc.nbt.tag.ITag;
import com.evilco.mc.nbt.tag.ITagContainer;
import java.util.Map;
import javax.annotation.Nonnull;
public interface INamedTagContainer
extends ITagContainer {
public ITag getTag(@Nonnull String var1);
public <T extends ITag> T getTag(String var1, Class<T> var2) throws UnexpectedTagTypeException, TagNotFoundException;
public Map<String, ITag> getTags();
public void removeTag(@Nonnull String var1);
public void setTag(@Nonnull ITag var1);
}

View file

@ -0,0 +1,29 @@
/*
* Decompiled with CFR 0.152.
*/
package com.evilco.mc.nbt.tag;
import com.evilco.mc.nbt.stream.NbtOutputStream;
import com.evilco.mc.nbt.tag.ITagContainer;
import java.io.IOException;
import java.nio.charset.Charset;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
public interface ITag {
public static final Charset STRING_CHARSET = Charset.forName("UTF-8");
public String getName();
public byte[] getNameBytes();
public ITagContainer getParent();
public byte getTagID();
public void setName(@Nonnull String var1);
public void setParent(@Nullable ITagContainer var1);
public void write(NbtOutputStream var1, boolean var2) throws IOException;
}

View file

@ -0,0 +1,12 @@
/*
* Decompiled with CFR 0.152.
*/
package com.evilco.mc.nbt.tag;
import com.evilco.mc.nbt.tag.ITag;
import javax.annotation.Nonnull;
public interface ITagContainer
extends ITag {
public void removeTag(@Nonnull ITag var1);
}

View file

@ -0,0 +1,45 @@
/*
* Decompiled with CFR 0.152.
*/
package com.evilco.mc.nbt.tag;
import com.evilco.mc.nbt.stream.NbtInputStream;
import com.evilco.mc.nbt.stream.NbtOutputStream;
import com.evilco.mc.nbt.tag.AbstractTag;
import com.evilco.mc.nbt.tag.TagType;
import java.io.IOException;
import javax.annotation.Nonnull;
public class TagByte
extends AbstractTag {
protected byte value;
public TagByte(@Nonnull String name, byte value) {
super(name);
this.setValue(value);
}
public TagByte(@Nonnull NbtInputStream inputStream, boolean anonymous) throws IOException {
super(inputStream, anonymous);
this.setValue(inputStream.readByte());
}
@Override
public byte getTagID() {
return TagType.BYTE.typeID;
}
public byte getValue() {
return this.value;
}
public void setValue(byte b) {
this.value = b;
}
@Override
public void write(NbtOutputStream outputStream, boolean anonymous) throws IOException {
super.write(outputStream, anonymous);
outputStream.write(this.getValue());
}
}

View file

@ -0,0 +1,51 @@
/*
* Decompiled with CFR 0.152.
*/
package com.evilco.mc.nbt.tag;
import com.evilco.mc.nbt.stream.NbtInputStream;
import com.evilco.mc.nbt.stream.NbtOutputStream;
import com.evilco.mc.nbt.tag.AbstractTag;
import com.evilco.mc.nbt.tag.TagType;
import com.google.common.base.Preconditions;
import java.io.IOException;
import javax.annotation.Nonnull;
public class TagByteArray
extends AbstractTag {
protected byte[] value;
public TagByteArray(@Nonnull String name, @Nonnull byte[] value) {
super(name);
this.setValue(value);
}
public TagByteArray(@Nonnull NbtInputStream inputStream, boolean anonymous) throws IOException {
super(inputStream, anonymous);
int size = inputStream.readInt();
byte[] data = new byte[size];
inputStream.readFully(data);
this.setValue(data);
}
@Override
public byte getTagID() {
return TagType.BYTE_ARRAY.typeID;
}
public byte[] getValue() {
return this.value;
}
public void setValue(@Nonnull byte[] b) {
Preconditions.checkNotNull(b, "b");
this.value = b;
}
@Override
public void write(NbtOutputStream outputStream, boolean anonymous) throws IOException {
super.write(outputStream, anonymous);
outputStream.writeInt(this.value.length);
outputStream.write(this.value);
}
}

View file

@ -0,0 +1,184 @@
/*
* Decompiled with CFR 0.152.
*/
package com.evilco.mc.nbt.tag;
import com.evilco.mc.nbt.error.TagNotFoundException;
import com.evilco.mc.nbt.error.UnexpectedTagTypeException;
import com.evilco.mc.nbt.stream.NbtInputStream;
import com.evilco.mc.nbt.stream.NbtOutputStream;
import com.evilco.mc.nbt.tag.AbstractTag;
import com.evilco.mc.nbt.tag.INamedTagContainer;
import com.evilco.mc.nbt.tag.ITag;
import com.evilco.mc.nbt.tag.TagByte;
import com.evilco.mc.nbt.tag.TagByteArray;
import com.evilco.mc.nbt.tag.TagDouble;
import com.evilco.mc.nbt.tag.TagFloat;
import com.evilco.mc.nbt.tag.TagInteger;
import com.evilco.mc.nbt.tag.TagIntegerArray;
import com.evilco.mc.nbt.tag.TagList;
import com.evilco.mc.nbt.tag.TagLong;
import com.evilco.mc.nbt.tag.TagShort;
import com.evilco.mc.nbt.tag.TagString;
import com.evilco.mc.nbt.tag.TagType;
import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableMap;
import java.io.IOException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.annotation.Nonnull;
public class TagCompound
extends AbstractTag
implements INamedTagContainer {
protected Map<String, ITag> tags = new HashMap<String, ITag>();
public TagCompound(String name) {
super(name);
}
public TagCompound(@Nonnull NbtInputStream inputStream, boolean anonymous) throws IOException {
super(inputStream, anonymous);
while (true) {
byte type;
TagType tagType;
if ((tagType = TagType.valueOf(type = inputStream.readByte())) == null) {
throw new IOException("Could not find a tag for type ID " + type + ".");
}
if (tagType == TagType.END) break;
this.setTag(inputStream.readTag(tagType, false));
}
}
@Override
public ITag getTag(@Nonnull String name) {
Preconditions.checkNotNull(name, "name");
return this.tags.get(name);
}
@Override
public <T extends ITag> T getTag(String name, Class<T> tagClass) throws UnexpectedTagTypeException, TagNotFoundException {
ITag tag = this.getTag(name);
if (tag == null) {
throw new TagNotFoundException("The compound tag is missing a " + name + " entry");
}
if (!tagClass.isInstance(tag)) {
throw new UnexpectedTagTypeException("The compound entry " + name + " should be of type " + tagClass.getSimpleName() + ", but is of type " + tag.getClass().getSimpleName());
}
return (T)tag;
}
public TagCompound getCompound(String name) throws UnexpectedTagTypeException, TagNotFoundException {
return this.getTag(name, TagCompound.class);
}
public int getInteger(String name) throws UnexpectedTagTypeException, TagNotFoundException {
return this.getTag(name, TagInteger.class).getValue();
}
public short getShort(String name) throws UnexpectedTagTypeException, TagNotFoundException {
return this.getTag(name, TagShort.class).getValue();
}
public byte getByte(String name) throws UnexpectedTagTypeException, TagNotFoundException {
return this.getTag(name, TagByte.class).getValue();
}
public long getLong(String name) throws UnexpectedTagTypeException, TagNotFoundException {
return this.getTag(name, TagLong.class).getValue();
}
public double getDouble(String name) throws UnexpectedTagTypeException, TagNotFoundException {
return this.getTag(name, TagDouble.class).getValue();
}
public float getFloat(String name) throws UnexpectedTagTypeException, TagNotFoundException {
return this.getTag(name, TagFloat.class).getValue();
}
public String getString(String name) throws UnexpectedTagTypeException, TagNotFoundException {
return this.getTag(name, TagString.class).getValue();
}
public <T extends ITag> List<T> getList(String name, Class<T> itemClass) throws UnexpectedTagTypeException, TagNotFoundException {
return this.getTag(name, TagList.class).getTags(itemClass);
}
public int[] getIntegerArray(String name) throws UnexpectedTagTypeException, TagNotFoundException {
return this.getTag(name, TagIntegerArray.class).getValues();
}
public byte[] getByteArray(String name) throws UnexpectedTagTypeException, TagNotFoundException {
return this.getTag(name, TagByteArray.class).getValue();
}
public String[] getStringArray(String name) throws UnexpectedTagTypeException, TagNotFoundException {
List<TagString> tags = this.getList(name, TagString.class);
String[] array = new String[tags.size()];
for (int i = 0; i < tags.size(); ++i) {
array[i] = tags.get(i).getValue();
}
return array;
}
public double[] getDoubleArray(String name) throws UnexpectedTagTypeException, TagNotFoundException {
List<TagDouble> tags = this.getList(name, TagDouble.class);
double[] array = new double[tags.size()];
for (int i = 0; i < tags.size(); ++i) {
array[i] = tags.get(i).getValue();
}
return array;
}
public float[] getFloatArray(String name) throws UnexpectedTagTypeException, TagNotFoundException {
List<TagFloat> tags = this.getList(name, TagFloat.class);
float[] array = new float[tags.size()];
for (int i = 0; i < tags.size(); ++i) {
array[i] = tags.get(i).getValue();
}
return array;
}
@Override
public Map<String, ITag> getTags() {
return new ImmutableMap.Builder<String, ITag>().putAll(this.tags).build();
}
@Override
public void removeTag(@Nonnull ITag tag) {
Preconditions.checkNotNull(tag, "tag");
this.tags.remove(tag.getName());
}
@Override
public void removeTag(@Nonnull String tag) {
Preconditions.checkNotNull(tag, "tag");
this.tags.remove(tag);
}
@Override
public void setTag(@Nonnull ITag tag) {
Preconditions.checkNotNull(tag, "tag");
if (this.tags.containsKey(tag)) {
this.tags.get(tag.getName()).setParent(null);
}
this.tags.put(tag.getName(), tag);
tag.setParent(this);
}
@Override
public byte getTagID() {
return TagType.COMPOUND.typeID;
}
@Override
public void write(NbtOutputStream outputStream, boolean anonymous) throws IOException {
super.write(outputStream, anonymous);
for (Map.Entry<String, ITag> tagEntry : this.tags.entrySet()) {
outputStream.writeByte(tagEntry.getValue().getTagID());
tagEntry.getValue().write(outputStream, false);
}
outputStream.writeByte(TagType.END.typeID);
}
}

View file

@ -0,0 +1,45 @@
/*
* Decompiled with CFR 0.152.
*/
package com.evilco.mc.nbt.tag;
import com.evilco.mc.nbt.stream.NbtInputStream;
import com.evilco.mc.nbt.stream.NbtOutputStream;
import com.evilco.mc.nbt.tag.AbstractTag;
import com.evilco.mc.nbt.tag.TagType;
import java.io.IOException;
import javax.annotation.Nonnull;
public class TagDouble
extends AbstractTag {
protected double value;
public TagDouble(@Nonnull String name, double value) {
super(name);
this.setValue(value);
}
public TagDouble(@Nonnull NbtInputStream inputStream, boolean anonymous) throws IOException {
super(inputStream, anonymous);
this.setValue(inputStream.readDouble());
}
@Override
public byte getTagID() {
return TagType.DOUBLE.typeID;
}
public double getValue() {
return this.value;
}
public void setValue(double d) {
this.value = d;
}
@Override
public void write(NbtOutputStream outputStream, boolean anonymous) throws IOException {
super.write(outputStream, anonymous);
outputStream.writeDouble(this.value);
}
}

View file

@ -0,0 +1,45 @@
/*
* Decompiled with CFR 0.152.
*/
package com.evilco.mc.nbt.tag;
import com.evilco.mc.nbt.stream.NbtInputStream;
import com.evilco.mc.nbt.stream.NbtOutputStream;
import com.evilco.mc.nbt.tag.AbstractTag;
import com.evilco.mc.nbt.tag.TagType;
import java.io.IOException;
import javax.annotation.Nonnull;
public class TagFloat
extends AbstractTag {
protected float value;
public TagFloat(@Nonnull String name, float value) {
super(name);
this.setValue(value);
}
public TagFloat(@Nonnull NbtInputStream inputStream, boolean anonymous) throws IOException {
super(inputStream, anonymous);
this.setValue(inputStream.readFloat());
}
@Override
public byte getTagID() {
return TagType.FLOAT.typeID;
}
public float getValue() {
return this.value;
}
public void setValue(float f) {
this.value = f;
}
@Override
public void write(NbtOutputStream outputStream, boolean anonymous) throws IOException {
super.write(outputStream, anonymous);
outputStream.writeFloat(this.value);
}
}

View file

@ -0,0 +1,45 @@
/*
* Decompiled with CFR 0.152.
*/
package com.evilco.mc.nbt.tag;
import com.evilco.mc.nbt.stream.NbtInputStream;
import com.evilco.mc.nbt.stream.NbtOutputStream;
import com.evilco.mc.nbt.tag.AbstractTag;
import com.evilco.mc.nbt.tag.TagType;
import java.io.IOException;
import javax.annotation.Nonnull;
public class TagInteger
extends AbstractTag {
protected int value;
public TagInteger(@Nonnull String name, int value) {
super(name);
this.setValue(value);
}
public TagInteger(@Nonnull NbtInputStream inputStream, boolean anonymous) throws IOException {
super(inputStream, anonymous);
this.setValue(inputStream.readInt());
}
@Override
public byte getTagID() {
return TagType.INTEGER.typeID;
}
public int getValue() {
return this.value;
}
public void setValue(int i) {
this.value = i;
}
@Override
public void write(NbtOutputStream outputStream, boolean anonymous) throws IOException {
super.write(outputStream, anonymous);
outputStream.writeInt(this.value);
}
}

View file

@ -0,0 +1,55 @@
/*
* Decompiled with CFR 0.152.
*/
package com.evilco.mc.nbt.tag;
import com.evilco.mc.nbt.stream.NbtInputStream;
import com.evilco.mc.nbt.stream.NbtOutputStream;
import com.evilco.mc.nbt.tag.AbstractTag;
import com.evilco.mc.nbt.tag.TagType;
import com.google.common.base.Preconditions;
import java.io.IOException;
import javax.annotation.Nonnull;
public class TagIntegerArray
extends AbstractTag {
protected int[] values;
public TagIntegerArray(@Nonnull String name, @Nonnull int[] values) {
super(name);
this.setValues(values);
}
public TagIntegerArray(@Nonnull NbtInputStream inputStream, boolean anonymous) throws IOException {
super(inputStream, anonymous);
int size = inputStream.readInt();
int[] data = new int[size];
for (int i = 0; i < size; ++i) {
data[i] = inputStream.readInt();
}
this.values = data;
}
@Override
public byte getTagID() {
return TagType.INTEGER_ARRAY.typeID;
}
public int[] getValues() {
return this.values;
}
public void setValues(@Nonnull int[] i) {
Preconditions.checkNotNull(i, "i");
this.values = i;
}
@Override
public void write(NbtOutputStream outputStream, boolean anonymous) throws IOException {
super.write(outputStream, anonymous);
outputStream.writeInt(this.values.length);
for (int i : this.values) {
outputStream.writeInt(i);
}
}
}

View file

@ -0,0 +1,96 @@
/*
* Decompiled with CFR 0.152.
*/
package com.evilco.mc.nbt.tag;
import com.evilco.mc.nbt.error.UnexpectedTagTypeException;
import com.evilco.mc.nbt.stream.NbtInputStream;
import com.evilco.mc.nbt.stream.NbtOutputStream;
import com.evilco.mc.nbt.tag.AbstractTag;
import com.evilco.mc.nbt.tag.IAnonymousTagContainer;
import com.evilco.mc.nbt.tag.ITag;
import com.evilco.mc.nbt.tag.TagType;
import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableList;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import javax.annotation.Nonnull;
public class TagList
extends AbstractTag
implements IAnonymousTagContainer {
protected List<ITag> tagList;
public TagList(@Nonnull String name) {
super(name);
this.tagList = new ArrayList<ITag>();
}
public TagList(@Nonnull String name, @Nonnull List<ITag> tagList) {
super(name);
Preconditions.checkNotNull(tagList, "tagList");
this.tagList = tagList;
}
public TagList(@Nonnull NbtInputStream inputStream, boolean anonymous) throws IOException {
super(inputStream, anonymous);
this.tagList = new ArrayList<ITag>();
byte type = inputStream.readByte();
TagType tagType = TagType.valueOf(type);
int size = inputStream.readInt();
if (tagType == TagType.END) {
return;
}
for (int i = 0; i < size; ++i) {
this.addTag(inputStream.readTag(tagType, true));
}
}
@Override
public void addTag(@Nonnull ITag tag) {
this.tagList.add(tag);
}
@Override
public List<ITag> getTags() {
return ((ImmutableList.Builder)new ImmutableList.Builder().addAll(this.tagList)).build();
}
@Override
public <T extends ITag> List<T> getTags(Class<T> tagClass) throws UnexpectedTagTypeException {
ImmutableList.Builder builder = new ImmutableList.Builder();
for (ITag tag : this.tagList) {
if (!tagClass.isInstance(tag)) {
throw new UnexpectedTagTypeException("The list entry should be of type " + tagClass.getSimpleName() + ", but is of type " + tag.getClass().getSimpleName());
}
builder.add(tag);
}
return builder.build();
}
@Override
public byte getTagID() {
return TagType.LIST.typeID;
}
@Override
public void removeTag(@Nonnull ITag tag) {
this.tagList.remove(tag);
}
@Override
public void setTag(int i, @Nonnull ITag tag) {
this.tagList.set(i, tag);
}
@Override
public void write(NbtOutputStream outputStream, boolean anonymous) throws IOException {
super.write(outputStream, anonymous);
outputStream.writeByte(this.tagList.size() > 0 ? this.tagList.get(0).getTagID() : TagType.END.typeID);
outputStream.writeInt(this.tagList.size());
for (ITag tag : this.tagList) {
tag.write(outputStream, true);
}
}
}

View file

@ -0,0 +1,45 @@
/*
* Decompiled with CFR 0.152.
*/
package com.evilco.mc.nbt.tag;
import com.evilco.mc.nbt.stream.NbtInputStream;
import com.evilco.mc.nbt.stream.NbtOutputStream;
import com.evilco.mc.nbt.tag.AbstractTag;
import com.evilco.mc.nbt.tag.TagType;
import java.io.IOException;
import javax.annotation.Nonnull;
public class TagLong
extends AbstractTag {
protected long value;
public TagLong(@Nonnull String name, long value) {
super(name);
this.setValue(value);
}
public TagLong(@Nonnull NbtInputStream inputStream, boolean anonymous) throws IOException {
super(inputStream, anonymous);
this.setValue(inputStream.readLong());
}
@Override
public byte getTagID() {
return TagType.LONG.typeID;
}
public long getValue() {
return this.value;
}
public void setValue(long l) {
this.value = l;
}
@Override
public void write(NbtOutputStream outputStream, boolean anonymous) throws IOException {
super.write(outputStream, anonymous);
outputStream.writeLong(this.value);
}
}

View file

@ -0,0 +1,45 @@
/*
* Decompiled with CFR 0.152.
*/
package com.evilco.mc.nbt.tag;
import com.evilco.mc.nbt.stream.NbtInputStream;
import com.evilco.mc.nbt.stream.NbtOutputStream;
import com.evilco.mc.nbt.tag.AbstractTag;
import com.evilco.mc.nbt.tag.TagType;
import java.io.IOException;
import javax.annotation.Nonnull;
public class TagShort
extends AbstractTag {
protected short value;
public TagShort(@Nonnull String name, short value) {
super(name);
this.setValue(value);
}
public TagShort(@Nonnull NbtInputStream inputStream, boolean anonymous) throws IOException {
super(inputStream, anonymous);
this.setValue(inputStream.readShort());
}
@Override
public byte getTagID() {
return TagType.SHORT.typeID;
}
public short getValue() {
return this.value;
}
public void setValue(short s) {
this.value = s;
}
@Override
public void write(NbtOutputStream outputStream, boolean anonymous) throws IOException {
super.write(outputStream, anonymous);
outputStream.writeShort(this.value);
}
}

View file

@ -0,0 +1,51 @@
/*
* Decompiled with CFR 0.152.
*/
package com.evilco.mc.nbt.tag;
import com.evilco.mc.nbt.stream.NbtInputStream;
import com.evilco.mc.nbt.stream.NbtOutputStream;
import com.evilco.mc.nbt.tag.AbstractTag;
import com.evilco.mc.nbt.tag.ITag;
import com.evilco.mc.nbt.tag.TagType;
import java.io.IOException;
import javax.annotation.Nonnull;
public class TagString
extends AbstractTag {
protected String value;
public TagString(@Nonnull String name, @Nonnull String value) {
super(name);
this.setValue(value);
}
public TagString(@Nonnull NbtInputStream inputStream, boolean anonymous) throws IOException {
super(inputStream, anonymous);
short size = inputStream.readShort();
byte[] data = new byte[size];
inputStream.readFully(data);
this.setValue(new String(data, ITag.STRING_CHARSET));
}
@Override
public byte getTagID() {
return TagType.STRING.typeID;
}
public String getValue() {
return this.value;
}
public void setValue(@Nonnull String s) {
this.value = s;
}
@Override
public void write(NbtOutputStream outputStream, boolean anonymous) throws IOException {
super.write(outputStream, anonymous);
byte[] outputBytes = this.value.getBytes(ITag.STRING_CHARSET);
outputStream.writeShort(outputBytes.length);
outputStream.write(outputBytes);
}
}

View file

@ -0,0 +1,55 @@
/*
* Decompiled with CFR 0.152.
*/
package com.evilco.mc.nbt.tag;
import com.evilco.mc.nbt.tag.ITag;
import com.evilco.mc.nbt.tag.TagByte;
import com.evilco.mc.nbt.tag.TagByteArray;
import com.evilco.mc.nbt.tag.TagCompound;
import com.evilco.mc.nbt.tag.TagDouble;
import com.evilco.mc.nbt.tag.TagFloat;
import com.evilco.mc.nbt.tag.TagInteger;
import com.evilco.mc.nbt.tag.TagIntegerArray;
import com.evilco.mc.nbt.tag.TagList;
import com.evilco.mc.nbt.tag.TagLong;
import com.evilco.mc.nbt.tag.TagShort;
import com.evilco.mc.nbt.tag.TagString;
import com.google.common.collect.ImmutableMap;
import java.util.Map;
public enum TagType {
BYTE(1, TagByte.class),
BYTE_ARRAY(7, TagByteArray.class),
COMPOUND(10, TagCompound.class),
DOUBLE(6, TagDouble.class),
END(0, null),
FLOAT(5, TagFloat.class),
INTEGER(3, TagInteger.class),
INTEGER_ARRAY(11, TagIntegerArray.class),
LIST(9, TagList.class),
LONG(4, TagLong.class),
SHORT(2, TagShort.class),
STRING(8, TagString.class);
protected static final Map<Byte, TagType> typeMap;
public final Class<? extends ITag> tagType;
public final byte typeID;
private TagType(int typeID, Class<? extends ITag> type) {
this.typeID = (byte)typeID;
this.tagType = type;
}
public static TagType valueOf(byte typeID) {
return typeMap.get(typeID);
}
static {
ImmutableMap.Builder<Byte, TagType> mapBuilder = new ImmutableMap.Builder<Byte, TagType>();
for (TagType type : TagType.values()) {
mapBuilder.put(type.typeID, type);
}
typeMap = mapBuilder.build();
}
}