Skip to content

Commit

Permalink
Cleanup 1.20.5->1.20.3 SET_EQUIPMENT translation (#841)
Browse files Browse the repository at this point in the history
  • Loading branch information
FlorianMichael committed Jul 27, 2024
1 parent d372130 commit 2df954d
Showing 1 changed file with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
import com.viaversion.viabackwards.protocol.v1_20_5to1_20_3.storage.SecureChatStorage;
import com.viaversion.viaversion.api.connection.UserConnection;
import com.viaversion.viaversion.api.data.entity.DimensionData;
import com.viaversion.viaversion.api.data.entity.EntityTracker;
import com.viaversion.viaversion.api.minecraft.Particle;
import com.viaversion.viaversion.api.minecraft.RegistryEntry;
import com.viaversion.viaversion.api.minecraft.entities.EntityType;
Expand Down Expand Up @@ -72,15 +71,16 @@ public void registerPackets() {

protocol.registerClientbound(ClientboundPackets1_20_5.SET_EQUIPMENT, wrapper -> {
final int entityId = wrapper.passthrough(Types.VAR_INT); // Entity id
final EntityType type = tracker(wrapper.user()).entityType(entityId);
byte slot;
do {
slot = wrapper.read(Types.BYTE);
final Item item = protocol.getItemRewriter().handleItemToClient(wrapper.user(), wrapper.read(Types1_20_5.ITEM));

if (slot == 6) {
final EntityTracker tracker = wrapper.user().getEntityTracker(Protocol1_20_5To1_20_3.class);
slot = 4; // Map body slot index to chest slot index for horses
final EntityType type = tracker.entityType(entityId);
if (type != null && type.isOrHasParent(EntityTypes1_20_5.ABSTRACT_HORSE)) {
slot = 4; // Map body slot index to chest slot index for horses
}
if (type != null && type.isOrHasParent(EntityTypes1_20_5.LLAMA)) {
// Cancel equipment and set correct entity data instead
wrapper.cancel();
Expand Down Expand Up @@ -449,4 +449,4 @@ public void onMappingDataLoaded() {
public EntityType typeFromId(final int type) {
return EntityTypes1_20_5.getTypeFromId(type);
}
}
}

0 comments on commit 2df954d

Please sign in to comment.