Basic reformat, hit once, hope never again

This commit is contained in:
thatsIch
2015-04-03 08:54:31 +02:00
parent 4ff1631f89
commit d34c988c88
886 changed files with 31400 additions and 30990 deletions
@@ -18,6 +18,7 @@
package appeng.tile.spatial;
import java.util.concurrent.Callable;
import net.minecraft.inventory.IInventory;
@@ -47,6 +48,7 @@ import appeng.tile.inventory.AppEngInternalInventory;
import appeng.tile.inventory.InvOperation;
import appeng.util.Platform;
public class TileSpatialIOPort extends AENetworkInvTile implements Callable
{
@@ -54,60 +56,71 @@ public class TileSpatialIOPort extends AENetworkInvTile implements Callable
final AppEngInternalInventory inv = new AppEngInternalInventory( this, 2 );
YesNo lastRedstoneState = YesNo.UNDECIDED;
@TileEvent(TileEventType.WORLD_NBT_WRITE)
public void writeToNBT_TileSpatialIOPort(NBTTagCompound data)
public TileSpatialIOPort()
{
this.gridProxy.setFlags( GridFlags.REQUIRE_CHANNEL );
}
@TileEvent( TileEventType.WORLD_NBT_WRITE )
public void writeToNBT_TileSpatialIOPort( NBTTagCompound data )
{
data.setInteger( "lastRedstoneState", this.lastRedstoneState.ordinal() );
}
@TileEvent(TileEventType.WORLD_NBT_READ)
public void readFromNBT_TileSpatialIOPort(NBTTagCompound data)
@TileEvent( TileEventType.WORLD_NBT_READ )
public void readFromNBT_TileSpatialIOPort( NBTTagCompound data )
{
if ( data.hasKey( "lastRedstoneState" ) )
if( data.hasKey( "lastRedstoneState" ) )
this.lastRedstoneState = YesNo.values()[data.getInteger( "lastRedstoneState" )];
}
public TileSpatialIOPort() {
this.gridProxy.setFlags( GridFlags.REQUIRE_CHANNEL );
}
public void updateRedstoneState()
{
YesNo currentState = this.worldObj.isBlockIndirectlyGettingPowered( this.xCoord, this.yCoord, this.zCoord ) ? YesNo.YES : YesNo.NO;
if ( this.lastRedstoneState != currentState )
{
this.lastRedstoneState = currentState;
if ( this.lastRedstoneState == YesNo.YES )
this.triggerTransition();
}
}
public boolean getRedstoneState()
{
if ( this.lastRedstoneState == YesNo.UNDECIDED )
if( this.lastRedstoneState == YesNo.UNDECIDED )
this.updateRedstoneState();
return this.lastRedstoneState == YesNo.YES;
}
public void updateRedstoneState()
{
YesNo currentState = this.worldObj.isBlockIndirectlyGettingPowered( this.xCoord, this.yCoord, this.zCoord ) ? YesNo.YES : YesNo.NO;
if( this.lastRedstoneState != currentState )
{
this.lastRedstoneState = currentState;
if( this.lastRedstoneState == YesNo.YES )
this.triggerTransition();
}
}
private void triggerTransition()
{
if ( Platform.isServer() )
if( Platform.isServer() )
{
ItemStack cell = this.getStackInSlot( 0 );
if ( this.isSpatialCell( cell ) )
if( this.isSpatialCell( cell ) )
{
TickHandler.INSTANCE.addCallable( null, this );// this needs to be cross world synced.
}
}
}
private boolean isSpatialCell( ItemStack cell )
{
if( cell != null && cell.getItem() instanceof ISpatialStorageCell )
{
ISpatialStorageCell sc = (ISpatialStorageCell) cell.getItem();
return sc != null && sc.isSpatialStorage( cell );
}
return false;
}
@Override
public Object call() throws Exception
{
ItemStack cell = this.getStackInSlot( 0 );
if ( this.isSpatialCell( cell ) && this.getStackInSlot( 1 ) == null )
if( this.isSpatialCell( cell ) && this.getStackInSlot( 1 ) == null )
{
IGrid gi = this.gridProxy.getGrid();
IEnergyGrid energy = this.gridProxy.getEnergy();
@@ -115,17 +128,17 @@ public class TileSpatialIOPort extends AENetworkInvTile implements Callable
ISpatialStorageCell sc = (ISpatialStorageCell) cell.getItem();
SpatialPylonCache spc = gi.getCache( ISpatialCache.class );
if ( spc.hasRegion() && spc.isValidRegion() )
if( spc.hasRegion() && spc.isValidRegion() )
{
double req = spc.requiredPower();
double pr = energy.extractAEPower( req, Actionable.SIMULATE, PowerMultiplier.CONFIG );
if ( Math.abs( pr - req ) < req * 0.001 )
if( Math.abs( pr - req ) < req * 0.001 )
{
MENetworkEvent res = gi.postEvent( new MENetworkSpatialEvent( this, req ) );
if ( !res.isCanceled() )
if( !res.isCanceled() )
{
TransitionResult tr = sc.doSpatialTransition( cell, this.worldObj, spc.getMin(), spc.getMax(), true );
if ( tr.success )
if( tr.success )
{
energy.extractAEPower( req, Actionable.MODULATE, PowerMultiplier.CONFIG );
this.setInventorySlotContents( 0, null );
@@ -140,7 +153,7 @@ public class TileSpatialIOPort extends AENetworkInvTile implements Callable
}
@Override
public AECableType getCableConnectionType(ForgeDirection dir)
public AECableType getCableConnectionType( ForgeDirection dir )
{
return AECableType.SMART;
}
@@ -158,43 +171,32 @@ public class TileSpatialIOPort extends AENetworkInvTile implements Callable
}
@Override
public boolean isItemValidForSlot(int i, ItemStack itemstack)
public boolean isItemValidForSlot( int i, ItemStack itemstack )
{
return (i == 0 && this.isSpatialCell( itemstack ));
}
private boolean isSpatialCell(ItemStack cell)
{
if ( cell != null && cell.getItem() instanceof ISpatialStorageCell )
{
ISpatialStorageCell sc = (ISpatialStorageCell) cell.getItem();
return sc != null && sc.isSpatialStorage( cell );
}
return false;
return ( i == 0 && this.isSpatialCell( itemstack ) );
}
@Override
public boolean canInsertItem(int slotIndex, ItemStack insertingItem, int side )
public void onChangeInventory( IInventory inv, int slot, InvOperation mc, ItemStack removed, ItemStack added )
{
}
@Override
public boolean canInsertItem( int slotIndex, ItemStack insertingItem, int side )
{
return this.isItemValidForSlot( slotIndex, insertingItem );
}
@Override
public boolean canExtractItem(int slotIndex, ItemStack extractedItem, int side )
public boolean canExtractItem( int slotIndex, ItemStack extractedItem, int side )
{
return slotIndex == 1;
}
@Override
public void onChangeInventory(IInventory inv, int slot, InvOperation mc, ItemStack removed, ItemStack added)
{
}
@Override
public int[] getAccessibleSlotsBySide(ForgeDirection side)
public int[] getAccessibleSlotsBySide( ForgeDirection side )
{
return this.sides;
}
}
@@ -18,6 +18,7 @@
package appeng.tile.spatial;
import java.util.EnumSet;
import io.netty.buffer.ByteBuf;
@@ -38,6 +39,7 @@ import appeng.tile.TileEvent;
import appeng.tile.events.TileEventType;
import appeng.tile.grid.AENetworkTile;
public class TileSpatialPylon extends AENetworkTile implements IAEMultiBlock
{
@@ -52,13 +54,18 @@ public class TileSpatialPylon extends AENetworkTile implements IAEMultiBlock
public final int DISPLAY_ENABLED = 0x10;
public final int DISPLAY_POWERED_ENABLED = 0x20;
public final int NET_STATUS = 0x10 + 0x20;
final SpatialPylonCalculator calc = new SpatialPylonCalculator( this );
int displayBits = 0;
SpatialPylonCluster cluster;
final SpatialPylonCalculator calc = new SpatialPylonCalculator( this );
boolean didHaveLight = false;
public TileSpatialPylon()
{
this.gridProxy.setFlags( GridFlags.REQUIRE_CHANNEL, GridFlags.MULTIBLOCK );
this.gridProxy.setIdlePowerUsage( 0.5 );
this.gridProxy.setValidSides( EnumSet.noneOf( ForgeDirection.class ) );
}
@Override
protected AENetworkProxy createProxy()
{
@@ -66,29 +73,10 @@ public class TileSpatialPylon extends AENetworkTile implements IAEMultiBlock
}
@Override
public boolean canBeRotated()
public void onChunkUnload()
{
return false;
}
@TileEvent(TileEventType.NETWORK_READ)
public boolean readFromStream_TileSpatialPylon(ByteBuf data)
{
int old = this.displayBits;
this.displayBits = data.readByte();
return old != this.displayBits;
}
@TileEvent(TileEventType.NETWORK_WRITE)
public void writeToStream_TileSpatialPylon(ByteBuf data)
{
data.writeByte( this.displayBits );
}
public TileSpatialPylon() {
this.gridProxy.setFlags( GridFlags.REQUIRE_CHANNEL, GridFlags.MULTIBLOCK );
this.gridProxy.setIdlePowerUsage( 0.5 );
this.gridProxy.setValidSides( EnumSet.noneOf( ForgeDirection.class ) );
this.disconnect( false );
super.onChunkUnload();
}
@Override
@@ -98,40 +86,6 @@ public class TileSpatialPylon extends AENetworkTile implements IAEMultiBlock
this.onNeighborBlockChange();
}
@Override
public void markForUpdate()
{
super.markForUpdate();
boolean hasLight = this.getLightValue() > 0;
if ( hasLight != this.didHaveLight )
{
this.didHaveLight = hasLight;
this.worldObj.func_147451_t( this.xCoord, this.yCoord, this.zCoord );
// worldObj.updateAllLightTypes( xCoord, yCoord, zCoord );
}
}
public int getLightValue()
{
if ( (this.displayBits & this.DISPLAY_POWERED_ENABLED) == this.DISPLAY_POWERED_ENABLED )
{
return 8;
}
return 0;
}
@MENetworkEventSubscribe
public void powerRender(MENetworkPowerStatusChange c)
{
this.recalculateDisplay();
}
@MENetworkEventSubscribe
public void activeRender(MENetworkChannelsChanged c)
{
this.recalculateDisplay();
}
@Override
public void invalidate()
{
@@ -139,100 +93,145 @@ public class TileSpatialPylon extends AENetworkTile implements IAEMultiBlock
super.invalidate();
}
@Override
public void onChunkUnload()
{
this.disconnect( false );
super.onChunkUnload();
}
public void onNeighborBlockChange()
{
this.calc.calculateMultiblock( this.worldObj, this.getLocation() );
}
@Override
public SpatialPylonCluster getCluster()
public void disconnect( boolean b )
{
return this.cluster;
}
public void recalculateDisplay()
{
int oldBits = this.displayBits;
this.displayBits = 0;
if ( this.cluster != null )
{
if ( this.cluster.min.equals( this.getLocation() ) )
this.displayBits = this.DISPLAY_END_MIN;
else if ( this.cluster.max.equals( this.getLocation() ) )
this.displayBits = this.DISPLAY_END_MAX;
else
this.displayBits = this.DISPLAY_MIDDLE;
switch (this.cluster.currentAxis)
{
case X:
this.displayBits |= this.DISPLAY_X;
break;
case Y:
this.displayBits |= this.DISPLAY_Y;
break;
case Z:
this.displayBits |= this.DISPLAY_Z;
break;
default:
this.displayBits = 0;
break;
}
try
{
if ( this.gridProxy.getEnergy().isNetworkPowered() )
this.displayBits |= this.DISPLAY_POWERED_ENABLED;
if ( this.cluster.isValid && this.gridProxy.isActive() )
this.displayBits |= this.DISPLAY_ENABLED;
}
catch (GridAccessException e)
{
// nothing?
}
}
if ( oldBits != this.displayBits )
this.markForUpdate();
}
public void updateStatus(SpatialPylonCluster c)
{
this.cluster = c;
this.gridProxy.setValidSides( c == null ? EnumSet.noneOf( ForgeDirection.class ) : EnumSet.allOf( ForgeDirection.class ) );
this.recalculateDisplay();
}
@Override
public void disconnect(boolean b)
{
if ( this.cluster != null )
if( this.cluster != null )
{
this.cluster.destroy();
this.updateStatus( null );
}
}
@Override
public SpatialPylonCluster getCluster()
{
return this.cluster;
}
@Override
public boolean isValid()
{
return true;
}
public void updateStatus( SpatialPylonCluster c )
{
this.cluster = c;
this.gridProxy.setValidSides( c == null ? EnumSet.noneOf( ForgeDirection.class ) : EnumSet.allOf( ForgeDirection.class ) );
this.recalculateDisplay();
}
public void recalculateDisplay()
{
int oldBits = this.displayBits;
this.displayBits = 0;
if( this.cluster != null )
{
if( this.cluster.min.equals( this.getLocation() ) )
this.displayBits = this.DISPLAY_END_MIN;
else if( this.cluster.max.equals( this.getLocation() ) )
this.displayBits = this.DISPLAY_END_MAX;
else
this.displayBits = this.DISPLAY_MIDDLE;
switch( this.cluster.currentAxis )
{
case X:
this.displayBits |= this.DISPLAY_X;
break;
case Y:
this.displayBits |= this.DISPLAY_Y;
break;
case Z:
this.displayBits |= this.DISPLAY_Z;
break;
default:
this.displayBits = 0;
break;
}
try
{
if( this.gridProxy.getEnergy().isNetworkPowered() )
this.displayBits |= this.DISPLAY_POWERED_ENABLED;
if( this.cluster.isValid && this.gridProxy.isActive() )
this.displayBits |= this.DISPLAY_ENABLED;
}
catch( GridAccessException e )
{
// nothing?
}
}
if( oldBits != this.displayBits )
this.markForUpdate();
}
@Override
public void markForUpdate()
{
super.markForUpdate();
boolean hasLight = this.getLightValue() > 0;
if( hasLight != this.didHaveLight )
{
this.didHaveLight = hasLight;
this.worldObj.func_147451_t( this.xCoord, this.yCoord, this.zCoord );
// worldObj.updateAllLightTypes( xCoord, yCoord, zCoord );
}
}
@Override
public boolean canBeRotated()
{
return false;
}
public int getLightValue()
{
if( ( this.displayBits & this.DISPLAY_POWERED_ENABLED ) == this.DISPLAY_POWERED_ENABLED )
{
return 8;
}
return 0;
}
@TileEvent( TileEventType.NETWORK_READ )
public boolean readFromStream_TileSpatialPylon( ByteBuf data )
{
int old = this.displayBits;
this.displayBits = data.readByte();
return old != this.displayBits;
}
@TileEvent( TileEventType.NETWORK_WRITE )
public void writeToStream_TileSpatialPylon( ByteBuf data )
{
data.writeByte( this.displayBits );
}
@MENetworkEventSubscribe
public void powerRender( MENetworkPowerStatusChange c )
{
this.recalculateDisplay();
}
@MENetworkEventSubscribe
public void activeRender( MENetworkChannelsChanged c )
{
this.recalculateDisplay();
}
public int getDisplayBits()
{
return this.displayBits;
}
}