Swapped out Gui Sync with something a little more fancy.

This commit is contained in:
AlgorithmX2 2014-05-07 00:22:42 -05:00
parent 24d497e583
commit 1db9283eed
25 changed files with 750 additions and 973 deletions

View file

@ -83,8 +83,8 @@ public class GuiCondenser extends AEBaseGui
mode.set( cvc.output );
mode.FillVar = "" + cvc.output.requiredPower;
pb.max = cvc.requiredEnergy;
pb.current = cvc.storedPower;
pb.max = (int) cvc.requiredEnergy;
pb.current = (int) cvc.storedPower;
}
}

View file

@ -26,7 +26,6 @@ public class GuiMAC extends GuiUpgradeable
public GuiMAC(InventoryPlayer inventoryPlayer, TileMolecularAssembler te) {
super( new ContainerMAC( inventoryPlayer, te ) );
this.ySize = 197;
this.xSize = 211;
}
protected GuiText getName()

View file

@ -1,7 +1,9 @@
package appeng.container;
import java.io.IOException;
import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
@ -10,6 +12,7 @@ import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.Container;
import net.minecraft.inventory.ICrafting;
import net.minecraft.inventory.IInventory;
import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack;
@ -31,6 +34,8 @@ import appeng.api.storage.IMEInventoryHandler;
import appeng.api.storage.data.IAEItemStack;
import appeng.client.me.InternalSlotME;
import appeng.client.me.SlotME;
import appeng.container.guisync.GuiSync;
import appeng.container.guisync.SyncDat;
import appeng.container.slot.AppEngSlot;
import appeng.container.slot.SlotCraftingMatrix;
import appeng.container.slot.SlotCraftingTerm;
@ -142,6 +147,7 @@ public abstract class AEBaseContainer extends Container
tileEntity = myTile;
part = myPart;
mySrc = new PlayerSource( ip.player, (IActionHost) (myTile instanceof IActionHost ? myTile : (myPart instanceof IActionHost ? myPart : null)) );
prepareSync();
}
public boolean canDragIntoSlot(Slot s)
@ -417,13 +423,63 @@ public abstract class AEBaseContainer extends Container
detectAndSendChanges();
}
HashMap<Integer, SyncDat> syncData = new HashMap<Integer, SyncDat>();
@Override
public void detectAndSendChanges()
{
sendCustomName();
if ( Platform.isServer() )
{
for (int i = 0; i < this.crafters.size(); ++i)
{
ICrafting icrafting = (ICrafting) this.crafters.get( i );
for (SyncDat sd : syncData.values())
sd.tick( icrafting );
}
}
super.detectAndSendChanges();
}
final public void updateProgressBar(int idx, int value)
{
if ( syncData.containsKey( idx ) )
{
syncData.get( idx ).update( value );
return;
}
}
final public void updateFullProgressBar(int idx, long value)
{
if ( syncData.containsKey( idx ) )
{
syncData.get( idx ).update( value );
return;
}
updateProgressBar( idx, (int) value );
}
private void prepareSync()
{
for (Field f : getClass().getFields())
{
if ( f.isAnnotationPresent( GuiSync.class ) )
{
GuiSync anno = f.getAnnotation( GuiSync.class );
if ( syncData.containsKey( anno.value() ) )
AELog.warning( "Channel already in use: " + anno.value() + " for " + f.getName() );
else
syncData.put( anno.value(), new SyncDat( this, f, anno ) );
}
}
}
protected void sendCustomName()
{
if ( !sentCustomName )
@ -744,11 +800,6 @@ public abstract class AEBaseContainer extends Container
}
}
public void updateFullProgressBar(int id, long value)
{
updateProgressBar( id, (int) value );
}
protected void updateHeld(EntityPlayerMP p)
{
try
@ -824,4 +875,9 @@ public abstract class AEBaseContainer extends Container
a.putStack( testA );
b.putStack( testB );
}
public void onUpdate(String field, Object oldValue, Object newValue)
{
}
}

View file

@ -0,0 +1,11 @@
package appeng.container.guisync;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
@Retention(RetentionPolicy.RUNTIME)
public @interface GuiSync {
int value();
}

View file

@ -0,0 +1,145 @@
package appeng.container.guisync;
import java.io.IOException;
import java.lang.reflect.Field;
import java.util.EnumSet;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.inventory.ICrafting;
import appeng.container.AEBaseContainer;
import appeng.core.AELog;
import appeng.core.sync.network.NetworkHandler;
import appeng.core.sync.packets.PacketProgressBar;
public class SyncDat
{
private Object clientVersion;
private AEBaseContainer source;
private Field field;
private int channel;
public SyncDat(AEBaseContainer container, Field field, GuiSync anno) {
clientVersion = null;
this.source = container;
this.field = field;
channel = anno.value();
}
public int getChannel()
{
return channel;
}
public void tick(ICrafting c)
{
try
{
Object val = field.get( source );
if ( val == clientVersion )
return;
else if ( val != null && clientVersion == null )
send( c, val );
else if ( !val.equals( clientVersion ) )
send( c, val );
}
catch (IllegalArgumentException e)
{
AELog.error( e );
}
catch (IllegalAccessException e)
{
AELog.error( e );
}
catch (IOException e)
{
AELog.error( e );
}
}
public void update(long val)
{
try
{
Object oldValue = field.get( source );
updateValue( oldValue, val );
}
catch (IllegalArgumentException e)
{
AELog.error( e );
}
catch (IllegalAccessException e)
{
AELog.error( e );
}
}
private void updateValue(Object oldValue, long val)
{
try
{
if ( field.getType().isEnum() )
{
EnumSet<? extends Enum> valList = EnumSet.allOf( (Class<? extends Enum>) field.getType() );
for (Enum e : valList)
{
if ( e.ordinal() == val )
{
field.set( source, e );
break;
}
}
}
else
{
if ( field.getType().equals( int.class ) )
field.set( source, (int) val );
else if ( field.getType().equals( long.class ) )
field.set( source, (long) val );
else if ( field.getType().equals( boolean.class ) )
field.set( source, val == 1 );
else if ( field.getType().equals( Integer.class ) )
field.set( source, (Integer) (int) val );
else if ( field.getType().equals( Long.class ) )
field.set( source, (Long) val );
else if ( field.getType().equals( Boolean.class ) )
field.set( source, (Boolean) (val == 1) );
}
source.onUpdate( field.getName(), oldValue, field.get( source ) );
}
catch (IllegalArgumentException e)
{
AELog.error( e );
}
catch (IllegalAccessException e)
{
AELog.error( e );
}
}
private void send(ICrafting o, Object val) throws IOException
{
if ( field.getType().isEnum() )
{
o.sendProgressBarUpdate( source, channel, ((Enum) val).ordinal() );
}
else if ( val instanceof Long || val.getClass() == long.class )
{
NetworkHandler.instance.sendTo( new PacketProgressBar( channel, (Long) val ), (EntityPlayerMP) o );
}
else if ( val instanceof Boolean || val.getClass() == boolean.class )
{
o.sendProgressBarUpdate( source, channel, ((Boolean) val) ? 1 : 0 );
}
else
{
o.sendProgressBarUpdate( source, channel, (Integer) val );
}
clientVersion = val;
}
}

View file

