mirror of
https://github.com/ViaVersion/ViaVersion.git
synced 2024-09-28 22:47:40 +02:00
Fix mob spawners when no EntityId is given
This commit is contained in:
parent
6e0554f4a4
commit
99ceb9ae79
@ -624,14 +624,29 @@ public class OutgoingTransformer {
|
|||||||
output.writeByte(action);
|
output.writeByte(action);
|
||||||
if (action == 1) { // update spawner
|
if (action == 1) { // update spawner
|
||||||
try {
|
try {
|
||||||
|
int index = input.readerIndex();
|
||||||
DataInputStream stream = new DataInputStream(new ByteBufInputStream(input));
|
DataInputStream stream = new DataInputStream(new ByteBufInputStream(input));
|
||||||
CompoundTag tag = (CompoundTag) NBTIO.readTag(stream);
|
CompoundTag tag = (CompoundTag) NBTIO.readTag(stream);
|
||||||
|
if(tag != null && tag.contains("EntityId")) {
|
||||||
String entity = (String) tag.get("EntityId").getValue();
|
String entity = (String) tag.get("EntityId").getValue();
|
||||||
|
System.out.println("EntityID: " + entity);
|
||||||
CompoundTag spawn = new CompoundTag("SpawnData");
|
CompoundTag spawn = new CompoundTag("SpawnData");
|
||||||
spawn.put(new StringTag("id", entity));
|
spawn.put(new StringTag("id", entity));
|
||||||
tag.put(spawn);
|
tag.put(spawn);
|
||||||
DataOutputStream out = new DataOutputStream(new ByteBufOutputStream(output));
|
DataOutputStream out = new DataOutputStream(new ByteBufOutputStream(output));
|
||||||
NBTIO.writeTag(out, tag);
|
NBTIO.writeTag(out, tag);
|
||||||
|
}
|
||||||
|
else if(tag != null) { // 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);
|
||||||
|
DataOutputStream out = new DataOutputStream(new ByteBufOutputStream(output));
|
||||||
|
NBTIO.writeTag(out, tag);
|
||||||
|
}
|
||||||
|
else { //There doesn't exist any NBT tag
|
||||||
|
input.readerIndex(index);
|
||||||
|
output.writeBytes(input, input.readableBytes());
|
||||||
|
}
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user