Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,11 @@ public void registerPackets() {
final Item item = wrapper.read(itemType());
if (equipmentSlot == SADDLE_EQUIPMENT_SLOT) {
// Send saddle entity data for horses
if (trackedEntity != null && trackedEntity.entityType().isOrHasParent(EntityTypes1_21_5.ABSTRACT_HORSE)) {
if (trackedEntity != null && (
trackedEntity.entityType().isOrHasParent(EntityTypes1_21_5.ABSTRACT_HORSE)
|| trackedEntity.entityType().isOrHasParent(EntityTypes1_21_5.PIG)
|| trackedEntity.entityType().isOrHasParent(EntityTypes1_21_5.STRIDER)
)) {
sendSaddledEntityData(wrapper.user(), trackedEntity, entityId, item.identifier() == 800);
}
} else {
Expand Down Expand Up @@ -285,30 +289,44 @@ private void convertClientAsset(final PacketWrapper wrapper) {
}

private void sendSaddledEntityData(final UserConnection connection, final TrackedEntity trackedEntity, final int entityId, final boolean saddled) {
byte data = 0;
if (trackedEntity.hasData()) {
final HorseDataStorage horseDataStorage = trackedEntity.data().get(HorseDataStorage.class);
if (horseDataStorage != null) {
if (horseDataStorage.saddled() == saddled) {
return;
EntityData entityData = null;

if (trackedEntity.entityType().isOrHasParent(EntityTypes1_21_5.ABSTRACT_HORSE)) {
byte data = 0;
if (trackedEntity.hasData()) {
final HorseDataStorage horseDataStorage = trackedEntity.data().get(HorseDataStorage.class);
if (horseDataStorage != null) {
if (horseDataStorage.saddled() == saddled) {
return;
}

data = horseDataStorage.data();
}
}

trackedEntity.data().put(new HorseDataStorage(data, saddled));

data = horseDataStorage.data();
if (saddled) {
data = (byte) (data | SADDLED_FLAG);
}
}

trackedEntity.data().put(new HorseDataStorage(data, saddled));
entityData = new EntityData(17, VersionedTypes.V1_21_4.entityDataTypes.byteType, data);

} else if (trackedEntity.entityType().isOrHasParent(EntityTypes1_21_5.PIG)) {
entityData = new EntityData(17, VersionedTypes.V1_21_4.entityDataTypes.booleanType, saddled);

if (saddled) {
data = (byte) (data | SADDLED_FLAG);
} else if (trackedEntity.entityType().isOrHasParent(EntityTypes1_21_5.STRIDER)) {
entityData = new EntityData(19, VersionedTypes.V1_21_4.entityDataTypes.booleanType, saddled);
}

final PacketWrapper entityDataPacket = PacketWrapper.create(ClientboundPackets1_21_2.SET_ENTITY_DATA, connection);
final List<EntityData> entityDataList = new ArrayList<>();
entityDataList.add(new EntityData(17, VersionedTypes.V1_21_4.entityDataTypes.byteType, data));
entityDataPacket.write(Types.VAR_INT, entityId);
entityDataPacket.write(VersionedTypes.V1_21_4.entityDataList, entityDataList);
entityDataPacket.send(Protocol1_21_5To1_21_4.class);
if (entityData != null) {
final PacketWrapper entityDataPacket = PacketWrapper.create(ClientboundPackets1_21_2.SET_ENTITY_DATA, connection);
final List<EntityData> entityDataList = new ArrayList<>();
entityDataList.add(entityData);
entityDataPacket.write(Types.VAR_INT, entityId);
entityDataPacket.write(VersionedTypes.V1_21_4.entityDataList, entityDataList);
entityDataPacket.send(Protocol1_21_5To1_21_4.class);
}
}

private String heightmapType(final int id) {
Expand Down