Add IDeepStorageUnit support
This commit is contained in:
parent
65b305b27d
commit
3d167922be
|
@ -38,7 +38,6 @@ public class GuiElectricPump extends GuiMekanism
|
|||
fontRenderer.drawString("Inventory", 8, (ySize - 94) + 2, 0x404040);
|
||||
fontRenderer.drawString(MekanismUtils.getEnergyDisplay(tileEntity.getEnergy()), 51, 26, 0x00CD00);
|
||||
fontRenderer.drawString(tileEntity.fluidTank.getFluid() != null ? tileEntity.fluidTank.getFluid().getFluid().getName() + ": " + tileEntity.fluidTank.getFluid().amount : "No fluid.", 51, 35, 0x00CD00);
|
||||
fontRenderer.drawString(tileEntity.getVoltage()*Mekanism.FROM_UE + "v", 51, 44, 0x00CD00);
|
||||
|
||||
if(xAxis >= 7 && xAxis <= 23 && yAxis >= 14 && yAxis <= 72)
|
||||
{
|
||||
|
|
|
@ -19,10 +19,11 @@ import net.minecraft.item.ItemStack;
|
|||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
import powercrystals.minefactoryreloaded.api.IDeepStorageUnit;
|
||||
|
||||
import com.google.common.io.ByteArrayDataInput;
|
||||
|
||||
public class TileEntityBin extends TileEntityBasicBlock implements ISidedInventory, IActiveState
|
||||
public class TileEntityBin extends TileEntityBasicBlock implements ISidedInventory, IActiveState, IDeepStorageUnit
|
||||
{
|
||||
public boolean isActive;
|
||||
|
||||
|
@ -459,4 +460,34 @@ public class TileEntityBin extends TileEntityBasicBlock implements ISidedInvento
|
|||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getStoredItemType()
|
||||
{
|
||||
return MekanismUtils.size(itemType, itemCount);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setStoredItemCount(int amount)
|
||||
{
|
||||
if(amount == 0)
|
||||
{
|
||||
setStoredItemType(null, 0);
|
||||
}
|
||||
|
||||
itemCount = amount;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setStoredItemType(ItemStack type, int amount)
|
||||
{
|
||||
itemType = type;
|
||||
itemCount = amount;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxStoredCount()
|
||||
{
|
||||
return MAX_STORAGE;
|
||||
}
|
||||
}
|
|
@ -5,7 +5,6 @@ import ic2.api.energy.event.EnergyTileUnloadEvent;
|
|||
import ic2.api.energy.tile.IEnergySink;
|
||||
import ic2.api.energy.tile.IEnergyTile;
|
||||
import ic2.api.tile.IEnergyStorage;
|
||||
import ic2.api.tile.IWrenchable;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.EnumSet;
|
||||
|
@ -33,7 +32,7 @@ import cofh.api.energy.IEnergyHandler;
|
|||
|
||||
import com.google.common.io.ByteArrayDataInput;
|
||||
|
||||
public abstract class TileEntityElectricBlock extends TileEntityContainerBlock implements IWrenchable, ITileNetwork, IPowerReceptor, IEnergyTile, IElectrical, IElectricalStorage, IConnector, IStrictEnergyStorage, IEnergyHandler, IEnergySink, IEnergyStorage, IStrictEnergyAcceptor, ICableOutputter
|
||||
public abstract class TileEntityElectricBlock extends TileEntityContainerBlock implements ITileNetwork, IPowerReceptor, IEnergyTile, IElectrical, IElectricalStorage, IConnector, IStrictEnergyStorage, IEnergyHandler, IEnergySink, IEnergyStorage, IStrictEnergyAcceptor, ICableOutputter
|
||||
{
|
||||
/** How much energy is stored in this block. */
|
||||
public double electricityStored;
|
||||
|
@ -419,27 +418,8 @@ public abstract class TileEntityElectricBlock extends TileEntityContainerBlock i
|
|||
{
|
||||
return i;
|
||||
}
|
||||
|
||||
if(!getConsumingSides().contains(direction))
|
||||
{
|
||||
return i;
|
||||
}
|
||||
|
||||
double givenEnergy = i*Mekanism.FROM_IC2;
|
||||
double rejects = 0;
|
||||
double neededEnergy = getMaxEnergy()-getEnergy();
|
||||
|
||||
if(givenEnergy <= neededEnergy)
|
||||
{
|
||||
setEnergy(getEnergy() + givenEnergy);
|
||||
}
|
||||
else if(givenEnergy > neededEnergy)
|
||||
{
|
||||
setEnergy(getEnergy() + neededEnergy);
|
||||
rejects = givenEnergy-neededEnergy;
|
||||
}
|
||||
|
||||
return rejects*Mekanism.TO_IC2;
|
||||
return transferEnergyToAcceptor(direction, i*Mekanism.FROM_IC2)*Mekanism.TO_IC2;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -450,18 +430,9 @@ public abstract class TileEntityElectricBlock extends TileEntityContainerBlock i
|
|||
return amount;
|
||||
}
|
||||
|
||||
double rejects = 0;
|
||||
double neededElectricity = getMaxEnergy()-getEnergy();
|
||||
double toUse = Math.min(getMaxEnergy()-getEnergy(), amount);
|
||||
setEnergy(getEnergy() + toUse);
|
||||
|
||||
if(amount <= neededElectricity)
|
||||
{
|
||||
setEnergy(getEnergy() + amount);
|
||||
}
|
||||
else {
|
||||
setEnergy(getEnergy() + neededElectricity);
|
||||
rejects = amount-neededElectricity;
|
||||
}
|
||||
|
||||
return rejects;
|
||||
return amount-toUse;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,6 +17,7 @@ import net.minecraft.inventory.ISidedInventory;
|
|||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
import powercrystals.minefactoryreloaded.api.IDeepStorageUnit;
|
||||
|
||||
public class TransporterManager
|
||||
{
|
||||
|
@ -99,7 +100,7 @@ public class TransporterManager
|
|||
}
|
||||
}
|
||||
|
||||
if(inv instanceof TileEntityBin)
|
||||
if(inv instanceof IDeepStorageUnit)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
@ -300,10 +301,10 @@ public class TransporterManager
|
|||
|
||||
if(slots != null && slots.length != 0)
|
||||
{
|
||||
if(sidedInventory instanceof TileEntityBin && ForgeDirection.getOrientation(side).getOpposite().ordinal() == 0)
|
||||
/*if(sidedInventory instanceof TileEntityBin && ForgeDirection.getOrientation(side).getOpposite().ordinal() == 0)
|
||||
{
|
||||
slots = sidedInventory.getAccessibleSlotsFromSide(1);
|
||||
}
|
||||
}*/
|
||||
|
||||
for(int get = 0; get <= slots.length - 1; get++)
|
||||
{
|
||||
|
|
|
@ -0,0 +1,26 @@
|
|||
package powercrystals.minefactoryreloaded.api;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public interface IDeepStorageUnit
|
||||
{
|
||||
/**
|
||||
* @return A populated ItemStack with stackSize for the full amount of materials in the DSU. May have a stackSize > getMaxStackSize().
|
||||
*/
|
||||
ItemStack getStoredItemType();
|
||||
|
||||
/**
|
||||
* Sets the total amount of the item currently being stored, or zero if it wants to remove all items.
|
||||
*/
|
||||
void setStoredItemCount(int amount);
|
||||
|
||||
/**
|
||||
* Sets the type of the stored item and initializes the number of stored items to amount. Will overwrite any existing stored items.
|
||||
*/
|
||||
void setStoredItemType(ItemStack type, int amount);
|
||||
|
||||
/**
|
||||
* @return The maximum number of items the DSU can hold.
|
||||
*/
|
||||
int getMaxStoredCount();
|
||||
}
|
Loading…
Reference in a new issue