Skip to content

Commit

Permalink
Fix transforms for modded ItemDisplayContexts being ignored
Browse files Browse the repository at this point in the history
  • Loading branch information
XFactHD committed Jun 22, 2024
1 parent 99bde8e commit 233b17e
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 5 deletions.
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
@@ -1,7 +1,7 @@
{
"parent": "minecraft:item/generated",
"display": {
"custom_transformtype_test:hanging": {
"neotests:hanging": {
"rotation": [
62,
147,
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

0 comments on commit 233b17e

Please sign in to comment.