3
0
Mirror von https://github.com/ViaVersion/ViaVersion.git synchronisiert 2024-12-27 08:30:09 +01:00

Update nbt usage

Dieser Commit ist enthalten in:
KennyTV 2021-03-14 16:57:37 +01:00 committet von Nassim
Ursprung 2f7de53e9b
Commit 388eb73782
24 geänderte Dateien mit 212 neuen und 242 gelöschten Zeilen

Datei anzeigen

@ -3,7 +3,7 @@ object Versions {
const val adventure = "4.6.0"
const val gson = "2.8.6"
const val fastUtil = "8.3.1"
const val openNBT = "1.2-SNAPSHOT"
const val openNBT = "2.0-SNAPSHOT"
const val javassist = "3.27.0-GA"
// Common provided

Datei anzeigen

@ -10,7 +10,7 @@ blossom {
dependencies {
api(project(":adventure", "shadow"))
api("it.unimi.dsi", "fastutil", Versions.fastUtil)
api("com.github.steveice10", "opennbt", Versions.openNBT)
api("com.viaversion", "opennbt", Versions.openNBT)
api("com.google.code.gson", "gson", Versions.gson)
compileOnlyApi("org.yaml", "snakeyaml", Versions.snakeYaml)

Datei anzeigen

@ -23,7 +23,6 @@
*/
package us.myles.ViaVersion.api.minecraft.nbt;
import com.github.steveice10.opennbt.tag.TagRegistry;
import com.github.steveice10.opennbt.tag.builtin.CompoundTag;
import org.jetbrains.annotations.NotNull;
@ -109,12 +108,12 @@ public final class BinaryTagIO {
@NotNull
public static CompoundTag readDataInput(final @NotNull DataInput input) throws IOException {
byte type = input.readByte();
if (type != TagRegistry.getIdFor(CompoundTag.class)) {
if (type != CompoundTag.ID) {
throw new IOException(String.format("Expected root tag to be a CompoundTag, was %s", type));
}
input.skipBytes(input.readUnsignedShort()); // read empty name
final CompoundTag compoundTag = new CompoundTag("");
final CompoundTag compoundTag = new CompoundTag();
compoundTag.read(input);
return compoundTag;
}
@ -175,7 +174,7 @@ public final class BinaryTagIO {
* @throws IOException if an exception was encountered while writing the compound tag
*/
public static void writeDataOutput(final @NotNull CompoundTag tag, final @NotNull DataOutput output) throws IOException {
output.writeByte(TagRegistry.getIdFor(CompoundTag.class));
output.writeByte(CompoundTag.ID);
output.writeUTF(""); // write empty name
tag.write(output);
}

Datei anzeigen

@ -33,11 +33,11 @@ import com.github.steveice10.opennbt.tag.builtin.IntTag;
import com.github.steveice10.opennbt.tag.builtin.ListTag;
import com.github.steveice10.opennbt.tag.builtin.LongArrayTag;
import com.github.steveice10.opennbt.tag.builtin.LongTag;
import com.github.steveice10.opennbt.tag.builtin.NumberTag;
import com.github.steveice10.opennbt.tag.builtin.ShortTag;
import com.github.steveice10.opennbt.tag.builtin.StringTag;
import com.github.steveice10.opennbt.tag.builtin.Tag;
import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.IntStream;
@ -46,25 +46,15 @@ import java.util.stream.IntStream;
* See https://github.com/KyoriPowered/adventure.
*/
/* package */ final class TagStringReader {
private static final Field NAME_FIELD = getNameField();
private final CharBuffer buffer;
private static Field getNameField() {
try {
return Tag.class.getDeclaredField("name");
} catch (NoSuchFieldException e) {
e.printStackTrace();
throw new IllegalArgumentException(e);
}
}
public TagStringReader(final CharBuffer buffer) {
this.buffer = buffer;
}
public CompoundTag compound() throws StringTagParseException {
this.buffer.expect(Tokens.COMPOUND_BEGIN);
final CompoundTag compoundTag = new CompoundTag("");
final CompoundTag compoundTag = new CompoundTag();
if (this.buffer.peek() == Tokens.COMPOUND_END) {
this.buffer.take();
return compoundTag;
@ -73,17 +63,7 @@ import java.util.stream.IntStream;
while (this.buffer.hasMore()) {
final String key = this.key();
final Tag tag = this.tag();
// Doesn't get around this with the steveice lib :/
try {
if (!NAME_FIELD.isAccessible()) {
NAME_FIELD.setAccessible(true);
}
NAME_FIELD.set(tag, key);
} catch (IllegalAccessException e) {
throw new IllegalArgumentException(e);
}
compoundTag.put(tag);
compoundTag.put(key, tag);
if (this.separatorOrCompleteWith(Tokens.COMPOUND_END)) {
return compoundTag;
}
@ -92,7 +72,7 @@ import java.util.stream.IntStream;
}
public ListTag list() throws StringTagParseException {
final ListTag listTag = new ListTag("");
final ListTag listTag = new ListTag();
this.buffer.expect(Tokens.ARRAY_BEGIN);
final boolean prefixedIndex = this.buffer.peek() == '0' && this.buffer.peek(1) == ':';
while (this.buffer.hasMore()) {
@ -126,11 +106,11 @@ import java.util.stream.IntStream;
.expect(Tokens.ARRAY_SIGNATURE_SEPARATOR);
if (elementType == Tokens.TYPE_BYTE) {
return new ByteArrayTag("", this.byteArray());
return new ByteArrayTag(this.byteArray());
} else if (elementType == Tokens.TYPE_INT) {
return new IntArrayTag("", this.intArray());
return new IntArrayTag(this.intArray());
} else if (elementType == Tokens.TYPE_LONG) {
return new LongArrayTag("", this.longArray());
return new LongArrayTag(this.longArray());
} else {
throw this.buffer.makeError("Type " + elementType + " is not a valid element type in an array!");
}
@ -164,7 +144,7 @@ import java.util.stream.IntStream;
if (!(value instanceof IntTag)) {
throw this.buffer.makeError("All elements of an int array must be ints!");
}
builder.add(((IntTag) value).getValue());
builder.add(((NumberTag) value).asInt());
if (this.separatorOrCompleteWith(Tokens.ARRAY_END)) {
return builder.build().toArray();
}
@ -226,7 +206,7 @@ import java.util.stream.IntStream;
case Tokens.DOUBLE_QUOTE:
// definitely a string tag
this.buffer.advance();
return new StringTag("", unescape(this.buffer.takeUntil(startToken).toString()));
return new StringTag(unescape(this.buffer.takeUntil(startToken).toString()));
default: // scalar
return this.scalar();
}
@ -251,19 +231,19 @@ import java.util.stream.IntStream;
switch (Character.toUpperCase(current)) { // try to read and return as a number
// case Tokens.TYPE_INTEGER: // handled below, ints are ~special~
case Tokens.TYPE_BYTE:
result = new ByteTag("", Byte.parseByte(builder.toString()));
result = new ByteTag(Byte.parseByte(builder.toString()));
break;
case Tokens.TYPE_SHORT:
result = new ShortTag("", (Short.parseShort(builder.toString())));
result = new ShortTag(Short.parseShort(builder.toString()));
break;
case Tokens.TYPE_LONG:
result = new LongTag("", (Long.parseLong(builder.toString())));
result = new LongTag(Long.parseLong(builder.toString()));
break;
case Tokens.TYPE_FLOAT:
result = new FloatTag("", (Float.parseFloat(builder.toString())));
result = new FloatTag(Float.parseFloat(builder.toString()));
break;
case Tokens.TYPE_DOUBLE:
result = new DoubleTag("", (Double.parseDouble(builder.toString())));
result = new DoubleTag(Double.parseDouble(builder.toString()));
break;
}
} catch (final NumberFormatException ex) {
@ -288,12 +268,12 @@ import java.util.stream.IntStream;
final String built = builder.toString();
if (possiblyNumeric) {
try {
return new IntTag("", Integer.parseInt(built));
return new IntTag(Integer.parseInt(built));
} catch (final NumberFormatException ex) {
// ignore
}
}
return new StringTag("", built);
return new StringTag(built);
}

Datei anzeigen

@ -39,6 +39,7 @@ import com.github.steveice10.opennbt.tag.builtin.Tag;
import java.io.IOException;
import java.io.Writer;
import java.util.Map;
/**
* See https://github.com/KyoriPowered/adventure.
@ -72,17 +73,17 @@ import java.io.Writer;
} else if (tag instanceof StringTag) {
return this.value(((StringTag) tag).getValue(), Tokens.EOF);
} else if (tag instanceof ByteTag) {
return this.value(Byte.toString(((ByteTag) tag).getValue()), Tokens.TYPE_BYTE);
return this.value(Byte.toString(((ByteTag) tag).asByte()), Tokens.TYPE_BYTE);
} else if (tag instanceof ShortTag) {
return this.value(Short.toString(((ShortTag) tag).getValue()), Tokens.TYPE_SHORT);
return this.value(Short.toString(((ShortTag) tag).asShort()), Tokens.TYPE_SHORT);
} else if (tag instanceof IntTag) {
return this.value(Integer.toString(((IntTag) tag).getValue()), Tokens.TYPE_INT);
return this.value(Integer.toString(((IntTag) tag).asInt()), Tokens.TYPE_INT);
} else if (tag instanceof LongTag) {
return this.value(Long.toString(((LongTag) tag).getValue()), Tokens.TYPE_LONG);
return this.value(Long.toString(((LongTag) tag).asLong()), Tokens.TYPE_LONG);
} else if (tag instanceof FloatTag) {
return this.value(Float.toString(((FloatTag) tag).getValue()), Tokens.TYPE_FLOAT);
return this.value(Float.toString(((FloatTag) tag).asFloat()), Tokens.TYPE_FLOAT);
} else if (tag instanceof DoubleTag) {
return this.value(Double.toString(((DoubleTag) tag).getValue()), Tokens.TYPE_DOUBLE);
return this.value(Double.toString(((DoubleTag) tag).asDouble()), Tokens.TYPE_DOUBLE);
} else {
throw new IOException("Unknown tag type: " + tag.getClass().getSimpleName());
// unknown!
@ -91,9 +92,9 @@ import java.io.Writer;
private TagStringWriter writeCompound(final CompoundTag tag) throws IOException {
this.beginCompound();
for (Tag t : tag) {
this.key(t.getName());
this.writeTag(t);
for (Map.Entry<String, Tag> entry : tag.entrySet()) {
this.key(entry.getKey());
this.writeTag(entry.getValue());
}
this.endCompound();
return this;

Datei anzeigen

@ -1,7 +1,6 @@
package us.myles.ViaVersion.api.type.types.minecraft;
import com.github.steveice10.opennbt.NBTIO;
import com.github.steveice10.opennbt.tag.TagRegistry;
import com.github.steveice10.opennbt.tag.builtin.CompoundTag;
import com.google.common.base.Preconditions;
import io.netty.buffer.ByteBuf;
@ -10,17 +9,9 @@ import io.netty.buffer.ByteBufOutputStream;
import us.myles.ViaVersion.api.type.Type;
import java.io.DataInput;
import java.io.DataInputStream;
import java.io.DataOutput;
import java.io.DataOutputStream;
public class NBTType extends Type<CompoundTag> {
static {
// We don't need them
TagRegistry.unregister(60);
TagRegistry.unregister(61);
TagRegistry.unregister(65);
}
public NBTType() {
super(CompoundTag.class);
@ -36,7 +27,7 @@ public class NBTType extends Type<CompoundTag> {
return null;
} else {
buffer.readerIndex(readerIndex);
return (CompoundTag) NBTIO.readTag((DataInput) new ByteBufInputStream(buffer));
return NBTIO.readTag((DataInput) new ByteBufInputStream(buffer));
}
}

Datei anzeigen

@ -116,12 +116,12 @@ public class Protocol1_12To1_11_1 extends Protocol<ClientboundPackets1_9_3, Clie
// Is this a bed?
if (block == 26) {
// NBT -> { color:14, x:132, y:64, z:222, id:"minecraft:bed" } (Debug output)
CompoundTag tag = new CompoundTag("");
tag.put(new IntTag("color", 14)); // Set color to red (Default in previous versions)
tag.put(new IntTag("x", x + (chunk.getX() << 4)));
tag.put(new IntTag("y", y + (i << 4)));
tag.put(new IntTag("z", z + (chunk.getZ() << 4)));
tag.put(new StringTag("id", "minecraft:bed"));
CompoundTag tag = new CompoundTag();
tag.put("color", new IntTag(14)); // Set color to red (Default in previous versions)
tag.put("x", new IntTag(x + (chunk.getX() << 4)));
tag.put("y", new IntTag(y + (i << 4)));
tag.put("z", new IntTag(z + (chunk.getZ() << 4)));
tag.put("id", new StringTag("minecraft:bed"));
// Add a fake block entity
chunk.getBlockEntities().add(tag);

Datei anzeigen

@ -49,7 +49,7 @@ public class ComponentRewriter1_13 extends ComponentRewriter {
ShortTag damageTag = tag.get("Damage");
// Call item converter
short damage = damageTag != null ? damageTag.getValue() : 0;
short damage = damageTag != null ? damageTag.asShort() : 0;
Item item = new Item();
item.setData(damage);
item.setTag(itemTag);
@ -57,10 +57,10 @@ public class ComponentRewriter1_13 extends ComponentRewriter {
// Serialize again
if (damage != item.getData()) {
tag.put(new ShortTag("Damage", item.getData()));
tag.put("Damage", new ShortTag(item.getData()));
}
if (itemTag != null) {
tag.put(itemTag);
tag.put("tag", itemTag);
}
JsonArray array = new JsonArray();

Datei anzeigen

@ -4,6 +4,7 @@ import com.github.steveice10.opennbt.conversion.ConverterRegistry;
import com.github.steveice10.opennbt.tag.builtin.CompoundTag;
import com.github.steveice10.opennbt.tag.builtin.IntTag;
import com.github.steveice10.opennbt.tag.builtin.ListTag;
import com.github.steveice10.opennbt.tag.builtin.NumberTag;
import com.github.steveice10.opennbt.tag.builtin.ShortTag;
import com.github.steveice10.opennbt.tag.builtin.StringTag;
import com.github.steveice10.opennbt.tag.builtin.Tag;
@ -263,12 +264,12 @@ public class InventoryPackets {
// NBT Additions
if (isDamageable(item.getIdentifier())) {
if (tag == null) item.setTag(tag = new CompoundTag("tag"));
tag.put(new IntTag("Damage", item.getData()));
if (tag == null) item.setTag(tag = new CompoundTag());
tag.put("Damage", new IntTag(item.getData()));
}
if (item.getIdentifier() == 358) { // map
if (tag == null) item.setTag(tag = new CompoundTag("tag"));
tag.put(new IntTag("map", item.getData()));
if (tag == null) item.setTag(tag = new CompoundTag());
tag.put("map", new IntTag(item.getData()));
}
// NBT Changes
@ -282,16 +283,16 @@ public class InventoryPackets {
IntTag base = blockEntityTag.get("Base");
// Set banner item id according to nbt
if (banner) {
rawId = 6800 + base.getValue();
rawId = 6800 + base.asInt();
}
base.setValue(15 - base.getValue());
base.setValue(15 - base.asInt());
}
if (blockEntityTag.get("Patterns") instanceof ListTag) {
for (Tag pattern : (ListTag) blockEntityTag.get("Patterns")) {
if (pattern instanceof CompoundTag) {
IntTag c = ((CompoundTag) pattern).get("Color");
c.setValue(15 - c.getValue()); // Invert color id
c.setValue(15 - c.asInt()); // Invert color id
}
}
}
@ -302,55 +303,53 @@ public class InventoryPackets {
CompoundTag display = tag.get("display");
if (display.get("Name") instanceof StringTag) {
StringTag name = display.get("Name");
display.put(new StringTag(NBT_TAG_NAME + "|Name", name.getValue()));
display.put(NBT_TAG_NAME + "|Name", new StringTag(name.getValue()));
name.setValue(ChatRewriter.legacyTextToJsonString(name.getValue(), true));
}
}
// ench is now Enchantments and now uses identifiers
if (tag.get("ench") instanceof ListTag) {
ListTag ench = tag.get("ench");
ListTag enchantments = new ListTag("Enchantments", CompoundTag.class);
ListTag enchantments = new ListTag(CompoundTag.class);
for (Tag enchEntry : ench) {
if (enchEntry instanceof CompoundTag) {
CompoundTag enchantmentEntry = new CompoundTag("");
short oldId = ((Number) ((CompoundTag) enchEntry).get("id").getValue()).shortValue();
CompoundTag enchantmentEntry = new CompoundTag();
short oldId = ((NumberTag) ((CompoundTag) enchEntry).get("id")).asShort();
String newId = Protocol1_13To1_12_2.MAPPINGS.getOldEnchantmentsIds().get(oldId);
if (newId == null) {
newId = "viaversion:legacy/" + oldId;
}
enchantmentEntry.put(new StringTag("id", newId));
enchantmentEntry.put(new ShortTag("lvl", ((Number) ((CompoundTag) enchEntry).get("lvl").getValue()).shortValue()));
enchantmentEntry.put("id", new StringTag(newId));
enchantmentEntry.put("lvl", new ShortTag(((NumberTag) ((CompoundTag) enchEntry).get("lvl")).asShort()));
enchantments.add(enchantmentEntry);
}
}
tag.remove("ench");
tag.put(enchantments);
tag.put("Enchantments", enchantments);
}
if (tag.get("StoredEnchantments") instanceof ListTag) {
ListTag storedEnch = tag.get("StoredEnchantments");
ListTag newStoredEnch = new ListTag("StoredEnchantments", CompoundTag.class);
ListTag newStoredEnch = new ListTag(CompoundTag.class);
for (Tag enchEntry : storedEnch) {
if (enchEntry instanceof CompoundTag) {
CompoundTag enchantmentEntry = new CompoundTag("");
short oldId = ((Number) ((CompoundTag) enchEntry).get("id").getValue()).shortValue();
CompoundTag enchantmentEntry = new CompoundTag();
short oldId = ((NumberTag) ((CompoundTag) enchEntry).get("id")).asShort();
String newId = Protocol1_13To1_12_2.MAPPINGS.getOldEnchantmentsIds().get(oldId);
if (newId == null) {
newId = "viaversion:legacy/" + oldId;
}
enchantmentEntry.put(new StringTag("id",
newId
));
enchantmentEntry.put(new ShortTag("lvl", ((Number) ((CompoundTag) enchEntry).get("lvl").getValue()).shortValue()));
enchantmentEntry.put("id", new StringTag(newId));
enchantmentEntry.put("lvl", new ShortTag(((NumberTag) ((CompoundTag) enchEntry).get("lvl")).asShort()));
newStoredEnch.add(enchantmentEntry);
}
}
tag.remove("StoredEnchantments");
tag.put(newStoredEnch);
tag.put("StoredEnchantments", newStoredEnch);
}
if (tag.get("CanPlaceOn") instanceof ListTag) {
ListTag old = tag.get("CanPlaceOn");
ListTag newCanPlaceOn = new ListTag("CanPlaceOn", StringTag.class);
tag.put(ConverterRegistry.convertToTag(NBT_TAG_NAME + "|CanPlaceOn", ConverterRegistry.convertToValue(old))); // There will be data losing
ListTag newCanPlaceOn = new ListTag(StringTag.class);
tag.put(NBT_TAG_NAME + "|CanPlaceOn", ConverterRegistry.convertToTag(ConverterRegistry.convertToValue(old))); // There will be data losing
for (Tag oldTag : old) {
Object value = oldTag.getValue();
String oldId = value.toString().replace("minecraft:", "");
@ -361,18 +360,18 @@ public class InventoryPackets {
String[] newValues = BlockIdData.blockIdMapping.get(oldId.toLowerCase(Locale.ROOT));
if (newValues != null) {
for (String newValue : newValues) {
newCanPlaceOn.add(new StringTag("", newValue));
newCanPlaceOn.add(new StringTag(newValue));
}
} else {
newCanPlaceOn.add(new StringTag("", oldId.toLowerCase(Locale.ROOT)));
newCanPlaceOn.add(new StringTag(oldId.toLowerCase(Locale.ROOT)));
}
}
tag.put(newCanPlaceOn);
tag.put("CanPlaceOn", newCanPlaceOn);
}
if (tag.get("CanDestroy") instanceof ListTag) {
ListTag old = tag.get("CanDestroy");
ListTag newCanDestroy = new ListTag("CanDestroy", StringTag.class);
tag.put(ConverterRegistry.convertToTag(NBT_TAG_NAME + "|CanDestroy", ConverterRegistry.convertToValue(old))); // There will be data losing
ListTag newCanDestroy = new ListTag(StringTag.class);
tag.put(NBT_TAG_NAME + "|CanDestroy", ConverterRegistry.convertToTag(ConverterRegistry.convertToValue(old))); // There will be data losing
for (Tag oldTag : old) {
Object value = oldTag.getValue();
String oldId = value.toString().replace("minecraft:", "");
@ -383,13 +382,13 @@ public class InventoryPackets {
String[] newValues = BlockIdData.blockIdMapping.get(oldId.toLowerCase(Locale.ROOT));
if (newValues != null) {
for (String newValue : newValues) {
newCanDestroy.add(new StringTag("", newValue));
newCanDestroy.add(new StringTag(newValue));
}
} else {
newCanDestroy.add(new StringTag("", oldId.toLowerCase(Locale.ROOT)));
newCanDestroy.add(new StringTag(oldId.toLowerCase(Locale.ROOT)));
}
}
tag.put(newCanDestroy);
tag.put("CanDestroy", newCanDestroy);
}
// Handle SpawnEggs
if (item.getIdentifier() == 383) {
@ -421,8 +420,8 @@ public class InventoryPackets {
if (!Protocol1_13To1_12_2.MAPPINGS.getItemMappings().containsKey(rawId)) {
if (!isDamageable(item.getIdentifier()) && item.getIdentifier() != 358) { // Map
if (tag == null) item.setTag(tag = new CompoundTag("tag"));
tag.put(new IntTag(NBT_TAG_NAME, originalId)); // Data will be lost, saving original id
if (tag == null) item.setTag(tag = new CompoundTag());
tag.put(NBT_TAG_NAME, new IntTag(originalId)); // Data will be lost, saving original id
}
if (item.getIdentifier() == 31 && item.getData() == 0) { // Shrub was removed
rawId = 32 << 4; // Dead Bush
@ -495,11 +494,11 @@ public class InventoryPackets {
if (eggEntityId.isPresent()) {
rawId = 383 << 16;
if (tag == null)
item.setTag(tag = new CompoundTag("tag"));
item.setTag(tag = new CompoundTag());
if (!tag.contains("EntityTag")) {
CompoundTag entityTag = new CompoundTag("EntityTag");
entityTag.put(new StringTag("id", eggEntityId.get()));
tag.put(entityTag);
CompoundTag entityTag = new CompoundTag();
entityTag.put("id", new StringTag(eggEntityId.get()));
tag.put("EntityTag", entityTag);
}
} else {
rawId = (oldId >> 4) << 16 | oldId & 0xF;
@ -542,13 +541,13 @@ public class InventoryPackets {
CompoundTag blockEntityTag = tag.get("BlockEntityTag");
if (blockEntityTag.get("Base") instanceof IntTag) {
IntTag base = blockEntityTag.get("Base");
base.setValue(15 - base.getValue()); // invert color id
base.setValue(15 - base.asInt()); // invert color id
}
if (blockEntityTag.get("Patterns") instanceof ListTag) {
for (Tag pattern : (ListTag) blockEntityTag.get("Patterns")) {
if (pattern instanceof CompoundTag) {
IntTag c = ((CompoundTag) pattern).get("Color");
c.setValue(15 - c.getValue()); // Invert color id
c.setValue(15 - c.asInt()); // Invert color id
}
}
}
@ -567,55 +566,52 @@ public class InventoryPackets {
// ench is now Enchantments and now uses identifiers
if (tag.get("Enchantments") instanceof ListTag) {
ListTag enchantments = tag.get("Enchantments");
ListTag ench = new ListTag("ench", CompoundTag.class);
ListTag ench = new ListTag(CompoundTag.class);
for (Tag enchantmentEntry : enchantments) {
if (enchantmentEntry instanceof CompoundTag) {
CompoundTag enchEntry = new CompoundTag("");
CompoundTag enchEntry = new CompoundTag();
String newId = (String) ((CompoundTag) enchantmentEntry).get("id").getValue();
Short oldId = Protocol1_13To1_12_2.MAPPINGS.getOldEnchantmentsIds().inverse().get(newId);
if (oldId == null && newId.startsWith("viaversion:legacy/")) {
oldId = Short.valueOf(newId.substring(18));
}
if (oldId != null) {
enchEntry.put(new ShortTag("id", oldId));
enchEntry.put(new ShortTag("lvl", (Short) ((CompoundTag) enchantmentEntry).get("lvl").getValue()));
enchEntry.put("id", new ShortTag(oldId));
enchEntry.put("lvl", new ShortTag((Short) ((CompoundTag) enchantmentEntry).get("lvl").getValue()));
ench.add(enchEntry);
}
}
}
tag.remove("Enchantments");
tag.put(ench);
tag.put("ench", ench);
}
if (tag.get("StoredEnchantments") instanceof ListTag) {
ListTag storedEnch = tag.get("StoredEnchantments");
ListTag newStoredEnch = new ListTag("StoredEnchantments", CompoundTag.class);
ListTag newStoredEnch = new ListTag(CompoundTag.class);
for (Tag enchantmentEntry : storedEnch) {
if (enchantmentEntry instanceof CompoundTag) {
CompoundTag enchEntry = new CompoundTag("");
CompoundTag enchEntry = new CompoundTag();
String newId = (String) ((CompoundTag) enchantmentEntry).get("id").getValue();
Short oldId = Protocol1_13To1_12_2.MAPPINGS.getOldEnchantmentsIds().inverse().get(newId);
if (oldId == null && newId.startsWith("viaversion:legacy/")) {
oldId = Short.valueOf(newId.substring(18));
}
if (oldId != null) {
enchEntry.put(new ShortTag("id", oldId));
enchEntry.put(new ShortTag("lvl", (Short) ((CompoundTag) enchantmentEntry).get("lvl").getValue()));
enchEntry.put("id", new ShortTag(oldId));
enchEntry.put("lvl", new ShortTag((Short) ((CompoundTag) enchantmentEntry).get("lvl").getValue()));
newStoredEnch.add(enchEntry);
}
}
}
tag.remove("StoredEnchantments");
tag.put(newStoredEnch);
tag.put("StoredEnchantments", newStoredEnch);
}
if (tag.get(NBT_TAG_NAME + "|CanPlaceOn") instanceof ListTag) {
tag.put(ConverterRegistry.convertToTag(
"CanPlaceOn",
ConverterRegistry.convertToValue(tag.get(NBT_TAG_NAME + "|CanPlaceOn"))
));
tag.put("CanPlaceOn", ConverterRegistry.convertToTag(ConverterRegistry.convertToValue(tag.get(NBT_TAG_NAME + "|CanPlaceOn"))));
tag.remove(NBT_TAG_NAME + "|CanPlaceOn");
} else if (tag.get("CanPlaceOn") instanceof ListTag) {
ListTag old = tag.get("CanPlaceOn");
ListTag newCanPlaceOn = new ListTag("CanPlaceOn", StringTag.class);
ListTag newCanPlaceOn = new ListTag(StringTag.class);
for (Tag oldTag : old) {
Object value = oldTag.getValue();
String[] newValues = BlockIdData.fallbackReverseMapping.get(value instanceof String
@ -623,23 +619,22 @@ public class InventoryPackets {
: null);
if (newValues != null) {
for (String newValue : newValues) {
newCanPlaceOn.add(new StringTag("", newValue));
newCanPlaceOn.add(new StringTag(newValue));
}
} else {
newCanPlaceOn.add(oldTag);
}
}
tag.put(newCanPlaceOn);
tag.put("CanPlaceOn", newCanPlaceOn);
}
if (tag.get(NBT_TAG_NAME + "|CanDestroy") instanceof ListTag) {
tag.put(ConverterRegistry.convertToTag(
"CanDestroy",
tag.put("CanDestroy", ConverterRegistry.convertToTag(
ConverterRegistry.convertToValue(tag.get(NBT_TAG_NAME + "|CanDestroy"))
));
tag.remove(NBT_TAG_NAME + "|CanDestroy");
} else if (tag.get("CanDestroy") instanceof ListTag) {
ListTag old = tag.get("CanDestroy");
ListTag newCanDestroy = new ListTag("CanDestroy", StringTag.class);
ListTag newCanDestroy = new ListTag(StringTag.class);
for (Tag oldTag : old) {
Object value = oldTag.getValue();
String[] newValues = BlockIdData.fallbackReverseMapping.get(value instanceof String
@ -647,13 +642,13 @@ public class InventoryPackets {
: null);
if (newValues != null) {
for (String newValue : newValues) {
newCanDestroy.add(new StringTag("", newValue));
newCanDestroy.add(new StringTag(newValue));
}
} else {
newCanDestroy.add(oldTag);
}
}
tag.put(newCanDestroy);
tag.put("CanDestroy", newCanDestroy);
}
}
}

Datei anzeigen

@ -30,7 +30,7 @@ public class BannerHandler implements BlockEntityProvider.BlockEntityHandler {
Tag base = tag.get("Base");
int color = 0;
if (base != null) {
color = ((Number) tag.get("Base").getValue()).intValue();
color = ((NumberTag) tag.get("Base")).asInt();
}
// Standing banner
if (blockId >= BANNER_START && blockId <= BANNER_STOP) {

Datei anzeigen

@ -1,6 +1,7 @@
package us.myles.ViaVersion.protocols.protocol1_13to1_12_2.providers.blockentities;
import com.github.steveice10.opennbt.tag.builtin.CompoundTag;
import com.github.steveice10.opennbt.tag.builtin.NumberTag;
import com.github.steveice10.opennbt.tag.builtin.Tag;
import us.myles.ViaVersion.api.Via;
import us.myles.ViaVersion.api.data.UserConnection;
@ -25,13 +26,13 @@ public class BedHandler implements BlockEntityProvider.BlockEntityHandler {
Tag color = tag.get("color");
if (color != null) {
blockId += (((Number) color.getValue()).intValue() * 16);
blockId += (((NumberTag) color).asInt() * 16);
}
return blockId;
}
private long getLong(Tag tag) {
return ((Integer) tag.getValue()).longValue();
private long getLong(NumberTag tag) {
return tag.asLong();
}
}

Datei anzeigen

@ -1,6 +1,7 @@
package us.myles.ViaVersion.protocols.protocol1_13to1_12_2.providers.blockentities;
import com.github.steveice10.opennbt.tag.builtin.CompoundTag;
import com.github.steveice10.opennbt.tag.builtin.NumberTag;
import com.github.steveice10.opennbt.tag.builtin.Tag;
import us.myles.ViaVersion.api.Via;
import us.myles.ViaVersion.api.data.UserConnection;
@ -26,10 +27,10 @@ public class SkullHandler implements BlockEntityProvider.BlockEntityHandler {
if (id >= SKULL_WALL_START && id <= SKULL_END) {
Tag skullType = tag.get("SkullType");
if (skullType != null) {
id += ((Number) tag.get("SkullType").getValue()).intValue() * 20;
id += ((NumberTag) tag.get("SkullType")).asInt() * 20;
}
if (tag.contains("Rot")) {
id += ((Number) tag.get("Rot").getValue()).intValue();
id += ((NumberTag) tag.get("Rot")).asInt();
}
} else {
Via.getPlatform().getLogger().warning("Why does this block have the skull block entity? " + tag);

Datei anzeigen

@ -217,8 +217,8 @@ public class InventoryPackets {
resyncPacket.write(Type.BYTE, (byte) 2); // 2 - Button - End left click
resyncPacket.write(Type.SHORT, ((short) ThreadLocalRandom.current().nextInt())); // 3 - Action number
resyncPacket.write(Type.VAR_INT, 5); // 4 - Mode - Drag
CompoundTag tag = new CompoundTag("");
tag.put(new DoubleTag("force_resync", Double.NaN)); // Tags with NaN are not equal
CompoundTag tag = new CompoundTag();
tag.put("force_resync", new DoubleTag(Double.NaN)); // Tags with NaN are not equal
resyncPacket.write(Type.FLAT_VAR_INT_ITEM, new Item(1, (byte) 1, (short) 0, tag)); // 5 - Clicked Item
resyncPacket.sendToServer(Protocol1_14To1_13_2.class, true, false);
}
@ -244,7 +244,7 @@ public class InventoryPackets {
Tag loreTag = display.get("Lore");
if (loreTag instanceof ListTag) {
ListTag lore = (ListTag) loreTag;
display.put(new ListTag(NBT_TAG_NAME + "|Lore", lore.clone().getValue())); // Save old lore
display.put(NBT_TAG_NAME + "|Lore", new ListTag(lore.clone().getValue())); // Save old lore
for (Tag loreEntry : lore) {
if (loreEntry instanceof StringTag) {
String jsonText = ChatRewriter.legacyTextToJsonString(((StringTag) loreEntry).getValue(), true);
@ -270,7 +270,7 @@ public class InventoryPackets {
ListTag lore = (ListTag) loreTag;
ListTag savedLore = display.remove(NBT_TAG_NAME + "|Lore");
if (savedLore != null) {
display.put(new ListTag("Lore", savedLore.getValue()));
display.put("Lore", new ListTag(savedLore.getValue()));
} else {
for (Tag loreEntry : lore) {
if (loreEntry instanceof StringTag) {

Datei anzeigen

@ -176,9 +176,9 @@ public class WorldPackets {
section.setNonAirBlocksCount(nonAirBlockCount);
}
CompoundTag heightMap = new CompoundTag("");
heightMap.put(new LongArrayTag("MOTION_BLOCKING", encodeHeightMap(motionBlocking)));
heightMap.put(new LongArrayTag("WORLD_SURFACE", encodeHeightMap(worldSurface)));
CompoundTag heightMap = new CompoundTag();
heightMap.put("MOTION_BLOCKING", new LongArrayTag(encodeHeightMap(motionBlocking)));
heightMap.put("WORLD_SURFACE", new LongArrayTag(encodeHeightMap(worldSurface)));
chunk.setHeightMap(heightMap);
PacketWrapper lightPacket = wrapper.create(0x24);

Datei anzeigen

@ -35,7 +35,7 @@ public class MappingData extends us.myles.ViaVersion.api.data.MappingData {
for (Tag dimension : dimensions) {
CompoundTag dimensionCompound = (CompoundTag) dimension;
// Copy with an empty name
CompoundTag dimensionData = new CompoundTag("", ((CompoundTag) dimensionCompound.get("element")).getValue());
CompoundTag dimensionData = new CompoundTag(((CompoundTag) dimensionCompound.get("element")).getValue());
dimensionDataMap.put(((StringTag) dimensionCompound.get("name")).getValue(), dimensionData);
}
}

Datei anzeigen

@ -46,83 +46,83 @@ public class EntityPackets {
wrapper.write(Type.STRING, dimensionName); // dimension
wrapper.write(Type.STRING, dimensionName); // world
};
public static final CompoundTag DIMENSIONS_TAG = new CompoundTag("");
public static final CompoundTag DIMENSIONS_TAG = new CompoundTag();
private static final String[] WORLD_NAMES = {"minecraft:overworld", "minecraft:the_nether", "minecraft:the_end"};
static {
ListTag list = new ListTag("dimension", CompoundTag.class);
ListTag list = new ListTag(CompoundTag.class);
list.add(createOverworldEntry());
list.add(createOverworldCavesEntry());
list.add(createNetherEntry());
list.add(createEndEntry());
DIMENSIONS_TAG.put(list);
DIMENSIONS_TAG.put("dimension", list);
}
private static CompoundTag createOverworldEntry() {
CompoundTag tag = new CompoundTag("");
tag.put(new StringTag("name", "minecraft:overworld"));
tag.put(new ByteTag("has_ceiling", (byte) 0));
CompoundTag tag = new CompoundTag();
tag.put("name", new StringTag("minecraft:overworld"));
tag.put("has_ceiling", new ByteTag((byte) 0));
addSharedOverwaldEntries(tag);
return tag;
}
private static CompoundTag createOverworldCavesEntry() {
CompoundTag tag = new CompoundTag("");
tag.put(new StringTag("name", "minecraft:overworld_caves"));
tag.put(new ByteTag("has_ceiling", (byte) 1));
CompoundTag tag = new CompoundTag();
tag.put("name", new StringTag("minecraft:overworld_caves"));
tag.put("has_ceiling", new ByteTag((byte) 1));
addSharedOverwaldEntries(tag);
return tag;
}
private static void addSharedOverwaldEntries(CompoundTag tag) {
tag.put(new ByteTag("piglin_safe", (byte) 0));
tag.put(new ByteTag("natural", (byte) 1));
tag.put(new FloatTag("ambient_light", 0));
tag.put(new StringTag("infiniburn", "minecraft:infiniburn_overworld"));
tag.put(new ByteTag("respawn_anchor_works", (byte) 0));
tag.put(new ByteTag("has_skylight", (byte) 1));
tag.put(new ByteTag("bed_works", (byte) 1));
tag.put(new ByteTag("has_raids", (byte) 1));
tag.put(new IntTag("logical_height", 256));
tag.put(new ByteTag("shrunk", (byte) 0));
tag.put(new ByteTag("ultrawarm", (byte) 0));
tag.put("piglin_safe", new ByteTag((byte) 0));
tag.put("natural", new ByteTag((byte) 1));
tag.put("ambient_light", new FloatTag(0));
tag.put("infiniburn", new StringTag("minecraft:infiniburn_overworld"));
tag.put("respawn_anchor_works", new ByteTag((byte) 0));
tag.put("has_skylight", new ByteTag((byte) 1));
tag.put("bed_works", new ByteTag((byte) 1));
tag.put("has_raids", new ByteTag((byte) 1));
tag.put("logical_height", new IntTag(256));
tag.put("shrunk", new ByteTag((byte) 0));
tag.put("ultrawarm", new ByteTag((byte) 0));
}
private static CompoundTag createNetherEntry() {
CompoundTag tag = new CompoundTag("");
tag.put(new ByteTag("piglin_safe", (byte) 1));
tag.put(new ByteTag("natural", (byte) 0));
tag.put(new FloatTag("ambient_light", 0.1F));
tag.put(new StringTag("infiniburn", "minecraft:infiniburn_nether"));
tag.put(new ByteTag("respawn_anchor_works", (byte) 1));
tag.put(new ByteTag("has_skylight", (byte) 0));
tag.put(new ByteTag("bed_works", (byte) 0));
tag.put(new LongTag("fixed_time", 18000));
tag.put(new ByteTag("has_raids", (byte) 0));
tag.put(new StringTag("name", "minecraft:the_nether"));
tag.put(new IntTag("logical_height", 128));
tag.put(new ByteTag("shrunk", (byte) 1));
tag.put(new ByteTag("ultrawarm", (byte) 1));
tag.put(new ByteTag("has_ceiling", (byte) 1));
CompoundTag tag = new CompoundTag();
tag.put("piglin_safe", new ByteTag((byte) 1));
tag.put("natural", new ByteTag((byte) 0));
tag.put("ambient_light",new FloatTag( 0.1F));
tag.put("infiniburn", new StringTag("minecraft:infiniburn_nether"));
tag.put("respawn_anchor_works", new ByteTag((byte) 1));
tag.put("has_skylight", new ByteTag((byte) 0));
tag.put("bed_works", new ByteTag((byte) 0));
tag.put("fixed_time", new LongTag(18000));
tag.put("has_raids", new ByteTag((byte) 0));
tag.put("name", new StringTag("minecraft:the_nether"));
tag.put("logical_height", new IntTag(128));
tag.put("shrunk", new ByteTag((byte) 1));
tag.put("ultrawarm", new ByteTag((byte) 1));
tag.put("has_ceiling", new ByteTag((byte) 1));
return tag;
}
private static CompoundTag createEndEntry() {
CompoundTag tag = new CompoundTag("");
tag.put(new ByteTag("piglin_safe", (byte) 0));
tag.put(new ByteTag("natural", (byte) 0));
tag.put(new FloatTag("ambient_light", 0));
tag.put(new StringTag("infiniburn", "minecraft:infiniburn_end"));
tag.put(new ByteTag("respawn_anchor_works", (byte) 0));
tag.put(new ByteTag("has_skylight", (byte) 0));
tag.put(new ByteTag("bed_works", (byte) 0));
tag.put(new LongTag("fixed_time", 6000));
tag.put(new ByteTag("has_raids", (byte) 1));
tag.put(new StringTag("name", "minecraft:the_end"));
tag.put(new IntTag("logical_height", 256));
tag.put(new ByteTag("shrunk", (byte) 0));
tag.put(new ByteTag("ultrawarm", (byte) 0));
tag.put(new ByteTag("has_ceiling", (byte) 0));
CompoundTag tag = new CompoundTag();
tag.put("piglin_safe", new ByteTag((byte) 0));
tag.put("natural", new ByteTag((byte) 0));
tag.put("ambient_light", new FloatTag(0));
tag.put("infiniburn", new StringTag("minecraft:infiniburn_end"));
tag.put("respawn_anchor_works", new ByteTag((byte) 0));
tag.put("has_skylight", new ByteTag((byte) 0));
tag.put("bed_works", new ByteTag((byte) 0));
tag.put("fixed_time", new LongTag(6000));
tag.put("has_raids", new ByteTag((byte) 1));
tag.put("name", new StringTag("minecraft:the_end"));
tag.put("logical_height", new IntTag(256));
tag.put("shrunk", new ByteTag((byte) 0));
tag.put("ultrawarm", new ByteTag((byte) 0));
tag.put("has_ceiling", new ByteTag((byte) 0));
return tag;
}

Datei anzeigen

@ -4,6 +4,7 @@ import com.github.steveice10.opennbt.tag.builtin.CompoundTag;
import com.github.steveice10.opennbt.tag.builtin.IntArrayTag;
import com.github.steveice10.opennbt.tag.builtin.ListTag;
import com.github.steveice10.opennbt.tag.builtin.LongTag;
import com.github.steveice10.opennbt.tag.builtin.NumberTag;
import com.github.steveice10.opennbt.tag.builtin.StringTag;
import com.github.steveice10.opennbt.tag.builtin.Tag;
import us.myles.ViaVersion.api.minecraft.item.Item;
@ -131,7 +132,7 @@ public class InventoryPackets {
Tag idTag = ownerCompundTag.get("Id");
if (idTag instanceof StringTag) {
UUID id = UUID.fromString((String) idTag.getValue());
ownerCompundTag.put(new IntArrayTag("Id", UUIDIntArrayType.uuidToIntArray(id)));
ownerCompundTag.put("Id", new IntArrayTag(UUIDIntArrayType.uuidToIntArray(id)));
}
}
}
@ -153,7 +154,7 @@ public class InventoryPackets {
Tag idTag = ownerCompundTag.get("Id");
if (idTag instanceof IntArrayTag) {
UUID id = UUIDIntArrayType.uuidFromIntArray((int[]) idTag.getValue());
ownerCompundTag.put(new StringTag("Id", id.toString()));
ownerCompundTag.put("Id", new StringTag(id.toString()));
}
}
}
@ -174,8 +175,8 @@ public class InventoryPackets {
Tag leastTag = attribute.get("UUIDLeast");
if (leastTag != null) {
Tag mostTag = attribute.get("UUIDMost");
int[] uuidIntArray = UUIDIntArrayType.bitsToIntArray(((Number) leastTag.getValue()).longValue(), ((Number) mostTag.getValue()).longValue());
attribute.put(new IntArrayTag("UUID", uuidIntArray));
int[] uuidIntArray = UUIDIntArrayType.bitsToIntArray(((NumberTag) leastTag).asLong(), ((NumberTag) mostTag).asLong());
attribute.put("UUID", new IntArrayTag(uuidIntArray));
}
}
}
@ -193,8 +194,8 @@ public class InventoryPackets {
IntArrayTag uuidTag = attribute.get("UUID");
if (uuidTag != null) {
UUID uuid = UUIDIntArrayType.uuidFromIntArray(uuidTag.getValue());
attribute.put(new LongTag("UUIDLeast", uuid.getLeastSignificantBits()));
attribute.put(new LongTag("UUIDMost", uuid.getMostSignificantBits()));
attribute.put("UUIDLeast", new LongTag(uuid.getLeastSignificantBits()));
attribute.put("UUIDMost", new LongTag(uuid.getMostSignificantBits()));
}
}
}

Datei anzeigen

@ -18,6 +18,7 @@ import us.myles.ViaVersion.protocols.protocol1_16to1_15_2.Protocol1_16To1_15_2;
import us.myles.ViaVersion.protocols.protocol1_16to1_15_2.types.Chunk1_16Type;
import us.myles.ViaVersion.util.CompactArrayUtil;
import java.util.Map;
import java.util.UUID;
public class WorldPackets {
@ -58,7 +59,7 @@ public class WorldPackets {
}
CompoundTag heightMaps = chunk.getHeightMap();
for (Tag heightMapTag : heightMaps) {
for (Tag heightMapTag : heightMaps.values()) {
LongArrayTag heightMap = (LongArrayTag) heightMapTag;
int[] heightMapData = new int[256];
CompactArrayUtil.iterateCompactArray(9, heightMapData.length, heightMap.getValue(), (i, v) -> heightMapData[i] = v);
@ -99,21 +100,21 @@ public class WorldPackets {
// target_uuid -> Target
UUID targetUuid = UUID.fromString((String) targetUuidTag.getValue());
compoundTag.put(new IntArrayTag("Target", UUIDIntArrayType.uuidToIntArray(targetUuid)));
compoundTag.put("Target", new IntArrayTag(UUIDIntArrayType.uuidToIntArray(targetUuid)));
} else if (id.equals("minecraft:skull") && compoundTag.get("Owner") instanceof CompoundTag) {
CompoundTag ownerTag = compoundTag.remove("Owner");
StringTag ownerUuidTag = ownerTag.remove("Id");
if (ownerUuidTag != null) {
UUID ownerUuid = UUID.fromString(ownerUuidTag.getValue());
ownerTag.put(new IntArrayTag("Id", UUIDIntArrayType.uuidToIntArray(ownerUuid)));
ownerTag.put("Id", new IntArrayTag(UUIDIntArrayType.uuidToIntArray(ownerUuid)));
}
// Owner -> SkullOwner
CompoundTag skullOwnerTag = new CompoundTag("SkullOwner");
for (Tag tag : ownerTag) {
skullOwnerTag.put(tag);
CompoundTag skullOwnerTag = new CompoundTag();
for (Map.Entry<String, Tag> entry : ownerTag.entrySet()) {
skullOwnerTag.put(entry.getKey(), entry.getValue());
}
compoundTag.put(skullOwnerTag);
compoundTag.put("SkullOwner", skullOwnerTag);
}
}
}

Datei anzeigen

@ -216,7 +216,7 @@ public class WorldPackets {
}
private static void addNewDimensionData(CompoundTag tag) {
tag.put(new IntTag("min_y", 0));
tag.put(new IntTag("height", 256));
tag.put("min_y", new IntTag(0));
tag.put("height", new IntTag(256));
}
}

Datei anzeigen

@ -59,13 +59,13 @@ public class Protocol1_9_3To1_9_1_2 extends Protocol<ClientboundPackets1_9, Clie
wrapper.write(Type.UNSIGNED_BYTE, (short) 9); //Action type (9 update sign)
//Create nbt
CompoundTag tag = new CompoundTag("");
tag.put(new StringTag("id", "Sign"));
tag.put(new IntTag("x", position.getX()));
tag.put(new IntTag("y", position.getY()));
tag.put(new IntTag("z", position.getZ()));
CompoundTag tag = new CompoundTag();
tag.put("id", new StringTag("Sign"));
tag.put("x", new IntTag(position.getX()));
tag.put("y", new IntTag(position.getY()));
tag.put("z", new IntTag(position.getZ()));
for (int i = 0; i < lines.length; i++) {
tag.put(new StringTag("Text" + (i + 1), lines[i].toString()));
tag.put("Text" + (i + 1), new StringTag(lines[i].toString()));
}
wrapper.write(Type.NBT, tag);

Datei anzeigen

@ -42,8 +42,8 @@ public class FakeTileEntity {
}
private static void register(int material, String name) {
CompoundTag comp = new CompoundTag("");
comp.put(new StringTag(name));
CompoundTag comp = new CompoundTag();
comp.put(name, new StringTag());
tileEntities.put(material, comp);
}
@ -61,9 +61,9 @@ public class FakeTileEntity {
CompoundTag originalTag = tileEntities.get(block);
if (originalTag != null) {
CompoundTag tag = originalTag.clone();
tag.put(new IntTag("x", x));
tag.put(new IntTag("y", y));
tag.put(new IntTag("z", z));
tag.put("x", new IntTag(x));
tag.put("y", new IntTag(y));
tag.put("z", new IntTag(z));
return tag;
}
return null;

Datei anzeigen

@ -237,14 +237,14 @@ public class ItemRewriter {
if (item.getIdentifier() == 383 && item.getData() != 0) { // Monster Egg
CompoundTag tag = item.getTag();
if (tag == null) {
tag = new CompoundTag("tag");
tag = new CompoundTag();
}
CompoundTag entityTag = new CompoundTag("EntityTag");
CompoundTag entityTag = new CompoundTag();
String entityName = ENTTIY_ID_TO_NAME.get((int) item.getData());
if (entityName != null) {
StringTag id = new StringTag("id", entityName);
entityTag.put(id);
tag.put(entityTag);
StringTag id = new StringTag(entityName);
entityTag.put("id", id);
tag.put("EntityTag", entityTag);
}
item.setTag(tag);
item.setData((short) 0);
@ -252,27 +252,27 @@ public class ItemRewriter {
if (item.getIdentifier() == 373) { // Potion
CompoundTag tag = item.getTag();
if (tag == null) {
tag = new CompoundTag("tag");
tag = new CompoundTag();
}
if (item.getData() >= 16384) {
item.setIdentifier(438); // splash id
item.setData((short) (item.getData() - 8192));
}
String name = potionNameFromDamage(item.getData());
StringTag potion = new StringTag("Potion", "minecraft:" + name);
tag.put(potion);
StringTag potion = new StringTag("minecraft:" + name);
tag.put("Potion", potion);
item.setTag(tag);
item.setData((short) 0);
}
if (item.getIdentifier() == 387) { // WRITTEN_BOOK
CompoundTag tag = item.getTag();
if (tag == null) {
tag = new CompoundTag("tag");
tag = new CompoundTag();
}
ListTag pages = tag.get("pages");
if (pages == null) {
pages = new ListTag("pages", Collections.<Tag>singletonList(new StringTag(Protocol1_9To1_8.fixJson("").toString())));
tag.put(pages);
pages = new ListTag(Collections.singletonList(new StringTag(Protocol1_9To1_8.fixJson("").toString())));
tag.put("pages", pages);
item.setTag(tag);
return;
}

Datei anzeigen

@ -186,13 +186,13 @@ public class WorldPackets {
if (tag != null) {
if (tag.contains("EntityId")) {
String entity = (String) tag.get("EntityId").getValue();
CompoundTag spawn = new CompoundTag("SpawnData");
spawn.put(new StringTag("id", entity));
tag.put(spawn);
CompoundTag spawn = new CompoundTag();
spawn.put("id", new StringTag(entity));
tag.put("SpawnData", spawn);
} else { // EntityID does not exist
CompoundTag spawn = new CompoundTag("SpawnData");
spawn.put(new StringTag("id", "AreaEffectCloud")); //Make spawners show up as empty when no EntityId is given.
tag.put(spawn);
CompoundTag spawn = new CompoundTag();
spawn.put("id", new StringTag("AreaEffectCloud")); //Make spawners show up as empty when no EntityId is given.
tag.put("SpawnData", spawn);
}
}
}

Datei anzeigen

@ -58,9 +58,9 @@ public class CommandBlockStorage extends StoredObject {
return Optional.empty();
tag = tag.clone();
tag.put(new ByteTag("powered", (byte) 0));
tag.put(new ByteTag("auto", (byte) 0));
tag.put(new ByteTag("conditionMet", (byte) 0));
tag.put("powered", new ByteTag((byte) 0));
tag.put("auto", new ByteTag((byte) 0));
tag.put("conditionMet", new ByteTag((byte) 0));
return Optional.of(tag);
}