Fixes #675 No disabled feature should log spam or crash anymore.

Deprecates the old usage of the AEItemDefinitions via the direct method access of

* blocks()
* parts()
* items()
* materials()

and thus use the new re-direct via definitions().

All definitions are now initialized, no matter what. But SubItems, Items and Blocks are not registered, if by chance are disabled.
This commit is contained in:
thatsIch
2015-01-03 02:53:14 +01:00
parent 3dd81433ac
commit 9986ffc458
385 changed files with 12477 additions and 8292 deletions
@@ -33,16 +33,20 @@ import appeng.api.networking.security.PlayerSource;
import appeng.api.storage.IMEMonitor;
import appeng.api.storage.data.IAEItemStack;
import appeng.client.texture.CableBusTextures;
import appeng.helpers.Reflected;
import appeng.me.GridAccessException;
import appeng.util.InventoryAdaptor;
import appeng.util.Platform;
import appeng.util.item.AEItemStack;
public class PartConversionMonitor extends PartStorageMonitor
{
@Reflected
public PartConversionMonitor( ItemStack is )
{
super( is );
public PartConversionMonitor(ItemStack is) {
super( PartConversionMonitor.class, is );
this.frontBright = CableBusTextures.PartConversionMonitor_Bright;
this.frontColored = CableBusTextures.PartConversionMonitor_Colored;
this.frontDark = CableBusTextures.PartConversionMonitor_Dark;
@@ -50,7 +54,7 @@ public class PartConversionMonitor extends PartStorageMonitor
}
@Override
public boolean onPartShiftActivate(EntityPlayer player, Vec3 pos)
public boolean onPartShiftActivate( EntityPlayer player, Vec3 pos )
{
if ( Platform.isClient() )
return true;
@@ -67,7 +71,7 @@ public class PartConversionMonitor extends PartStorageMonitor
if ( item == null && this.getDisplayed() != null )
{
ModeB = true;
item = ((IAEItemStack) this.getDisplayed()).getItemStack();
item = ( (IAEItemStack) this.getDisplayed() ).getItemStack();
}
if ( item != null )
@@ -83,7 +87,7 @@ public class PartConversionMonitor extends PartStorageMonitor
if ( ModeB )
{
for (int x = 0; x < player.inventory.getSizeInventory(); x++)
for ( int x = 0; x < player.inventory.getSizeInventory(); x++ )
{
ItemStack targetStack = player.inventory.getStackInSlot( x );
if ( input.equals( targetStack ) )
@@ -101,7 +105,7 @@ public class PartConversionMonitor extends PartStorageMonitor
player.inventory.setInventorySlotContents( player.inventory.currentItem, failedToInsert == null ? null : failedToInsert.getItemStack() );
}
}
catch (GridAccessException e)
catch ( GridAccessException e )
{
// :P
}
@@ -110,7 +114,7 @@ public class PartConversionMonitor extends PartStorageMonitor
}
@Override
protected void extractItem(EntityPlayer player)
protected void extractItem( EntityPlayer player )
{
IAEItemStack input = (IAEItemStack) this.getDisplayed();
if ( input != null )
@@ -143,11 +147,10 @@ public class PartConversionMonitor extends PartStorageMonitor
player.openContainer.detectAndSendChanges();
}
}
catch (GridAccessException e)
catch ( GridAccessException e )
{
// :P
}
}
}
}
@@ -18,6 +18,7 @@
package appeng.parts.reporting;
import java.util.List;
import net.minecraft.entity.player.EntityPlayer;
@@ -27,44 +28,48 @@ import net.minecraft.nbt.NBTTagCompound;
import appeng.client.texture.CableBusTextures;
import appeng.core.sync.GuiBridge;
import appeng.helpers.Reflected;
import appeng.tile.inventory.AppEngInternalInventory;
import appeng.tile.inventory.InvOperation;
public class PartCraftingTerminal extends PartTerminal
{
private final AppEngInternalInventory craftingGrid = new AppEngInternalInventory( this, 9 );
final AppEngInternalInventory craftingGrid = new AppEngInternalInventory( this, 9 );
@Override
public void writeToNBT(NBTTagCompound data)
@Reflected
public PartCraftingTerminal( ItemStack is )
{
super.writeToNBT( data );
this.craftingGrid.writeToNBT( data, "craftingGrid" );
super( is );
this.frontBright = CableBusTextures.PartCraftingTerm_Bright;
this.frontColored = CableBusTextures.PartCraftingTerm_Colored;
this.frontDark = CableBusTextures.PartCraftingTerm_Dark;
// frontSolid = CableBusTextures.PartCraftingTerm_Solid;
}
@Override
public void readFromNBT(NBTTagCompound data)
public void getDrops( List<ItemStack> drops, boolean wrenched )
{
super.getDrops( drops, wrenched );
for ( ItemStack is : this.craftingGrid )
if ( is != null )
drops.add( is );
}
@Override
public void readFromNBT( NBTTagCompound data )
{
super.readFromNBT( data );
this.craftingGrid.readFromNBT( data, "craftingGrid" );
}
@Override
public void getDrops(List<ItemStack> drops, boolean wrenched)
public void writeToNBT( NBTTagCompound data )
{
super.getDrops( drops, wrenched );
for (ItemStack is : this.craftingGrid)
if ( is != null )
drops.add( is );
}
public PartCraftingTerminal(ItemStack is) {
super( PartCraftingTerminal.class, is );
this.frontBright = CableBusTextures.PartCraftingTerm_Bright;
this.frontColored = CableBusTextures.PartCraftingTerm_Colored;
this.frontDark = CableBusTextures.PartCraftingTerm_Dark;
// frontSolid = CableBusTextures.PartCraftingTerm_Solid;
super.writeToNBT( data );
this.craftingGrid.writeToNBT( data, "craftingGrid" );
}
@Override
@@ -80,23 +85,22 @@ public class PartCraftingTerminal extends PartTerminal
z = this.tile.zCoord;
}
if( GuiBridge.GUI_CRAFTING_TERMINAL.hasPermissions( this.getHost().getTile(), x, y, z, this.side, p ) )
if ( GuiBridge.GUI_CRAFTING_TERMINAL.hasPermissions( this.getHost().getTile(), x, y, z, this.side, p ) )
return GuiBridge.GUI_CRAFTING_TERMINAL;
return GuiBridge.GUI_ME;
}
@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 )
{
this.host.markForSave();
}
@Override
public IInventory getInventoryByName(String name)
public IInventory getInventoryByName( String name )
{
if ( name.equals( "crafting" ) )
return this.craftingGrid;
return super.getInventoryByName( name );
}
}
@@ -18,6 +18,7 @@
package appeng.parts.reporting;
import net.minecraft.client.renderer.RenderBlocks;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.item.ItemStack;
@@ -29,22 +30,22 @@ import cpw.mods.fml.relauncher.SideOnly;
import appeng.api.parts.IPartRenderHelper;
import appeng.client.texture.CableBusTextures;
public class PartDarkMonitor extends PartMonitor
{
public PartDarkMonitor(ItemStack is) {
super( PartDarkMonitor.class, is, false );
public PartDarkMonitor( ItemStack is )
{
super( is, false );
this.notLightSource = false;
}
@Override
@SideOnly(Side.CLIENT)
public void renderInventory(IPartRenderHelper rh, RenderBlocks renderer)
@SideOnly( Side.CLIENT )
public void renderInventory( IPartRenderHelper rh, RenderBlocks renderer )
{
rh.setBounds( 2, 2, 14, 14, 14, 16 );
rh.setTexture( CableBusTextures.PartMonitorSides.getIcon(), CableBusTextures.PartMonitorSides.getIcon(), CableBusTextures.PartMonitorBack.getIcon(),
this.is.getIconIndex(), CableBusTextures.PartMonitorSides.getIcon(), CableBusTextures.PartMonitorSides.getIcon() );
rh.setTexture( CableBusTextures.PartMonitorSides.getIcon(), CableBusTextures.PartMonitorSides.getIcon(), CableBusTextures.PartMonitorBack.getIcon(), this.is.getIconIndex(), CableBusTextures.PartMonitorSides.getIcon(), CableBusTextures.PartMonitorSides.getIcon() );
rh.renderInventoryBox( renderer );
rh.setInvColor( this.getColor().mediumVariant );
@@ -55,11 +56,10 @@ public class PartDarkMonitor extends PartMonitor
}
@Override
@SideOnly(Side.CLIENT)
public void renderStatic(int x, int y, int z, IPartRenderHelper rh, RenderBlocks renderer)
@SideOnly( Side.CLIENT )
public void renderStatic( int x, int y, int z, IPartRenderHelper rh, RenderBlocks renderer )
{
rh.setTexture( CableBusTextures.PartMonitorSides.getIcon(), CableBusTextures.PartMonitorSides.getIcon(), CableBusTextures.PartMonitorBack.getIcon(),
this.is.getIconIndex(), CableBusTextures.PartMonitorSides.getIcon(), CableBusTextures.PartMonitorSides.getIcon() );
rh.setTexture( CableBusTextures.PartMonitorSides.getIcon(), CableBusTextures.PartMonitorSides.getIcon(), CableBusTextures.PartMonitorBack.getIcon(), this.is.getIconIndex(), CableBusTextures.PartMonitorSides.getIcon(), CableBusTextures.PartMonitorSides.getIcon() );
rh.setBounds( 2, 2, 14, 14, 14, 16 );
rh.renderBlock( x, y, z, renderer );
@@ -76,5 +76,4 @@ public class PartDarkMonitor extends PartMonitor
rh.setBounds( 4, 4, 13, 12, 12, 14 );
rh.renderBlock( x, y, z, renderer );
}
}
@@ -18,6 +18,7 @@
package appeng.parts.reporting;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.util.Vec3;
@@ -26,18 +27,20 @@ import appeng.client.texture.CableBusTextures;
import appeng.core.sync.GuiBridge;
import appeng.util.Platform;
public class PartInterfaceTerminal extends PartMonitor
{
public PartInterfaceTerminal( ItemStack is )
{
super( is, true );
public PartInterfaceTerminal(ItemStack is) {
super( PartInterfaceTerminal.class, is, true );
this.frontBright = CableBusTextures.PartInterfaceTerm_Bright;
this.frontColored = CableBusTextures.PartInterfaceTerm_Colored;
this.frontDark = CableBusTextures.PartInterfaceTerm_Dark;
}
@Override
public boolean onPartActivate(EntityPlayer player, Vec3 pos)
public boolean onPartActivate( EntityPlayer player, Vec3 pos )
{
if ( !super.onPartActivate( player, pos ) )
{
@@ -221,13 +221,13 @@ public class PartMonitor extends AEBasePart implements IPartMonitor, IPowerChann
return false;
}
}
public PartMonitor(ItemStack is) {
this( PartMonitor.class, is, false );
this( is, false );
}
protected PartMonitor(Class c, ItemStack is, boolean requireChannel) {
super( c, is );
protected PartMonitor(ItemStack is, boolean requireChannel) {
super( is );
if ( requireChannel )
{
@@ -18,6 +18,7 @@
package appeng.parts.reporting;
import java.util.List;
import net.minecraft.entity.player.EntityPlayer;
@@ -30,20 +31,39 @@ import appeng.api.networking.crafting.ICraftingPatternDetails;
import appeng.api.storage.data.IAEItemStack;
import appeng.client.texture.CableBusTextures;
import appeng.core.sync.GuiBridge;
import appeng.helpers.Reflected;
import appeng.tile.inventory.AppEngInternalInventory;
import appeng.tile.inventory.InvOperation;
public class PartPatternTerminal extends PartTerminal
{
final AppEngInternalInventory crafting = new AppEngInternalInventory( this, 9 );
final AppEngInternalInventory output = new AppEngInternalInventory( this, 3 );
final AppEngInternalInventory pattern = new AppEngInternalInventory( this, 2 );
private final AppEngInternalInventory crafting = new AppEngInternalInventory( this, 9 );
private final AppEngInternalInventory output = new AppEngInternalInventory( this, 3 );
private final AppEngInternalInventory pattern = new AppEngInternalInventory( this, 2 );
private boolean craftingMode = true;
@Reflected
public PartPatternTerminal( ItemStack is )
{
super( is );
this.frontBright = CableBusTextures.PartPatternTerm_Bright;
this.frontColored = CableBusTextures.PartPatternTerm_Colored;
this.frontDark = CableBusTextures.PartPatternTerm_Dark;
}
@Override
public void writeToNBT(NBTTagCompound data)
public void getDrops( List<ItemStack> drops, boolean wrenched )
{
for ( ItemStack is : this.pattern )
if ( is != null )
drops.add( is );
}
@Override
public void writeToNBT( NBTTagCompound data )
{
super.writeToNBT( data );
data.setBoolean( "craftingMode", this.craftingMode );
@@ -53,7 +73,7 @@ public class PartPatternTerminal extends PartTerminal
}
@Override
public void readFromNBT(NBTTagCompound data)
public void readFromNBT( NBTTagCompound data )
{
super.readFromNBT( data );
this.setCraftingRecipe( data.getBoolean( "craftingMode" ) );
@@ -62,21 +82,6 @@ public class PartPatternTerminal extends PartTerminal
this.crafting.readFromNBT( data, "craftingGrid" );
}
@Override
public void getDrops(List<ItemStack> drops, boolean wrenched)
{
for (ItemStack is : this.pattern)
if ( is != null )
drops.add( is );
}
public PartPatternTerminal(ItemStack is) {
super( PartPatternTerminal.class, is );
this.frontBright = CableBusTextures.PartPatternTerm_Bright;
this.frontColored = CableBusTextures.PartPatternTerm_Colored;
this.frontDark = CableBusTextures.PartPatternTerm_Dark;
}
@Override
public GuiBridge getGui( EntityPlayer p )
{
@@ -90,28 +95,13 @@ public class PartPatternTerminal extends PartTerminal
z = this.tile.zCoord;
}
if( GuiBridge.GUI_PATTERN_TERMINAL.hasPermissions( this.getHost().getTile(), x, y, z, this.side, p ) )
if ( GuiBridge.GUI_PATTERN_TERMINAL.hasPermissions( this.getHost().getTile(), x, y, z, this.side, p ) )
return GuiBridge.GUI_PATTERN_TERMINAL;
return GuiBridge.GUI_ME;
}
@Override
public IInventory getInventoryByName(String name)
{
if ( name.equals( "crafting" ) )
return this.crafting;
if ( name.equals( "output" ) )
return this.output;
if ( name.equals( "pattern" ) )
return this.pattern;
return super.getInventoryByName( name );
}
@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.pattern && slot == 1 )
{
@@ -124,13 +114,13 @@ public class PartPatternTerminal extends PartTerminal
{
this.setCraftingRecipe( details.isCraftable() );
for (int x = 0; x < this.crafting.getSizeInventory() && x < details.getInputs().length; x++)
for ( int x = 0; x < this.crafting.getSizeInventory() && x < details.getInputs().length; x++ )
{
IAEItemStack item = details.getInputs()[x];
this.crafting.setInventorySlotContents( x, item == null ? null : item.getItemStack() );
}
for (int x = 0; x < this.output.getSizeInventory() && x < details.getOutputs().length; x++)
for ( int x = 0; x < this.output.getSizeInventory() && x < details.getOutputs().length; x++ )
{
IAEItemStack item = details.getOutputs()[x];
this.output.setInventorySlotContents( x, item == null ? null : item.getItemStack() );
@@ -146,22 +136,11 @@ public class PartPatternTerminal extends PartTerminal
this.host.markForSave();
}
public boolean isCraftingRecipe()
{
return this.craftingMode;
}
public void setCraftingRecipe(boolean craftingMode)
{
this.craftingMode = craftingMode;
this.fixCraftingRecipes();
}
private void fixCraftingRecipes()
{
if ( this.craftingMode )
{
for (int x = 0; x < this.crafting.getSizeInventory(); x++)
for ( int x = 0; x < this.crafting.getSizeInventory(); x++ )
{
ItemStack is = this.crafting.getStackInSlot( x );
if ( is != null )
@@ -169,4 +148,30 @@ public class PartPatternTerminal extends PartTerminal
}
}
}
public boolean isCraftingRecipe()
{
return this.craftingMode;
}
public void setCraftingRecipe( boolean craftingMode )
{
this.craftingMode = craftingMode;
this.fixCraftingRecipes();
}
@Override
public IInventory getInventoryByName( String name )
{
if ( name.equals( "crafting" ) )
return this.crafting;
if ( name.equals( "output" ) )
return this.output;
if ( name.equals( "pattern" ) )
return this.pattern;
return super.getInventoryByName( name );
}
}
@@ -18,6 +18,7 @@
package appeng.parts.reporting;
import net.minecraft.client.renderer.RenderBlocks;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.item.ItemStack;
@@ -29,28 +30,28 @@ import cpw.mods.fml.relauncher.SideOnly;
import appeng.api.parts.IPartRenderHelper;
import appeng.client.texture.CableBusTextures;
public class PartSemiDarkMonitor extends PartMonitor
{
public PartSemiDarkMonitor( ItemStack is )
{
super( is, false );
public PartSemiDarkMonitor(ItemStack is) {
super( PartSemiDarkMonitor.class, is,false );
this.notLightSource = false;
}
@Override
@SideOnly(Side.CLIENT)
public void renderInventory(IPartRenderHelper rh, RenderBlocks renderer)
@SideOnly( Side.CLIENT )
public void renderInventory( IPartRenderHelper rh, RenderBlocks renderer )
{
rh.setBounds( 2, 2, 14, 14, 14, 16 );
rh.setTexture( CableBusTextures.PartMonitorSides.getIcon(), CableBusTextures.PartMonitorSides.getIcon(), CableBusTextures.PartMonitorBack.getIcon(),
this.is.getIconIndex(), CableBusTextures.PartMonitorSides.getIcon(), CableBusTextures.PartMonitorSides.getIcon() );
rh.setTexture( CableBusTextures.PartMonitorSides.getIcon(), CableBusTextures.PartMonitorSides.getIcon(), CableBusTextures.PartMonitorBack.getIcon(), this.is.getIconIndex(), CableBusTextures.PartMonitorSides.getIcon(), CableBusTextures.PartMonitorSides.getIcon() );
rh.renderInventoryBox( renderer );
int light = this.getColor().whiteVariant;
int dark = this.getColor().mediumVariant;
rh.setInvColor( (((((light >> 16) & 0xff) + ((dark >> 16) & 0xff)) / 2) << 16) | (((((light >> 8) & 0xff) + ((dark >> 8) & 0xff)) / 2) << 8)
| ((((light) & 0xff) + ((dark) & 0xff)) / 2) );
rh.setInvColor( ( ( ( ( ( light >> 16 ) & 0xff ) + ( ( dark >> 16 ) & 0xff ) ) / 2 ) << 16 ) | ( ( ( ( ( light >> 8 ) & 0xff ) + ( ( dark >> 8 ) & 0xff ) ) / 2 ) << 8 ) | ( ( ( ( light ) & 0xff ) + ( ( dark ) & 0xff ) ) / 2 ) );
rh.renderInventoryFace( this.frontBright.getIcon(), ForgeDirection.SOUTH, renderer );
rh.setBounds( 4, 4, 13, 12, 12, 14 );
@@ -58,11 +59,10 @@ public class PartSemiDarkMonitor extends PartMonitor
}
@Override
@SideOnly(Side.CLIENT)
public void renderStatic(int x, int y, int z, IPartRenderHelper rh, RenderBlocks renderer)
@SideOnly( Side.CLIENT )
public void renderStatic( int x, int y, int z, IPartRenderHelper rh, RenderBlocks renderer )
{
rh.setTexture( CableBusTextures.PartMonitorSides.getIcon(), CableBusTextures.PartMonitorSides.getIcon(), CableBusTextures.PartMonitorBack.getIcon(),
this.is.getIconIndex(), CableBusTextures.PartMonitorSides.getIcon(), CableBusTextures.PartMonitorSides.getIcon() );
rh.setTexture( CableBusTextures.PartMonitorSides.getIcon(), CableBusTextures.PartMonitorSides.getIcon(), CableBusTextures.PartMonitorBack.getIcon(), this.is.getIconIndex(), CableBusTextures.PartMonitorSides.getIcon(), CableBusTextures.PartMonitorSides.getIcon() );
rh.setBounds( 2, 2, 14, 14, 14, 16 );
rh.renderBlock( x, y, z, renderer );
@@ -75,12 +75,10 @@ public class PartSemiDarkMonitor extends PartMonitor
int light = this.getColor().whiteVariant;
int dark = this.getColor().mediumVariant;
Tessellator.instance.setColorOpaque( (((light >> 16) & 0xff) + ((dark >> 16) & 0xff)) / 2, (((light >> 8) & 0xff) + ((dark >> 8) & 0xff)) / 2,
(((light) & 0xff) + ((dark) & 0xff)) / 2 );
Tessellator.instance.setColorOpaque( ( ( ( light >> 16 ) & 0xff ) + ( ( dark >> 16 ) & 0xff ) ) / 2, ( ( ( light >> 8 ) & 0xff ) + ( ( dark >> 8 ) & 0xff ) ) / 2, ( ( ( light ) & 0xff ) + ( ( dark ) & 0xff ) ) / 2 );
rh.renderFace( x, y, z, this.frontBright.getIcon(), ForgeDirection.SOUTH, renderer );
rh.setBounds( 4, 4, 13, 12, 12, 14 );
rh.renderBlock( x, y, z, renderer );
}
}
@@ -57,18 +57,36 @@ import appeng.client.ClientHelper;
import appeng.client.texture.CableBusTextures;
import appeng.core.AELog;
import appeng.core.localization.PlayerMessages;
import appeng.helpers.Reflected;
import appeng.me.GridAccessException;
import appeng.util.Platform;
import appeng.util.item.AEItemStack;
public class PartStorageMonitor extends PartMonitor implements IPartStorageMonitor, IStackWatcherHost
{
IAEItemStack configuredItem;
boolean isLocked;
IStackWatcher myWatcher;
@SideOnly( Side.CLIENT )
private boolean updateList;
@SideOnly( Side.CLIENT )
private Integer dspList;
@Reflected
public PartStorageMonitor( ItemStack is )
{
super( is, true );
this.frontBright = CableBusTextures.PartStorageMonitor_Bright;
this.frontColored = CableBusTextures.PartStorageMonitor_Colored;
this.frontDark = CableBusTextures.PartStorageMonitor_Dark;
// frontSolid = CableBusTextures.PartStorageMonitor_Solid;
}
@Override
public void writeToNBT(NBTTagCompound data)
public void writeToNBT( NBTTagCompound data )
{
super.writeToNBT( data );
@@ -82,7 +100,7 @@ public class PartStorageMonitor extends PartMonitor implements IPartStorageMonit
}
@Override
public void readFromNBT(NBTTagCompound data)
public void readFromNBT( NBTTagCompound data )
{
super.readFromNBT( data );
@@ -93,7 +111,39 @@ public class PartStorageMonitor extends PartMonitor implements IPartStorageMonit
}
@Override
public void writeToStream(ByteBuf data) throws IOException
public boolean onPartActivate( EntityPlayer player, Vec3 pos )
{
if ( Platform.isClient() )
return true;
if ( !this.proxy.isActive() )
return false;
if ( !Platform.hasPermissions( this.getLocation(), player ) )
return false;
TileEntity te = this.tile;
ItemStack eq = player.getCurrentEquippedItem();
if ( Platform.isWrench( player, eq, te.xCoord, te.yCoord, te.zCoord ) )
{
this.isLocked = !this.isLocked;
player.addChatMessage( ( this.isLocked ? PlayerMessages.isNowLocked : PlayerMessages.isNowUnlocked ).get() );
this.getHost().markForUpdate();
}
else if ( !this.isLocked )
{
this.configuredItem = AEItemStack.create( eq );
this.configureWatchers();
this.getHost().markForUpdate();
}
else
this.extractItem( player );
return true;
}
@Override
public void writeToStream( ByteBuf data ) throws IOException
{
super.writeToStream( data );
@@ -105,7 +155,7 @@ public class PartStorageMonitor extends PartMonitor implements IPartStorageMonit
}
@Override
public boolean readFromStream(ByteBuf data) throws IOException
public boolean readFromStream( ByteBuf data ) throws IOException
{
boolean stuff = super.readFromStream( data );
@@ -122,69 +172,47 @@ public class PartStorageMonitor extends PartMonitor implements IPartStorageMonit
return stuff;
}
@Override
public boolean onPartActivate(EntityPlayer player, Vec3 pos)
// update the system...
public void configureWatchers()
{
if ( Platform.isClient() )
return true;
if ( this.myWatcher != null )
this.myWatcher.clear();
if ( !this.proxy.isActive() )
return false;
if ( !Platform.hasPermissions( this.getLocation(), player ) )
return false;
TileEntity te = this.tile;
ItemStack eq = player.getCurrentEquippedItem();
if ( Platform.isWrench( player, eq, te.xCoord, te.yCoord, te.zCoord ) )
try
{
this.isLocked = !this.isLocked;
player.addChatMessage( (this.isLocked ? PlayerMessages.isNowLocked : PlayerMessages.isNowUnlocked).get() );
this.getHost().markForUpdate();
if ( this.configuredItem != null )
{
if ( this.myWatcher != null )
this.myWatcher.add( this.configuredItem );
this.updateReportingValue( this.proxy.getStorage().getItemInventory() );
}
}
else if ( !this.isLocked )
catch ( GridAccessException e )
{
this.configuredItem = AEItemStack.create( eq );
this.configureWatchers();
this.getHost().markForUpdate();
// >.>
}
else
this.extractItem( player );
return true;
}
protected void extractItem(EntityPlayer player)
protected void extractItem( EntityPlayer player )
{
}
protected PartStorageMonitor(Class myClass, ItemStack is) {
super( myClass, is, true );
}
public PartStorageMonitor(ItemStack is) {
super( PartStorageMonitor.class, is, true );
this.frontBright = CableBusTextures.PartStorageMonitor_Bright;
this.frontColored = CableBusTextures.PartStorageMonitor_Colored;
this.frontDark = CableBusTextures.PartStorageMonitor_Dark;
// frontSolid = CableBusTextures.PartStorageMonitor_Solid;
}
@Override
public boolean requireDynamicRender()
private void updateReportingValue( IMEMonitor<IAEItemStack> itemInventory )
{
return true;
if ( this.configuredItem != null )
{
IAEItemStack result = itemInventory.getStorageList().findPrecise( this.configuredItem );
if ( result == null )
this.configuredItem.setStackSize( 0 );
else
this.configuredItem.setStackSize( result.getStackSize() );
}
}
@SideOnly(Side.CLIENT)
private boolean updateList;
@SideOnly(Side.CLIENT)
private Integer dspList;
@Override
@SideOnly(Side.CLIENT)
@SideOnly( Side.CLIENT )
protected void finalize() throws Throwable
{
super.finalize();
@@ -193,8 +221,8 @@ public class PartStorageMonitor extends PartMonitor implements IPartStorageMonit
}
@Override
@SideOnly(Side.CLIENT)
public void renderDynamic(double x, double y, double z, IPartRenderHelper rh, RenderBlocks renderer)
@SideOnly( Side.CLIENT )
public void renderDynamic( double x, double y, double z, IPartRenderHelper rh, RenderBlocks renderer )
{
if ( this.dspList == null )
this.dspList = GLAllocation.generateDisplayLists( 1 );
@@ -203,7 +231,7 @@ public class PartStorageMonitor extends PartMonitor implements IPartStorageMonit
if ( Platform.isDrawing( tess ) )
return;
if ( (this.clientFlags & (this.POWERED_FLAG | this.CHANNEL_FLAG)) != (this.POWERED_FLAG | this.CHANNEL_FLAG) )
if ( ( this.clientFlags & ( this.POWERED_FLAG | this.CHANNEL_FLAG ) ) != ( this.POWERED_FLAG | this.CHANNEL_FLAG ) )
return;
IAEItemStack ais = (IAEItemStack) this.getDisplayed();
@@ -226,7 +254,19 @@ public class PartStorageMonitor extends PartMonitor implements IPartStorageMonit
}
}
private void tesrRenderScreen(Tessellator tess, IAEItemStack ais)
@Override
public boolean requireDynamicRender()
{
return true;
}
@Override
public IAEStack getDisplayed()
{
return this.configuredItem;
}
private void tesrRenderScreen( Tessellator tess, IAEItemStack ais )
{
GL11.glPushAttrib( GL11.GL_ALL_ATTRIB_BITS );
ForgeDirection d = this.side;
@@ -288,9 +328,8 @@ public class PartStorageMonitor extends PartMonitor implements IPartStorageMonit
tess.setColorOpaque_F( 1.0f, 1.0f, 1.0f );
ClientHelper.proxy.doRenderItem( sis, this.tile.getWorldObj() );
}
catch (Exception e)
catch ( Exception e )
{
AELog.error( e );
}
@@ -320,63 +359,21 @@ public class PartStorageMonitor extends PartMonitor implements IPartStorageMonit
GL11.glPopAttrib();
}
@Override
public IAEStack getDisplayed()
{
return this.configuredItem;
}
@Override
public boolean isLocked()
{
return this.isLocked;
}
IStackWatcher myWatcher;
@Override
public void updateWatcher(IStackWatcher newWatcher)
public void updateWatcher( IStackWatcher newWatcher )
{
this.myWatcher = newWatcher;
this.configureWatchers();
}
// update the system...
public void configureWatchers()
{
if ( this.myWatcher != null )
this.myWatcher.clear();
try
{
if ( this.configuredItem != null )
{
if ( this.myWatcher != null )
this.myWatcher.add( this.configuredItem );
this.updateReportingValue( this.proxy.getStorage().getItemInventory() );
}
}
catch (GridAccessException e)
{
// >.>
}
}
private void updateReportingValue(IMEMonitor<IAEItemStack> itemInventory)
{
if ( this.configuredItem != null )
{
IAEItemStack result = itemInventory.getStorageList().findPrecise( this.configuredItem );
if ( result == null )
this.configuredItem.setStackSize( 0 );
else
this.configuredItem.setStackSize( result.getStackSize() );
}
}
@Override
public void onStackChange(IItemList o, IAEStack fullStack, IAEStack diffStack, BaseActionSource src, StorageChannel chan)
public void onStackChange( IItemList o, IAEStack fullStack, IAEStack diffStack, BaseActionSource src, StorageChannel chan )
{
if ( this.configuredItem != null )
{
@@ -390,9 +387,8 @@ public class PartStorageMonitor extends PartMonitor implements IPartStorageMonit
}
@Override
public boolean showNetworkInfo(MovingObjectPosition where)
public boolean showNetworkInfo( MovingObjectPosition where )
{
return false;
}
}
@@ -18,6 +18,7 @@
package appeng.parts.reporting;
import java.util.List;
import net.minecraft.entity.player.EntityPlayer;
@@ -44,48 +45,17 @@ import appeng.util.ConfigManager;
import appeng.util.IConfigManagerHost;
import appeng.util.Platform;
public class PartTerminal extends PartMonitor implements ITerminalHost, IConfigManagerHost, IViewCellStorage, IAEAppEngInventory
{
final IConfigManager cm = new ConfigManager( this );
final AppEngInternalInventory viewCell = new AppEngInternalInventory( this, 5 );
public PartTerminal(Class clz, ItemStack is) {
super( clz, is, true );
this.cm.registerSetting( Settings.SORT_BY, SortOrder.NAME );
this.cm.registerSetting( Settings.VIEW_MODE, ViewItems.ALL );
this.cm.registerSetting( Settings.SORT_DIRECTION, SortDir.ASCENDING );
}
@Override
public void getDrops(List<ItemStack> drops, boolean wrenched)
public PartTerminal( ItemStack is )
{
super.getDrops( drops, wrenched );
super( is, true );
for (ItemStack is : this.viewCell)
if ( is != null )
drops.add( is );
}
@Override
public void readFromNBT(NBTTagCompound data)
{
super.readFromNBT( data );
this.cm.readFromNBT( data );
this.viewCell.readFromNBT( data, "viewCell" );
}
@Override
public void writeToNBT(NBTTagCompound data)
{
super.writeToNBT( data );
this.cm.writeToNBT( data );
this.viewCell.writeToNBT( data, "viewCell" );
}
public PartTerminal(ItemStack is) {
super( PartTerminal.class, is, true );
this.frontBright = CableBusTextures.PartTerminal_Bright;
this.frontColored = CableBusTextures.PartTerminal_Colored;
this.frontDark = CableBusTextures.PartTerminal_Dark;
@@ -96,13 +66,40 @@ public class PartTerminal extends PartMonitor implements ITerminalHost, IConfigM
this.cm.registerSetting( Settings.SORT_DIRECTION, SortDir.ASCENDING );
}
public GuiBridge getGui( EntityPlayer player )
@Override
public void getDrops( List<ItemStack> drops, boolean wrenched )
{
return GuiBridge.GUI_ME;
super.getDrops( drops, wrenched );
for ( ItemStack is : this.viewCell )
if ( is != null )
drops.add( is );
}
@Override
public boolean onPartActivate(EntityPlayer player, Vec3 pos)
public IConfigManager getConfigManager()
{
return this.cm;
}
@Override
public void writeToNBT( NBTTagCompound data )
{
super.writeToNBT( data );
this.cm.writeToNBT( data );
this.viewCell.writeToNBT( data, "viewCell" );
}
@Override
public void readFromNBT( NBTTagCompound data )
{
super.readFromNBT( data );
this.cm.readFromNBT( data );
this.viewCell.readFromNBT( data, "viewCell" );
}
@Override
public boolean onPartActivate( EntityPlayer player, Vec3 pos )
{
if ( !super.onPartActivate( player, pos ) )
{
@@ -119,18 +116,9 @@ public class PartTerminal extends PartMonitor implements ITerminalHost, IConfigM
return false;
}
@Override
public IMEMonitor getFluidInventory()
public GuiBridge getGui( EntityPlayer player )
{
try
{
return this.proxy.getStorage().getFluidInventory();
}
catch (GridAccessException e)
{
// err nope?
}
return null;
return GuiBridge.GUI_ME;
}
@Override
@@ -140,7 +128,7 @@ public class PartTerminal extends PartMonitor implements ITerminalHost, IConfigM
{
return this.proxy.getStorage().getItemInventory();
}
catch (GridAccessException e)
catch ( GridAccessException e )
{
// err nope?
}
@@ -148,13 +136,21 @@ public class PartTerminal extends PartMonitor implements ITerminalHost, IConfigM
}
@Override
public IConfigManager getConfigManager()
public IMEMonitor getFluidInventory()
{
return this.cm;
try
{
return this.proxy.getStorage().getFluidInventory();
}
catch ( GridAccessException e )
{
// err nope?
}
return null;
}
@Override
public void updateSetting(IConfigManager manager, Enum settingName, Enum newValue)
public void updateSetting( IConfigManager manager, Enum settingName, Enum newValue )
{
}
@@ -166,7 +162,7 @@ public class PartTerminal extends PartMonitor implements ITerminalHost, IConfigM
}
@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 )
{
this.host.markForSave();
}