@ -1,324 +1,310 @@
package appeng.container.implementations;
import java.util.Iterator;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.ICrafting;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import appeng.api.AEApi;
import appeng.api.config.CopyMode;
import appeng.api.config.FuzzyMode;
import appeng.api.config.Settings;
import appeng.api.storage.ICellWorkbenchItem;
import appeng.api.storage.IMEInventory;
import appeng.api.storage.StorageChannel;
import appeng.api.storage.data.IAEItemStack;
import appeng.api.storage.data.IItemList;
import appeng.container.slot.OptionalSlotRestrictedInput;
import appeng.container.slot.SlotFakeTypeOnly;
import appeng.container.slot.SlotRestrictedInput;
import appeng.container.slot.SlotRestrictedInput.PlaceableItemType;
import appeng.tile.inventory.AppEngNullInventory;
import appeng.tile.misc.TileCellWorkbench;
import appeng.util.Platform;
import appeng.util.iterators.NullIterator;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class ContainerCellWorkbench extends ContainerUpgradeable
{
TileCellWorkbench workBench;
AppEngNullInventory ni = new AppEngNullInventory();
public IInventory getCellUpgradeInventory()
{
IInventory ri = workBench.getCellUpgradeInventory();
return ri == null ? ni : ri;
}
public void setFuzzy(FuzzyMode valueOf)
{
ICellWorkbenchItem cwi = workBench.getCell();
if ( cwi != null )
cwi.setFuzzyMode( workBench.getInventoryByName( "cell" ).getStackInSlot( 0 ), valueOf );
}
private FuzzyMode getFuzzyMode()
{
ICellWorkbenchItem cwi = workBench.getCell();
if ( cwi != null )
return cwi.getFuzzyMode( workBench.getInventoryByName( "cell" ).getStackInSlot( 0 ) );
return FuzzyMode.IGNORE_ALL;
}
public void nextCopyMode()
{
workBench.getConfigManager().putSetting( Settings.COPY_MODE, Platform.nextEnum( getCopyMode() ) );
}
public CopyMode getCopyMode()
{
return (CopyMode) workBench.getConfigManager().getSetting( Settings.COPY_MODE );
}
class Upgrades implements IInventory
{
@Override
public int getSizeInventory()
{
return getCellUpgradeInventory().getSizeInventory();
}
@Override
public ItemStack getStackInSlot(int i)
{
return getCellUpgradeInventory().getStackInSlot( i );
}
@Override
public ItemStack decrStackSize(int i, int j)
{
IInventory inv = getCellUpgradeInventory();
ItemStack is = inv.decrStackSize( i, j );
inv.markDirty();
return is;
}
@Override
public ItemStack getStackInSlotOnClosing(int i)
{
IInventory inv = getCellUpgradeInventory();
ItemStack is = inv.getStackInSlotOnClosing( i );
inv.markDirty();
return is;
}
@Override
public void setInventorySlotContents(int i, ItemStack itemstack)
{
IInventory inv = getCellUpgradeInventory();
inv.setInventorySlotContents( i, itemstack );
inv.markDirty();
}
@Override
public String getInventoryName()
{
return "Upgrades";
}
@Override
public boolean hasCustomInventoryName()
{
return false;
}
@Override
public int getInventoryStackLimit()
{
return 1;
}
@Override
public void markDirty()
{
}
@Override
public boolean isUseableByPlayer(EntityPlayer entityplayer)
{
return false;
}
@Override
public void openInventory()
{
}
@Override
public void closeInventory()
{
}
@Override
public boolean isItemValidForSlot(int i, ItemStack itemstack)
{
return getCellUpgradeInventory().isItemValidForSlot( i, itemstack );
}
};
IInventory UpgradeInventoryWrapper;
ItemStack prevStack = null;
int lastUpgrades = 0;
public CopyMode copyMode = CopyMode.CLEAR_ON_REMOVE;
public ContainerCellWorkbench(InventoryPlayer ip, TileCellWorkbench te) {
super( ip, te );
workBench = te;
}
@Override
protected int getHeight()
{
return 251;
}
@Override
public int availableUpgrades()
{
ItemStack is = workBench.getInventoryByName( "cell" ).getStackInSlot( 0 );
if ( prevStack != is )
{
prevStack = is;
return lastUpgrades = getCellUpgradeInventory().getSizeInventory();
}
return lastUpgrades;
}
@Override
public boolean isSlotEnabled(int idx)
{
return idx < availableUpgrades();
}
@Override
protected void setupConfig()
{
int x = 8;
int y = 29;
int offset = 0;
IInventory cell = myte.getInventoryByName( "cell" );
addSlotToContainer( new SlotRestrictedInput( PlaceableItemType.WORKBENCH_CELL, cell, 0, 152, 8 ) );
IInventory inv = myte.getInventoryByName( "config" );
UpgradeInventoryWrapper = new Upgrades();// Platform.isServer() ? new Upgrades() : new AppEngInternalInventory(
// null, 3 * 8 );
for (int w = 0; w < 7; w++)
for (int z = 0; z < 9; z++)
addSlotToContainer( new SlotFakeTypeOnly( inv, offset++, x + z * 18, y + w * 18 ) );
for (int zz = 0; zz < 3; zz++)
for (int z = 0; z < 8; z++)
{
int iSLot = zz * 8 + z;
addSlotToContainer( new OptionalSlotRestrictedInput( PlaceableItemType.UPGRADES, UpgradeInventoryWrapper, this, iSLot, 187 + zz * 18,
8 + 18 * z, iSLot ) );
}
/*
* if ( supportCapacity() ) { for (int w = 0; w < 2; w++) for (int z = 0; z < 9; z++) addSlotToContainer( new
* OptionalSlotFakeTypeOnly( inv, this, offset++, x, y, z, w, 1 ) );
*
* for (int w = 0; w < 2; w++) for (int z = 0; z < 9; z++) addSlotToContainer( new OptionalSlotFakeTypeOnly(
* inv, this, offset++, x, y, z, w + 2, 2 ) );
*
* for (int w = 0; w < 2; w++) for (int z = 0; z < 9; z++) addSlotToContainer( new OptionalSlotFakeTypeOnly(
* inv, this, offset++, x, y, z, w + 4, 3 ) ); }
*/
}
ItemStack LastCell;
@Override
@SideOnly(Side.CLIENT)
public void updateProgressBar(int idx, int value)
{
super.updateProgressBar( idx, value );
if ( idx == 2 )
{
this.copyMode = CopyMode.values()[value];
workBench.getConfigManager().putSetting( Settings.COPY_MODE, this.copyMode );
}
}
@Override
public void detectAndSendChanges()
{
ItemStack is = workBench.getInventoryByName( "cell" ).getStackInSlot( 0 );
if ( Platform.isServer() )
{
for (int i = 0; i < this.crafters.size(); ++i)
{
ICrafting icrafting = (ICrafting) this.crafters.get( i );
if ( copyMode != getCopyMode() )
{
icrafting.sendProgressBarUpdate( this, 2, (int) getCopyMode().ordinal() );
}
if ( this.fzMode != getFuzzyMode() )
{
icrafting.sendProgressBarUpdate( this, 1, (int) getFuzzyMode().ordinal() );
}
if ( prevStack != is )
{
// if the bars changed an item was probably made, so just send shit!
for (Object s : inventorySlots)
{
if ( s instanceof OptionalSlotRestrictedInput )
{
OptionalSlotRestrictedInput sri = (OptionalSlotRestrictedInput) s;
icrafting.sendSlotContents( this, sri.slotNumber, sri.getStack() );
}
}
((EntityPlayerMP) icrafting).isChangingQuantityOnly = false;
}
}
package appeng.container.implementations;
import java.util.Iterator;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.ICrafting;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import appeng.api.AEApi;
import appeng.api.config.CopyMode;
import appeng.api.config.FuzzyMode;
import appeng.api.config.Settings;
import appeng.api.storage.ICellWorkbenchItem;
import appeng.api.storage.IMEInventory;
import appeng.api.storage.StorageChannel;
import appeng.api.storage.data.IAEItemStack;
import appeng.api.storage.data.IItemList;
import appeng.container.guisync.GuiSync;
import appeng.container.slot.OptionalSlotRestrictedInput;
import appeng.container.slot.SlotFakeTypeOnly;
import appeng.container.slot.SlotRestrictedInput;
import appeng.container.slot.SlotRestrictedInput.PlaceableItemType;
import appeng.tile.inventory.AppEngNullInventory;
import appeng.tile.misc.TileCellWorkbench;
import appeng.util.Platform;
import appeng.util.iterators.NullIterator;
public class ContainerCellWorkbench extends ContainerUpgradeable
{
TileCellWorkbench workBench;
AppEngNullInventory ni = new AppEngNullInventory();
public IInventory getCellUpgradeInventory()
{
IInventory ri = workBench.getCellUpgradeInventory();
return ri == null ? ni : ri;
}
public void setFuzzy(FuzzyMode valueOf)
{
ICellWorkbenchItem cwi = workBench.getCell();
if ( cwi != null )
cwi.setFuzzyMode( workBench.getInventoryByName( "cell" ).getStackInSlot( 0 ), valueOf );
}
private FuzzyMode getFuzzyMode()
{
ICellWorkbenchItem cwi = workBench.getCell();
if ( cwi != null )
return cwi.getFuzzyMode( workBench.getInventoryByName( "cell" ).getStackInSlot( 0 ) );
return FuzzyMode.IGNORE_ALL;
}
public void nextCopyMode()
{
workBench.getConfigManager().putSetting( Settings.COPY_MODE, Platform.nextEnum( getCopyMode() ) );
}
public CopyMode getCopyMode()
{
return (CopyMode) workBench.getConfigManager().getSetting( Settings.COPY_MODE );
}
class Upgrades implements IInventory
{
@Override
public int getSizeInventory()
{
return getCellUpgradeInventory().getSizeInventory();
}
@Override
public ItemStack getStackInSlot(int i)
{
return getCellUpgradeInventory().getStackInSlot( i );
}
@Override
public ItemStack decrStackSize(int i, int j)
{
IInventory inv = getCellUpgradeInventory();
ItemStack is = inv.decrStackSize( i, j );
inv.markDirty();
return is;
}
@Override
public ItemStack getStackInSlotOnClosing(int i)
{
IInventory inv = getCellUpgradeInventory();
ItemStack is = inv.getStackInSlotOnClosing( i );
inv.markDirty();
return is;
}
@Override
public void setInventorySlotContents(int i, ItemStack itemstack)
{
IInventory inv = getCellUpgradeInventory();
inv.setInventorySlotContents( i, itemstack );
inv.markDirty();
}
@Override
public String getInventoryName()
{
return "Upgrades";
}
@Override
public boolean hasCustomInventoryName()
{
return false;
}
@Override
public int getInventoryStackLimit()
{
return 1;
}
@Override
public void markDirty()
{
}
@Override
public boolean isUseableByPlayer(EntityPlayer entityplayer)
{
return false;
}
@Override
public void openInventory()
{
}
@Override
public void closeInventory()
{
}
@Override
public boolean isItemValidForSlot(int i, ItemStack itemstack)
{
return getCellUpgradeInventory().isItemValidForSlot( i, itemstack );
}
};
IInventory UpgradeInventoryWrapper;
ItemStack prevStack = null;
int lastUpgrades = 0;
@GuiSync(2)
public CopyMode copyMode = CopyMode.CLEAR_ON_REMOVE;
public ContainerCellWorkbench(InventoryPlayer ip, TileCellWorkbench te) {
super( ip, te );
workBench = te;
}
@Override
protected int getHeight()
{
return 251;
}
@Override
public int availableUpgrades()
{
ItemStack is = workBench.getInventoryByName( "cell" ).getStackInSlot( 0 );
if ( prevStack != is )
{
prevStack = is;
return lastUpgrades = getCellUpgradeInventory().getSizeInventory();
}
return lastUpgrades;
}
@Override
public boolean isSlotEnabled(int idx)
{
return idx < availableUpgrades();
}
@Override
protected void setupConfig()
{
int x = 8;
int y = 29;
int offset = 0;
IInventory cell = myte.getInventoryByName( "cell" );
addSlotToContainer( new SlotRestrictedInput( PlaceableItemType.WORKBENCH_CELL, cell, 0, 152, 8 ) );
IInventory inv = myte.getInventoryByName( "config" );
UpgradeInventoryWrapper = new Upgrades();// Platform.isServer() ? new Upgrades() : new AppEngInternalInventory(
// null, 3 * 8 );
for (int w = 0; w < 7; w++)
for (int z = 0; z < 9; z++)
addSlotToContainer( new SlotFakeTypeOnly( inv, offset++, x + z * 18, y + w * 18 ) );
for (int zz = 0; zz < 3; zz++)
for (int z = 0; z < 8; z++)
{
int iSLot = zz * 8 + z;
addSlotToContainer( new OptionalSlotRestrictedInput( PlaceableItemType.UPGRADES, UpgradeInventoryWrapper, this, iSLot, 187 + zz * 18,
8 + 18 * z, iSLot ) );
}
/*
* if ( supportCapacity() ) { for (int w = 0; w < 2; w++) for (int z = 0; z < 9; z++) addSlotToContainer( new
* OptionalSlotFakeTypeOnly( inv, this, offset++, x, y, z, w, 1 ) );
*
* for (int w = 0; w < 2; w++) for (int z = 0; z < 9; z++) addSlotToContainer( new OptionalSlotFakeTypeOnly(
* inv, this, offset++, x, y, z, w + 2, 2 ) );
*
* for (int w = 0; w < 2; w++) for (int z = 0; z < 9; z++) addSlotToContainer( new OptionalSlotFakeTypeOnly(
* inv, this, offset++, x, y, z, w + 4, 3 ) ); }
*/
}
ItemStack LastCell;
@Override
public void onUpdate(String field, Object oldValue, Object newValue)
{
if ( field.equals( "copyMode" ) )
workBench.getConfigManager().putSetting( Settings.COPY_MODE, this.copyMode );
super.onUpdate( field, oldValue, newValue );
}
@Override
public void detectAndSendChanges()
{
ItemStack is = workBench.getInventoryByName( "cell" ).getStackInSlot( 0 );
if ( Platform.isServer() )
{
for (int i = 0; i < this.crafters.size(); ++i)
{
ICrafting icrafting = (ICrafting) this.crafters.get( i );
if ( prevStack != is )
{
// if the bars changed an item was probably made, so just send shit!
for (Object s : inventorySlots)
{
if ( s instanceof OptionalSlotRestrictedInput )
{
OptionalSlotRestrictedInput sri = (OptionalSlotRestrictedInput) s;
icrafting.sendSlotContents( this, sri.slotNumber, sri.getStack() );
}
}
((EntityPlayerMP) icrafting).isChangingQuantityOnly = false;
}
}
this.copyMode = getCopyMode();
this.fzMode = (FuzzyMode) getFuzzyMode();
}
prevStack = is;
standardDetectAndSendChanges();
}
public void clear()
{
IInventory inv = myte.getInventoryByName( "config" );
for (int x = 0; x < inv.getSizeInventory(); x++)
inv.setInventorySlotContents( x, null );
detectAndSendChanges();
}
public void partition()
{
IInventory inv = myte.getInventoryByName( "config" );
IMEInventory<IAEItemStack> cellInv = AEApi.instance().registries().cell()
.getCellInventory( myte.getInventoryByName( "cell" ).getStackInSlot( 0 ), StorageChannel.ITEMS );
Iterator<IAEItemStack> i = new NullIterator<IAEItemStack>();
if ( cellInv != null )
{
IItemList<IAEItemStack> list = cellInv.getAvailableItems( AEApi.instance().storage().createItemList() );
i = list.iterator();
}
for (int x = 0; x < inv.getSizeInventory(); x++)
{
if ( i.hasNext() )
{
ItemStack g = i.next().getItemStack();
g.stackSize = 1;
inv.setInventorySlotContents( x, g );
}
else
inv.setInventorySlotContents( x, null );
}
detectAndSendChanges();
}
}
}
prevStack = is;
standardDetectAndSendChanges();
}
public void clear()
{
IInventory inv = myte.getInventoryByName( "config" );
for (int x = 0; x < inv.getSizeInventory(); x++)
inv.setInventorySlotContents( x, null );
detectAndSendChanges();
}
public void partition()
{
IInventory inv = myte.getInventoryByName( "config" );
IMEInventory<IAEItemStack> cellInv = AEApi.instance().registries().cell()
.getCellInventory( myte.getInventoryByName( "cell" ).getStackInSlot( 0 ), StorageChannel.ITEMS );
Iterator<IAEItemStack> i = new NullIterator<IAEItemStack>();
if ( cellInv != null )
{
IItemList<IAEItemStack> list = cellInv.getAvailableItems( AEApi.instance().storage().createItemList() );
i = list.iterator();
}
for (int x = 0; x < inv.getSizeInventory(); x++)
{
if ( i.hasNext() )
{
ItemStack g = i.next().getItemStack();
g.stackSize = 1;
inv.setInventorySlotContents( x, g );
}
else
inv.setInventorySlotContents( x, null );
}
detectAndSendChanges();
}
}

