Basic reformat, hit once, hope never again
This commit is contained in:
@@ -56,41 +56,41 @@ public class PartConversionMonitor extends PartStorageMonitor
|
||||
@Override
|
||||
public boolean onPartShiftActivate( EntityPlayer player, Vec3 pos )
|
||||
{
|
||||
if ( Platform.isClient() )
|
||||
if( Platform.isClient() )
|
||||
return true;
|
||||
|
||||
if ( !this.proxy.isActive() )
|
||||
if( !this.proxy.isActive() )
|
||||
return false;
|
||||
|
||||
if ( !Platform.hasPermissions( this.getLocation(), player ) )
|
||||
if( !Platform.hasPermissions( this.getLocation(), player ) )
|
||||
return false;
|
||||
|
||||
boolean ModeB = false;
|
||||
|
||||
ItemStack item = player.getCurrentEquippedItem();
|
||||
if ( item == null && this.getDisplayed() != null )
|
||||
if( item == null && this.getDisplayed() != null )
|
||||
{
|
||||
ModeB = true;
|
||||
item = ( (IAEItemStack) this.getDisplayed() ).getItemStack();
|
||||
}
|
||||
|
||||
if ( item != null )
|
||||
if( item != null )
|
||||
{
|
||||
try
|
||||
{
|
||||
if ( !this.proxy.isActive() )
|
||||
if( !this.proxy.isActive() )
|
||||
return false;
|
||||
|
||||
IEnergySource energy = this.proxy.getEnergy();
|
||||
IMEMonitor<IAEItemStack> cell = this.proxy.getStorage().getItemInventory();
|
||||
IAEItemStack input = AEItemStack.create( item );
|
||||
|
||||
if ( ModeB )
|
||||
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 ) )
|
||||
if( input.equals( targetStack ) )
|
||||
{
|
||||
IAEItemStack insertItem = input.copy();
|
||||
insertItem.setStackSize( targetStack.stackSize );
|
||||
@@ -105,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
|
||||
}
|
||||
@@ -117,11 +117,11 @@ public class PartConversionMonitor extends PartStorageMonitor
|
||||
protected void extractItem( EntityPlayer player )
|
||||
{
|
||||
IAEItemStack input = (IAEItemStack) this.getDisplayed();
|
||||
if ( input != null )
|
||||
if( input != null )
|
||||
{
|
||||
try
|
||||
{
|
||||
if ( !this.proxy.isActive() )
|
||||
if( !this.proxy.isActive() )
|
||||
return;
|
||||
|
||||
IEnergySource energy = this.proxy.getEnergy();
|
||||
@@ -131,23 +131,23 @@ public class PartConversionMonitor extends PartStorageMonitor
|
||||
input.setStackSize( is.getMaxStackSize() );
|
||||
|
||||
IAEItemStack retrieved = Platform.poweredExtraction( energy, cell, input, new PlayerSource( player, this ) );
|
||||
if ( retrieved != null )
|
||||
if( retrieved != null )
|
||||
{
|
||||
ItemStack newItems = retrieved.getItemStack();
|
||||
InventoryAdaptor adaptor = InventoryAdaptor.getAdaptor( player, ForgeDirection.UNKNOWN );
|
||||
newItems = adaptor.addItems( newItems );
|
||||
if ( newItems != null )
|
||||
if( newItems != null )
|
||||
{
|
||||
TileEntity te = this.tile;
|
||||
List<ItemStack> list = Collections.singletonList( newItems );
|
||||
Platform.spawnDrops( player.worldObj, te.xCoord + this.side.offsetX, te.yCoord + this.side.offsetY, te.zCoord + this.side.offsetZ, list );
|
||||
}
|
||||
|
||||
if ( player.openContainer != null )
|
||||
if( player.openContainer != null )
|
||||
player.openContainer.detectAndSendChanges();
|
||||
}
|
||||
}
|
||||
catch ( GridAccessException e )
|
||||
catch( GridAccessException e )
|
||||
{
|
||||
// :P
|
||||
}
|
||||
|
||||
@@ -53,8 +53,8 @@ public class PartCraftingTerminal extends PartTerminal
|
||||
{
|
||||
super.getDrops( drops, wrenched );
|
||||
|
||||
for ( ItemStack is : this.craftingGrid )
|
||||
if ( is != null )
|
||||
for( ItemStack is : this.craftingGrid )
|
||||
if( is != null )
|
||||
drops.add( is );
|
||||
}
|
||||
|
||||
@@ -78,14 +78,14 @@ public class PartCraftingTerminal extends PartTerminal
|
||||
int x = (int) p.posX;
|
||||
int y = (int) p.posY;
|
||||
int z = (int) p.posZ;
|
||||
if ( this.getHost().getTile() != null )
|
||||
if( this.getHost().getTile() != null )
|
||||
{
|
||||
x = this.tile.xCoord;
|
||||
y = this.tile.yCoord;
|
||||
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;
|
||||
}
|
||||
@@ -99,7 +99,7 @@ public class PartCraftingTerminal extends PartTerminal
|
||||
@Override
|
||||
public IInventory getInventoryByName( String name )
|
||||
{
|
||||
if ( name.equals( "crafting" ) )
|
||||
if( name.equals( "crafting" ) )
|
||||
return this.craftingGrid;
|
||||
return super.getInventoryByName( name );
|
||||
}
|
||||
|
||||
@@ -64,7 +64,7 @@ public class PartDarkMonitor extends PartMonitor
|
||||
rh.setBounds( 2, 2, 14, 14, 14, 16 );
|
||||
rh.renderBlock( x, y, z, renderer );
|
||||
|
||||
if ( this.getLightLevel() > 0 )
|
||||
if( this.getLightLevel() > 0 )
|
||||
{
|
||||
int l = 13;
|
||||
Tessellator.instance.setBrightness( l << 20 | l << 4 );
|
||||
|
||||
@@ -42,11 +42,11 @@ public class PartInterfaceTerminal extends PartMonitor
|
||||
@Override
|
||||
public boolean onPartActivate( EntityPlayer player, Vec3 pos )
|
||||
{
|
||||
if ( !super.onPartActivate( player, pos ) )
|
||||
if( !super.onPartActivate( player, pos ) )
|
||||
{
|
||||
if ( !player.isSneaking() )
|
||||
if( !player.isSneaking() )
|
||||
{
|
||||
if ( Platform.isClient() )
|
||||
if( Platform.isClient() )
|
||||
return true;
|
||||
|
||||
Platform.openGUI( player, this.getHost().getTile(), this.side, GuiBridge.GUI_INTERFACE_TERMINAL );
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
|
||||
package appeng.parts.reporting;
|
||||
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
@@ -48,205 +49,67 @@ import appeng.me.GridAccessException;
|
||||
import appeng.parts.AEBasePart;
|
||||
import appeng.util.Platform;
|
||||
|
||||
|
||||
public class PartMonitor extends AEBasePart implements IPartMonitor, IPowerChannelState
|
||||
{
|
||||
|
||||
// CableBusTextures frontSolid = CableBusTextures.PartMonitor_Solid;
|
||||
CableBusTextures frontDark = CableBusTextures.PartMonitor_Colored;
|
||||
CableBusTextures frontBright = CableBusTextures.PartMonitor_Bright;
|
||||
CableBusTextures frontColored = CableBusTextures.PartMonitor_Colored;
|
||||
|
||||
boolean notLightSource = !this.getClass().equals( PartMonitor.class );
|
||||
|
||||
final int POWERED_FLAG = 4;
|
||||
final int BOOTING_FLAG = 8;
|
||||
final int CHANNEL_FLAG = 16;
|
||||
|
||||
// CableBusTextures frontSolid = CableBusTextures.PartMonitor_Solid;
|
||||
CableBusTextures frontDark = CableBusTextures.PartMonitor_Colored;
|
||||
CableBusTextures frontBright = CableBusTextures.PartMonitor_Bright;
|
||||
CableBusTextures frontColored = CableBusTextures.PartMonitor_Colored;
|
||||
boolean notLightSource = !this.getClass().equals( PartMonitor.class );
|
||||
byte spin = 0; // 0-3
|
||||
int clientFlags = 0; // sent as byte.
|
||||
float opacity = -1;
|
||||
|
||||
@Override
|
||||
public void onPlacement(EntityPlayer player, ItemStack held, ForgeDirection side)
|
||||
public PartMonitor( ItemStack is )
|
||||
{
|
||||
super.onPlacement( player, held, side );
|
||||
|
||||
byte rotation = (byte) (MathHelper.floor_double( (player.rotationYaw * 4F) / 360F + 2.5D ) & 3);
|
||||
if ( side == ForgeDirection.UP )
|
||||
this.spin = rotation;
|
||||
else if ( side == ForgeDirection.DOWN )
|
||||
this.spin = rotation;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT(NBTTagCompound data)
|
||||
{
|
||||
super.writeToNBT( data );
|
||||
data.setFloat( "opacity", this.opacity );
|
||||
data.setByte( "spin", this.spin );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound data)
|
||||
{
|
||||
super.readFromNBT( data );
|
||||
if ( data.hasKey( "opacity" ) )
|
||||
this.opacity = data.getFloat( "opacity" );
|
||||
this.spin = data.getByte( "spin" );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onPartActivate(EntityPlayer player, Vec3 pos)
|
||||
{
|
||||
TileEntity te = this.getTile();
|
||||
|
||||
if ( !player.isSneaking() && Platform.isWrench( player, player.inventory.getCurrentItem(), te.xCoord, te.yCoord, te.zCoord ) )
|
||||
{
|
||||
if ( Platform.isServer() )
|
||||
{
|
||||
if ( this.spin > 3 )
|
||||
this.spin = 0;
|
||||
|
||||
switch (this.spin)
|
||||
{
|
||||
case 0:
|
||||
this.spin = 1;
|
||||
break;
|
||||
case 1:
|
||||
this.spin = 3;
|
||||
break;
|
||||
case 2:
|
||||
this.spin = 0;
|
||||
break;
|
||||
case 3:
|
||||
this.spin = 2;
|
||||
break;
|
||||
}
|
||||
|
||||
this.host.markForUpdate();
|
||||
this.saveChanges();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
else
|
||||
return super.onPartActivate( player, pos );
|
||||
}
|
||||
|
||||
@MENetworkEventSubscribe
|
||||
public void bootingRender(MENetworkBootingStatusChange c)
|
||||
{
|
||||
if ( this.notLightSource )
|
||||
this.getHost().markForUpdate();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNeighborChanged()
|
||||
{
|
||||
this.opacity = -1;
|
||||
this.getHost().markForUpdate();
|
||||
}
|
||||
|
||||
@MENetworkEventSubscribe
|
||||
public void powerRender(MENetworkPowerStatusChange c)
|
||||
{
|
||||
this.getHost().markForUpdate();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToStream(ByteBuf data) throws IOException
|
||||
{
|
||||
super.writeToStream( data );
|
||||
this.clientFlags = this.spin & 3;
|
||||
|
||||
try
|
||||
{
|
||||
if ( this.proxy.getEnergy().isNetworkPowered() )
|
||||
this.clientFlags |= this.POWERED_FLAG;
|
||||
|
||||
if ( this.proxy.getPath().isNetworkBooting() )
|
||||
this.clientFlags |= this.BOOTING_FLAG;
|
||||
|
||||
if ( this.proxy.getNode().meetsChannelRequirements() )
|
||||
this.clientFlags |= this.CHANNEL_FLAG;
|
||||
}
|
||||
catch (GridAccessException e)
|
||||
{
|
||||
// um.. nothing.
|
||||
}
|
||||
|
||||
data.writeByte( (byte) this.clientFlags );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean readFromStream(ByteBuf data) throws IOException
|
||||
{
|
||||
super.readFromStream( data );
|
||||
int oldFlags = this.clientFlags;
|
||||
this.clientFlags = data.readByte();
|
||||
this.spin = (byte) (this.clientFlags & 3);
|
||||
if ( this.clientFlags == oldFlags )
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getLightLevel()
|
||||
{
|
||||
return this.blockLight( this.isPowered() ? (this.notLightSource ? 9 : 15) : 0 );
|
||||
}
|
||||
|
||||
private int blockLight(int emit)
|
||||
{
|
||||
if ( this.opacity < 0 )
|
||||
{
|
||||
TileEntity te = this.getTile();
|
||||
this.opacity = 255 - te.getWorldObj().getBlockLightOpacity( te.xCoord + this.side.offsetX, te.yCoord + this.side.offsetY, te.zCoord + this.side.offsetZ );
|
||||
}
|
||||
|
||||
return (int) (emit * (this.opacity / 255.0f));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPowered()
|
||||
{
|
||||
try
|
||||
{
|
||||
if ( Platform.isServer() )
|
||||
return this.proxy.getEnergy().isNetworkPowered();
|
||||
else
|
||||
return ((this.clientFlags & this.POWERED_FLAG) == this.POWERED_FLAG);
|
||||
}
|
||||
catch (GridAccessException e)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public PartMonitor(ItemStack is) {
|
||||
this( is, false );
|
||||
}
|
||||
|
||||
protected PartMonitor(ItemStack is, boolean requireChannel) {
|
||||
protected PartMonitor( ItemStack is, boolean requireChannel )
|
||||
{
|
||||
super( is );
|
||||
|
||||
if ( requireChannel )
|
||||
if( requireChannel )
|
||||
{
|
||||
this.proxy.setFlags( GridFlags.REQUIRE_CHANNEL );
|
||||
this.proxy.setIdlePowerUsage( 1.0 / 2.0 );
|
||||
}
|
||||
else
|
||||
this.proxy.setIdlePowerUsage( 1.0 / 16.0 ); // lights drain a little bit.
|
||||
}
|
||||
|
||||
@MENetworkEventSubscribe
|
||||
public void bootingRender( MENetworkBootingStatusChange c )
|
||||
{
|
||||
if( this.notLightSource )
|
||||
this.getHost().markForUpdate();
|
||||
}
|
||||
|
||||
@MENetworkEventSubscribe
|
||||
public void powerRender( MENetworkPowerStatusChange c )
|
||||
{
|
||||
this.getHost().markForUpdate();
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void renderInventory(IPartRenderHelper rh, RenderBlocks renderer)
|
||||
public void getBoxes( IPartCollisionHelper bch )
|
||||
{
|
||||
bch.addBox( 2, 2, 14, 14, 14, 16 );
|
||||
bch.addBox( 4, 4, 13, 12, 12, 14 );
|
||||
}
|
||||
|
||||
@Override
|
||||
@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().whiteVariant );
|
||||
@@ -263,18 +126,17 @@ public class PartMonitor extends AEBasePart implements IPartMonitor, IPowerChann
|
||||
}
|
||||
|
||||
@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 )
|
||||
{
|
||||
this.renderCache = rh.useSimplifiedRendering( x, y, z, this, this.renderCache );
|
||||
|
||||
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 );
|
||||
|
||||
if ( this.getLightLevel() > 0 )
|
||||
if( this.getLightLevel() > 0 )
|
||||
{
|
||||
int l = 13;
|
||||
Tessellator.instance.setBrightness( l << 20 | l << 4 );
|
||||
@@ -293,28 +155,26 @@ public class PartMonitor extends AEBasePart implements IPartMonitor, IPowerChann
|
||||
|
||||
renderer.uvRotateBottom = renderer.uvRotateEast = renderer.uvRotateNorth = renderer.uvRotateSouth = renderer.uvRotateTop = renderer.uvRotateWest = 0;
|
||||
|
||||
if ( this.notLightSource )
|
||||
if( this.notLightSource )
|
||||
{
|
||||
rh.setTexture( CableBusTextures.PartMonitorSidesStatus.getIcon(), CableBusTextures.PartMonitorSidesStatus.getIcon(),
|
||||
CableBusTextures.PartMonitorBack.getIcon(), this.is.getIconIndex(), CableBusTextures.PartMonitorSidesStatus.getIcon(),
|
||||
CableBusTextures.PartMonitorSidesStatus.getIcon() );
|
||||
rh.setTexture( CableBusTextures.PartMonitorSidesStatus.getIcon(), CableBusTextures.PartMonitorSidesStatus.getIcon(), CableBusTextures.PartMonitorBack.getIcon(), this.is.getIconIndex(), CableBusTextures.PartMonitorSidesStatus.getIcon(), CableBusTextures.PartMonitorSidesStatus.getIcon() );
|
||||
}
|
||||
|
||||
rh.setBounds( 4, 4, 13, 12, 12, 14 );
|
||||
rh.renderBlock( x, y, z, renderer );
|
||||
|
||||
if ( this.notLightSource )
|
||||
if( this.notLightSource )
|
||||
{
|
||||
boolean hasChan = (this.clientFlags & (this.POWERED_FLAG | this.CHANNEL_FLAG)) == (this.POWERED_FLAG | this.CHANNEL_FLAG);
|
||||
boolean hasPower = (this.clientFlags & this.POWERED_FLAG) == this.POWERED_FLAG;
|
||||
boolean hasChan = ( this.clientFlags & ( this.POWERED_FLAG | this.CHANNEL_FLAG ) ) == ( this.POWERED_FLAG | this.CHANNEL_FLAG );
|
||||
boolean hasPower = ( this.clientFlags & this.POWERED_FLAG ) == this.POWERED_FLAG;
|
||||
|
||||
if ( hasChan )
|
||||
if( hasChan )
|
||||
{
|
||||
int l = 14;
|
||||
Tessellator.instance.setBrightness( l << 20 | l << 4 );
|
||||
Tessellator.instance.setColorOpaque_I( this.getColor().blackVariant );
|
||||
}
|
||||
else if ( hasPower )
|
||||
else if( hasPower )
|
||||
{
|
||||
int l = 9;
|
||||
Tessellator.instance.setBrightness( l << 20 | l << 4 );
|
||||
@@ -331,23 +191,157 @@ public class PartMonitor extends AEBasePart implements IPartMonitor, IPowerChann
|
||||
rh.renderFace( x, y, z, CableBusTextures.PartMonitorSidesStatusLights.getIcon(), ForgeDirection.UP, renderer );
|
||||
rh.renderFace( x, y, z, CableBusTextures.PartMonitorSidesStatusLights.getIcon(), ForgeDirection.DOWN, renderer );
|
||||
}
|
||||
}
|
||||
|
||||
private int blockLight( int emit )
|
||||
{
|
||||
if( this.opacity < 0 )
|
||||
{
|
||||
TileEntity te = this.getTile();
|
||||
this.opacity = 255 - te.getWorldObj().getBlockLightOpacity( te.xCoord + this.side.offsetX, te.yCoord + this.side.offsetY, te.zCoord + this.side.offsetZ );
|
||||
}
|
||||
|
||||
return (int) ( emit * ( this.opacity / 255.0f ) );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getBoxes(IPartCollisionHelper bch)
|
||||
public boolean isPowered()
|
||||
{
|
||||
bch.addBox( 2, 2, 14, 14, 14, 16 );
|
||||
bch.addBox( 4, 4, 13, 12, 12, 14 );
|
||||
try
|
||||
{
|
||||
if( Platform.isServer() )
|
||||
return this.proxy.getEnergy().isNetworkPowered();
|
||||
else
|
||||
return ( ( this.clientFlags & this.POWERED_FLAG ) == this.POWERED_FLAG );
|
||||
}
|
||||
catch( GridAccessException e )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNeighborChanged()
|
||||
{
|
||||
this.opacity = -1;
|
||||
this.getHost().markForUpdate();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT( NBTTagCompound data )
|
||||
{
|
||||
super.readFromNBT( data );
|
||||
if( data.hasKey( "opacity" ) )
|
||||
this.opacity = data.getFloat( "opacity" );
|
||||
this.spin = data.getByte( "spin" );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT( NBTTagCompound data )
|
||||
{
|
||||
super.writeToNBT( data );
|
||||
data.setFloat( "opacity", this.opacity );
|
||||
data.setByte( "spin", this.spin );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToStream( ByteBuf data ) throws IOException
|
||||
{
|
||||
super.writeToStream( data );
|
||||
this.clientFlags = this.spin & 3;
|
||||
|
||||
try
|
||||
{
|
||||
if( this.proxy.getEnergy().isNetworkPowered() )
|
||||
this.clientFlags |= this.POWERED_FLAG;
|
||||
|
||||
if( this.proxy.getPath().isNetworkBooting() )
|
||||
this.clientFlags |= this.BOOTING_FLAG;
|
||||
|
||||
if( this.proxy.getNode().meetsChannelRequirements() )
|
||||
this.clientFlags |= this.CHANNEL_FLAG;
|
||||
}
|
||||
catch( GridAccessException e )
|
||||
{
|
||||
// um.. nothing.
|
||||
}
|
||||
|
||||
data.writeByte( (byte) this.clientFlags );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean readFromStream( ByteBuf data ) throws IOException
|
||||
{
|
||||
super.readFromStream( data );
|
||||
int oldFlags = this.clientFlags;
|
||||
this.clientFlags = data.readByte();
|
||||
this.spin = (byte) ( this.clientFlags & 3 );
|
||||
if( this.clientFlags == oldFlags )
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getLightLevel()
|
||||
{
|
||||
return this.blockLight( this.isPowered() ? ( this.notLightSource ? 9 : 15 ) : 0 );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onPartActivate( EntityPlayer player, Vec3 pos )
|
||||
{
|
||||
TileEntity te = this.getTile();
|
||||
|
||||
if( !player.isSneaking() && Platform.isWrench( player, player.inventory.getCurrentItem(), te.xCoord, te.yCoord, te.zCoord ) )
|
||||
{
|
||||
if( Platform.isServer() )
|
||||
{
|
||||
if( this.spin > 3 )
|
||||
this.spin = 0;
|
||||
|
||||
switch( this.spin )
|
||||
{
|
||||
case 0:
|
||||
this.spin = 1;
|
||||
break;
|
||||
case 1:
|
||||
this.spin = 3;
|
||||
break;
|
||||
case 2:
|
||||
this.spin = 0;
|
||||
break;
|
||||
case 3:
|
||||
this.spin = 2;
|
||||
break;
|
||||
}
|
||||
|
||||
this.host.markForUpdate();
|
||||
this.saveChanges();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
else
|
||||
return super.onPartActivate( player, pos );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPlacement( EntityPlayer player, ItemStack held, ForgeDirection side )
|
||||
{
|
||||
super.onPlacement( player, held, side );
|
||||
|
||||
byte rotation = (byte) ( MathHelper.floor_double( ( player.rotationYaw * 4F ) / 360F + 2.5D ) & 3 );
|
||||
if( side == ForgeDirection.UP )
|
||||
this.spin = rotation;
|
||||
else if( side == ForgeDirection.DOWN )
|
||||
this.spin = rotation;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isActive()
|
||||
{
|
||||
if ( this.notLightSource )
|
||||
return ((this.clientFlags & (this.CHANNEL_FLAG | this.POWERED_FLAG)) == (this.CHANNEL_FLAG | this.POWERED_FLAG));
|
||||
if( this.notLightSource )
|
||||
return ( ( this.clientFlags & ( this.CHANNEL_FLAG | this.POWERED_FLAG ) ) == ( this.CHANNEL_FLAG | this.POWERED_FLAG ) );
|
||||
else
|
||||
return this.isPowered();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -57,21 +57,11 @@ public class PartPatternTerminal extends PartTerminal
|
||||
@Override
|
||||
public void getDrops( List<ItemStack> drops, boolean wrenched )
|
||||
{
|
||||
for ( ItemStack is : this.pattern )
|
||||
if ( is != null )
|
||||
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 );
|
||||
this.pattern.writeToNBT( data, "pattern" );
|
||||
this.output.writeToNBT( data, "outputList" );
|
||||
this.crafting.writeToNBT( data, "craftingGrid" );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT( NBTTagCompound data )
|
||||
{
|
||||
@@ -82,20 +72,30 @@ public class PartPatternTerminal extends PartTerminal
|
||||
this.crafting.readFromNBT( data, "craftingGrid" );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT( NBTTagCompound data )
|
||||
{
|
||||
super.writeToNBT( data );
|
||||
data.setBoolean( "craftingMode", this.craftingMode );
|
||||
this.pattern.writeToNBT( data, "pattern" );
|
||||
this.output.writeToNBT( data, "outputList" );
|
||||
this.crafting.writeToNBT( data, "craftingGrid" );
|
||||
}
|
||||
|
||||
@Override
|
||||
public GuiBridge getGui( EntityPlayer p )
|
||||
{
|
||||
int x = (int) p.posX;
|
||||
int y = (int) p.posY;
|
||||
int z = (int) p.posZ;
|
||||
if ( this.getHost().getTile() != null )
|
||||
if( this.getHost().getTile() != null )
|
||||
{
|
||||
x = this.tile.xCoord;
|
||||
y = this.tile.yCoord;
|
||||
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;
|
||||
}
|
||||
@@ -103,24 +103,24 @@ public class PartPatternTerminal extends PartTerminal
|
||||
@Override
|
||||
public void onChangeInventory( IInventory inv, int slot, InvOperation mc, ItemStack removedStack, ItemStack newStack )
|
||||
{
|
||||
if ( inv == this.pattern && slot == 1 )
|
||||
if( inv == this.pattern && slot == 1 )
|
||||
{
|
||||
ItemStack is = this.pattern.getStackInSlot( 1 );
|
||||
if ( is != null && is.getItem() instanceof ICraftingPatternItem )
|
||||
if( is != null && is.getItem() instanceof ICraftingPatternItem )
|
||||
{
|
||||
ICraftingPatternItem pattern = (ICraftingPatternItem) is.getItem();
|
||||
ICraftingPatternDetails details = pattern.getPatternForItem( is, this.getHost().getTile().getWorldObj() );
|
||||
if ( details != null )
|
||||
if( details != null )
|
||||
{
|
||||
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() );
|
||||
@@ -128,7 +128,7 @@ public class PartPatternTerminal extends PartTerminal
|
||||
}
|
||||
}
|
||||
}
|
||||
else if ( inv == this.crafting )
|
||||
else if( inv == this.crafting )
|
||||
{
|
||||
this.fixCraftingRecipes();
|
||||
}
|
||||
@@ -138,12 +138,12 @@ public class PartPatternTerminal extends PartTerminal
|
||||
|
||||
private void fixCraftingRecipes()
|
||||
{
|
||||
if ( this.craftingMode )
|
||||
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 )
|
||||
if( is != null )
|
||||
is.stackSize = 1;
|
||||
}
|
||||
}
|
||||
@@ -163,13 +163,13 @@ public class PartPatternTerminal extends PartTerminal
|
||||
@Override
|
||||
public IInventory getInventoryByName( String name )
|
||||
{
|
||||
if ( name.equals( "crafting" ) )
|
||||
if( name.equals( "crafting" ) )
|
||||
return this.crafting;
|
||||
|
||||
if ( name.equals( "output" ) )
|
||||
if( name.equals( "output" ) )
|
||||
return this.output;
|
||||
|
||||
if ( name.equals( "pattern" ) )
|
||||
if( name.equals( "pattern" ) )
|
||||
return this.pattern;
|
||||
|
||||
return super.getInventoryByName( name );
|
||||
|
||||
@@ -67,7 +67,7 @@ public class PartSemiDarkMonitor extends PartMonitor
|
||||
rh.setBounds( 2, 2, 14, 14, 14, 16 );
|
||||
rh.renderBlock( x, y, z, renderer );
|
||||
|
||||
if ( this.getLightLevel() > 0 )
|
||||
if( this.getLightLevel() > 0 )
|
||||
{
|
||||
int l = 13;
|
||||
Tessellator.instance.setBrightness( l << 20 | l << 4 );
|
||||
|
||||
@@ -86,6 +86,17 @@ public class PartStorageMonitor extends PartMonitor implements IPartStorageMonit
|
||||
// frontSolid = CableBusTextures.PartStorageMonitor_Solid;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT( NBTTagCompound data )
|
||||
{
|
||||
super.readFromNBT( data );
|
||||
|
||||
this.isLocked = data.getBoolean( "isLocked" );
|
||||
|
||||
NBTTagCompound myItem = data.getCompoundTag( "configuredItem" );
|
||||
this.configuredItem = AEItemStack.loadItemStackFromNBT( myItem );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT( NBTTagCompound data )
|
||||
{
|
||||
@@ -101,14 +112,33 @@ public class PartStorageMonitor extends PartMonitor implements IPartStorageMonit
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT( NBTTagCompound data )
|
||||
public void writeToStream( ByteBuf data ) throws IOException
|
||||
{
|
||||
super.readFromNBT( data );
|
||||
super.writeToStream( data );
|
||||
|
||||
this.isLocked = data.getBoolean( "isLocked" );
|
||||
data.writeByte( this.spin );
|
||||
data.writeBoolean( this.isLocked );
|
||||
data.writeBoolean( this.configuredItem != null );
|
||||
if( this.configuredItem != null )
|
||||
this.configuredItem.writeToPacket( data );
|
||||
}
|
||||
|
||||
NBTTagCompound myItem = data.getCompoundTag( "configuredItem" );
|
||||
this.configuredItem = AEItemStack.loadItemStackFromNBT( myItem );
|
||||
@Override
|
||||
public boolean readFromStream( ByteBuf data ) throws IOException
|
||||
{
|
||||
boolean stuff = super.readFromStream( data );
|
||||
|
||||
this.spin = data.readByte();
|
||||
this.isLocked = data.readBoolean();
|
||||
boolean val = data.readBoolean();
|
||||
if( val )
|
||||
this.configuredItem = AEItemStack.loadItemStackFromPacket( data );
|
||||
else
|
||||
this.configuredItem = null;
|
||||
|
||||
this.updateList = true;
|
||||
|
||||
return stuff;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -143,36 +173,6 @@ public class PartStorageMonitor extends PartMonitor implements IPartStorageMonit
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToStream( ByteBuf data ) throws IOException
|
||||
{
|
||||
super.writeToStream( data );
|
||||
|
||||
data.writeByte( this.spin );
|
||||
data.writeBoolean( this.isLocked );
|
||||
data.writeBoolean( this.configuredItem != null );
|
||||
if( this.configuredItem != null )
|
||||
this.configuredItem.writeToPacket( data );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean readFromStream( ByteBuf data ) throws IOException
|
||||
{
|
||||
boolean stuff = super.readFromStream( data );
|
||||
|
||||
this.spin = data.readByte();
|
||||
this.isLocked = data.readBoolean();
|
||||
boolean val = data.readBoolean();
|
||||
if( val )
|
||||
this.configuredItem = AEItemStack.loadItemStackFromPacket( data );
|
||||
else
|
||||
this.configuredItem = null;
|
||||
|
||||
this.updateList = true;
|
||||
|
||||
return stuff;
|
||||
}
|
||||
|
||||
// update the system...
|
||||
public void configureWatchers()
|
||||
{
|
||||
|
||||
@@ -71,8 +71,8 @@ public class PartTerminal extends PartMonitor implements ITerminalHost, IConfigM
|
||||
{
|
||||
super.getDrops( drops, wrenched );
|
||||
|
||||
for ( ItemStack is : this.viewCell )
|
||||
if ( is != null )
|
||||
for( ItemStack is : this.viewCell )
|
||||
if( is != null )
|
||||
drops.add( is );
|
||||
}
|
||||
|
||||
@@ -82,14 +82,6 @@ public class PartTerminal extends PartMonitor implements ITerminalHost, IConfigM
|
||||
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 )
|
||||
{
|
||||
@@ -98,14 +90,22 @@ public class PartTerminal extends PartMonitor implements ITerminalHost, IConfigM
|
||||
this.viewCell.readFromNBT( data, "viewCell" );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT( NBTTagCompound data )
|
||||
{
|
||||
super.writeToNBT( data );
|
||||
this.cm.writeToNBT( data );
|
||||
this.viewCell.writeToNBT( data, "viewCell" );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onPartActivate( EntityPlayer player, Vec3 pos )
|
||||
{
|
||||
if ( !super.onPartActivate( player, pos ) )
|
||||
if( !super.onPartActivate( player, pos ) )
|
||||
{
|
||||
if ( !player.isSneaking() )
|
||||
if( !player.isSneaking() )
|
||||
{
|
||||
if ( Platform.isClient() )
|
||||
if( Platform.isClient() )
|
||||
return true;
|
||||
|
||||
Platform.openGUI( player, this.getHost().getTile(), this.side, this.getGui( player ) );
|
||||
@@ -128,7 +128,7 @@ public class PartTerminal extends PartMonitor implements ITerminalHost, IConfigM
|
||||
{
|
||||
return this.proxy.getStorage().getItemInventory();
|
||||
}
|
||||
catch ( GridAccessException e )
|
||||
catch( GridAccessException e )
|
||||
{
|
||||
// err nope?
|
||||
}
|
||||
@@ -142,7 +142,7 @@ public class PartTerminal extends PartMonitor implements ITerminalHost, IConfigM
|
||||
{
|
||||
return this.proxy.getStorage().getFluidInventory();
|
||||
}
|
||||
catch ( GridAccessException e )
|
||||
catch( GridAccessException e )
|
||||
{
|
||||
// err nope?
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user