SteamWar/BauSystem
Archiviert
13
0

Simplify TraceEntity_12

Dieser Commit ist enthalten in:
jojo 2020-12-27 15:10:26 +01:00
Ursprung df00896c93
Commit 6c89fec5a1

Datei anzeigen

@ -50,21 +50,10 @@ class TraceEntity_12 extends EntityFallingBlock implements AbstractTraceEntity {
@Override
public AbstractTraceEntity display(Player player) {
PacketPlayOutSpawnEntity packetPlayOutSpawnEntity = new PacketPlayOutSpawnEntity(this, 0);
// Todo:
// Reflection needed?
setValue("c", packetPlayOutSpawnEntity, position.getX());
setValue("d", packetPlayOutSpawnEntity, position.getY());
setValue("e", packetPlayOutSpawnEntity, position.getZ());
setValue("f", packetPlayOutSpawnEntity, 0);
setValue("g", packetPlayOutSpawnEntity, 0);
setValue("h", packetPlayOutSpawnEntity, 0);
PacketPlayOutSpawnEntity packetPlayOutSpawnEntity = new PacketPlayOutSpawnEntity(this, 0, 0);
PlayerConnection playerConnection = ((CraftPlayer) player).getHandle().playerConnection;
playerConnection.sendPacket(packetPlayOutSpawnEntity);
PacketPlayOutEntityTeleport packetPlayOutEntityTeleport = new PacketPlayOutEntityTeleport(this);
playerConnection.sendPacket(packetPlayOutEntityTeleport);
if (tnt) {
PacketPlayOutEntityMetadata packetPlayOutEntityMetadata = new PacketPlayOutEntityMetadata(getId(), datawatcher, true);
playerConnection.sendPacket(packetPlayOutEntityMetadata);
@ -81,14 +70,4 @@ class TraceEntity_12 extends EntityFallingBlock implements AbstractTraceEntity {
return this;
}
private static void setValue(String field, Object object, Object value) {
try {
Field f = object.getClass().getDeclaredField(field);
f.setAccessible(true);
f.set(object, value);
} catch (NoSuchFieldException | IllegalAccessException e) {
throw new SecurityException(e);
}
}
}