View file

@ -1,125 +1,56 @@
package appeng.container.implementations;
import java.io.IOException;
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.SlotOutput;
import appeng.container.slot.SlotRestrictedInput;
import appeng.container.slot.SlotRestrictedInput.PlaceableItemType;
import appeng.core.AELog;
import appeng.core.sync.network.NetworkHandler;
import appeng.core.sync.packets.PacketProgressBar;
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) {
super( ip, te, null );
myte = te;
addSlotToContainer( new SlotRestrictedInput( PlaceableItemType.TRASH, te, 0, 51, 52 ) );
addSlotToContainer( new SlotOutput( te, 1, 105, 52, -1 ) );
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 )
{
try
{
NetworkHandler.instance.sendTo( new PacketProgressBar( 0, (int) maxDisplay ), (EntityPlayerMP) icrafting );
}
catch (IOException e)
{
AELog.error( e );
}
changed = true;
}
if ( this.storedPower != this.myte.storedPower )
{
try
{
NetworkHandler.instance.sendTo( new PacketProgressBar( 1, (int) this.myte.storedPower ), (EntityPlayerMP) icrafting );
}
catch (IOException e)
{
AELog.error( e );
}
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).isChangingQuantityOnly = 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];
}
}
}
package appeng.container.implementations;
import net.minecraft.entity.player.InventoryPlayer;
import appeng.api.config.CondenserOuput;
import appeng.api.config.Settings;
import appeng.container.AEBaseContainer;
import appeng.container.guisync.GuiSync;
import appeng.container.slot.SlotOutput;
import appeng.container.slot.SlotRestrictedInput;
import appeng.container.slot.SlotRestrictedInput.PlaceableItemType;
import appeng.tile.misc.TileCondenser;
import appeng.util.Platform;
public class ContainerCondenser extends AEBaseContainer
{
TileCondenser myte;
public ContainerCondenser(InventoryPlayer ip, TileCondenser te) {
super( ip, te, null );
myte = te;
addSlotToContainer( new SlotRestrictedInput( PlaceableItemType.TRASH, te, 0, 51, 52 ) );
addSlotToContainer( new SlotOutput( te, 1, 105, 52, -1 ) );
addSlotToContainer( (new SlotRestrictedInput( PlaceableItemType.STORAGE_COMPONENT, te.getInternalInventory(), 2, 101, 26 )).setStackLimit( 1 ) );
bindPlayerInventory( ip, 0, 197 - /* height of playerinventory */82 );
}
@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 );
this.requiredEnergy = (int) maxDisplay;
this.storedPower = (int) this.myte.storedPower;
this.output = (CondenserOuput) this.myte.getConfigManager().getSetting( Settings.CONDENSER_OUTPUT );
}
super.detectAndSendChanges();
}
@GuiSync(0)
public long requiredEnergy = 0;
@GuiSync(1)
public long storedPower = 0;
@GuiSync(2)
public CondenserOuput output = CondenserOuput.TRASH;
}

