Consolidate in other method

This commit is contained in:
Raoul Van den Berge
2016-05-22 00:38:33 +02:00
parent 5464dccea6
commit dd4be87f60
4 changed files with 9 additions and 12 deletions

View File

@@ -93,6 +93,10 @@ public abstract class TileBase extends TileEntity implements ITickable {
return oldState.getBlock() != newState.getBlock();
}
public TileEntity getFacingTile() {
return worldObj.getTileEntity(pos.offset(direction));
}
public IInventory getDroppedInventory() {
return null;
}

View File

@@ -29,7 +29,7 @@ public class TileExporter extends TileMachine implements ICompareConfig {
@Override
public void updateMachine() {
IItemHandler handler = RefinedStorageUtils.getItemHandler(worldObj.getTileEntity(pos.offset(getDirection())), getDirection().getOpposite());
IItemHandler handler = RefinedStorageUtils.getItemHandler(getFacingTile(), getDirection().getOpposite());
if (handler != null && ticks % RefinedStorageUtils.getSpeed(upgradesInventory) == 0) {
for (int i = 0; i < inventory.getSizeInventory(); ++i) {

View File

@@ -5,7 +5,6 @@ import net.minecraft.inventory.Container;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.items.IItemHandler;
import powercrystals.minefactoryreloaded.api.IDeepStorageUnit;
import refinedstorage.RefinedStorage;
@@ -162,16 +161,12 @@ public class TileExternalStorage extends TileMachine implements IStorageProvider
return false;
}
public TileEntity getFront() {
return worldObj.getTileEntity(pos.offset(getDirection()));
}
public IDeepStorageUnit getStorageUnit() {
return getFront() instanceof IDeepStorageUnit ? (IDeepStorageUnit) getFront() : null;
return getFacingTile() instanceof IDeepStorageUnit ? (IDeepStorageUnit) getFacingTile() : null;
}
public IItemHandler getItemHandler() {
return RefinedStorageUtils.getItemHandler(getFront(), getDirection().getOpposite());
return RefinedStorageUtils.getItemHandler(getFacingTile(), getDirection().getOpposite());
}
@Override

View File

@@ -5,7 +5,6 @@ import net.minecraft.inventory.Container;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.items.IItemHandler;
import refinedstorage.RefinedStorageUtils;
import refinedstorage.container.ContainerImporter;
@@ -32,10 +31,9 @@ public class TileImporter extends TileMachine implements ICompareConfig, IModeCo
@Override
public void updateMachine() {
TileEntity tile = worldObj.getTileEntity(pos.offset(getDirection()));
IItemHandler handler = RefinedStorageUtils.getItemHandler(tile, getDirection().getOpposite());
IItemHandler handler = RefinedStorageUtils.getItemHandler(getFacingTile(), getDirection().getOpposite());
if (tile instanceof TileDiskDrive || handler == null) {
if (getFacingTile() instanceof TileDiskDrive || handler == null) {
return;
}