Fix #384 Client crash at forestry.farming.gadgets.TileHatch

This commit is contained in:
mezz committed 2014-12-19 23:40:07 -08:00
1 parent 46348fca07
commit d63377532c
3 files changed
+58 -41

No files matched your search

@@ -140,8 +140,12 @@ public class TileAlvearyPlain extends TileAlveary implements ISidedInventory, IB
return;
// Add swarm effects
if (worldObj.getTotalWorldTime() % 200 * 10 == 0)
onQueenChange(getStructureInventory().getStackInSlot(SLOT_QUEEN));
if (worldObj.getTotalWorldTime() % 200 == 0) {
ISidedInventory inventory = getStructureInventory();
if (inventory != null)
onQueenChange(inventory.getStackInSlot(SLOT_QUEEN));
}
if (getErrorState() == EnumErrorCode.OK)
queen.doFX(beekeepingLogic.getEffectData(), this);
@@ -166,15 +170,18 @@ public class TileAlvearyPlain extends TileAlveary implements ISidedInventory, IB
if (!isMaster())
return;
if (getStructureInventory() == null)
ISidedInventory inventory = getStructureInventory();
if (inventory == null)
return;
// / Multiplayer FX
if (PluginApiculture.beeInterface.isMated(getStructureInventory().getStackInSlot(SLOT_QUEEN)))
ItemStack queenStack = inventory.getStackInSlot(SLOT_QUEEN);
if (PluginApiculture.beeInterface.isMated(queenStack)) {
if (getErrorState() == EnumErrorCode.OK && worldObj.getTotalWorldTime() % 2 == 0) {
IBee displayQueen = PluginApiculture.beeInterface.getMember(getStructureInventory().getStackInSlot(SLOT_QUEEN));
IBee displayQueen = PluginApiculture.beeInterface.getMember(queenStack);
displayQueen.doFX(beekeepingLogic.getEffectData(), this);
}
}
}
private void equalizeTemperature() {
@@ -544,37 +551,37 @@ public class TileAlvearyPlain extends TileAlveary implements ISidedInventory, IB
@Override
public int getSizeInventory() {
IInventory inv = getStructureInventory();
if (inv != null)
return inv.getSizeInventory();
else
if (inv == null)
return 0;
return inv.getSizeInventory();
}
@Override
public ItemStack getStackInSlot(int slotIndex) {
IInventory inv = getStructureInventory();
if (inv != null)
return inv.getStackInSlot(slotIndex);
else
if (inv == null)
return null;
return inv.getStackInSlot(slotIndex);
}
@Override
public ItemStack decrStackSize(int slotIndex, int amount) {
IInventory inv = getStructureInventory();
if (inv != null)
return inv.decrStackSize(slotIndex, amount);
else
if (inv == null)
return null;
return inv.decrStackSize(slotIndex, amount);
}
@Override
public ItemStack getStackInSlotOnClosing(int slotIndex) {
IInventory inv = getStructureInventory();
if (inv != null)
return inv.getStackInSlotOnClosing(slotIndex);
else
if (inv == null)
return null;
return inv.getStackInSlotOnClosing(slotIndex);
}
@Override
@@ -598,10 +605,10 @@ public class TileAlvearyPlain extends TileAlveary implements ISidedInventory, IB
@Override
public int getInventoryStackLimit() {
IInventory inv = getStructureInventory();
if (inv != null)
return inv.getInventoryStackLimit();
else
if (inv == null)
return 0;
return inv.getInventoryStackLimit();
}
@Override
+2 -2
View File
@@ -60,7 +60,7 @@ public class Utils {
if (tile instanceof ITileStructure) {
IInventory inventory = ((ITileStructure) tile).getInventory();
if (inventory != null)
if (inventory != null) {
for (int i = 0; i < inventory.getSizeInventory(); i++) {
if (inventory.getStackInSlot(i) == null)
continue;
@@ -68,7 +68,7 @@ public class Utils {
StackUtils.dropItemStackAsEntity(inventory.getStackInSlot(i), world, x, y, z);
inventory.setInventorySlotContents(i, null);
}
}
} else {
IInventory inventory;
@@ -13,6 +13,7 @@ package forestry.farming.gadgets;
import buildcraft.api.statements.ITriggerExternal;
import cpw.mods.fml.common.Optional;
import forestry.api.core.ITileStructure;
import forestry.core.config.Defaults;
import forestry.core.inventory.AdjacentInventoryCache;
import forestry.core.inventory.ITileFilter;
import forestry.core.inventory.InvTools;
@@ -57,7 +58,11 @@ public class TileHatch extends TileFarm implements ISidedInventory {
/* AUTO-EJECTING */
private IInventory getProductInventory() {
return new InventoryMapper(getStructureInventory(), TileFarmPlain.SLOT_PRODUCTION_1, TileFarmPlain.SLOT_COUNT_PRODUCTION);
TileInventoryAdapter inventory = getStructureInventory();
if (inventory == null)
return null;
return new InventoryMapper(inventory, TileFarmPlain.SLOT_PRODUCTION_1, TileFarmPlain.SLOT_COUNT_PRODUCTION);
}
protected void dumpStash() {
@@ -87,37 +92,37 @@ public class TileHatch extends TileFarm implements ISidedInventory {
@Override
public int getSizeInventory() {
IInventory inv = getStructureInventory();
if (inv != null)
return inv.getSizeInventory();
else
if (inv == null)
return 0;
return inv.getSizeInventory();
}
@Override
public ItemStack getStackInSlot(int slotIndex) {
IInventory inv = getStructureInventory();
if (inv != null)
return inv.getStackInSlot(slotIndex);
else
if (inv == null)
return null;
return inv.getStackInSlot(slotIndex);
}
@Override
public ItemStack decrStackSize(int slotIndex, int amount) {
IInventory inv = getStructureInventory();
if (inv != null)
return inv.decrStackSize(slotIndex, amount);
else
if (inv == null)
return null;
return inv.decrStackSize(slotIndex, amount);
}
@Override
public ItemStack getStackInSlotOnClosing(int slotIndex) {
IInventory inv = getStructureInventory();
if (inv != null)
return inv.getStackInSlotOnClosing(slotIndex);
else
if (inv == null)
return null;
return inv.getStackInSlotOnClosing(slotIndex);
}
@Override
@@ -130,10 +135,10 @@ public class TileHatch extends TileFarm implements ISidedInventory {
@Override
public int getInventoryStackLimit() {
IInventory inv = getStructureInventory();
if (inv != null)
return inv.getInventoryStackLimit();
else
if (inv == null)
return 0;
return inv.getInventoryStackLimit();
}
@Override
@@ -171,7 +176,8 @@ public class TileHatch extends TileFarm implements ISidedInventory {
if (!(struct instanceof TileFarmPlain))
return false;
if (!getStructureInventory().isItemValidForSlot(slotIndex, itemstack))
TileInventoryAdapter inventory = getStructureInventory();
if (inventory == null || !inventory.isItemValidForSlot(slotIndex, itemstack))
return false;
TileFarmPlain housing = (TileFarmPlain) struct;
@@ -196,7 +202,8 @@ public class TileHatch extends TileFarm implements ISidedInventory {
@Override
public boolean canExtractItem(int slotIndex, ItemStack itemstack, int side) {
if (!getStructureInventory().canExtractItem(slotIndex, itemstack, side))
TileInventoryAdapter inventory = getStructureInventory();
if (inventory == null || !inventory.canExtractItem(slotIndex, itemstack, side))
return false;
return slotIndex >= TileFarmPlain.SLOT_PRODUCTION_1 && slotIndex < TileFarmPlain.SLOT_PRODUCTION_1 + TileFarmPlain.SLOT_COUNT_PRODUCTION;
@@ -204,7 +211,10 @@ public class TileHatch extends TileFarm implements ISidedInventory {
@Override
public int[] getAccessibleSlotsFromSide(int side) {
return getStructureInventory().getAccessibleSlotsFromSide(side);
TileInventoryAdapter inventory = getStructureInventory();
if (inventory == null)
return Defaults.FACINGS_NONE;
return inventory.getAccessibleSlotsFromSide(side);
}
/* ITRIGGERPROVIDER */