2013-12-27 23:59:59 +01:00
|
|
|
package appeng.container.implementations;
|
|
|
|
|
|
|
|
import net.minecraft.entity.player.EntityPlayerMP;
|
|
|
|
import net.minecraft.entity.player.InventoryPlayer;
|
|
|
|
import net.minecraft.inventory.ICrafting;
|
|
|
|
import appeng.api.config.CondenserOuput;
|
|
|
|
import appeng.api.config.Settings;
|
|
|
|
import appeng.container.AEBaseContainer;
|
2014-01-20 17:41:37 +01:00
|
|
|
import appeng.container.slot.SlotOutput;
|
2013-12-27 23:59:59 +01:00
|
|
|
import appeng.container.slot.SlotRestrictedInput;
|
|
|
|
import appeng.container.slot.SlotRestrictedInput.PlaceableItemType;
|
|
|
|
import appeng.tile.misc.TileCondenser;
|
|
|
|
import appeng.util.Platform;
|
|
|
|
import cpw.mods.fml.relauncher.Side;
|
|
|
|
import cpw.mods.fml.relauncher.SideOnly;
|
|
|
|
|
|
|
|
public class ContainerCondenser extends AEBaseContainer
|
|
|
|
{
|
|
|
|
|
|
|
|
TileCondenser myte;
|
|
|
|
|
|
|
|
public ContainerCondenser(InventoryPlayer ip, TileCondenser te) {
|
2014-01-02 06:51:41 +01:00
|
|
|
super( ip, te, null );
|
2013-12-27 23:59:59 +01:00
|
|
|
myte = te;
|
|
|
|
|
|
|
|
addSlotToContainer( new SlotRestrictedInput( PlaceableItemType.TRASH, te, 0, 51, 52 ) );
|
2014-01-31 04:08:44 +01:00
|
|
|
addSlotToContainer( new SlotOutput( te, 1, 105, 52, -1 ) );
|
2013-12-27 23:59:59 +01:00
|
|
|
addSlotToContainer( (new SlotRestrictedInput( PlaceableItemType.STORAGE_COMPONENT, te.getInternalInventory(), 2, 101, 26 )).setStackLimit( 1 ) );
|
|
|
|
|
|
|
|
bindPlayerInventory( ip, 0, 197 - /* height of playerinventory */82 );
|
|
|
|
}
|
|
|
|
|
|
|
|
public int requiredEnergy = 0;
|
|
|
|
public int storedPower = 0;
|
|
|
|
public CondenserOuput output = CondenserOuput.TRASH;
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void detectAndSendChanges()
|
|
|
|
{
|
|
|
|
if ( Platform.isServer() )
|
|
|
|
{
|
|
|
|
double maxStorage = this.myte.getStorage();
|
|
|
|
double requiredEnergy = this.myte.getRequiredPower();
|
|
|
|
int maxDisplay = requiredEnergy == 0 ? (int) maxStorage : (int) Math.min( requiredEnergy, maxStorage );
|
|
|
|
|
|
|
|
for (int i = 0; i < this.crafters.size(); ++i)
|
|
|
|
{
|
|
|
|
boolean changed = false;
|
|
|
|
|
|
|
|
ICrafting icrafting = (ICrafting) this.crafters.get( i );
|
|
|
|
|
|
|
|
if ( this.requiredEnergy != maxDisplay )
|
|
|
|
{
|
|
|
|
icrafting.sendProgressBarUpdate( this, 0, (int) maxDisplay );
|
|
|
|
changed = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( this.storedPower != this.myte.storedPower )
|
|
|
|
{
|
|
|
|
icrafting.sendProgressBarUpdate( this, 1, (int) this.myte.storedPower );
|
|
|
|
changed = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( this.output != this.myte.getConfigManager().getSetting( Settings.CONDENSER_OUTPUT ) )
|
|
|
|
{
|
|
|
|
icrafting.sendProgressBarUpdate( this, 2, (int) this.myte.getConfigManager().getSetting( Settings.CONDENSER_OUTPUT ).ordinal() );
|
|
|
|
changed = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( changed )
|
|
|
|
{
|
|
|
|
// if the bars changed an item was probably made, so just send shit!
|
2014-02-09 02:34:52 +01:00
|
|
|
((EntityPlayerMP) icrafting).isChangingQuantityOnly = false;
|
2013-12-27 23:59:59 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
this.requiredEnergy = (int) maxDisplay;
|
|
|
|
this.storedPower = (int) this.myte.storedPower;
|
|
|
|
this.output = (CondenserOuput) this.myte.getConfigManager().getSetting( Settings.CONDENSER_OUTPUT );
|
|
|
|
}
|
|
|
|
|
|
|
|
super.detectAndSendChanges();
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@SideOnly(Side.CLIENT)
|
|
|
|
public void updateProgressBar(int idx, int value)
|
|
|
|
{
|
|
|
|
if ( idx == 0 )
|
|
|
|
{
|
|
|
|
this.requiredEnergy = value;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( idx == 1 )
|
|
|
|
{
|
|
|
|
this.storedPower = value;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( idx == 2 )
|
|
|
|
{
|
|
|
|
this.output = CondenserOuput.values()[value];
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|