View file

@ -1,7 +1,6 @@
package appeng.container.implementations;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.ICrafting;
import net.minecraft.inventory.IInventory;
import appeng.api.config.FuzzyMode;
import appeng.api.config.SecurityPermissions;
@ -83,30 +82,10 @@ public class ContainerFormationPlane extends ContainerUpgradeable
if ( Platform.isServer() )
{
for (int i = 0; i < this.crafters.size(); ++i)
{
ICrafting icrafting = (ICrafting) this.crafters.get( i );
if ( this.fzMode != this.myte.getConfigManager().getSetting( Settings.FUZZY_MODE ) )
{
icrafting.sendProgressBarUpdate( this, 4, (int) this.myte.getConfigManager().getSetting( Settings.FUZZY_MODE ).ordinal() );
}
}
this.fzMode = (FuzzyMode) this.myte.getConfigManager().getSetting( Settings.FUZZY_MODE );
}
standardDetectAndSendChanges();
}
@Override
public void updateProgressBar(int idx, int value)
{
super.updateProgressBar( idx, value );
if ( idx == 4 )
this.fzMode = FuzzyMode.values()[value];
}
}

View file

@ -1,118 +1,89 @@
package appeng.container.implementations;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.ICrafting;
import net.minecraft.inventory.IInventory;
import appeng.api.config.FullnessMode;
import appeng.api.config.OperationMode;
import appeng.api.config.RedstoneMode;
import appeng.api.config.SecurityPermissions;
import appeng.api.config.Settings;
import appeng.container.slot.SlotOutput;
import appeng.container.slot.SlotRestrictedInput;
import appeng.container.slot.SlotRestrictedInput.PlaceableItemType;
import appeng.tile.storage.TileIOPort;
import appeng.util.Platform;
public class ContainerIOPort extends ContainerUpgradeable
{
TileIOPort ioPort;
public OperationMode opMode = OperationMode.EMPTY;
public FullnessMode fMode = FullnessMode.EMPTY;
public ContainerIOPort(InventoryPlayer ip, TileIOPort te) {
super( ip, te );
ioPort = te;
}
@Override
protected int getHeight()
{
return 166;
}
@Override
public int availableUpgrades()
{
return 3;
}
@Override
protected boolean supportCapacity()
{
return false;
}
@Override
protected void setupConfig()
{
int offx = 19;
int offy = 17;
IInventory cells = myte.getInventoryByName( "cells" );
for (int y = 0; y < 3; y++)
for (int x = 0; x < 2; x++)
addSlotToContainer( new SlotRestrictedInput( PlaceableItemType.STORAGE_CELLS, cells, x + y * 2, offx + x * 18, offy + y * 18 ) );
offx = 122;
offy = 17;
for (int y = 0; y < 3; y++)
for (int x = 0; x < 2; x++)
addSlotToContainer( new SlotOutput( cells, 6 + x + y * 2, offx + x * 18, offy + y * 18, PlaceableItemType.STORAGE_CELLS.IIcon ) );
IInventory upgrades = myte.getInventoryByName( "upgrades" );
addSlotToContainer( (new SlotRestrictedInput( PlaceableItemType.UPGRADES, upgrades, 0, 187, 8 + 18 * 0 )).setNotDraggable() );
addSlotToContainer( (new SlotRestrictedInput( PlaceableItemType.UPGRADES, upgrades, 1, 187, 8 + 18 * 1 )).setNotDraggable() );
addSlotToContainer( (new SlotRestrictedInput( PlaceableItemType.UPGRADES, upgrades, 2, 187, 8 + 18 * 2 )).setNotDraggable() );
}
@Override
public void detectAndSendChanges()
{
verifyPermissions( SecurityPermissions.BUILD, false );
if ( Platform.isServer() )
{
for (int i = 0; i < this.crafters.size(); ++i)
{
ICrafting icrafting = (ICrafting) this.crafters.get( i );
if ( this.rsMode != this.myte.getConfigManager().getSetting( Settings.REDSTONE_CONTROLLED ) )
{
icrafting.sendProgressBarUpdate( this, 0, (int) this.myte.getConfigManager().getSetting( Settings.REDSTONE_CONTROLLED ).ordinal() );
}
if ( this.fMode != this.myte.getConfigManager().getSetting( Settings.FULLNESS_MODE ) )
{
icrafting.sendProgressBarUpdate( this, 2, (int) this.myte.getConfigManager().getSetting( Settings.FULLNESS_MODE ).ordinal() );
}
if ( this.opMode != this.myte.getConfigManager().getSetting( Settings.OPERATION_MODE ) )
{
icrafting.sendProgressBarUpdate( this, 3, (int) this.myte.getConfigManager().getSetting( Settings.OPERATION_MODE ).ordinal() );
}
}
this.opMode = (OperationMode) myte.getConfigManager().getSetting( Settings.OPERATION_MODE );
this.fMode = (FullnessMode) this.myte.getConfigManager().getSetting( Settings.FULLNESS_MODE );
this.rsMode = (RedstoneMode) this.myte.getConfigManager().getSetting( Settings.REDSTONE_CONTROLLED );
}
standardDetectAndSendChanges();
}
@Override
public void updateProgressBar(int idx, int value)
{
super.updateProgressBar( idx, value );
if ( idx == 2 )
this.fMode = FullnessMode.values()[value];
if ( idx == 3 )
this.opMode = OperationMode.values()[value];
}
}
package appeng.container.implementations;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.IInventory;
import appeng.api.config.FullnessMode;
import appeng.api.config.OperationMode;
import appeng.api.config.RedstoneMode;
import appeng.api.config.SecurityPermissions;
import appeng.api.config.Settings;
import appeng.container.guisync.GuiSync;
import appeng.container.slot.SlotOutput;
import appeng.container.slot.SlotRestrictedInput;
import appeng.container.slot.SlotRestrictedInput.PlaceableItemType;
import appeng.tile.storage.TileIOPort;
import appeng.util.Platform;
public class ContainerIOPort extends ContainerUpgradeable
{
TileIOPort ioPort;
@GuiSync(2)
public FullnessMode fMode = FullnessMode.EMPTY;
@GuiSync(3)
public OperationMode opMode = OperationMode.EMPTY;
public ContainerIOPort(InventoryPlayer ip, TileIOPort te) {
super( ip, te );
ioPort = te;
}
@Override
protected int getHeight()
{
return 166;
}
@Override
public int availableUpgrades()
{
return 3;
}
@Override
protected boolean supportCapacity()
{
return false;
}
@Override
protected void setupConfig()
{
int offx = 19;
int offy = 17;
IInventory cells = myte.getInventoryByName( "cells" );
for (int y = 0; y < 3; y++)
for (int x = 0; x < 2; x++)
addSlotToContainer( new SlotRestrictedInput( PlaceableItemType.STORAGE_CELLS, cells, x + y * 2, offx + x * 18, offy + y * 18 ) );
offx = 122;
offy = 17;
for (int y = 0; y < 3; y++)
for (int x = 0; x < 2; x++)
addSlotToContainer( new SlotOutput( cells, 6 + x + y * 2, offx + x * 18, offy + y * 18, PlaceableItemType.STORAGE_CELLS.IIcon ) );
IInventory upgrades = myte.getInventoryByName( "upgrades" );
addSlotToContainer( (new SlotRestrictedInput( PlaceableItemType.UPGRADES, upgrades, 0, 187, 8 + 18 * 0 )).setNotDraggable() );
addSlotToContainer( (new SlotRestrictedInput( PlaceableItemType.UPGRADES, upgrades, 1, 187, 8 + 18 * 1 )).setNotDraggable() );
addSlotToContainer( (new SlotRestrictedInput( PlaceableItemType.UPGRADES, upgrades, 2, 187, 8 + 18 * 2 )).setNotDraggable() );
}
@Override
public void detectAndSendChanges()
{
verifyPermissions( SecurityPermissions.BUILD, false );
if ( Platform.isServer() )
{
this.opMode = (OperationMode) myte.getConfigManager().getSetting( Settings.OPERATION_MODE );
this.fMode = (FullnessMode) this.myte.getConfigManager().getSetting( Settings.FULLNESS_MODE );
this.rsMode = (RedstoneMode) this.myte.getConfigManager().getSetting( Settings.REDSTONE_CONTROLLED );
}
standardDetectAndSendChanges();
}
}

