SteamWar/SpigotCore
Archiviert
13
0

WIP CoreREntity
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful

Dieser Commit ist enthalten in:
Lixfel 2023-01-09 17:35:00 +01:00
Ursprung cc65253364
Commit cea2ffdac6
8 geänderte Dateien mit 107 neuen und 83 gelöschten Zeilen

Datei anzeigen

@ -37,6 +37,7 @@ public class ProtocolWrapper18 implements ProtocolWrapper {
} }
private static final Reflection.FieldAccessor<?> spawnType = Reflection.getField(ProtocolWrapper.spawnPacket, EntityTypes.class, 0); private static final Reflection.FieldAccessor<?> spawnType = Reflection.getField(ProtocolWrapper.spawnPacket, EntityTypes.class, 0);
private static final Reflection.FieldAccessor<Integer> spawnLivingType = Reflection.getField(ProtocolWrapper.spawnLivingPacket, int.class, 1);
@Override @Override
public void setSpawnPacketType(Object packet, EntityType type) { public void setSpawnPacketType(Object packet, EntityType type) {
switch(type) { switch(type) {
@ -49,6 +50,11 @@ public class ProtocolWrapper18 implements ProtocolWrapper {
case FIREBALL: case FIREBALL:
spawnType.set(packet, EntityTypes.S); spawnType.set(packet, EntityTypes.S);
break; break;
case ARMOR_STAND:
spawnLivingType.set(packet, 1);
break;
default:
throw new IllegalArgumentException(type.name() + " is not implemented");
} }
} }

Datei anzeigen

@ -49,6 +49,11 @@ public class ProtocolWrapper19 implements ProtocolWrapper {
case FIREBALL: case FIREBALL:
spawnType.set(packet, EntityTypes.V); spawnType.set(packet, EntityTypes.V);
break; break;
case ARMOR_STAND:
spawnType.set(packet, EntityTypes.d);
break;
default:
throw new IllegalArgumentException(type.name() + " is not implemented");
} }
} }

Datei anzeigen

@ -31,7 +31,6 @@ import org.bukkit.entity.Player;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import java.util.UUID;
public class BountifulWrapper8 implements BountifulWrapper.IBountifulWrapper { public class BountifulWrapper8 implements BountifulWrapper.IBountifulWrapper {
@ -66,30 +65,21 @@ public class BountifulWrapper8 implements BountifulWrapper.IBountifulWrapper {
return watchableObjectConstructor.invoke(watchableDatatypes.get(value.getClass()), dwo, value); return watchableObjectConstructor.invoke(watchableDatatypes.get(value.getClass()), dwo, value);
} }
private static final Class<?> teleportPacket = Reflection.getClass("{nms.network.protocol.game}.PacketPlayOutEntityTeleport");
private static final Reflection.FieldAccessor<Integer> teleportX = Reflection.getField(teleportPacket, int.class, 1);
private static final Reflection.FieldAccessor<Integer> teleportY = Reflection.getField(teleportPacket, int.class, 2);
private static final Reflection.FieldAccessor<Integer> teleportZ = Reflection.getField(teleportPacket, int.class, 3);
@Override @Override
public void setTeleportPacketPosition(Object packet, double x, double y, double z) { public BountifulWrapper.PositionSetter getPositionSetter(Class<?> packetClass, int fieldOffset8) {
teleportX.set(packet, MathHelper.floor(x * 32)); Reflection.FieldAccessor<Integer> posX = Reflection.getField(packetClass, int.class, fieldOffset8);
teleportY.set(packet, MathHelper.floor(y * 32)); Reflection.FieldAccessor<Integer> posY = Reflection.getField(packetClass, int.class, fieldOffset8+1);
teleportZ.set(packet, MathHelper.floor(z * 32)); Reflection.FieldAccessor<Integer> posZ = Reflection.getField(packetClass, int.class, fieldOffset8+2);
return (packet, x, y, z) -> {
posX.set(packet, MathHelper.floor(x * 32));
posY.set(packet, MathHelper.floor(y * 32));
posZ.set(packet, MathHelper.floor(z * 32));
};
} }
@Override @Override
public void setSpawnPacketUUID(Object packet, UUID uuid) { public BountifulWrapper.UUIDSetter getUUIDSetter(Class<?> packetClass) {
// field not present return (packet, uuid) -> {};
}
private static final Class<?> namedSpawnPacket = Reflection.getClass("{nms.network.protocol.game}.PacketPlayOutNamedEntitySpawn");
private static final Reflection.FieldAccessor<Integer> namedSpawnX = Reflection.getField(namedSpawnPacket, int.class, 0);
private static final Reflection.FieldAccessor<Integer> namedSpawnY = Reflection.getField(namedSpawnPacket, int.class, 1);
private static final Reflection.FieldAccessor<Integer> namedSpawnZ = Reflection.getField(namedSpawnPacket, int.class, 2);
@Override
public void setNamedSpawnPosition(Object packet, double x, double y, double z) {
namedSpawnX.set(packet, MathHelper.floor(x * 32));
namedSpawnY.set(packet, MathHelper.floor(y * 32));
namedSpawnZ.set(packet, MathHelper.floor(z * 32));
} }
} }

