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
+139 -142
View File
@@ -18,6 +18,7 @@
package appeng.parts.misc;
import java.util.ArrayList;
import java.util.EnumSet;
import java.util.List;
@@ -44,113 +45,41 @@ import appeng.api.parts.IPartHost;
import appeng.api.parts.IPartRenderHelper;
import appeng.api.util.AECableType;
import appeng.client.texture.CableBusTextures;
import appeng.helpers.Reflected;
import appeng.me.helpers.AENetworkProxy;
import appeng.parts.PartBasicState;
import appeng.util.Platform;
public class PartToggleBus extends PartBasicState
{
protected final int REDSTONE_FLAG = 4;
final AENetworkProxy outerProxy = new AENetworkProxy( this, "outer", null, true );
IGridConnection connection;
protected final int REDSTONE_FLAG = 4;
boolean hasRedstone = false;
@Override
public void onPlacement(EntityPlayer player, ItemStack held, ForgeDirection side)
@Reflected
public PartToggleBus( ItemStack is )
{
super.onPlacement( player, held, side );
this.outerProxy.setOwner( player );
}
super( is );
@Override
protected int populateFlags(int cf)
{
return cf | (this.getIntention() ? this.REDSTONE_FLAG : 0);
}
@Override
public void onNeighborChanged()
{
boolean oldHasRedstone = this.hasRedstone;
this.hasRedstone = this.getHost().hasRedstone( this.side );
if ( this.hasRedstone != oldHasRedstone )
{
this.updateInternalState();
this.getHost().markForUpdate();
}
}
public PartToggleBus(ItemStack is) {
this( PartToggleBus.class, is );
this.proxy.setIdlePowerUsage( 0.0 );
this.outerProxy.setIdlePowerUsage( 0.0 );
this.proxy.setFlags();
this.outerProxy.setFlags();
}
public PartToggleBus(Class cls, ItemStack is) {
super( cls, is );
@Override
public void setColors( boolean hasChan, boolean hasPower )
{
this.hasRedstone = ( this.clientFlags & this.REDSTONE_FLAG ) == this.REDSTONE_FLAG;
super.setColors( hasChan && this.hasRedstone, hasPower && this.hasRedstone );
}
@Override
public void setPartHostInfo(ForgeDirection side, IPartHost host, TileEntity tile)
protected int populateFlags( int cf )
{
super.setPartHostInfo( side, host, tile );
this.outerProxy.setValidSides( EnumSet.of( side ) );
}
@Override
public void readFromNBT(NBTTagCompound extra)
{
super.readFromNBT( extra );
this.outerProxy.readFromNBT( extra );
}
@Override
public void writeToNBT(NBTTagCompound extra)
{
super.writeToNBT( extra );
this.outerProxy.writeToNBT( extra );
}
@Override
public void addToWorld()
{
super.addToWorld();
this.outerProxy.onReady();
this.hasRedstone = this.getHost().hasRedstone( this.side );
this.updateInternalState();
}
private void updateInternalState()
{
boolean intention = this.getIntention();
if ( intention == ( this.connection == null ) )
{
if ( this.proxy.getNode() != null && this.outerProxy.getNode() != null )
{
if ( intention )
{
try
{
this.connection = AEApi.instance().createGridConnection( this.proxy.getNode(), this.outerProxy.getNode() );
}
catch (FailedConnection e)
{
// :(
}
}
else
{
this.connection.destroy();
this.connection = null;
}
}
}
return cf | ( this.getIntention() ? this.REDSTONE_FLAG : 0 );
}
protected boolean getIntention()
@@ -158,55 +87,6 @@ public class PartToggleBus extends PartBasicState
return this.getHost().hasRedstone( this.side );
}
@Override
public void removeFromWorld()
{
super.removeFromWorld();
this.outerProxy.invalidate();
}
@Override
public IGridNode getExternalFacingNode()
{
return this.outerProxy.getNode();
}
@Override
public AECableType getCableConnectionType(ForgeDirection dir)
{
return AECableType.GLASS;
}
@Override
public void setColors(boolean hasChan, boolean hasPower)
{
this.hasRedstone = (this.clientFlags & this.REDSTONE_FLAG) == this.REDSTONE_FLAG;
super.setColors( hasChan && this.hasRedstone, hasPower && this.hasRedstone );
}
@Override
@SideOnly(Side.CLIENT)
public void renderStatic(int x, int y, int z, IPartRenderHelper rh, RenderBlocks renderer)
{
this.renderCache = rh.useSimplifiedRendering( x, y, z, this, this.renderCache );
rh.setTexture( this.is.getIconIndex() );
rh.setBounds( 6, 6, 14, 10, 10, 16 );
rh.renderBlock( x, y, z, renderer );
rh.setBounds( 6, 6, 11, 10, 10, 13 );
rh.renderBlock( x, y, z, renderer );
rh.setTexture( CableBusTextures.PartMonitorSidesStatus.getIcon(), CableBusTextures.PartMonitorSidesStatus.getIcon(),
CableBusTextures.PartMonitorBack.getIcon(), this.is.getIconIndex(), CableBusTextures.PartMonitorSidesStatus.getIcon(),
CableBusTextures.PartMonitorSidesStatus.getIcon() );
rh.setBounds( 6, 6, 13, 10, 10, 14 );
rh.renderBlock( x, y, z, renderer );
this.renderLights( x, y, z, rh, renderer );
}
@Override
public IIcon getBreakingTexture()
{
@@ -214,14 +94,8 @@ public class PartToggleBus extends PartBasicState
}
@Override
public void getBoxes(IPartCollisionHelper bch)
{
bch.addBox( 6, 6, 11, 10, 10, 16 );
}
@Override
@SideOnly(Side.CLIENT)
public void renderInventory(IPartRenderHelper rh, RenderBlocks renderer)
@SideOnly( Side.CLIENT )
public void renderInventory( IPartRenderHelper rh, RenderBlocks renderer )
{
GL11.glTranslated( -0.2, -0.3, 0.0 );
@@ -244,12 +118,108 @@ public class PartToggleBus extends PartBasicState
rh.setTexture( null );
}
@Override
@SideOnly( Side.CLIENT )
public void renderStatic( int x, int y, int z, IPartRenderHelper rh, RenderBlocks renderer )
{
this.renderCache = rh.useSimplifiedRendering( x, y, z, this, this.renderCache );
rh.setTexture( this.is.getIconIndex() );
rh.setBounds( 6, 6, 14, 10, 10, 16 );
rh.renderBlock( x, y, z, renderer );
rh.setBounds( 6, 6, 11, 10, 10, 13 );
rh.renderBlock( x, y, z, renderer );
rh.setTexture( CableBusTextures.PartMonitorSidesStatus.getIcon(), CableBusTextures.PartMonitorSidesStatus.getIcon(), CableBusTextures.PartMonitorBack.getIcon(), this.is.getIconIndex(), CableBusTextures.PartMonitorSidesStatus.getIcon(), CableBusTextures.PartMonitorSidesStatus.getIcon() );
rh.setBounds( 6, 6, 13, 10, 10, 14 );
rh.renderBlock( x, y, z, renderer );
this.renderLights( x, y, z, rh, renderer );
}
@Override
public void onNeighborChanged()
{
boolean oldHasRedstone = this.hasRedstone;
this.hasRedstone = this.getHost().hasRedstone( this.side );
if ( this.hasRedstone != oldHasRedstone )
{
this.updateInternalState();
this.getHost().markForUpdate();
}
}
@Override
public void readFromNBT( NBTTagCompound extra )
{
super.readFromNBT( extra );
this.outerProxy.readFromNBT( extra );
}
@Override
public void writeToNBT( NBTTagCompound extra )
{
super.writeToNBT( extra );
this.outerProxy.writeToNBT( extra );
}
@Override
public void removeFromWorld()
{
super.removeFromWorld();
this.outerProxy.invalidate();
}
@Override
public void addToWorld()
{
super.addToWorld();
this.outerProxy.onReady();
this.hasRedstone = this.getHost().hasRedstone( this.side );
this.updateInternalState();
}
@Override
public void setPartHostInfo( ForgeDirection side, IPartHost host, TileEntity tile )
{
super.setPartHostInfo( side, host, tile );
this.outerProxy.setValidSides( EnumSet.of( side ) );
}
@Override
public IGridNode getExternalFacingNode()
{
return this.outerProxy.getNode();
}
@Override
public void getBoxes( IPartCollisionHelper bch )
{
bch.addBox( 6, 6, 11, 10, 10, 16 );
}
@Override
public AECableType getCableConnectionType( ForgeDirection dir )
{
return AECableType.GLASS;
}
@Override
public int cableConnectionRenderTo()
{
return 5;
}
@Override
public void onPlacement( EntityPlayer player, ItemStack held, ForgeDirection side )
{
super.onPlacement( player, held, side );
this.outerProxy.setOwner( player );
}
@Override
public void securityBreak()
{
@@ -262,4 +232,31 @@ public class PartToggleBus extends PartBasicState
this.is.stackSize = 0;
}
}
private void updateInternalState()
{
boolean intention = this.getIntention();
if ( intention == ( this.connection == null ) )
{
if ( this.proxy.getNode() != null && this.outerProxy.getNode() != null )
{
if ( intention )
{
try
{
this.connection = AEApi.instance().createGridConnection( this.proxy.getNode(), this.outerProxy.getNode() );
}
catch ( FailedConnection e )
{
// :(
}
}
else
{
this.connection.destroy();
this.connection = null;
}
}
}
}
}