View file

@ -1,22 +1,23 @@
package appeng.container.implementations;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.ICrafting;
import appeng.container.AEBaseContainer;
import appeng.container.guisync.GuiSync;
import appeng.container.slot.SlotOutput;
import appeng.container.slot.SlotRestrictedInput;
import appeng.container.slot.SlotRestrictedInput.PlaceableItemType;
import appeng.tile.misc.TileInscriber;
import appeng.util.Platform;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class ContainerInscriber extends AEBaseContainer
{
TileInscriber myte;
@GuiSync(0)
public int maxProessingTime = -1;
@GuiSync(1)
public int processingTime = -1;
public ContainerInscriber(InventoryPlayer ip, TileInscriber te) {
@ -39,37 +40,8 @@ public class ContainerInscriber extends AEBaseContainer
if ( Platform.isServer() )
{
int localMax = myte.maxProessingTime;
int localTime = myte.processingTime;
for (int i = 0; i < this.crafters.size(); ++i)
{
ICrafting icrafting = (ICrafting) this.crafters.get( i );
if ( this.maxProessingTime != localMax )
{
icrafting.sendProgressBarUpdate( this, 0, localMax );
}
if ( this.processingTime != localTime )
{
icrafting.sendProgressBarUpdate( this, 1, localTime );
}
}
this.maxProessingTime = localMax;
this.processingTime = localTime;
this.maxProessingTime = myte.maxProessingTime;
this.processingTime = myte.processingTime;
}
}
@Override
@SideOnly(Side.CLIENT)
public void updateProgressBar(int idx, int value)
{
if ( idx == 0 )
this.maxProessingTime = value;
if ( idx == 1 )
this.processingTime = value;
}
}

View file

@ -1,24 +1,18 @@
package appeng.container.implementations;
import java.io.IOException;
import net.minecraft.client.gui.GuiTextField;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.ICrafting;
import net.minecraft.inventory.IInventory;
import appeng.api.config.FuzzyMode;
import appeng.api.config.LevelType;
import appeng.api.config.RedstoneMode;
import appeng.api.config.SecurityPermissions;
import appeng.api.config.Settings;
import appeng.container.guisync.GuiSync;
import appeng.container.slot.SlotFakeTypeOnly;
import appeng.container.slot.SlotRestrictedInput;
import appeng.container.slot.SlotRestrictedInput.PlaceableItemType;
import appeng.core.AELog;
import appeng.core.sync.network.NetworkHandler;
import appeng.core.sync.packets.PacketProgressBar;
import appeng.parts.automation.PartLevelEmitter;
import appeng.util.Platform;
import cpw.mods.fml.relauncher.Side;
@ -28,7 +22,6 @@ public class ContainerLevelEmitter extends ContainerUpgradeable
{
PartLevelEmitter lvlEmitter;
long EmitterValue = -1;
@SideOnly(Side.CLIENT)
public GuiTextField textField;
@ -84,8 +77,12 @@ public class ContainerLevelEmitter extends ContainerUpgradeable
addSlotToContainer( new SlotFakeTypeOnly( inv, 0, x, y ) );
}
@GuiSync(2)
public LevelType lvType;
@GuiSync(3)
public long EmitterValue = -1;
@Override
public void detectAndSendChanges()
{
@ -93,39 +90,6 @@ public class ContainerLevelEmitter extends ContainerUpgradeable
if ( Platform.isServer() )
{
for (int i = 0; i < this.crafters.size(); ++i)
{
ICrafting icrafting = (ICrafting) this.crafters.get( i );
if ( this.rsMode != this.myte.getConfigManager().getSetting( Settings.REDSTONE_EMITTER ) )
{
icrafting.sendProgressBarUpdate( this, 0, (int) this.myte.getConfigManager().getSetting( Settings.REDSTONE_EMITTER ).ordinal() );
}
if ( this.fzMode != this.myte.getConfigManager().getSetting( Settings.FUZZY_MODE ) )
{
icrafting.sendProgressBarUpdate( this, 1, (int) this.myte.getConfigManager().getSetting( Settings.FUZZY_MODE ).ordinal() );
}
if ( this.lvType != this.myte.getConfigManager().getSetting( Settings.LEVEL_TYPE ) )
{
icrafting.sendProgressBarUpdate( this, 2, (int) this.myte.getConfigManager().getSetting( Settings.LEVEL_TYPE ).ordinal() );
}
if ( this.EmitterValue != lvlEmitter.getReportingValue() )
{
try
{
NetworkHandler.instance.sendTo( new PacketProgressBar( 3, lvlEmitter.getReportingValue() ), (EntityPlayerMP) icrafting );
}
catch (IOException e)
{
AELog.error( e );
}
// icrafting.sendProgressBarUpdate( this, 2, (int) lvlEmitter.getReportingValue() );
}
}
this.EmitterValue = lvlEmitter.getReportingValue();
this.lvType = (LevelType) this.myte.getConfigManager().getSetting( Settings.LEVEL_TYPE );
this.fzMode = (FuzzyMode) this.myte.getConfigManager().getSetting( Settings.FUZZY_MODE );
@ -135,25 +99,10 @@ public class ContainerLevelEmitter extends ContainerUpgradeable
standardDetectAndSendChanges();
}
@Override
public void updateProgressBar(int idx, int value)
public void onUpdate(String field, Object oldValue, Object newValue)
{
super.updateProgressBar( idx, value );
if ( idx == 2 )
if ( field.equals( "EmitterValue" ) )
{
lvType = LevelType.values()[value];
}
}
@Override
public void updateFullProgressBar(int idx, long value)
{
super.updateFullProgressBar( idx, value );
if ( idx == 3 )
{
EmitterValue = value;
if ( textField != null )
textField.setText( "" + EmitterValue );
}

View file

@ -1,7 +1,6 @@
package appeng.container.implementations;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.ICrafting;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
@ -99,26 +98,10 @@ public class ContainerMAC extends ContainerUpgradeable
if ( Platform.isServer() )
{
for (int i = 0; i < this.crafters.size(); ++i)
{
ICrafting icrafting = (ICrafting) this.crafters.get( i );
if ( this.rsMode != this.myte.getConfigManager().getSetting( Settings.REDSTONE_CONTROLLED ) )
{
icrafting.sendProgressBarUpdate( this, 0, (int) this.myte.getConfigManager().getSetting( Settings.REDSTONE_CONTROLLED ).ordinal() );
}
}
this.rsMode = (RedstoneMode) this.myte.getConfigManager().getSetting( Settings.REDSTONE_CONTROLLED );
}
standardDetectAndSendChanges();
}
@Override
public void updateProgressBar(int idx, int value)
{
super.updateProgressBar( idx, value );
}
}

