Dieser Commit ist enthalten in:
Ursprung
8d3037f67d
Commit
d8825f0262
@ -66,10 +66,10 @@ public class BountifulWrapper8 implements BountifulWrapper.IBountifulWrapper {
|
||||
}
|
||||
|
||||
@Override
|
||||
public BountifulWrapper.PositionSetter getPositionSetter(Class<?> packetClass, int fieldOffset8) {
|
||||
Reflection.FieldAccessor<Integer> posX = Reflection.getField(packetClass, int.class, fieldOffset8);
|
||||
Reflection.FieldAccessor<Integer> posY = Reflection.getField(packetClass, int.class, fieldOffset8+1);
|
||||
Reflection.FieldAccessor<Integer> posZ = Reflection.getField(packetClass, int.class, fieldOffset8+2);
|
||||
public BountifulWrapper.PositionSetter getPositionSetter(Class<?> packetClass, int fieldOffset) {
|
||||
Reflection.FieldAccessor<Integer> posX = Reflection.getField(packetClass, int.class, fieldOffset);
|
||||
Reflection.FieldAccessor<Integer> posY = Reflection.getField(packetClass, int.class, fieldOffset +1);
|
||||
Reflection.FieldAccessor<Integer> posZ = Reflection.getField(packetClass, int.class, fieldOffset +2);
|
||||
|
||||
return (packet, x, y, z) -> {
|
||||
posX.set(packet, MathHelper.floor(x * 32));
|
||||
|
@ -56,10 +56,10 @@ public class BountifulWrapper9 implements BountifulWrapper.IBountifulWrapper {
|
||||
}
|
||||
|
||||
@Override
|
||||
public BountifulWrapper.PositionSetter getPositionSetter(Class<?> packetClass, int fieldOffset8) {
|
||||
Reflection.FieldAccessor<Double> posX = Reflection.getField(packetClass, double.class, 0);
|
||||
Reflection.FieldAccessor<Double> posY = Reflection.getField(packetClass, double.class, 1);
|
||||
Reflection.FieldAccessor<Double> posZ = Reflection.getField(packetClass, double.class, 2);
|
||||
public BountifulWrapper.PositionSetter getPositionSetter(Class<?> packetClass, int fieldOffset) {
|
||||
Reflection.FieldAccessor<Double> posX = Reflection.getField(packetClass, double.class, fieldOffset);
|
||||
Reflection.FieldAccessor<Double> posY = Reflection.getField(packetClass, double.class, fieldOffset+1);
|
||||
Reflection.FieldAccessor<Double> posZ = Reflection.getField(packetClass, double.class, fieldOffset+2);
|
||||
|
||||
return (packet, x, y, z) -> {
|
||||
posX.set(packet, x);
|
||||
|
@ -38,7 +38,7 @@ public class BountifulWrapper {
|
||||
Object getDataWatcherObject(int index, Class<?> type);
|
||||
Object getDataWatcherItem(Object dataWatcherObject, Object value);
|
||||
|
||||
PositionSetter getPositionSetter(Class<?> packetClass, int fieldOffset8);
|
||||
PositionSetter getPositionSetter(Class<?> packetClass, int fieldOffset);
|
||||
UUIDSetter getUUIDSetter(Class<?> packetClass);
|
||||
}
|
||||
|
||||
|
@ -178,8 +178,24 @@ public class REntity {
|
||||
server.removeEntity(this);
|
||||
}
|
||||
|
||||
private static final Function<REntity, Object> livingSpawnPacketGenerator = entitySpawnPacketGenerator(ProtocolWrapper.spawnLivingPacket, 2);
|
||||
private static final Function<REntity, Object> spawnPacketGenerator = entitySpawnPacketGenerator(ProtocolWrapper.spawnPacket, 1);
|
||||
private static int spawnPacketOffset() {
|
||||
switch (Core.getVersion()) {
|
||||
case 8:
|
||||
case 18:
|
||||
return 1;
|
||||
case 9:
|
||||
case 10:
|
||||
case 12:
|
||||
case 14:
|
||||
case 15:
|
||||
return 0;
|
||||
case 19:
|
||||
default:
|
||||
return 2;
|
||||
}
|
||||
}
|
||||
private static final Function<REntity, Object> spawnPacketGenerator = entitySpawnPacketGenerator(ProtocolWrapper.spawnPacket, spawnPacketOffset());
|
||||
private static final Function<REntity, Object> livingSpawnPacketGenerator = Core.getVersion() >= 19 ? spawnPacketGenerator : entitySpawnPacketGenerator(ProtocolWrapper.spawnLivingPacket, Core.getVersion() == 8 ? 2 : 0);
|
||||
void spawn(Consumer<Object> packetSink) {
|
||||
if(entityType.isAlive()) {
|
||||
packetSink.accept(livingSpawnPacketGenerator.apply(this));
|
||||
@ -274,7 +290,7 @@ public class REntity {
|
||||
|
||||
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 BountifulWrapper.PositionSetter teleportPosition = BountifulWrapper.impl.getPositionSetter(teleportPacket, 1);
|
||||
private static final BountifulWrapper.PositionSetter teleportPosition = BountifulWrapper.impl.getPositionSetter(teleportPacket, Core.getVersion() == 8 ? 1 : 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 Object getTeleportPacket(){
|
||||
@ -307,9 +323,9 @@ public class REntity {
|
||||
return packet;
|
||||
}
|
||||
|
||||
private static Function<REntity, Object> entitySpawnPacketGenerator(Class<?> spawnPacket, int posOffset8) {
|
||||
private static Function<REntity, Object> entitySpawnPacketGenerator(Class<?> spawnPacket, int posOffset) {
|
||||
BountifulWrapper.UUIDSetter uuid = BountifulWrapper.impl.getUUIDSetter(spawnPacket);
|
||||
Function<REntity, Object> packetGenerator = spawnPacketGenerator(spawnPacket, posOffset8);
|
||||
Function<REntity, Object> packetGenerator = spawnPacketGenerator(spawnPacket, posOffset);
|
||||
|
||||
return entity -> {
|
||||
Object packet = packetGenerator.apply(entity);
|
||||
@ -319,9 +335,9 @@ public class REntity {
|
||||
};
|
||||
}
|
||||
|
||||
protected static Function<REntity, Object> spawnPacketGenerator(Class<?> spawnPacket, int posOffset8) {
|
||||
protected static Function<REntity, Object> spawnPacketGenerator(Class<?> spawnPacket, int posOffset) {
|
||||
Reflection.FieldAccessor<Integer> entityId = Reflection.getField(spawnPacket, int.class, 0);
|
||||
BountifulWrapper.PositionSetter position = BountifulWrapper.impl.getPositionSetter(spawnPacket, posOffset8);
|
||||
BountifulWrapper.PositionSetter position = BountifulWrapper.impl.getPositionSetter(spawnPacket, posOffset);
|
||||
|
||||
return entity -> {
|
||||
Object packet = Reflection.newInstance(spawnPacket);
|
||||
|
@ -115,7 +115,7 @@ public class RPlayer extends REntity {
|
||||
}
|
||||
|
||||
private static final Class<?> namedSpawnPacket = Reflection.getClass("{nms.network.protocol.game}.PacketPlayOutNamedEntitySpawn");
|
||||
private static final Function<REntity, Object> namedSpawnPacketGenerator = spawnPacketGenerator(namedSpawnPacket, 1);
|
||||
private static final Function<REntity, Object> namedSpawnPacketGenerator = spawnPacketGenerator(namedSpawnPacket, Core.getVersion() == 8 ? 1 : 0);
|
||||
private static final Reflection.FieldAccessor<UUID> namedSpawnUUID = Reflection.getField(namedSpawnPacket, UUID.class, 0);
|
||||
private Object getNamedSpawnPacket() {
|
||||
Object packet = namedSpawnPacketGenerator.apply(this);
|
||||
|
In neuem Issue referenzieren
Einen Benutzer sperren