Datei anzeigen

@ -43,21 +43,25 @@ public class ProtocolWrapper8 implements ProtocolWrapper {
} }
private static final Reflection.FieldAccessor<?> spawnType; private static final Reflection.FieldAccessor<?> spawnType;
private static final Reflection.FieldAccessor<Integer> spawnLivingType = Reflection.getField(ProtocolWrapper.spawnLivingPacket, int.class, 1);
private static final Object tnt; private static final Object tnt;
private static final Object arrow; private static final Object arrow;
private static final Object fireball; private static final Object fireball;
private static final int armorStand;
static { static {
if(Core.getVersion() < 14) { if(Core.getVersion() < 14) {
spawnType = Reflection.getField(ProtocolWrapper.spawnPacket, int.class, Core.getVersion() > 8 ? 6 : 9); spawnType = Reflection.getField(ProtocolWrapper.spawnPacket, int.class, Core.getVersion() > 8 ? 6 : 9);
tnt = 50; tnt = 50;
arrow = 60; arrow = 60;
fireball = 63; fireball = 63;
armorStand = 30;
} else { } else {
Class<?> entityTypes = Reflection.getClass("{nms.world.entity}.EntityTypes"); Class<?> entityTypes = Reflection.getClass("{nms.world.entity}.EntityTypes");
spawnType = Reflection.getField(ProtocolWrapper.spawnPacket, entityTypes, 0); spawnType = Reflection.getField(ProtocolWrapper.spawnPacket, entityTypes, 0);
tnt = Reflection.getField(entityTypes, "TNT", entityTypes).get(null); tnt = Reflection.getField(entityTypes, "TNT", entityTypes).get(null);
arrow = Reflection.getField(entityTypes, "ARROW", entityTypes).get(null); arrow = Reflection.getField(entityTypes, "ARROW", entityTypes).get(null);
fireball = Reflection.getField(entityTypes, "FIREBALL", entityTypes).get(null); fireball = Reflection.getField(entityTypes, "FIREBALL", entityTypes).get(null);
armorStand = 1;
} }
} }
@Override @Override
@ -72,6 +76,11 @@ public class ProtocolWrapper8 implements ProtocolWrapper {
case FIREBALL: case FIREBALL:
spawnType.set(packet, fireball); spawnType.set(packet, fireball);
break; break;
case ARMOR_STAND:
spawnLivingType.set(packet, armorStand);
break;
default:
throw new IllegalArgumentException(type.name() + " is not implemented");
} }
} }

Datei anzeigen

