More null annotations

This commit is contained in:
mezz committed 2017-02-07 00:05:24 -08:00
1 parent da8a833485
commit a5daa93bf1
163 files changed
+952 -849

No files matched your search

@@ -6,33 +6,33 @@ import binnie.craftgui.minecraft.InventoryType;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import javax.annotation.Nullable;
import java.util.ArrayList;
import java.util.List;
public class ControlPlayerInventory extends Control {
private List<ControlSlot> slots;
private final List<ControlSlot> slots;
public ControlPlayerInventory(final IWidget parent, final boolean wide) {
super(parent, parent.getSize().x() / 2 - (wide ? 110 : 81), parent.getSize().y() - (wide ? 54 : 76) - 12, wide ? 220 : 162, wide ? 54 : 76);
this.slots = new ArrayList<>();
for (int row = 0; row < 3; ++row) {
for (int column = 0; column < 9; ++column) {
final ControlSlot slot = new ControlSlot(this, (wide ? 58 : 0) + column * 18, row * 18);
final ControlSlot slot = new ControlSlot.Builder(this, (wide ? 58 : 0) + column * 18, row * 18).assign(InventoryType.Player, 9 + column + row * 9);
this.slots.add(slot);
}
}
if (wide) {
for (int i1 = 0; i1 < 9; ++i1) {
final ControlSlot slot2 = new ControlSlot(this, i1 % 3 * 18, i1 / 3 * 18);
final ControlSlot slot2 = new ControlSlot.Builder(this, i1 % 3 * 18, i1 / 3 * 18).assign(InventoryType.Player, i1);
this.slots.add(slot2);
}
} else {
for (int i1 = 0; i1 < 9; ++i1) {
final ControlSlot slot2 = new ControlSlot(this, i1 * 18, 58);
final ControlSlot slot2 = new ControlSlot.Builder(this, i1 * 18, 58).assign(InventoryType.Player, i1);
this.slots.add(slot2);
}
}
this.create();
}
public ControlPlayerInventory(final IWidget parent) {
@@ -44,30 +44,13 @@ public class ControlPlayerInventory extends Control {
this.slots = new ArrayList<>();
for (int row = 0; row < 6; ++row) {
for (int column = 0; column < 6; ++column) {
final ControlSlot slot = new ControlSlot(this, column * 18, row * 18);
final ControlSlot slot = new ControlSlot.Builder(this, column * 18, row * 18).assign(InventoryType.Player, 9 + column + row * 9);
this.slots.add(slot);
}
}
this.create();
}
public void create() {
for (int row = 0; row < 3; ++row) {
for (int column = 0; column < 9; ++column) {
final ControlSlot slot = this.slots.get(column + row * 9);
slot.assign(InventoryType.Player, 9 + column + row * 9);
}
}
for (int i1 = 0; i1 < 9; ++i1) {
final ControlSlot slot2 = this.slots.get(27 + i1);
slot2.assign(InventoryType.Player, i1);
}
}
public void addItem(final ItemStack item) {
if (item == null) {
return;
}
public void addItem(@Nullable final ItemStack item) {
for (final ControlSlot slot : this.slots) {
if (!slot.slot.getHasStack()) {
slot.slot.putStack(item);
@@ -77,10 +60,12 @@ public class ControlPlayerInventory extends Control {
public void addInventory(final IInventory inventory) {
for (int i = 0; i < inventory.getSizeInventory(); ++i) {
this.addItem(inventory.getStackInSlot(i));
ItemStack stackInSlot = inventory.getStackInSlot(i);
this.addItem(stackInSlot);
}
}
@Nullable
public ControlSlot getSlot(final int i) {
if (i < 0 || i >= this.slots.size()) {
return null;