View file

@ -34,6 +34,7 @@ import appeng.api.storage.data.IItemList;
import appeng.api.util.IConfigManager;
import appeng.api.util.IConfigureableObject;
import appeng.container.AEBaseContainer;
import appeng.container.guisync.GuiSync;
import appeng.container.slot.SlotRestrictedInput;
import appeng.container.slot.SlotRestrictedInput.PlaceableItemType;
import appeng.core.AELog;
@ -54,7 +55,10 @@ public class ContainerMEMonitorable extends AEBaseContainer implements IConfigMa
IConfigManager serverCM;
IConfigManager clientCM;
@GuiSync(99)
public boolean canAccessViewCells = false;
@GuiSync(98)
public boolean hasPower = false;
public SlotRestrictedInput cellView[] = new SlotRestrictedInput[5];
@ -203,12 +207,6 @@ public class ContainerMEMonitorable extends AEBaseContainer implements IConfigMa
if ( cellView[y] != null )
cellView[y].allowEdit = canAccessViewCells;
}
for (Object c : this.crafters)
{
if ( c instanceof ICrafting )
((ICrafting) c).sendProgressBarUpdate( this, 99, canAccessViewCells ? 1 : 0 );
}
}
super.detectAndSendChanges();
@ -217,7 +215,6 @@ public class ContainerMEMonitorable extends AEBaseContainer implements IConfigMa
protected void updatePowerStatus()
{
boolean oldHasPower = hasPower;
try
{
if ( networkNode != null )
@ -231,19 +228,6 @@ public class ContainerMEMonitorable extends AEBaseContainer implements IConfigMa
{
// :P
}
if ( hasPower != oldHasPower )
{
for (Object c : this.crafters)
{
if ( c instanceof ICrafting )
{
ICrafting cr = (ICrafting) c;
cr.sendProgressBarUpdate( this, 98, hasPower ? 1 : 0 );
}
}
}
}
@Override
@ -301,19 +285,16 @@ public class ContainerMEMonitorable extends AEBaseContainer implements IConfigMa
}
@Override
public void updateProgressBar(int idx, int value)
public void onUpdate(String field, Object oldValue, Object newValue)
{
super.updateProgressBar( idx, value );
if ( field.equals( "canAccessViewCells" ) )
{
for (int y = 0; y < 5; y++)
if ( cellView[y] != null )
cellView[y].allowEdit = canAccessViewCells;
}
if ( idx == 98 )
hasPower = value == 1;
if ( idx == 99 )
canAccessViewCells = value == 1;
for (int y = 0; y < 5; y++)
if ( cellView[y] != null )
cellView[y].allowEdit = canAccessViewCells;
super.onUpdate( field, oldValue, newValue );
}
@Override

View file

@ -5,7 +5,6 @@ import java.io.IOException;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.ICrafting;
import net.minecraft.item.ItemStack;
import net.minecraftforge.common.util.ForgeDirection;
import appeng.api.AEApi;
@ -18,10 +17,9 @@ import appeng.api.networking.energy.IEnergyGrid;
import appeng.api.storage.data.IAEItemStack;
import appeng.api.storage.data.IItemList;
import appeng.container.AEBaseContainer;
import appeng.core.AELog;
import appeng.container.guisync.GuiSync;
import appeng.core.sync.network.NetworkHandler;
import appeng.core.sync.packets.PacketMEInventoryUpdate;
import appeng.core.sync.packets.PacketProgressBar;
import appeng.util.Platform;
import appeng.util.item.AEItemStack;
@ -57,27 +55,15 @@ public class ContainerNetworkStatus extends AEBaseContainer
int delay = 40;
@GuiSync(0)
public long avgAddition;
@GuiSync(1)
public long powerUsage;
@GuiSync(2)
public long currentPower;
@GuiSync(3)
public long maxPower;
@Override
public void updateFullProgressBar(int id, long value)
{
if ( id == 0 )
avgAddition = value;
if ( id == 1 )
powerUsage = value;
if ( id == 2 )
currentPower = value;
if ( id == 3 )
maxPower = value;
}
@Override
public void detectAndSendChanges()
{
@ -93,22 +79,6 @@ public class ContainerNetworkStatus extends AEBaseContainer
powerUsage = (long) (100.0 * eg.getAvgPowerUsage());
currentPower = (long) (100.0 * eg.getStoredPower());
maxPower = (long) (100.0 * eg.getMaxStoredPower());
for (Object c : this.crafters)
{
ICrafting icrafting = (ICrafting) c;
try
{
NetworkHandler.instance.sendTo( new PacketProgressBar( 0, avgAddition ), (EntityPlayerMP) icrafting );
NetworkHandler.instance.sendTo( new PacketProgressBar( 1, powerUsage ), (EntityPlayerMP) icrafting );
NetworkHandler.instance.sendTo( new PacketProgressBar( 2, currentPower ), (EntityPlayerMP) icrafting );
NetworkHandler.instance.sendTo( new PacketProgressBar( 3, maxPower ), (EntityPlayerMP) icrafting );
}
catch (IOException e)
{
AELog.error( e );
}
}
}
PacketMEInventoryUpdate piu;

View file

