@@ -134,12 +134,16 @@ public void setSlot(ItemSlot value) {
134
134
List <Pair <ItemSlot , ItemStack >> slots = modifier .read (0 );
135
135
switch (slots .size ()) {
136
136
case 0 : {
137
- slots .add (new Pair <>(value , null ));
138
- modifier .write (0 , slots );
137
+ if (value != null ) {
138
+ slots .add (new Pair <>(value , null ));
139
+ modifier .write (0 , slots );
140
+ }
139
141
return ;
140
142
}
141
143
case 1 : {
142
- slots .get (0 ).setFirst (value );
144
+ final Pair <ItemSlot , ItemStack > first ;
145
+ if ((first = slots .get (0 )).getSecond () != null ) first .setFirst (value );
146
+ else slots .remove (0 );
143
147
modifier .write (0 , slots );
144
148
return ;
145
149
}
@@ -204,12 +208,16 @@ public void setItem(ItemStack value) {
204
208
List <Pair <ItemSlot , ItemStack >> slots = modifier .read (0 );
205
209
switch (slots .size ()) {
206
210
case 0 : {
207
- slots .add (new Pair <>(null , value ));
208
- modifier .write (0 , slots );
211
+ if (value != null ) {
212
+ slots .add (new Pair <>(null , value ));
213
+ modifier .write (0 , slots );
214
+ }
209
215
return ;
210
216
}
211
217
case 1 : {
212
- slots .get (0 ).setSecond (value );
218
+ final Pair <ItemSlot , ItemStack > first ;
219
+ if ((first = slots .get (0 )).getFirst () != null ) first .setSecond (value );
220
+ else slots .remove (0 );
213
221
modifier .write (0 , slots );
214
222
return ;
215
223
}
0 commit comments