@ -55,32 +55,23 @@ public class BountifulWrapper9 implements BountifulWrapper.IBountifulWrapper {
return itemConstructor.invoke(dwo, value); return itemConstructor.invoke(dwo, value);
} }
private static final Class<?> teleportPacket = Reflection.getClass("{nms.network.protocol.game}.PacketPlayOutEntityTeleport");
private static final Reflection.FieldAccessor<Double> teleportX = Reflection.getField(teleportPacket, double.class, 0);
private static final Reflection.FieldAccessor<Double> teleportY = Reflection.getField(teleportPacket, double.class, 1);
private static final Reflection.FieldAccessor<Double> teleportZ = Reflection.getField(teleportPacket, double.class, 2);
@Override @Override
public void setTeleportPacketPosition(Object packet, double x, double y, double z) { public BountifulWrapper.PositionSetter getPositionSetter(Class<?> packetClass, int fieldOffset8) {
teleportX.set(packet, x); Reflection.FieldAccessor<Double> posX = Reflection.getField(packetClass, double.class, 0);
teleportY.set(packet, y); Reflection.FieldAccessor<Double> posY = Reflection.getField(packetClass, double.class, 1);
teleportZ.set(packet, z); Reflection.FieldAccessor<Double> posZ = Reflection.getField(packetClass, double.class, 2);
return (packet, x, y, z) -> {
posX.set(packet, x);
posY.set(packet, y);
posZ.set(packet, z);
};
} }
private static final Class<?> spawnPacket = Reflection.getClass("{nms.network.protocol.game}.PacketPlayOutSpawnEntity");
private static final Reflection.FieldAccessor<UUID> spawnUUID = Reflection.getField(spawnPacket, UUID.class, 0);
@Override @Override
public void setSpawnPacketUUID(Object packet, UUID uuid) { public BountifulWrapper.UUIDSetter getUUIDSetter(Class<?> packetClass) {
spawnUUID.set(packet, uuid); Reflection.FieldAccessor<UUID> uuidField = Reflection.getField(packetClass, UUID.class, 0);
}
private static final Class<?> namedSpawnPacket = Reflection.getClass("{nms.network.protocol.game}.PacketPlayOutNamedEntitySpawn"); return uuidField::set;
private static final Reflection.FieldAccessor<Double> namedSpawnX = Reflection.getField(namedSpawnPacket, double.class, 0);
private static final Reflection.FieldAccessor<Double> namedSpawnY = Reflection.getField(namedSpawnPacket, double.class, 1);
private static final Reflection.FieldAccessor<Double> namedSpawnZ = Reflection.getField(namedSpawnPacket, double.class, 2);
@Override
public void setNamedSpawnPosition(Object packet, double x, double y, double z) {
namedSpawnX.set(packet, x);
namedSpawnY.set(packet, y);
namedSpawnZ.set(packet, z);
} }
} }

Datei anzeigen

@ -37,8 +37,16 @@ public class BountifulWrapper {
Object getDataWatcherObject(int index, Class<?> type); Object getDataWatcherObject(int index, Class<?> type);
Object getDataWatcherItem(Object dataWatcherObject, Object value); Object getDataWatcherItem(Object dataWatcherObject, Object value);
void setTeleportPacketPosition(Object packet, double x, double y, double z);
void setSpawnPacketUUID(Object packet, UUID uuid); PositionSetter getPositionSetter(Class<?> packetClass, int fieldOffset8);
void setNamedSpawnPosition(Object packet, double x, double y, double z); UUIDSetter getUUIDSetter(Class<?> packetClass);
}
public interface PositionSetter {
void set(Object packet, double x, double y, double z);
}
public interface UUIDSetter {
void set(Object packet, UUID uuid);
} }
} }

Datei anzeigen

@ -27,6 +27,7 @@ public interface ProtocolWrapper {
Class<?> itemStack = Reflection.getClass("{nms.world.item}.ItemStack"); Class<?> itemStack = Reflection.getClass("{nms.world.item}.ItemStack");
Class<?> spawnPacket = Reflection.getClass("{nms.network.protocol.game}.PacketPlayOutSpawnEntity"); Class<?> spawnPacket = Reflection.getClass("{nms.network.protocol.game}.PacketPlayOutSpawnEntity");
Class<?> spawnLivingPacket = Core.getVersion() > 18 ? ProtocolWrapper.spawnPacket : Reflection.getClass("{nms.network.protocol.game}.PacketPlayOutSpawnEntityLiving");
Class<?> equipmentPacket = Reflection.getClass("{nms.network.protocol.game}.PacketPlayOutEntityEquipment"); Class<?> equipmentPacket = Reflection.getClass("{nms.network.protocol.game}.PacketPlayOutEntityEquipment");
// 0: hand, 1: offhand, 2: feet, 3: legs, 4: chest, 5: head // 0: hand, 1: offhand, 2: feet, 3: legs, 4: chest, 5: head

Datei anzeigen

@ -74,6 +74,7 @@ public class REntity {
private boolean invisible; private boolean invisible;
private boolean sneaks; private boolean sneaks;
private boolean bowDrawn;
private int fireTick; private int fireTick;
private String displayName; private String displayName;
private final Map<Object, ItemStack> itemSlots; private final Map<Object, ItemStack> itemSlots;
@ -157,24 +158,29 @@ public class REntity {
public void sneak(boolean sneaking) { public void sneak(boolean sneaking) {
sneaks = sneaking; sneaks = sneaking;
server.updateEntity(this, getDataWatcherPacket(sneakingDataWatcher, FlatteningWrapper.impl.getPose(sneaking))); //TODO entityStatusData in 1.8! if(Core.getVersion() > 12) {
server.updateEntity(this, getDataWatcherPacket(sneakingDataWatcher, FlatteningWrapper.impl.getPose(sneaking)));
} else {
server.updateEntity(this, getDataWatcherPacket(entityStatusWatcher, getEntityStatus()));
}
} }
public void setOnFire(boolean perma) { public void setOnFire(boolean perma) {
fireTick = perma ? -1 : 21; fireTick = perma ? -1 : 21;
server.updateEntity(this, getDataWatcherPacket(entityStatusWatcher, (byte) 1)); server.updateEntity(this, getDataWatcherPacket(entityStatusWatcher, getEntityStatus()));
} }
public void setInvisible(boolean invisible) { public void setInvisible(boolean invisible) {
this.invisible = invisible; this.invisible = invisible;
server.updateEntity(this, getDataWatcherPacket(entityStatusWatcher, (byte) 0x20)); server.updateEntity(this, getDataWatcherPacket(entityStatusWatcher, getEntityStatus()));
} }
public void setBowDrawn(boolean drawn, boolean offHand) { public void setBowDrawn(boolean drawn, boolean offHand) {
bowDrawn = drawn;
if(Core.getVersion() > 8){ if(Core.getVersion() > 8){
server.updateEntity(this, getDataWatcherPacket(bowDrawnWatcher, (byte) ((drawn ? 1 : 0) + (offHand ? 2 : 0)))); server.updateEntity(this, getDataWatcherPacket(bowDrawnWatcher, (byte) ((drawn ? 1 : 0) + (offHand ? 2 : 0))));
}else{ }else{
server.updateEntity(this, getDataWatcherPacket(entityStatusWatcher, (byte)0x10)); server.updateEntity(this, getDataWatcherPacket(entityStatusWatcher, getEntityStatus()));
} }
} }
@ -217,7 +223,7 @@ public class REntity {
server.updateEntity(this, getEquipmentPacket(slot, stack)); server.updateEntity(this, getEquipmentPacket(slot, stack));
} }
public void close() { public void die() {
server.removeEntity(this); server.removeEntity(this);
} }
@ -229,30 +235,27 @@ public class REntity {
packetSink.accept(getEquipmentPacket(entry.getKey(), entry.getValue())); packetSink.accept(getEquipmentPacket(entry.getKey(), entry.getValue()));
} }
packetSink.accept(getDataWatcherPacket(skinPartsDataWatcher, (byte) 0x7F)); //TODO multiversioning packetSink.accept(getDataWatcherPacket(skinPartsDataWatcher, (byte) 0x7F)); //TODO multiversioning
} else if(entityType == EntityType.ARMOR_STAND) { } else if(entityType.isAlive()) {
packetSink.accept(getSpawnLivingEntityPacket()); packetSink.accept(getSpawnLivingEntityPacket());
packetSink.accept(getDataWatcherPacket(sizeWatcher, (byte) 0x10)); // small size //TODO multiversioning packetSink.accept(getDataWatcherPacket(sizeWatcher, (byte) 0x10)); // small size //TODO multiversioning TODO only on ArmorStands
for (Map.Entry<Object, ItemStack> entry : itemSlots.entrySet()) { for (Map.Entry<Object, ItemStack> entry : itemSlots.entrySet()) {
packetSink.accept(getEquipmentPacket(entry.getKey(), entry.getValue())); packetSink.accept(getEquipmentPacket(entry.getKey(), entry.getValue()));
} }
} else { } else {
packetSink.accept(getSpawnEntityPacket()); packetSink.accept(getSpawnEntityPacket());
} }
packetSink.accept(getTeleportPacket()); //TODO teleport necessary //packetSink.accept(getTeleportPacket());
packetSink.accept(getHeadRotationPacket()); //TODO head rotation for all types? packetSink.accept(getHeadRotationPacket()); //TODO head rotation for all types?
//TODO merge MetadataPacket (DataWatcherPackets) //TODO merge MetadataPacket (DataWatcherPackets)
if(sneaks) { if(Core.getVersion() > 12 && sneaks) {
packetSink.accept(getDataWatcherPacket(entityStatusWatcher, FlatteningWrapper.impl.getPose(true))); packetSink.accept(getDataWatcherPacket(sneakingDataWatcher, FlatteningWrapper.impl.getPose(true)));
} }
if(fireTick != 0) { byte status = getEntityStatus();
packetSink.accept(getDataWatcherPacket(sneakingDataWatcher, getDataWatcherPacket(entityStatusWatcher, (byte)1))); if(status != 0) {
} packetSink.accept(getDataWatcherPacket(entityStatusWatcher, getEntityStatus()));
if(invisible) {
packetSink.accept(getDataWatcherPacket(entityStatusWatcher, (byte) 0x20));
} }
if(displayName != null) { if(displayName != null) {
@ -265,7 +268,7 @@ public class REntity {
if(fireTick > 0) { if(fireTick > 0) {
fireTick--; fireTick--;
if(fireTick == 0) { if(fireTick == 0) {
server.updateEntity(this, getDataWatcherPacket(entityStatusWatcher, (byte)0)); server.updateEntity(this, getDataWatcherPacket(entityStatusWatcher, getEntityStatus()));
} }
} }
} }
@ -297,6 +300,21 @@ public class REntity {
return z; return z;
} }
private byte getEntityStatus() {
byte status = 0;
if(fireTick != 0)
status |= 1;
if(Core.getVersion() <= 12 && sneaks)
status |= 2;
if(Core.getVersion() == 8 && bowDrawn)
status |= 0x10;
if(invisible)
status |= 0x20;
return status;
}
private static final Class<?> metadataPacket = Reflection.getClass("{nms.network.protocol.game}.PacketPlayOutEntityMetadata"); private static final Class<?> metadataPacket = Reflection.getClass("{nms.network.protocol.game}.PacketPlayOutEntityMetadata");
private static final Reflection.FieldAccessor<Integer> metadataEntity = Reflection.getField(metadataPacket, int.class, 0); private static final Reflection.FieldAccessor<Integer> metadataEntity = Reflection.getField(metadataPacket, int.class, 0);
private static final Reflection.FieldAccessor<List> metadataMetadata = Reflection.getField(metadataPacket, List.class, 0); private static final Reflection.FieldAccessor<List> metadataMetadata = Reflection.getField(metadataPacket, List.class, 0);
@ -316,12 +334,13 @@ public class REntity {
private static final Class<?> teleportPacket = Reflection.getClass("{nms.network.protocol.game}.PacketPlayOutEntityTeleport"); private static final Class<?> teleportPacket = Reflection.getClass("{nms.network.protocol.game}.PacketPlayOutEntityTeleport");
private static final Reflection.FieldAccessor<Integer> teleportEntity = Reflection.getField(teleportPacket, int.class, 0); private static final Reflection.FieldAccessor<Integer> teleportEntity = Reflection.getField(teleportPacket, int.class, 0);
private static final BountifulWrapper.PositionSetter teleportPosition = BountifulWrapper.impl.getPositionSetter(teleportPacket, 1);
private static final Reflection.FieldAccessor<Byte> teleportYaw = Reflection.getField(teleportPacket, byte.class, 0); private static final Reflection.FieldAccessor<Byte> teleportYaw = Reflection.getField(teleportPacket, byte.class, 0);
private static final Reflection.FieldAccessor<Byte> teleportPitch = Reflection.getField(teleportPacket, byte.class, 1); private static final Reflection.FieldAccessor<Byte> teleportPitch = Reflection.getField(teleportPacket, byte.class, 1);
private Object getTeleportPacket(){ private Object getTeleportPacket(){
Object packet = Reflection.newInstance(teleportPacket); Object packet = Reflection.newInstance(teleportPacket);
teleportEntity.set(packet, entityId); teleportEntity.set(packet, entityId);
BountifulWrapper.impl.setTeleportPacketPosition(packet, x, y, z); teleportPosition.set(packet, x, y, z);
teleportYaw.set(packet, yaw); teleportYaw.set(packet, yaw);
teleportPitch.set(packet, pitch); teleportPitch.set(packet, pitch);
return packet; return packet;
@ -366,42 +385,37 @@ public class REntity {
private static final Class<?> namedSpawnPacket = Reflection.getClass("{nms.network.protocol.game}.PacketPlayOutNamedEntitySpawn"); private static final Class<?> namedSpawnPacket = Reflection.getClass("{nms.network.protocol.game}.PacketPlayOutNamedEntitySpawn");
private static final Reflection.FieldAccessor<Integer> namedSpawnEntity = Reflection.getField(namedSpawnPacket, int.class, 0); private static final Reflection.FieldAccessor<Integer> namedSpawnEntity = Reflection.getField(namedSpawnPacket, int.class, 0);
private static final Reflection.FieldAccessor<UUID> namedSpawnUUID = Reflection.getField(namedSpawnPacket, UUID.class, 0); private static final Reflection.FieldAccessor<UUID> namedSpawnUUID = Reflection.getField(namedSpawnPacket, UUID.class, 0);
private static final BountifulWrapper.PositionSetter namedSpawnPosition = BountifulWrapper.impl.getPositionSetter(namedSpawnPacket, 1);
private Object getNamedSpawnPacket() { private Object getNamedSpawnPacket() {
Object packet = Reflection.newInstance(namedSpawnPacket); Object packet = Reflection.newInstance(namedSpawnPacket);
namedSpawnEntity.set(packet, entityId); namedSpawnEntity.set(packet, entityId);
namedSpawnUUID.set(packet, uuid); namedSpawnUUID.set(packet, uuid);
BountifulWrapper.impl.setNamedSpawnPosition(packet, x, y, z); namedSpawnPosition.set(packet, x, y, z);
FlatteningWrapper.impl.setNamedSpawnPacketDataWatcher(packet); FlatteningWrapper.impl.setNamedSpawnPacketDataWatcher(packet);
return packet; return packet;
} }
private static final Class<?> spawnLivingPacket = Reflection.getClass("{nms.network.protocol.game}.PacketPlayOutSpawnEntityLiving"); //TODO not existing in 1.19 private static final Reflection.FieldAccessor<Integer> spawnLivingEntityId = Reflection.getField(ProtocolWrapper.spawnLivingPacket, int.class, 0);
private static final Reflection.ConstructorInvoker spawnLivingPacketConstructor = Reflection.getConstructor(spawnLivingPacket); //TODO multiversioning private static final BountifulWrapper.UUIDSetter livingSpawnUUID = BountifulWrapper.impl.getUUIDSetter(ProtocolWrapper.spawnLivingPacket);
private static final Reflection.FieldAccessor<Integer> spawnLivingEntityId = Reflection.getField(spawnLivingPacket, int.class, 0); //TODO multiversioning private static final BountifulWrapper.PositionSetter livingSpawnPosition = BountifulWrapper.impl.getPositionSetter(ProtocolWrapper.spawnLivingPacket, 2); //TODO only diff to spawnEntity, simplify code
private static final Reflection.FieldAccessor<UUID> spawnLivingUUID = Reflection.getField(spawnLivingPacket, UUID.class, 0); //TODO not existing in 1.8
private static final Reflection.FieldAccessor<Integer> spawnLivingEntityType = Reflection.getField(spawnLivingPacket, int.class, 1); //TODO multiversioning
private static final Reflection.FieldAccessor<Double> spawnLivingEntityX = Reflection.getField(spawnLivingPacket, double.class, 0); //TODO int in 1.8
private static final Reflection.FieldAccessor<Double> spawnLivingEntityY = Reflection.getField(spawnLivingPacket, double.class, 1); //TODO int in 1.8
private static final Reflection.FieldAccessor<Double> spawnLivingEntityZ = Reflection.getField(spawnLivingPacket, double.class, 2); //TODO int in 1.8
private Object getSpawnLivingEntityPacket() { private Object getSpawnLivingEntityPacket() {
Object packet = spawnLivingPacketConstructor.invoke(); Object packet = Reflection.newInstance(ProtocolWrapper.spawnLivingPacket);
spawnLivingEntityId.set(packet, entityId); spawnLivingEntityId.set(packet, entityId);
spawnLivingUUID.set(packet, uuid); livingSpawnUUID.set(packet, uuid);
spawnLivingEntityType.set(packet, 1); //TODO set correct type ProtocolWrapper.impl.setSpawnPacketType(packet, entityType);
spawnLivingEntityX.set(packet, x); livingSpawnPosition.set(packet, x, y, z);
spawnLivingEntityY.set(packet, y);
spawnLivingEntityZ.set(packet, z);
return packet; return packet;
} }
private static final Reflection.FieldAccessor<Integer> spawnEntity = Reflection.getField(ProtocolWrapper.spawnPacket, int.class, 0); private static final Reflection.FieldAccessor<Integer> spawnEntity = Reflection.getField(ProtocolWrapper.spawnPacket, int.class, 0);
private static final BountifulWrapper.UUIDSetter spawnUUID = BountifulWrapper.impl.getUUIDSetter(ProtocolWrapper.spawnPacket);
private static final BountifulWrapper.PositionSetter spawnPosition = BountifulWrapper.impl.getPositionSetter(ProtocolWrapper.spawnPacket, 1);
private Object getSpawnEntityPacket() { private Object getSpawnEntityPacket() {
Object packet = Reflection.newInstance(ProtocolWrapper.spawnPacket); Object packet = Reflection.newInstance(ProtocolWrapper.spawnPacket);
spawnEntity.set(packet, entityId); spawnEntity.set(packet, entityId);
BountifulWrapper.impl.setSpawnPacketUUID(packet, uuid); spawnUUID.set(packet, uuid);
ProtocolWrapper.impl.setSpawnPacketType(packet, entityType); ProtocolWrapper.impl.setSpawnPacketType(packet, entityType);
//TODO set position spawnPosition.set(packet, x, y, z);
return packet; return packet;
} }