Mirror von
https://github.com/ViaVersion/ViaVersion.git
synchronisiert 2024-12-25 15:50:10 +01:00
Fixed spawners showing the correct mob
Dieser Commit ist enthalten in:
Ursprung
9c88d0a37f
Commit
bd5f44b477
@ -1,12 +1,19 @@
|
|||||||
package us.myles.ViaVersion.transformers;
|
package us.myles.ViaVersion.transformers;
|
||||||
|
|
||||||
import io.netty.buffer.ByteBuf;
|
import io.netty.buffer.ByteBuf;
|
||||||
|
import io.netty.buffer.ByteBufInputStream;
|
||||||
|
import io.netty.buffer.ByteBufOutputStream;
|
||||||
|
|
||||||
import org.bukkit.entity.EntityType;
|
import org.bukkit.entity.EntityType;
|
||||||
import org.json.simple.JSONObject;
|
import org.json.simple.JSONObject;
|
||||||
import org.json.simple.parser.JSONParser;
|
import org.json.simple.parser.JSONParser;
|
||||||
import org.json.simple.parser.ParseException;
|
import org.json.simple.parser.ParseException;
|
||||||
import org.spacehq.mc.protocol.data.game.chunk.Column;
|
import org.spacehq.mc.protocol.data.game.chunk.Column;
|
||||||
import org.spacehq.mc.protocol.util.NetUtil;
|
import org.spacehq.mc.protocol.util.NetUtil;
|
||||||
|
import org.spacehq.opennbt.NBTIO;
|
||||||
|
import org.spacehq.opennbt.tag.builtin.CompoundTag;
|
||||||
|
import org.spacehq.opennbt.tag.builtin.StringTag;
|
||||||
|
|
||||||
import us.myles.ViaVersion.CancelException;
|
import us.myles.ViaVersion.CancelException;
|
||||||
import us.myles.ViaVersion.ConnectionInfo;
|
import us.myles.ViaVersion.ConnectionInfo;
|
||||||
import us.myles.ViaVersion.ViaVersionPlugin;
|
import us.myles.ViaVersion.ViaVersionPlugin;
|
||||||
@ -20,6 +27,8 @@ import us.myles.ViaVersion.util.EntityUtil;
|
|||||||
import us.myles.ViaVersion.util.PacketUtil;
|
import us.myles.ViaVersion.util.PacketUtil;
|
||||||
import us.myles.ViaVersion.util.ReflectionUtil;
|
import us.myles.ViaVersion.util.ReflectionUtil;
|
||||||
|
|
||||||
|
import java.io.DataInputStream;
|
||||||
|
import java.io.DataOutputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
@ -545,6 +554,32 @@ public class OutgoingTransformer {
|
|||||||
output.writeBytes(input);
|
output.writeBytes(input);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (packet == PacketType.PLAY_UPDATE_BLOCK_ENTITY) {
|
||||||
|
long[] pos = PacketUtil.readBlockPosition(input);
|
||||||
|
int action = input.readUnsignedByte();
|
||||||
|
if(action == 1) { // update spawner
|
||||||
|
try {
|
||||||
|
DataInputStream stream = new DataInputStream(new ByteBufInputStream(input));
|
||||||
|
CompoundTag tag = (CompoundTag) NBTIO.readTag(stream);
|
||||||
|
String entity = (String) tag.get("EntityId").getValue();
|
||||||
|
CompoundTag spawn = new CompoundTag("SpawnData");
|
||||||
|
spawn.put(new StringTag("id", entity));
|
||||||
|
tag.put(spawn);
|
||||||
|
PacketUtil.writeBlockPosition(output, pos[0], pos[1], pos[2]);
|
||||||
|
output.writeByte(action);
|
||||||
|
DataOutputStream out = new DataOutputStream(new ByteBufOutputStream(output));
|
||||||
|
NBTIO.writeTag(out, tag);
|
||||||
|
} catch (IOException e) {
|
||||||
|
// TODO Auto-generated catch block
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
PacketUtil.writeBlockPosition(output, pos[0], pos[1], pos[2]);
|
||||||
|
output.writeByte(action);
|
||||||
|
output.writeBytes(input, input.readableBytes());
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (packet == PacketType.PLAY_CHUNK_DATA) {
|
if (packet == PacketType.PLAY_CHUNK_DATA) {
|
||||||
// We need to catch unloading chunk packets as defined by wiki.vg
|
// We need to catch unloading chunk packets as defined by wiki.vg
|
||||||
// To unload chunks, send this packet with Ground-Up Continuous=true and no 16^3 chunks (eg. Primary Bit Mask=0)
|
// To unload chunks, send this packet with Ground-Up Continuous=true and no 16^3 chunks (eg. Primary Bit Mask=0)
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren