Basic reformat, hit once, hope never again
This commit is contained in:
@@ -18,6 +18,7 @@
|
||||
|
||||
package appeng.tile.misc;
|
||||
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import net.minecraft.inventory.IInventory;
|
||||
@@ -41,6 +42,7 @@ import appeng.tile.inventory.InvOperation;
|
||||
import appeng.util.ConfigManager;
|
||||
import appeng.util.IConfigManagerHost;
|
||||
|
||||
|
||||
public class TileCellWorkbench extends AEBaseTile implements IUpgradeableHost, IAEAppEngInventory, IConfigManagerHost
|
||||
{
|
||||
|
||||
@@ -50,21 +52,28 @@ public class TileCellWorkbench extends AEBaseTile implements IUpgradeableHost, I
|
||||
|
||||
IInventory cacheUpgrades = null;
|
||||
IInventory cacheConfig = null;
|
||||
private boolean locked = false;
|
||||
|
||||
public TileCellWorkbench()
|
||||
{
|
||||
this.cm.registerSetting( Settings.COPY_MODE, CopyMode.CLEAR_ON_REMOVE );
|
||||
this.cell.enableClientEvents = true;
|
||||
}
|
||||
|
||||
public IInventory getCellUpgradeInventory()
|
||||
{
|
||||
if ( this.cacheUpgrades == null )
|
||||
if( this.cacheUpgrades == null )
|
||||
{
|
||||
ICellWorkbenchItem cell = this.getCell();
|
||||
if ( cell == null )
|
||||
if( cell == null )
|
||||
return null;
|
||||
|
||||
ItemStack is = this.cell.getStackInSlot( 0 );
|
||||
if ( is == null )
|
||||
if( is == null )
|
||||
return null;
|
||||
|
||||
IInventory inv = cell.getUpgradesInventory( is );
|
||||
if ( inv == null )
|
||||
if( inv == null )
|
||||
return null;
|
||||
|
||||
return this.cacheUpgrades = inv;
|
||||
@@ -72,72 +81,55 @@ public class TileCellWorkbench extends AEBaseTile implements IUpgradeableHost, I
|
||||
return this.cacheUpgrades;
|
||||
}
|
||||
|
||||
public IInventory getCellConfigInventory()
|
||||
public ICellWorkbenchItem getCell()
|
||||
{
|
||||
if ( this.cacheConfig == null )
|
||||
{
|
||||
ICellWorkbenchItem cell = this.getCell();
|
||||
if ( cell == null )
|
||||
return null;
|
||||
if( this.cell.getStackInSlot( 0 ) == null )
|
||||
return null;
|
||||
|
||||
ItemStack is = this.cell.getStackInSlot( 0 );
|
||||
if ( is == null )
|
||||
return null;
|
||||
if( this.cell.getStackInSlot( 0 ).getItem() instanceof ICellWorkbenchItem )
|
||||
return ( (ICellWorkbenchItem) this.cell.getStackInSlot( 0 ).getItem() );
|
||||
|
||||
IInventory inv = cell.getConfigInventory( is );
|
||||
if ( inv == null )
|
||||
return null;
|
||||
|
||||
return this.cacheConfig = inv;
|
||||
}
|
||||
return this.cacheConfig;
|
||||
return null;
|
||||
}
|
||||
|
||||
@TileEvent(TileEventType.WORLD_NBT_WRITE)
|
||||
public void writeToNBT_TileCellWorkbench(NBTTagCompound data)
|
||||
@TileEvent( TileEventType.WORLD_NBT_WRITE )
|
||||
public void writeToNBT_TileCellWorkbench( NBTTagCompound data )
|
||||
{
|
||||
this.cell.writeToNBT( data, "cell" );
|
||||
this.config.writeToNBT( data, "config" );
|
||||
this.cm.writeToNBT( data );
|
||||
}
|
||||
|
||||
@TileEvent(TileEventType.WORLD_NBT_READ)
|
||||
public void readFromNBT_TileCellWorkbench(NBTTagCompound data)
|
||||
@TileEvent( TileEventType.WORLD_NBT_READ )
|
||||
public void readFromNBT_TileCellWorkbench( NBTTagCompound data )
|
||||
{
|
||||
this.cell.readFromNBT( data, "cell" );
|
||||
this.config.readFromNBT( data, "config" );
|
||||
this.cm.readFromNBT( data );
|
||||
}
|
||||
|
||||
public TileCellWorkbench() {
|
||||
this.cm.registerSetting( Settings.COPY_MODE, CopyMode.CLEAR_ON_REMOVE );
|
||||
this.cell.enableClientEvents = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IInventory getInventoryByName(String name)
|
||||
public IInventory getInventoryByName( String name )
|
||||
{
|
||||
if ( name.equals( "config" ) )
|
||||
if( name.equals( "config" ) )
|
||||
return this.config;
|
||||
|
||||
if ( name.equals( "cell" ) )
|
||||
if( name.equals( "cell" ) )
|
||||
return this.cell;
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getInstalledUpgrades(Upgrades u)
|
||||
public int getInstalledUpgrades( Upgrades u )
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
private boolean locked = false;
|
||||
|
||||
@Override
|
||||
public void onChangeInventory(IInventory inv, int slot, InvOperation mc, ItemStack removedStack, ItemStack newStack)
|
||||
public void onChangeInventory( IInventory inv, int slot, InvOperation mc, ItemStack removedStack, ItemStack newStack )
|
||||
{
|
||||
if ( inv == this.cell && !this.locked )
|
||||
if( inv == this.cell && !this.locked )
|
||||
{
|
||||
this.locked = true;
|
||||
|
||||
@@ -145,34 +137,34 @@ public class TileCellWorkbench extends AEBaseTile implements IUpgradeableHost, I
|
||||
this.cacheConfig = null;
|
||||
|
||||
IInventory c = this.getCellConfigInventory();
|
||||
if ( c != null )
|
||||
if( c != null )
|
||||
{
|
||||
boolean cellHasConfig = false;
|
||||
for (int x = 0; x < c.getSizeInventory(); x++)
|
||||
for( int x = 0; x < c.getSizeInventory(); x++ )
|
||||
{
|
||||
if ( c.getStackInSlot( x ) != null )
|
||||
if( c.getStackInSlot( x ) != null )
|
||||
{
|
||||
cellHasConfig = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if ( cellHasConfig )
|
||||
if( cellHasConfig )
|
||||
{
|
||||
for (int x = 0; x < this.config.getSizeInventory(); x++)
|
||||
for( int x = 0; x < this.config.getSizeInventory(); x++ )
|
||||
this.config.setInventorySlotContents( x, c.getStackInSlot( x ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int x = 0; x < this.config.getSizeInventory(); x++)
|
||||
for( int x = 0; x < this.config.getSizeInventory(); x++ )
|
||||
c.setInventorySlotContents( x, this.config.getStackInSlot( x ) );
|
||||
|
||||
c.markDirty();
|
||||
}
|
||||
}
|
||||
else if ( this.cm.getSetting( Settings.COPY_MODE ) == CopyMode.CLEAR_ON_REMOVE )
|
||||
else if( this.cm.getSetting( Settings.COPY_MODE ) == CopyMode.CLEAR_ON_REMOVE )
|
||||
{
|
||||
for (int x = 0; x < this.config.getSizeInventory(); x++)
|
||||
for( int x = 0; x < this.config.getSizeInventory(); x++ )
|
||||
this.config.setInventorySlotContents( x, null );
|
||||
|
||||
this.markDirty();
|
||||
@@ -180,12 +172,12 @@ public class TileCellWorkbench extends AEBaseTile implements IUpgradeableHost, I
|
||||
|
||||
this.locked = false;
|
||||
}
|
||||
else if ( inv == this.config && !this.locked )
|
||||
else if( inv == this.config && !this.locked )
|
||||
{
|
||||
IInventory c = this.getCellConfigInventory();
|
||||
if ( c != null )
|
||||
if( c != null )
|
||||
{
|
||||
for (int x = 0; x < this.config.getSizeInventory(); x++)
|
||||
for( int x = 0; x < this.config.getSizeInventory(); x++ )
|
||||
c.setInventorySlotContents( x, this.config.getStackInSlot( x ) );
|
||||
|
||||
c.markDirty();
|
||||
@@ -193,26 +185,36 @@ public class TileCellWorkbench extends AEBaseTile implements IUpgradeableHost, I
|
||||
}
|
||||
}
|
||||
|
||||
public IInventory getCellConfigInventory()
|
||||
{
|
||||
if( this.cacheConfig == null )
|
||||
{
|
||||
ICellWorkbenchItem cell = this.getCell();
|
||||
if( cell == null )
|
||||
return null;
|
||||
|
||||
ItemStack is = this.cell.getStackInSlot( 0 );
|
||||
if( is == null )
|
||||
return null;
|
||||
|
||||
IInventory inv = cell.getConfigInventory( is );
|
||||
if( inv == null )
|
||||
return null;
|
||||
|
||||
return this.cacheConfig = inv;
|
||||
}
|
||||
return this.cacheConfig;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getDrops(World w, int x, int y, int z, ArrayList<ItemStack> drops)
|
||||
public void getDrops( World w, int x, int y, int z, ArrayList<ItemStack> drops )
|
||||
{
|
||||
super.getDrops( w, x, y, z, drops );
|
||||
|
||||
if ( this.cell.getStackInSlot( 0 ) != null )
|
||||
if( this.cell.getStackInSlot( 0 ) != null )
|
||||
drops.add( this.cell.getStackInSlot( 0 ) );
|
||||
}
|
||||
|
||||
public ICellWorkbenchItem getCell()
|
||||
{
|
||||
if ( this.cell.getStackInSlot( 0 ) == null )
|
||||
return null;
|
||||
|
||||
if ( this.cell.getStackInSlot( 0 ).getItem() instanceof ICellWorkbenchItem )
|
||||
return ((ICellWorkbenchItem) this.cell.getStackInSlot( 0 ).getItem());
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IConfigManager getConfigManager()
|
||||
{
|
||||
@@ -220,9 +222,8 @@ public class TileCellWorkbench extends AEBaseTile implements IUpgradeableHost, I
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateSetting(IConfigManager manager, Enum settingName, Enum newValue)
|
||||
public void updateSetting( IConfigManager manager, Enum settingName, Enum newValue )
|
||||
{
|
||||
// nothing here..
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user