fix OOB crash
This commit is contained in:
@@ -115,23 +115,25 @@ public class ContainerMEPortableCell extends ContainerMEMonitorable implements I
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ItemStack slotClick(int slotId, int dragType, ClickType clickTypeIn, EntityPlayer player) {
|
public ItemStack slotClick(int slotId, int dragType, ClickType clickTypeIn, EntityPlayer player) {
|
||||||
if (clickTypeIn == ClickType.PICKUP && dragType == 1) {
|
if (slotId >= 0 && slotId < this.inventorySlots.size()) {
|
||||||
if (this.inventorySlots.get(slotId) == magnetSlot) {
|
if (clickTypeIn == ClickType.PICKUP && dragType == 1) {
|
||||||
ItemStack itemStack = magnetSlot.getStack();
|
if (this.inventorySlots.get(slotId) == magnetSlot) {
|
||||||
if (!magnetSlot.getStack().isEmpty()) {
|
ItemStack itemStack = magnetSlot.getStack();
|
||||||
NBTTagCompound tag = itemStack.getTagCompound();
|
if (!magnetSlot.getStack().isEmpty()) {
|
||||||
if (tag == null) {
|
NBTTagCompound tag = itemStack.getTagCompound();
|
||||||
tag = new NBTTagCompound();
|
if (tag == null) {
|
||||||
|
tag = new NBTTagCompound();
|
||||||
|
}
|
||||||
|
if (tag.hasKey("enabled")) {
|
||||||
|
boolean e = tag.getBoolean("enabled");
|
||||||
|
tag.setBoolean("enabled", !e);
|
||||||
|
} else {
|
||||||
|
tag.setBoolean("enabled", false);
|
||||||
|
}
|
||||||
|
magnetSlot.getStack().setTagCompound(tag);
|
||||||
|
magnetSlot.onSlotChanged();
|
||||||
|
return ItemStack.EMPTY;
|
||||||
}
|
}
|
||||||
if (tag.hasKey("enabled")) {
|
|
||||||
boolean e = tag.getBoolean("enabled");
|
|
||||||
tag.setBoolean("enabled", !e);
|
|
||||||
} else {
|
|
||||||
tag.setBoolean("enabled", false);
|
|
||||||
}
|
|
||||||
magnetSlot.getStack().setTagCompound(tag);
|
|
||||||
magnetSlot.onSlotChanged();
|
|
||||||
return ItemStack.EMPTY;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+18
-16
@@ -164,23 +164,25 @@ public class ContainerWirelessPatternTerminal extends ContainerPatternEncoder im
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ItemStack slotClick(int slotId, int dragType, ClickType clickTypeIn, EntityPlayer player) {
|
public ItemStack slotClick(int slotId, int dragType, ClickType clickTypeIn, EntityPlayer player) {
|
||||||
if (clickTypeIn == ClickType.PICKUP && dragType == 1) {
|
if (slotId >= 0 && slotId < this.inventorySlots.size()) {
|
||||||
if (this.inventorySlots.get(slotId) == magnetSlot) {
|
if (clickTypeIn == ClickType.PICKUP && dragType == 1) {
|
||||||
ItemStack itemStack = magnetSlot.getStack();
|
if (this.inventorySlots.get(slotId) == magnetSlot) {
|
||||||
if (!magnetSlot.getStack().isEmpty()) {
|
ItemStack itemStack = magnetSlot.getStack();
|
||||||
NBTTagCompound tag = itemStack.getTagCompound();
|
if (!magnetSlot.getStack().isEmpty()) {
|
||||||
if (tag == null) {
|
NBTTagCompound tag = itemStack.getTagCompound();
|
||||||
tag = new NBTTagCompound();
|
if (tag == null) {
|
||||||
|
tag = new NBTTagCompound();
|
||||||
|
}
|
||||||
|
if (tag.hasKey("enabled")) {
|
||||||
|
boolean e = tag.getBoolean("enabled");
|
||||||
|
tag.setBoolean("enabled", !e);
|
||||||
|
} else {
|
||||||
|
tag.setBoolean("enabled", false);
|
||||||
|
}
|
||||||
|
magnetSlot.getStack().setTagCompound(tag);
|
||||||
|
magnetSlot.onSlotChanged();
|
||||||
|
return ItemStack.EMPTY;
|
||||||
}
|
}
|
||||||
if (tag.hasKey("enabled")) {
|
|
||||||
boolean e = tag.getBoolean("enabled");
|
|
||||||
tag.setBoolean("enabled", !e);
|
|
||||||
} else {
|
|
||||||
tag.setBoolean("enabled", false);
|
|
||||||
}
|
|
||||||
magnetSlot.getStack().setTagCompound(tag);
|
|
||||||
magnetSlot.onSlotChanged();
|
|
||||||
return ItemStack.EMPTY;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user