Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix set equipment translation in 1.20.5->.3 and replace magic values #886

Merged
merged 3 commits into from
Sep 15, 2024
Merged
Show file tree
Hide file tree
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 @@ -26,7 +26,6 @@
import com.viaversion.viabackwards.protocol.v1_20_2to1_20.provider.AdvancementCriteriaProvider;
import com.viaversion.viaversion.api.Via;
import com.viaversion.viaversion.api.connection.UserConnection;
import com.viaversion.viaversion.api.data.ParticleMappings;
import com.viaversion.viaversion.api.data.entity.EntityTracker;
import com.viaversion.viaversion.api.minecraft.ChunkPosition;
import com.viaversion.viaversion.api.minecraft.blockentity.BlockEntity;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,12 @@ public void registerPackets() {
do {
slot = wrapper.read(Types.BYTE);
final Item item = protocol.getItemRewriter().handleItemToClient(wrapper.user(), wrapper.read(Types1_20_5.ITEM));
final int rawSlot = slot & 0x7F;

if (rawSlot == 6) {
final boolean lastSlot = (slot & 0xFFFFFF80) == 0;
slot = (byte) (lastSlot ? 4 : 4 | 0xFFFFFF80); // Map body slot index to chest slot index for horses, also wolves

if (slot == 6) {
slot = 4; // Map body slot index to chest slot index for horses, also wolves
if (type != null && type.isOrHasParent(EntityTypes1_20_5.LLAMA)) {
// Cancel equipment and set correct entity data instead
wrapper.cancel();
Expand All @@ -89,7 +92,7 @@ public void registerPackets() {

wrapper.write(Types.BYTE, slot);
wrapper.write(Types.ITEM1_20_2, item);
} while (slot < 0);
} while ((slot & 0xFFFFFF80) != 0);
});

protocol.registerClientbound(ClientboundPackets1_20_5.HORSE_SCREEN_OPEN, wrapper -> {
Expand Down