AE2 First Commit, the dawn of 1.7 hast arrived.
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
package appeng.container.implementations;
|
||||
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import appeng.container.AEBaseContainer;
|
||||
import appeng.container.slot.SlotRestrictedInput;
|
||||
import appeng.container.slot.SlotRestrictedInput.PlaceableItemType;
|
||||
import appeng.tile.storage.TileChest;
|
||||
|
||||
public class ContainerChest extends AEBaseContainer
|
||||
{
|
||||
|
||||
TileChest myte;
|
||||
|
||||
public ContainerChest(InventoryPlayer ip, TileChest te) {
|
||||
super( ip, te );
|
||||
myte = te;
|
||||
|
||||
addSlotToContainer( new SlotRestrictedInput( PlaceableItemType.STORAGE_CELLS, myte, 1, 80, 37 ) );
|
||||
|
||||
bindPlayerInventory( ip, 0, 166 - /* height of playerinventory */82 );
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,106 @@
|
||||
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;
|
||||
import appeng.container.slot.SlotRestrictedInput;
|
||||
import appeng.container.slot.SlotRestrictedInput.PlaceableItemType;
|
||||
import appeng.tile.misc.TileCondenser;
|
||||
import appeng.util.Platform;
|
||||
import buildcraft.core.gui.slots.SlotOutput;
|
||||
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) {
|
||||
super( ip, te );
|
||||
myte = te;
|
||||
|
||||
addSlotToContainer( new SlotRestrictedInput( PlaceableItemType.TRASH, te, 0, 51, 52 ) );
|
||||
addSlotToContainer( new SlotOutput( te, 1, 105, 52 ) );
|
||||
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!
|
||||
((EntityPlayerMP) icrafting).playerInventoryBeingManipulated = false;
|
||||
}
|
||||
}
|
||||
|
||||
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];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package appeng.container.implementations;
|
||||
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import appeng.container.AEBaseContainer;
|
||||
import appeng.container.slot.SlotRestrictedInput;
|
||||
import appeng.container.slot.SlotRestrictedInput.PlaceableItemType;
|
||||
import appeng.tile.storage.TileDrive;
|
||||
|
||||
public class ContainerDrive extends AEBaseContainer
|
||||
{
|
||||
|
||||
TileDrive myte;
|
||||
|
||||
public ContainerDrive(InventoryPlayer ip, TileDrive te) {
|
||||
super( ip, te );
|
||||
myte = te;
|
||||
|
||||
for (int y = 0; y < 5; y++)
|
||||
for (int x = 0; x < 2; x++)
|
||||
{
|
||||
addSlotToContainer( new SlotRestrictedInput( PlaceableItemType.STORAGE_CELLS, te, x + y * 2, 71 + x * 18, 14 + y * 18 ) );
|
||||
}
|
||||
|
||||
bindPlayerInventory( ip, 0, 199 - /* height of playerinventory */82 );
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
package appeng.container.implementations;
|
||||
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import appeng.container.AEBaseContainer;
|
||||
import appeng.container.slot.SlotInaccessable;
|
||||
import appeng.container.slot.SlotOutput;
|
||||
import appeng.container.slot.SlotRestrictedInput;
|
||||
import appeng.container.slot.SlotRestrictedInput.PlaceableItemType;
|
||||
import appeng.tile.grindstone.TileGrinder;
|
||||
|
||||
public class ContainerGrinder extends AEBaseContainer
|
||||
{
|
||||
|
||||
TileGrinder myte;
|
||||
|
||||
public ContainerGrinder(InventoryPlayer ip, TileGrinder te) {
|
||||
super( ip, te );
|
||||
myte = te;
|
||||
|
||||
addSlotToContainer( new SlotRestrictedInput( PlaceableItemType.ORE, te, 0, 12, 17 ) );
|
||||
addSlotToContainer( new SlotRestrictedInput( PlaceableItemType.ORE, te, 1, 12 + 18, 17 ) );
|
||||
addSlotToContainer( new SlotRestrictedInput( PlaceableItemType.ORE, te, 2, 12 + 36, 17 ) );
|
||||
|
||||
addSlotToContainer( new SlotInaccessable( te, 6, 80, 40 ) );
|
||||
|
||||
addSlotToContainer( new SlotOutput( te, 3, 112, 63, 2 * 16 + 15 ) );
|
||||
addSlotToContainer( new SlotOutput( te, 4, 112 + 18, 63, 2 * 16 + 15 ) );
|
||||
addSlotToContainer( new SlotOutput( te, 5, 112 + 36, 63, 2 * 16 + 15 ) );
|
||||
|
||||
bindPlayerInventory( ip, 0, 176 - /* height of playerinventory */82 );
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package appeng.container.implementations;
|
||||
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import appeng.container.AEBaseContainer;
|
||||
import appeng.parts.automation.PartLevelEmitter;
|
||||
|
||||
public class ContainerLevelEmitter extends AEBaseContainer
|
||||
{
|
||||
|
||||
PartLevelEmitter myte;
|
||||
|
||||
public ContainerLevelEmitter(InventoryPlayer ip, PartLevelEmitter te) {
|
||||
super( ip, te.getHost().getTile() );
|
||||
myte = te;
|
||||
|
||||
// addSlotToContainer( new SlotRestrictedInput(
|
||||
// PlaceableItemType.WIRELESS_TERMINAL, te, 0, 71, 14 ) );
|
||||
// addSlotToContainer( new SlotOutput( te, 1, 71, 14,
|
||||
// PlaceableItemType.WIRELESS_TERMINAL.icon ) );
|
||||
|
||||
bindPlayerInventory( ip, 0, 199 - /* height of playerinventory */82 );
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,166 @@
|
||||
package appeng.container.implementations;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.ICrafting;
|
||||
import net.minecraft.network.packet.Packet;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
import appeng.api.implementations.IMEChest;
|
||||
import appeng.api.implementations.IStorageMonitorable;
|
||||
import appeng.api.networking.IGrid;
|
||||
import appeng.api.networking.IGridHost;
|
||||
import appeng.api.networking.IGridNode;
|
||||
import appeng.api.networking.energy.IEnergyGrid;
|
||||
import appeng.api.storage.IMEMonitor;
|
||||
import appeng.api.storage.IMEMontorHandlerReciever;
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.api.storage.data.IItemList;
|
||||
import appeng.container.AEBaseContainer;
|
||||
import appeng.core.sync.packets.PacketMEInventoryUpdate;
|
||||
import appeng.util.Platform;
|
||||
import appeng.util.item.ItemList;
|
||||
import cpw.mods.fml.common.network.PacketDispatcher;
|
||||
import cpw.mods.fml.common.network.Player;
|
||||
|
||||
public class ContainerMEMonitorable extends AEBaseContainer implements IMEMontorHandlerReciever<IAEItemStack>
|
||||
{
|
||||
|
||||
final IMEMonitor<IAEItemStack> monitor;
|
||||
final IItemList<IAEItemStack> items = new ItemList<IAEItemStack>();
|
||||
|
||||
public ContainerMEMonitorable(InventoryPlayer ip, IStorageMonitorable montiorable) {
|
||||
super( ip, montiorable instanceof TileEntity ? (TileEntity) montiorable : null );
|
||||
|
||||
if ( Platform.isServer() )
|
||||
{
|
||||
monitor = montiorable.getItemInventory();
|
||||
monitor.addListener( this, null );
|
||||
|
||||
cellInv = monitor;
|
||||
if ( montiorable instanceof IMEChest )
|
||||
powerSrc = (IMEChest) montiorable;
|
||||
else if ( montiorable instanceof IGridHost )
|
||||
{
|
||||
IGridNode node = ((IGridHost) montiorable).getGridNode( ForgeDirection.UNKNOWN );
|
||||
if ( node != null )
|
||||
{
|
||||
IGrid g = node.getGrid();
|
||||
if ( g != null )
|
||||
powerSrc = g.getCache( IEnergyGrid.class );
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
monitor = null;
|
||||
|
||||
bindPlayerInventory( ip, 0, 0 );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void detectAndSendChanges()
|
||||
{
|
||||
if ( Platform.isServer() )
|
||||
{
|
||||
if ( !items.isEmpty() )
|
||||
{
|
||||
try
|
||||
{
|
||||
IItemList<IAEItemStack> monitorCache = monitor.getStorageList();
|
||||
|
||||
PacketMEInventoryUpdate piu = new PacketMEInventoryUpdate();
|
||||
|
||||
for (IAEItemStack is : items)
|
||||
{
|
||||
IAEItemStack send = monitorCache.findPrecise( is );
|
||||
if ( send == null )
|
||||
{
|
||||
is.setStackSize( 0 );
|
||||
piu.appendItem( is );
|
||||
}
|
||||
else
|
||||
piu.appendItem( send );
|
||||
}
|
||||
|
||||
if ( !piu.isEmpty() )
|
||||
{
|
||||
Packet p = piu.getPacket();
|
||||
items.resetStatus();
|
||||
|
||||
for (Object c : this.crafters)
|
||||
{
|
||||
if ( c instanceof Player )
|
||||
PacketDispatcher.sendPacketToPlayer( p, (Player) c );
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
super.detectAndSendChanges();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addCraftingToCrafters(ICrafting c)
|
||||
{
|
||||
super.addCraftingToCrafters( c );
|
||||
|
||||
if ( Platform.isServer() && c instanceof Player )
|
||||
{
|
||||
try
|
||||
{
|
||||
PacketMEInventoryUpdate piu = new PacketMEInventoryUpdate();
|
||||
IItemList<IAEItemStack> monitorCache = monitor.getStorageList();
|
||||
|
||||
for (IAEItemStack send : monitorCache)
|
||||
{
|
||||
piu.appendItem( send );
|
||||
}
|
||||
|
||||
Packet p = piu.getPacket();
|
||||
PacketDispatcher.sendPacketToPlayer( p, (Player) c );
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onContainerClosed(EntityPlayer player)
|
||||
{
|
||||
super.onContainerClosed( player );
|
||||
if ( monitor != null )
|
||||
monitor.removeListener( this );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeCraftingFromCrafters(ICrafting c)
|
||||
{
|
||||
super.removeCraftingFromCrafters( c );
|
||||
|
||||
if ( this.crafters.isEmpty() )
|
||||
monitor.removeListener( this );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void postChange(IAEItemStack change)
|
||||
{
|
||||
items.add( change );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValid(Object verificationToken)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package appeng.container.implementations;
|
||||
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import appeng.container.AEBaseContainer;
|
||||
|
||||
public class ContainerNetworkStatus extends AEBaseContainer
|
||||
{
|
||||
|
||||
TileEntity myte;
|
||||
|
||||
public ContainerNetworkStatus(InventoryPlayer ip, TileEntity te) {
|
||||
super( ip, (TileEntity) te );
|
||||
myte = te;
|
||||
|
||||
// addSlotToContainer( new SlotRestrictedInput(
|
||||
// PlaceableItemType.WIRELESS_TERMINAL, te, 0, 71, 14 ) );
|
||||
// addSlotToContainer( new SlotOutput( te, 1, 71, 14,
|
||||
// PlaceableItemType.WIRELESS_TERMINAL.icon ) );
|
||||
|
||||
bindPlayerInventory( ip, 0, 199 - /* height of playerinventory */82 );
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
package appeng.container.implementations;
|
||||
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import appeng.container.AEBaseContainer;
|
||||
import appeng.container.slot.SlotOutput;
|
||||
import appeng.container.slot.SlotRestrictedInput;
|
||||
import appeng.container.slot.SlotRestrictedInput.PlaceableItemType;
|
||||
import appeng.tile.spatial.TileSpatialIOPort;
|
||||
|
||||
public class ContainerSpatialIOPort extends AEBaseContainer
|
||||
{
|
||||
|
||||
TileSpatialIOPort myte;
|
||||
|
||||
public ContainerSpatialIOPort(InventoryPlayer ip, TileSpatialIOPort te) {
|
||||
super( ip, te );
|
||||
myte = te;
|
||||
|
||||
addSlotToContainer( new SlotRestrictedInput( PlaceableItemType.SPATIAL_STORAGE_CELLS, te, 0, 71, 14 ) );
|
||||
addSlotToContainer( new SlotOutput( te, 1, 71, 14, PlaceableItemType.SPATIAL_STORAGE_CELLS.icon ) );
|
||||
|
||||
bindPlayerInventory( ip, 0, 199 - /* height of playerinventory */82 );
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,78 @@
|
||||
package appeng.container.implementations;
|
||||
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.ICrafting;
|
||||
import appeng.container.AEBaseContainer;
|
||||
import appeng.container.slot.SlotRestrictedInput;
|
||||
import appeng.container.slot.SlotRestrictedInput.PlaceableItemType;
|
||||
import appeng.core.AELog;
|
||||
import appeng.tile.misc.TileVibrationChamber;
|
||||
import appeng.util.Platform;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
public class ContainerVibrationChamber extends AEBaseContainer
|
||||
{
|
||||
|
||||
TileVibrationChamber myte;
|
||||
|
||||
public ContainerVibrationChamber(InventoryPlayer ip, TileVibrationChamber te) {
|
||||
super( ip, te );
|
||||
myte = te;
|
||||
|
||||
addSlotToContainer( new SlotRestrictedInput( PlaceableItemType.FUEL, te, 0, 80, 37 ) );
|
||||
|
||||
bindPlayerInventory( ip, 0, 166 - /* height of playerinventory */82 );
|
||||
}
|
||||
|
||||
public int aePerTick = 5;
|
||||
public int burnSpeed = 100;
|
||||
public int burnProgress = 0;
|
||||
|
||||
@Override
|
||||
public void detectAndSendChanges()
|
||||
{
|
||||
super.detectAndSendChanges();
|
||||
|
||||
if ( Platform.isServer() )
|
||||
{
|
||||
int burnProgress = (int) (this.myte.maxBurnTime <= 0 ? 0 : 12 * this.myte.burnTime / this.myte.maxBurnTime);
|
||||
|
||||
for (int i = 0; i < this.crafters.size(); ++i)
|
||||
{
|
||||
ICrafting icrafting = (ICrafting) this.crafters.get( i );
|
||||
|
||||
if ( this.burnProgress != burnProgress )
|
||||
{
|
||||
icrafting.sendProgressBarUpdate( this, 0, (int) burnProgress );
|
||||
}
|
||||
|
||||
if ( this.burnSpeed != this.myte.burnSpeed )
|
||||
{
|
||||
AELog.info( "" + this.myte.burnSpeed );
|
||||
icrafting.sendProgressBarUpdate( this, 1, this.myte.burnSpeed );
|
||||
}
|
||||
}
|
||||
|
||||
this.burnProgress = burnProgress;
|
||||
this.burnSpeed = this.myte.burnSpeed;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void updateProgressBar(int idx, int value)
|
||||
{
|
||||
if ( idx == 0 )
|
||||
{
|
||||
this.burnProgress = value;
|
||||
}
|
||||
|
||||
if ( idx == 1 )
|
||||
{
|
||||
this.burnSpeed = value;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user