@@ -93,10 +93,8 @@ public class LoomInventoryTranslator extends AbstractBlockInventoryTranslator {
93
93
PATTERN_TO_INDEX .put ("vhr" , index ++);
94
94
PATTERN_TO_INDEX .put ("hhb" , index ++);
95
95
PATTERN_TO_INDEX .put ("bo" , index ++);
96
- index ++; // Bordure indented, does not appear to exist in Bedrock?
97
96
PATTERN_TO_INDEX .put ("gra" , index ++);
98
97
PATTERN_TO_INDEX .put ("gru" , index );
99
- // Bricks do not appear to be a pattern on Bedrock, either
100
98
}
101
99
102
100
public LoomInventoryTranslator () {
@@ -120,7 +118,7 @@ protected boolean shouldRejectItemPlace(GeyserSession session, Inventory invento
120
118
121
119
@ Override
122
120
protected boolean shouldHandleRequestFirst (ItemStackRequestAction action , Inventory inventory ) {
123
- // If the LOOM_MATERIAL slot is not empty, we are crafting a pattern that does not come from an item
121
+ // If the LOOM_MATERIAL slot is empty, we are crafting a pattern that does not come from an item
124
122
return action .getType () == ItemStackRequestActionType .CRAFT_LOOM && inventory .getItem (2 ).isEmpty ();
125
123
}
126
124
@@ -135,17 +133,19 @@ public ItemStackResponse translateSpecialRequest(GeyserSession session, Inventor
135
133
return rejectRequest (request );
136
134
}
137
135
138
- // Get the patterns compound tag
139
- List <NbtMap > newBlockEntityTag = craftData .getResultItems ()[0 ].getTag ().getList ("Patterns" , NbtType .COMPOUND );
140
- // Get the pattern that the Bedrock client requests - the last pattern in the Patterns list
141
- NbtMap pattern = newBlockEntityTag .get (newBlockEntityTag .size () - 1 );
142
136
String bedrockPattern = ((CraftLoomAction ) headerData ).getPatternId ();
143
137
144
138
// Get the Java index of this pattern
145
139
int index = PATTERN_TO_INDEX .getOrDefault (bedrockPattern , -1 );
146
140
if (index == -1 ) {
147
141
return rejectRequest (request );
148
142
}
143
+
144
+ // Get the patterns compound tag
145
+ List <NbtMap > newBlockEntityTag = craftData .getResultItems ()[0 ].getTag ().getList ("Patterns" , NbtType .COMPOUND );
146
+ // Get the pattern that the Bedrock client requests - the last pattern in the Patterns list
147
+ NbtMap pattern = newBlockEntityTag .get (newBlockEntityTag .size () - 1 );
148
+
149
149
// Java's formula: 4 * row + col
150
150
// And the Java loom window has a fixed row/width of four
151
151
// So... Number / 4 = row (so we don't have to bother there), and number % 4 is our column, which leads us back to our index. :)
@@ -156,10 +156,7 @@ public ItemStackResponse translateSpecialRequest(GeyserSession session, Inventor
156
156
inputCopy .setNetId (session .getNextItemNetId ());
157
157
BannerPatternLayer bannerPatternLayer = BannerItem .getJavaBannerPattern (session , pattern ); // TODO
158
158
if (bannerPatternLayer != null ) {
159
- List <BannerPatternLayer > patternsList = inputCopy .getComponent (DataComponentType .BANNER_PATTERNS );
160
- if (patternsList == null ) {
161
- patternsList = new ArrayList <>();
162
- }
159
+ List <BannerPatternLayer > patternsList = new ArrayList <>(inputCopy .getComponentElseGet (DataComponentType .BANNER_PATTERNS , ArrayList ::new ));
163
160
patternsList .add (bannerPatternLayer );
164
161
inputCopy .getOrCreateComponents ().put (DataComponentType .BANNER_PATTERNS , patternsList );
165
162
}
0 commit comments