Skip to content

Commit

Permalink
chore: respect nulls in WrapperPlayServerEntityEquipment
Browse files Browse the repository at this point in the history
  • Loading branch information
JarvisCraft committed Jan 20, 2021
1 parent e173e4d commit 66ce68d
Showing 1 changed file with 14 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -134,12 +134,16 @@ public void setSlot(ItemSlot value) {
List<Pair<ItemSlot, ItemStack>> slots = modifier.read(0);
switch (slots.size()) {
case 0: {
slots.add(new Pair<>(value, null));
modifier.write(0, slots);
if (value != null) {
slots.add(new Pair<>(value, null));
modifier.write(0, slots);
}
return;
}
case 1: {
slots.get(0).setFirst(value);
final Pair<ItemSlot, ItemStack> first;
if ((first = slots.get(0)).getSecond() != null) first.setFirst(value);
else slots.remove(0);
modifier.write(0, slots);
return;
}
Expand Down Expand Up @@ -204,12 +208,16 @@ public void setItem(ItemStack value) {
List<Pair<ItemSlot, ItemStack>> slots = modifier.read(0);
switch (slots.size()) {
case 0: {
slots.add(new Pair<>(null, value));
modifier.write(0, slots);
if (value != null) {
slots.add(new Pair<>(null, value));
modifier.write(0, slots);
}
return;
}
case 1: {
slots.get(0).setSecond(value);
final Pair<ItemSlot, ItemStack> first;
if ((first = slots.get(0)).getFirst() != null) first.setSecond(value);
else slots.remove(0);
modifier.write(0, slots);
return;
}
Expand Down

0 comments on commit 66ce68d

Please sign in to comment.