Dieser Commit ist enthalten in:
Ursprung
99c9518d76
Commit
78a85f3d8c
@ -231,12 +231,35 @@ public class REntity {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
private static final Function<REntity, Object> spawnPacketGenerator = entitySpawnPacketGenerator(ProtocolWrapper.spawnPacket, spawnPacketOffset());
|
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);
|
private static int objectDataOffset() {
|
||||||
|
switch (Core.getVersion()) {
|
||||||
|
case 8:
|
||||||
|
return 9;
|
||||||
|
case 9:
|
||||||
|
case 14:
|
||||||
|
case 12:
|
||||||
|
case 10:
|
||||||
|
case 15:
|
||||||
|
case 18:
|
||||||
|
return 6;
|
||||||
|
case 19:
|
||||||
|
default:
|
||||||
|
return 4;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private static final Reflection.FieldAccessor<Integer> additionalData = Reflection.getField(ProtocolWrapper.spawnPacket, int.class, objectDataOffset());
|
||||||
|
private Object spawnPacketGenerator() {
|
||||||
|
Object packet = spawnPacketGenerator.apply(this);
|
||||||
|
additionalData.set(packet, objectData);
|
||||||
|
return packet;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static final Function<REntity, Object> livingSpawnPacketGenerator = Core.getVersion() >= 19 ? REntity::spawnPacketGenerator : entitySpawnPacketGenerator(ProtocolWrapper.spawnLivingPacket, Core.getVersion() == 8 ? 2 : 0);
|
||||||
void spawn(Consumer<Object> packetSink) {
|
void spawn(Consumer<Object> packetSink) {
|
||||||
if(entityType.isAlive()) {
|
if(entityType.isAlive()) {
|
||||||
packetSink.accept(livingSpawnPacketGenerator.apply(this));
|
packetSink.accept(livingSpawnPacketGenerator.apply(this));
|
||||||
} else {
|
} else {
|
||||||
packetSink.accept(spawnPacketGenerator.apply(this));
|
packetSink.accept(spawnPacketGenerator());
|
||||||
}
|
}
|
||||||
|
|
||||||
postSpawn(packetSink);
|
postSpawn(packetSink);
|
||||||
@ -261,7 +284,7 @@ public class REntity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(Core.getVersion() > 8 && noGravity)
|
if(Core.getVersion() > 8 && noGravity)
|
||||||
packetSink.accept(getDataWatcherPacket(noGravityDataWatcher,this.noGravity));
|
packetSink.accept(getDataWatcherPacket(noGravityDataWatcher, true));
|
||||||
}
|
}
|
||||||
|
|
||||||
void tick() {
|
void tick() {
|
||||||
@ -378,33 +401,11 @@ public class REntity {
|
|||||||
|
|
||||||
protected static Function<REntity, Object> spawnPacketGenerator(Class<?> spawnPacket, int posOffset) {
|
protected static Function<REntity, Object> spawnPacketGenerator(Class<?> spawnPacket, int posOffset) {
|
||||||
Reflection.FieldAccessor<Integer> entityId = Reflection.getField(spawnPacket, int.class, 0);
|
Reflection.FieldAccessor<Integer> entityId = Reflection.getField(spawnPacket, int.class, 0);
|
||||||
|
|
||||||
int index;
|
|
||||||
switch (Core.getVersion()) {
|
|
||||||
case 8:
|
|
||||||
index = 9;
|
|
||||||
break;
|
|
||||||
case 9:
|
|
||||||
case 14:
|
|
||||||
case 12:
|
|
||||||
case 10:
|
|
||||||
case 15:
|
|
||||||
case 18:
|
|
||||||
index = 6;
|
|
||||||
break;
|
|
||||||
case 19:
|
|
||||||
default:
|
|
||||||
index = 4;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
Reflection.FieldAccessor<Integer> additionalData = Reflection.getField(spawnPacket, int.class, index);
|
|
||||||
BountifulWrapper.PositionSetter position = BountifulWrapper.impl.getPositionSetter(spawnPacket, posOffset);
|
BountifulWrapper.PositionSetter position = BountifulWrapper.impl.getPositionSetter(spawnPacket, posOffset);
|
||||||
|
|
||||||
return entity -> {
|
return entity -> {
|
||||||
Object packet = Reflection.newInstance(spawnPacket);
|
Object packet = Reflection.newInstance(spawnPacket);
|
||||||
entityId.set(packet, entity.entityId);
|
entityId.set(packet, entity.entityId);
|
||||||
additionalData.set(packet,entity.objectData);
|
|
||||||
position.set(packet, entity.x, entity.y, entity.z);
|
position.set(packet, entity.x, entity.y, entity.z);
|
||||||
return packet;
|
return packet;
|
||||||
};
|
};
|
||||||
|
In neuem Issue referenzieren
Einen Benutzer sperren