@ -6,7 +6,6 @@ import java.util.List;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.ICrafting;
import net.minecraft.inventory.IInventory;
import net.minecraft.inventory.InventoryCrafting;
import net.minecraft.inventory.Slot;
@ -26,6 +25,7 @@ import appeng.api.storage.ITerminalHost;
import appeng.api.storage.data.IAEItemStack;
import appeng.api.storage.data.IItemList;
import appeng.container.ContainerNull;
import appeng.container.guisync.GuiSync;
import appeng.container.slot.IOptionalSlotHost;
import appeng.container.slot.OptionalSlotFake;
import appeng.container.slot.SlotFake;
@ -57,7 +57,6 @@ public class ContainerPatternTerm extends ContainerMEMonitorable implements IAEA
SlotRestrictedInput patternSlotOUT;
public PartPatternTerminal ct;
public boolean craftingMode = true;
public ContainerPatternTerm(InventoryPlayer ip, ITerminalHost montiorable) {
super( ip, montiorable, false );
@ -133,6 +132,9 @@ public class ContainerPatternTerm extends ContainerMEMonitorable implements IAEA
return is;
}
@GuiSync(97)
public boolean craftingMode = true;
@Override
public void detectAndSendChanges()
{
@ -143,23 +145,15 @@ public class ContainerPatternTerm extends ContainerMEMonitorable implements IAEA
{
craftingMode = ct.craftingMode;
updateOrderOfOutputSlots();
for (Object c : this.crafters)
{
if ( c instanceof ICrafting )
((ICrafting) c).sendProgressBarUpdate( this, 97, craftingMode ? 1 : 0 );
}
}
}
}
@Override
public void updateProgressBar(int idx, int value)
public void onUpdate(String field, Object oldValue, Object newValue)
{
super.updateProgressBar( idx, value );
if ( idx == 97 )
if ( field.equals( "craftingMode" ) )
{
craftingMode = value == 1;
getAndUpdateOutput();
updateOrderOfOutputSlots();
}

View file

@ -3,11 +3,11 @@ package appeng.container.implementations;
import net.minecraft.client.gui.GuiTextField;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.ICrafting;
import net.minecraft.tileentity.TileEntity;
import appeng.api.config.SecurityPermissions;
import appeng.api.parts.IPart;
import appeng.container.AEBaseContainer;
import appeng.container.guisync.GuiSync;
import appeng.helpers.IPriorityHost;
import appeng.util.Platform;
import cpw.mods.fml.relauncher.Side;
@ -33,7 +33,8 @@ public class ContainerPriority extends AEBaseContainer
priHost = te;
}
int PriorityValue = -1;
@GuiSync(2)
long PriorityValue = -1;
public void setPriority(int newValue, EntityPlayer player)
{
@ -48,31 +49,19 @@ public class ContainerPriority extends AEBaseContainer
if ( Platform.isServer() )
{
for (int i = 0; i < this.crafters.size(); ++i)
{
ICrafting icrafting = (ICrafting) this.crafters.get( i );
if ( this.PriorityValue != priHost.getPriority() )
{
icrafting.sendProgressBarUpdate( this, 2, (int) priHost.getPriority() );
}
}
this.PriorityValue = (int) priHost.getPriority();
this.PriorityValue = priHost.getPriority();
}
}
@Override
public void updateProgressBar(int idx, int value)
public void onUpdate(String field, Object oldValue, Object newValue)
{
super.updateProgressBar( idx, value );
if ( idx == 2 )
if ( field.equals( "PriorityValue" ) )
{
PriorityValue = value;
if ( textField != null )
textField.setText( "" + PriorityValue );
}
}
super.onUpdate( field, oldValue, newValue );
}
}

View file

@ -12,6 +12,7 @@ import appeng.api.features.INetworkEncodable;
import appeng.api.features.IWirelessTermHandler;
import appeng.api.implementations.items.IBiometricCard;
import appeng.api.storage.ITerminalHost;
import appeng.container.guisync.GuiSync;
import appeng.container.slot.SlotOutput;
import appeng.container.slot.SlotRestrictedInput;
import appeng.container.slot.SlotRestrictedInput.PlaceableItemType;
@ -19,7 +20,6 @@ import appeng.tile.inventory.AppEngInternalInventory;
import appeng.tile.inventory.IAEAppEngInventory;
import appeng.tile.inventory.InvOperation;
import appeng.tile.misc.TileSecurity;
import appeng.util.Platform;
public class ContainerSecurity extends ContainerMEMonitorable implements IAEAppEngInventory
{
@ -46,6 +46,7 @@ public class ContainerSecurity extends ContainerMEMonitorable implements IAEAppE
bindPlayerInventory( ip, 0, 0 );
}
@GuiSync(0)
public int security = 0;
@Override
@ -82,21 +83,12 @@ public class ContainerSecurity extends ContainerMEMonitorable implements IAEAppE
}
}
@Override
public void updateProgressBar(int key, int value)
{
super.updateProgressBar( key, value );
if ( key == 0 )
security = value;
}
@Override
public void detectAndSendChanges()
{
verifyPermissions( SecurityPermissions.SECURITY, false );
int newSecurity = 0;
security = 0;
ItemStack a = configSlot.getStack();
if ( a != null && a.getItem() instanceof IBiometricCard )
@ -104,26 +96,11 @@ public class ContainerSecurity extends ContainerMEMonitorable implements IAEAppE
IBiometricCard bc = (IBiometricCard) a.getItem();
for (SecurityPermissions sp : bc.getPermissions( a ))
newSecurity = newSecurity | (1 << sp.ordinal());
security = security | (1 << sp.ordinal());
}
updatePowerStatus();
if ( newSecurity != security )
{
if ( Platform.isServer() )
{
for (int i = 0; i < this.crafters.size(); ++i)
{
ICrafting icrafting = (ICrafting) this.crafters.get( i );
icrafting.sendProgressBarUpdate( this, 0, newSecurity );
}
}
security = newSecurity;
}
super.detectAndSendChanges();
}

View file

@ -1,22 +1,16 @@
package appeng.container.implementations;
import java.io.IOException;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.ICrafting;
import net.minecraftforge.common.util.ForgeDirection;
import appeng.api.config.SecurityPermissions;
import appeng.api.networking.IGrid;
import appeng.api.networking.energy.IEnergyGrid;
import appeng.api.networking.spatial.ISpatialCache;
import appeng.container.AEBaseContainer;
import appeng.container.guisync.GuiSync;
import appeng.container.slot.SlotOutput;
import appeng.container.slot.SlotRestrictedInput;
import appeng.container.slot.SlotRestrictedInput.PlaceableItemType;
import appeng.core.AELog;
import appeng.core.sync.network.NetworkHandler;
import appeng.core.sync.packets.PacketProgressBar;
import appeng.tile.spatial.TileSpatialIOPort;
import appeng.util.Platform;
@ -27,29 +21,17 @@ public class ContainerSpatialIOPort extends AEBaseContainer
IGrid network;
public long reqPower;
@GuiSync(0)
public long currentPower;
@GuiSync(1)
public long maxPower;
@GuiSync(2)
public long reqPower;
@GuiSync(3)
public long eff;
int delay = 40;
@Override
public void updateFullProgressBar(int id, long value)
{
if ( id == 0 )
currentPower = value;
if ( id == 1 )
maxPower = value;
if ( id == 2 )
reqPower = value;
if ( id == 3 )
eff = value;
}
public ContainerSpatialIOPort(InventoryPlayer ip, TileSpatialIOPort te) {
super( ip, te, null );
myte = te;
@ -83,22 +65,6 @@ public class ContainerSpatialIOPort extends AEBaseContainer
maxPower = (long) (100.0 * eg.getMaxStoredPower());
reqPower = (long) (100.0 * sc.requiredPower());
eff = (long) (100.0f * sc.currentEffiency());
for (Object c : this.crafters)
{
ICrafting icrafting = (ICrafting) c;
try
{
NetworkHandler.instance.sendTo( new PacketProgressBar( 0, currentPower ), (EntityPlayerMP) icrafting );
NetworkHandler.instance.sendTo( new PacketProgressBar( 1, maxPower ), (EntityPlayerMP) icrafting );
NetworkHandler.instance.sendTo( new PacketProgressBar( 2, reqPower ), (EntityPlayerMP) icrafting );
NetworkHandler.instance.sendTo( new PacketProgressBar( 3, eff ), (EntityPlayerMP) icrafting );
}
catch (IOException e)
{
AELog.error( e );
}
}
}
}
}

View file

