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

[1.21] Fix transforms for modded ItemDisplayContexts being ignored #1164

Merged
merged 2 commits into from
Jun 24, 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 @@ -40,14 +40,28 @@
this.thirdPersonLeftHand = p_111798_;
this.thirdPersonRightHand = p_111799_;
this.firstPersonLeftHand = p_111800_;
@@ -64,6 +_,7 @@
@@ -64,9 +_,21 @@
this.gui = p_111803_;
this.ground = p_111804_;
this.fixed = p_111805_;
+ this.moddedTransforms = moddedTransforms;
}

public ItemTransform getTransform(ItemDisplayContext p_270619_) {
+ if (p_270619_.isModded()) {
+ ItemTransform moddedTransform = moddedTransforms.get(p_270619_);
+ if (moddedTransform != null) {
+ return moddedTransform;
+ }
+ ItemDisplayContext moddedFallback = p_270619_.fallback();
+ if (moddedFallback == null) {
+ return ItemTransform.NO_TRANSFORM;
+ }
+ p_270619_ = moddedFallback;
+ }
return switch (p_270619_) {
case THIRD_PERSON_LEFT_HAND -> this.thirdPersonLeftHand;
case THIRD_PERSON_RIGHT_HAND -> this.thirdPersonRightHand;
@@ -104,9 +_,23 @@
ItemTransform itemtransform5 = this.getTransform(p_111822_, jsonobject, ItemDisplayContext.GUI);
ItemTransform itemtransform6 = this.getTransform(p_111822_, jsonobject, ItemDisplayContext.GROUND);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -237,10 +237,8 @@ public void onDataPacket(Connection net, ClientboundBlockEntityDataPacket pkt, H
@Override
protected void saveAdditional(CompoundTag tag, HolderLookup.Provider holderLookup) {
super.saveAdditional(tag, holderLookup);
var c = new CompoundTag();
if (heldItem != null) {
heldItem.save(holderLookup, c);
tag.put("item", c);
tag.put("item", heldItem.save(holderLookup, new CompoundTag()));
}
}

Expand Down
Loading