@ -1,13 +1,13 @@
package appeng.container.implementations;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.ICrafting;
import net.minecraft.inventory.IInventory;
import appeng.api.config.AccessRestriction;
import appeng.api.config.FuzzyMode;
import appeng.api.config.SecurityPermissions;
import appeng.api.config.Settings;
import appeng.api.config.Upgrades;
import appeng.container.guisync.GuiSync;
import appeng.container.slot.OptionalSlotFakeTypeOnly;
import appeng.container.slot.SlotFakeTypeOnly;
import appeng.container.slot.SlotRestrictedInput;
@ -19,6 +19,8 @@ public class ContainerStorageBus extends ContainerUpgradeable
{
PartStorageBus storageBus;
@GuiSync(3)
public AccessRestriction rwMode = AccessRestriction.READ_WRITE;
public ContainerStorageBus(InventoryPlayer ip, PartStorageBus te) {
@ -85,21 +87,6 @@ public class ContainerStorageBus extends ContainerUpgradeable
if ( Platform.isServer() )
{
for (int i = 0; i < this.crafters.size(); ++i)
{
ICrafting icrafting = (ICrafting) this.crafters.get( i );
if ( this.rwMode != this.myte.getConfigManager().getSetting( Settings.ACCESS ) )
{
icrafting.sendProgressBarUpdate( this, 3, (int) this.myte.getConfigManager().getSetting( Settings.ACCESS ).ordinal() );
}
if ( this.fzMode != this.myte.getConfigManager().getSetting( Settings.FUZZY_MODE ) )
{
icrafting.sendProgressBarUpdate( this, 4, (int) this.myte.getConfigManager().getSetting( Settings.FUZZY_MODE ).ordinal() );
}
}
this.fzMode = (FuzzyMode) this.myte.getConfigManager().getSetting( Settings.FUZZY_MODE );
this.rwMode = (AccessRestriction) this.myte.getConfigManager().getSetting( Settings.ACCESS );
}
@ -107,17 +94,4 @@ public class ContainerStorageBus extends ContainerUpgradeable
standardDetectAndSendChanges();
}
@Override
public void updateProgressBar(int idx, int value)
{
super.updateProgressBar( idx, value );
if ( idx == 3 )
this.rwMode = AccessRestriction.values()[value];
if ( idx == 4 )
this.fzMode = FuzzyMode.values()[value];
}
}

View file

@ -1,7 +1,6 @@
package appeng.container.implementations;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.ICrafting;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
@ -14,6 +13,7 @@ import appeng.api.config.Upgrades;
import appeng.api.implementations.IUpgradeableHost;
import appeng.api.parts.IPart;
import appeng.container.AEBaseContainer;
import appeng.container.guisync.GuiSync;
import appeng.container.slot.IOptionalSlotHost;
import appeng.container.slot.OptionalSlotFake;
import appeng.container.slot.OptionalSlotFakeTypeOnly;
@ -23,8 +23,6 @@ import appeng.container.slot.SlotRestrictedInput.PlaceableItemType;
import appeng.items.contents.NetworkToolViewer;
import appeng.items.tools.ToolNetworkTool;
import appeng.util.Platform;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class ContainerUpgradeable extends AEBaseContainer implements IOptionalSlotHost
{
@ -133,7 +131,10 @@ public class ContainerUpgradeable extends AEBaseContainer implements IOptionalSl
return true;
}
@GuiSync(0)
public RedstoneMode rsMode = RedstoneMode.IGNORE;
@GuiSync(1)
public FuzzyMode fzMode = FuzzyMode.IGNORE_ALL;
public void checkToolbox()
@ -164,21 +165,6 @@ public class ContainerUpgradeable extends AEBaseContainer implements IOptionalSl
if ( Platform.isServer() )
{
for (int i = 0; i < this.crafters.size(); ++i)
{
ICrafting icrafting = (ICrafting) this.crafters.get( i );
if ( this.rsMode != this.myte.getConfigManager().getSetting( Settings.REDSTONE_CONTROLLED ) )
{
icrafting.sendProgressBarUpdate( this, 0, (int) this.myte.getConfigManager().getSetting( Settings.REDSTONE_CONTROLLED ).ordinal() );
}
if ( this.fzMode != this.myte.getConfigManager().getSetting( Settings.FUZZY_MODE ) )
{
icrafting.sendProgressBarUpdate( this, 1, (int) this.myte.getConfigManager().getSetting( Settings.FUZZY_MODE ).ordinal() );
}
}
this.fzMode = (FuzzyMode) this.myte.getConfigManager().getSetting( Settings.FUZZY_MODE );
this.rsMode = (RedstoneMode) this.myte.getConfigManager().getSetting( Settings.REDSTONE_CONTROLLED );
}
@ -203,19 +189,6 @@ public class ContainerUpgradeable extends AEBaseContainer implements IOptionalSl
super.detectAndSendChanges();
}
@Override
@SideOnly(Side.CLIENT)
public void updateProgressBar(int idx, int value)
{
if ( idx == 0 )
this.rsMode = RedstoneMode.values()[value];
if ( idx == 1 )
this.fzMode = FuzzyMode.values()[value];
}
public boolean hasToolbox()
{
return tbinv != null;

View file

@ -1,14 +1,12 @@
package appeng.container.implementations;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.ICrafting;
import appeng.container.AEBaseContainer;
import appeng.container.guisync.GuiSync;
import appeng.container.slot.SlotRestrictedInput;
import appeng.container.slot.SlotRestrictedInput.PlaceableItemType;
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
{
@ -25,52 +23,23 @@ public class ContainerVibrationChamber extends AEBaseContainer
}
public int aePerTick = 5;
public int burnSpeed = 100;
@GuiSync(0)
public int burnProgress = 0;
@GuiSync(1)
public int burnSpeed = 100;
@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 )
{
icrafting.sendProgressBarUpdate( this, 1, this.myte.burnSpeed );
}
}
this.burnProgress = burnProgress;
this.burnProgress = (int) (this.myte.maxBurnTime <= 0 ? 0 : 12 * this.myte.burnTime / this.myte.maxBurnTime);
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;
}
super.detectAndSendChanges();
}
}

View file

@ -570,6 +570,10 @@ public class Registration
Upgrades.INVERTER.registerItem( AEApi.instance().items().itemMassCannon.stack( 1 ), 1 );
Upgrades.SPEED.registerItem( AEApi.instance().items().itemMassCannon.stack( 1 ), 4 );
// molecular assembler
Upgrades.REDSTONE.registerItem( AEApi.instance().blocks().blockMolecularAssembler.stack( 1 ), 1 );
Upgrades.SPEED.registerItem( AEApi.instance().blocks().blockMolecularAssembler.stack( 1 ), 5 );
AEApi.instance().registries().wireless().registerWirelessHandler( (IWirelessTermHandler) AEApi.instance().items().itemWirelessTerminal.item() );
if ( AEConfig.instance.isFeatureEnabled( AEFeature.ChestLoot ) )

View file

@ -20,7 +20,6 @@ import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.IIcon;
import net.minecraft.world.World;
import net.minecraftforge.oredict.OreDictionary;
import appeng.api.config.Upgrades;
import appeng.api.implementations.items.IItemGroup;
import appeng.api.implementations.items.IStorageComponent;
@ -28,7 +27,6 @@ import appeng.api.implementations.items.IUpgradeModule;
import appeng.client.texture.MissingIcon;
import appeng.core.AEConfig;
import appeng.core.features.AEFeature;
import appeng.core.features.AEFeatureHandler;
import appeng.core.features.ItemStackSrc;
import appeng.items.AEBaseItem;
import appeng.items.materials.ItemMultiMaterial;
@ -179,9 +177,10 @@ public class OldItemMaterial extends AEBaseItem implements IStorageComponent, IU
{
return "AE2-OLD-ITEM";
}
@Override
public String getItemStackDisplayName(ItemStack par1ItemStack) {
public String getItemStackDisplayName(ItemStack par1ItemStack)
{
return "AE2-OLD-ITEM";
}

View file

@ -19,7 +19,6 @@ import appeng.api.parts.IPart;
import appeng.api.parts.IPartItem;
import appeng.core.AEConfig;
import appeng.core.features.AEFeature;
import appeng.core.features.AEFeatureHandler;
import appeng.core.features.ItemStackSrc;
import appeng.core.localization.GuiText;
import appeng.items.AEBaseItem;
@ -150,9 +149,10 @@ public class OldItemPart extends AEBaseItem implements IPartItem, IItemGroup, II
{
return "PART";
}
@Override
public String getItemStackDisplayName(ItemStack par1ItemStack) {
public String getItemStackDisplayName(ItemStack par1ItemStack)
{
return "AE2-OLD-PART";
}

View file

@ -5,7 +5,6 @@ import java.util.EnumSet;
import net.minecraft.entity.Entity;
import net.minecraft.item.ItemStack;
import net.minecraft.util.IIcon;
import net.minecraftforge.oredict.OreDictionary;
import appeng.core.AppEng;
import appeng.core.features.AEFeature;
import appeng.entity.EntityChargedQuartz;