Basic reformat, hit once, hope never again
This commit is contained in:
@@ -18,6 +18,7 @@
|
||||
|
||||
package appeng.parts;
|
||||
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.EnumSet;
|
||||
@@ -71,27 +72,74 @@ import appeng.tile.inventory.AppEngInternalAEInventory;
|
||||
import appeng.util.Platform;
|
||||
import appeng.util.SettingsFrom;
|
||||
|
||||
|
||||
public abstract class AEBasePart implements IPart, IGridProxyable, IActionHost, IUpgradeableHost, ICustomNameObject
|
||||
{
|
||||
|
||||
protected ISimplifiedBundle renderCache = null;
|
||||
|
||||
protected final AENetworkProxy proxy;
|
||||
protected final ItemStack is;
|
||||
protected ISimplifiedBundle renderCache = null;
|
||||
protected TileEntity tile = null;
|
||||
protected IPartHost host = null;
|
||||
protected ForgeDirection side = null;
|
||||
|
||||
protected final ItemStack is;
|
||||
|
||||
public AEBasePart(ItemStack is) {
|
||||
public AEBasePart( ItemStack is )
|
||||
{
|
||||
this.is = is;
|
||||
this.proxy = new AENetworkProxy( this, "part", is, this instanceof PartCable );
|
||||
this.proxy.setValidSides( EnumSet.noneOf( ForgeDirection.class ) );
|
||||
}
|
||||
|
||||
public IPartHost getHost()
|
||||
{
|
||||
return this.host;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void renderInventory(IPartRenderHelper rh, RenderBlocks renderer)
|
||||
public IGridNode getGridNode( ForgeDirection dir )
|
||||
{
|
||||
return this.proxy.getNode();
|
||||
}
|
||||
|
||||
@Override
|
||||
public AECableType getCableConnectionType( ForgeDirection dir )
|
||||
{
|
||||
return AECableType.GLASS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void securityBreak()
|
||||
{
|
||||
if( this.is.stackSize > 0 )
|
||||
{
|
||||
List<ItemStack> items = new ArrayList<ItemStack>();
|
||||
items.add( this.is.copy() );
|
||||
this.host.removePart( this.side, false );
|
||||
Platform.spawnDrops( this.tile.getWorldObj(), this.tile.xCoord, this.tile.yCoord, this.tile.zCoord, items );
|
||||
this.is.stackSize = 0;
|
||||
}
|
||||
}
|
||||
|
||||
protected AEColor getColor()
|
||||
{
|
||||
if( this.host == null )
|
||||
return AEColor.Transparent;
|
||||
return this.host.getColor();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getBoxes( IPartCollisionHelper bch )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getInstalledUpgrades( Upgrades u )
|
||||
{
|
||||
return 0;
|
||||
} @Override
|
||||
@SideOnly( Side.CLIENT )
|
||||
public void renderInventory( IPartRenderHelper rh, RenderBlocks renderer )
|
||||
{
|
||||
rh.setBounds( 1, 1, 1, 15, 15, 15 );
|
||||
rh.renderInventoryBox( renderer );
|
||||
@@ -101,24 +149,78 @@ public abstract class AEBasePart implements IPart, IGridProxyable, IActionHost,
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void renderStatic(int x, int y, int z, IPartRenderHelper rh, RenderBlocks renderer)
|
||||
public TileEntity getTile()
|
||||
{
|
||||
return this.tile;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AENetworkProxy getProxy()
|
||||
{
|
||||
return this.proxy;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DimensionalCoord getLocation()
|
||||
{
|
||||
return new DimensionalCoord( this.tile );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void gridChanged()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public IGridNode getActionableNode()
|
||||
{
|
||||
return this.proxy.getNode();
|
||||
}
|
||||
|
||||
public void saveChanges()
|
||||
{
|
||||
this.host.markForSave();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCustomName()
|
||||
{
|
||||
return this.is.getDisplayName();
|
||||
} @Override
|
||||
@SideOnly( Side.CLIENT )
|
||||
public void renderStatic( int x, int y, int z, IPartRenderHelper rh, RenderBlocks renderer )
|
||||
{
|
||||
rh.setBounds( 1, 1, 1, 15, 15, 15 );
|
||||
rh.renderBlock( x, y, z, renderer );
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void renderDynamic(double x, double y, double z, IPartRenderHelper rh, RenderBlocks renderer)
|
||||
public boolean hasCustomName()
|
||||
{
|
||||
return this.is.hasDisplayName();
|
||||
}
|
||||
|
||||
public void addEntityCrashInfo( CrashReportCategory crashreportcategory )
|
||||
{
|
||||
crashreportcategory.addCrashSection( "Part Side", this.side );
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
@SideOnly( Side.CLIENT )
|
||||
public void renderDynamic( double x, double y, double z, IPartRenderHelper rh, RenderBlocks renderer )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getItemStack(PartItemStack type)
|
||||
public ItemStack getItemStack( PartItemStack type )
|
||||
{
|
||||
if ( type == PartItemStack.Network )
|
||||
if( type == PartItemStack.Network )
|
||||
{
|
||||
ItemStack copy = this.is.copy();
|
||||
copy.setTagCompound( null );
|
||||
@@ -146,13 +248,13 @@ public abstract class AEBasePart implements IPart, IGridProxyable, IActionHost,
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound data)
|
||||
public void readFromNBT( NBTTagCompound data )
|
||||
{
|
||||
this.proxy.readFromNBT( data );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT(NBTTagCompound data)
|
||||
public void writeToNBT( NBTTagCompound data )
|
||||
{
|
||||
this.proxy.writeToNBT( data );
|
||||
}
|
||||
@@ -170,13 +272,13 @@ public abstract class AEBasePart implements IPart, IGridProxyable, IActionHost,
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToStream(ByteBuf data) throws IOException
|
||||
public void writeToStream( ByteBuf data ) throws IOException
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean readFromStream(ByteBuf data) throws IOException
|
||||
public boolean readFromStream( ByteBuf data ) throws IOException
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@@ -188,7 +290,7 @@ public abstract class AEBasePart implements IPart, IGridProxyable, IActionHost,
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEntityCollision(Entity entity)
|
||||
public void onEntityCollision( Entity entity )
|
||||
{
|
||||
|
||||
}
|
||||
@@ -206,18 +308,13 @@ public abstract class AEBasePart implements IPart, IGridProxyable, IActionHost,
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPartHostInfo(ForgeDirection side, IPartHost host, TileEntity tile)
|
||||
public void setPartHostInfo( ForgeDirection side, IPartHost host, TileEntity tile )
|
||||
{
|
||||
this.side = side;
|
||||
this.tile = tile;
|
||||
this.host = host;
|
||||
}
|
||||
|
||||
public IPartHost getHost()
|
||||
{
|
||||
return this.host;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IGridNode getExternalFacingNode()
|
||||
{
|
||||
@@ -225,33 +322,8 @@ public abstract class AEBasePart implements IPart, IGridProxyable, IActionHost,
|
||||
}
|
||||
|
||||
@Override
|
||||
public IGridNode getGridNode(ForgeDirection dir)
|
||||
{
|
||||
return this.proxy.getNode();
|
||||
}
|
||||
|
||||
protected AEColor getColor()
|
||||
{
|
||||
if ( this.host == null )
|
||||
return AEColor.Transparent;
|
||||
return this.host.getColor();
|
||||
}
|
||||
|
||||
@Override
|
||||
public DimensionalCoord getLocation()
|
||||
{
|
||||
return new DimensionalCoord( this.tile );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getBoxes(IPartCollisionHelper bch)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void randomDisplayTick(World world, int x, int y, int z, Random r)
|
||||
@SideOnly( Side.CLIENT )
|
||||
public void randomDisplayTick( World world, int x, int y, int z, Random r )
|
||||
{
|
||||
|
||||
}
|
||||
@@ -263,13 +335,7 @@ public abstract class AEBasePart implements IPart, IGridProxyable, IActionHost,
|
||||
}
|
||||
|
||||
@Override
|
||||
public AECableType getCableConnectionType(ForgeDirection dir)
|
||||
{
|
||||
return AECableType.GLASS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getDrops(List<ItemStack> drops, boolean wrenched)
|
||||
public void getDrops( List<ItemStack> drops, boolean wrenched )
|
||||
{
|
||||
|
||||
}
|
||||
@@ -281,13 +347,7 @@ public abstract class AEBasePart implements IPart, IGridProxyable, IActionHost,
|
||||
}
|
||||
|
||||
@Override
|
||||
public void gridChanged()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isLadder(EntityLivingBase entity)
|
||||
public boolean isLadder( EntityLivingBase entity )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@@ -299,45 +359,39 @@ public abstract class AEBasePart implements IPart, IGridProxyable, IActionHost,
|
||||
}
|
||||
|
||||
@Override
|
||||
public IInventory getInventoryByName(String name)
|
||||
public IInventory getInventoryByName( String name )
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getInstalledUpgrades(Upgrades u)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* depending on the from, different settings will be accepted, don't call this with null
|
||||
*
|
||||
* @param from source of settings
|
||||
* @param from source of settings
|
||||
* @param compound compound of source
|
||||
*/
|
||||
public void uploadSettings(SettingsFrom from, NBTTagCompound compound)
|
||||
public void uploadSettings( SettingsFrom from, NBTTagCompound compound )
|
||||
{
|
||||
if ( compound != null )
|
||||
if( compound != null )
|
||||
{
|
||||
IConfigManager cm = this.getConfigManager();
|
||||
if ( cm != null )
|
||||
if( cm != null )
|
||||
cm.readFromNBT( compound );
|
||||
}
|
||||
|
||||
if ( this instanceof IPriorityHost )
|
||||
if( this instanceof IPriorityHost )
|
||||
{
|
||||
IPriorityHost pHost = (IPriorityHost) this;
|
||||
pHost.setPriority( compound.getInteger( "priority" ) );
|
||||
}
|
||||
|
||||
IInventory inv = this.getInventoryByName( "config" );
|
||||
if ( inv instanceof AppEngInternalAEInventory )
|
||||
if( inv instanceof AppEngInternalAEInventory )
|
||||
{
|
||||
AppEngInternalAEInventory target = (AppEngInternalAEInventory) inv;
|
||||
AppEngInternalAEInventory tmp = new AppEngInternalAEInventory( null, target.getSizeInventory() );
|
||||
tmp.readFromNBT( compound, "config" );
|
||||
for (int x = 0; x < tmp.getSizeInventory(); x++)
|
||||
for( int x = 0; x < tmp.getSizeInventory(); x++ )
|
||||
target.setInventorySlotContents( x, tmp.getStackInSlot( x ) );
|
||||
}
|
||||
}
|
||||
@@ -346,26 +400,27 @@ public abstract class AEBasePart implements IPart, IGridProxyable, IActionHost,
|
||||
* null means nothing to store...
|
||||
*
|
||||
* @param from source of settings
|
||||
*
|
||||
* @return compound of source
|
||||
*/
|
||||
public NBTTagCompound downloadSettings(SettingsFrom from)
|
||||
public NBTTagCompound downloadSettings( SettingsFrom from )
|
||||
{
|
||||
NBTTagCompound output = new NBTTagCompound();
|
||||
|
||||
IConfigManager cm = this.getConfigManager();
|
||||
if ( cm != null )
|
||||
if( cm != null )
|
||||
cm.writeToNBT( output );
|
||||
|
||||
if ( this instanceof IPriorityHost )
|
||||
if( this instanceof IPriorityHost )
|
||||
{
|
||||
IPriorityHost pHost = (IPriorityHost) this;
|
||||
output.setInteger( "priority", pHost.getPriority() );
|
||||
}
|
||||
|
||||
IInventory inv = this.getInventoryByName( "config" );
|
||||
if ( inv instanceof AppEngInternalAEInventory )
|
||||
if( inv instanceof AppEngInternalAEInventory )
|
||||
{
|
||||
((AppEngInternalAEInventory) inv).writeToNBT( output, "config" );
|
||||
( (AppEngInternalAEInventory) inv ).writeToNBT( output, "config" );
|
||||
}
|
||||
|
||||
return output.hasNoTags() ? null : output;
|
||||
@@ -376,11 +431,11 @@ public abstract class AEBasePart implements IPart, IGridProxyable, IActionHost,
|
||||
return true;
|
||||
}
|
||||
|
||||
private boolean useMemoryCard(EntityPlayer player)
|
||||
private boolean useMemoryCard( EntityPlayer player )
|
||||
{
|
||||
ItemStack memCardIS = player.inventory.getCurrentItem();
|
||||
|
||||
if ( memCardIS != null && this.useStandardMemoryCard() && memCardIS.getItem() instanceof IMemoryCard )
|
||||
if( memCardIS != null && this.useStandardMemoryCard() && memCardIS.getItem() instanceof IMemoryCard )
|
||||
{
|
||||
IMemoryCard memoryCard = (IMemoryCard) memCardIS.getItem();
|
||||
|
||||
@@ -388,9 +443,9 @@ public abstract class AEBasePart implements IPart, IGridProxyable, IActionHost,
|
||||
|
||||
// Blocks and parts share the same soul!
|
||||
final IDefinitions definitions = AEApi.instance().definitions();
|
||||
if ( definitions.parts().iface().isSameAs( is ) )
|
||||
if( definitions.parts().iface().isSameAs( is ) )
|
||||
{
|
||||
for ( ItemStack iface : definitions.blocks().iface().maybeStack( 1 ).asSet() )
|
||||
for( ItemStack iface : definitions.blocks().iface().maybeStack( 1 ).asSet() )
|
||||
{
|
||||
is = iface;
|
||||
}
|
||||
@@ -398,10 +453,10 @@ public abstract class AEBasePart implements IPart, IGridProxyable, IActionHost,
|
||||
|
||||
String name = is.getUnlocalizedName();
|
||||
|
||||
if ( player.isSneaking() )
|
||||
if( player.isSneaking() )
|
||||
{
|
||||
NBTTagCompound data = this.downloadSettings( SettingsFrom.MEMORY_CARD );
|
||||
if ( data != null )
|
||||
if( data != null )
|
||||
{
|
||||
memoryCard.setMemoryCardContents( memCardIS, name, data );
|
||||
memoryCard.notifyUser( player, MemoryCardMessages.SETTINGS_SAVED );
|
||||
@@ -411,7 +466,7 @@ public abstract class AEBasePart implements IPart, IGridProxyable, IActionHost,
|
||||
{
|
||||
String storedName = memoryCard.getSettingsName( memCardIS );
|
||||
NBTTagCompound data = memoryCard.getData( memCardIS );
|
||||
if ( name.equals( storedName ) )
|
||||
if( name.equals( storedName ) )
|
||||
{
|
||||
this.uploadSettings( SettingsFrom.MEMORY_CARD, data );
|
||||
memoryCard.notifyUser( player, MemoryCardMessages.SETTINGS_LOADED );
|
||||
@@ -425,81 +480,45 @@ public abstract class AEBasePart implements IPart, IGridProxyable, IActionHost,
|
||||
}
|
||||
|
||||
@Override
|
||||
final public boolean onActivate(EntityPlayer player, Vec3 pos)
|
||||
final public boolean onActivate( EntityPlayer player, Vec3 pos )
|
||||
{
|
||||
if ( this.useMemoryCard( player ) )
|
||||
if( this.useMemoryCard( player ) )
|
||||
return true;
|
||||
|
||||
return this.onPartActivate( player, pos );
|
||||
}
|
||||
|
||||
@Override
|
||||
final public boolean onShiftActivate(EntityPlayer player, Vec3 pos)
|
||||
final public boolean onShiftActivate( EntityPlayer player, Vec3 pos )
|
||||
{
|
||||
if ( this.useMemoryCard( player ) )
|
||||
if( this.useMemoryCard( player ) )
|
||||
return true;
|
||||
|
||||
return this.onPartShiftActivate( player, pos );
|
||||
}
|
||||
|
||||
public boolean onPartActivate(EntityPlayer player, Vec3 pos)
|
||||
public boolean onPartActivate( EntityPlayer player, Vec3 pos )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean onPartShiftActivate(EntityPlayer player, Vec3 pos)
|
||||
public boolean onPartShiftActivate( EntityPlayer player, Vec3 pos )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPlacement(EntityPlayer player, ItemStack held, ForgeDirection side)
|
||||
public void onPlacement( EntityPlayer player, ItemStack held, ForgeDirection side )
|
||||
{
|
||||
this.proxy.setOwner( player );
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity getTile()
|
||||
{
|
||||
return this.tile;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void securityBreak()
|
||||
{
|
||||
if ( this.is.stackSize > 0 )
|
||||
{
|
||||
List<ItemStack> items = new ArrayList<ItemStack>();
|
||||
items.add( this.is.copy() );
|
||||
this.host.removePart( this.side, false );
|
||||
Platform.spawnDrops( this.tile.getWorldObj(), this.tile.xCoord, this.tile.yCoord, this.tile.zCoord, items );
|
||||
this.is.stackSize = 0;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public AENetworkProxy getProxy()
|
||||
{
|
||||
return this.proxy;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IGridNode getActionableNode()
|
||||
{
|
||||
return this.proxy.getNode();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canBePlacedOn(BusSupport what)
|
||||
public boolean canBePlacedOn( BusSupport what )
|
||||
{
|
||||
return what == BusSupport.CABLE;
|
||||
}
|
||||
|
||||
public void saveChanges()
|
||||
{
|
||||
this.host.markForSave();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean requireDynamicRender()
|
||||
{
|
||||
@@ -507,26 +526,9 @@ public abstract class AEBasePart implements IPart, IGridProxyable, IActionHost,
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCustomName()
|
||||
{
|
||||
return this.is.getDisplayName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasCustomName()
|
||||
{
|
||||
return this.is.hasDisplayName();
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
@SideOnly( Side.CLIENT )
|
||||
public IIcon getBreakingTexture()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
public void addEntityCrashInfo(CrashReportCategory crashreportcategory)
|
||||
{
|
||||
crashreportcategory.addCrashSection( "Part Side", this.side );
|
||||
}
|
||||
}
|
||||
@@ -18,6 +18,7 @@
|
||||
|
||||
package appeng.parts;
|
||||
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.entity.Entity;
|
||||
@@ -26,6 +27,7 @@ import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
import appeng.api.parts.IPartCollisionHelper;
|
||||
|
||||
|
||||
public class BusCollisionHelper implements IPartCollisionHelper
|
||||
{
|
||||
|
||||
@@ -38,7 +40,8 @@ public class BusCollisionHelper implements IPartCollisionHelper
|
||||
final private Entity entity;
|
||||
final private boolean isVisual;
|
||||
|
||||
public BusCollisionHelper(List<AxisAlignedBB> boxes, ForgeDirection x, ForgeDirection y, ForgeDirection z, Entity e, boolean visual) {
|
||||
public BusCollisionHelper( List<AxisAlignedBB> boxes, ForgeDirection x, ForgeDirection y, ForgeDirection z, Entity e, boolean visual )
|
||||
{
|
||||
this.boxes = boxes;
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
@@ -47,58 +50,53 @@ public class BusCollisionHelper implements IPartCollisionHelper
|
||||
this.isVisual = visual;
|
||||
}
|
||||
|
||||
public BusCollisionHelper(List<AxisAlignedBB> boxes, ForgeDirection s, Entity e, boolean visual) {
|
||||
public BusCollisionHelper( List<AxisAlignedBB> boxes, ForgeDirection s, Entity e, boolean visual )
|
||||
{
|
||||
this.boxes = boxes;
|
||||
this.entity = e;
|
||||
this.isVisual = visual;
|
||||
|
||||
switch (s)
|
||||
switch( s )
|
||||
{
|
||||
case DOWN:
|
||||
this.x = ForgeDirection.EAST;
|
||||
this.y = ForgeDirection.NORTH;
|
||||
this.z = ForgeDirection.DOWN;
|
||||
break;
|
||||
case UP:
|
||||
this.x = ForgeDirection.EAST;
|
||||
this.y = ForgeDirection.SOUTH;
|
||||
this.z = ForgeDirection.UP;
|
||||
break;
|
||||
case EAST:
|
||||
this.x = ForgeDirection.SOUTH;
|
||||
this.y = ForgeDirection.UP;
|
||||
this.z = ForgeDirection.EAST;
|
||||
break;
|
||||
case WEST:
|
||||
this.x = ForgeDirection.NORTH;
|
||||
this.y = ForgeDirection.UP;
|
||||
this.z = ForgeDirection.WEST;
|
||||
break;
|
||||
case NORTH:
|
||||
this.x = ForgeDirection.WEST;
|
||||
this.y = ForgeDirection.UP;
|
||||
this.z = ForgeDirection.NORTH;
|
||||
break;
|
||||
case SOUTH:
|
||||
this.x = ForgeDirection.EAST;
|
||||
this.y = ForgeDirection.UP;
|
||||
this.z = ForgeDirection.SOUTH;
|
||||
break;
|
||||
case UNKNOWN:
|
||||
default:
|
||||
this.x = ForgeDirection.EAST;
|
||||
this.y = ForgeDirection.UP;
|
||||
this.z = ForgeDirection.SOUTH;
|
||||
break;
|
||||
case DOWN:
|
||||
this.x = ForgeDirection.EAST;
|
||||
this.y = ForgeDirection.NORTH;
|
||||
this.z = ForgeDirection.DOWN;
|
||||
break;
|
||||
case UP:
|
||||
this.x = ForgeDirection.EAST;
|
||||
this.y = ForgeDirection.SOUTH;
|
||||
this.z = ForgeDirection.UP;
|
||||
break;
|
||||
case EAST:
|
||||
this.x = ForgeDirection.SOUTH;
|
||||
this.y = ForgeDirection.UP;
|
||||
this.z = ForgeDirection.EAST;
|
||||
break;
|
||||
case WEST:
|
||||
this.x = ForgeDirection.NORTH;
|
||||
this.y = ForgeDirection.UP;
|
||||
this.z = ForgeDirection.WEST;
|
||||
break;
|
||||
case NORTH:
|
||||
this.x = ForgeDirection.WEST;
|
||||
this.y = ForgeDirection.UP;
|
||||
this.z = ForgeDirection.NORTH;
|
||||
break;
|
||||
case SOUTH:
|
||||
this.x = ForgeDirection.EAST;
|
||||
this.y = ForgeDirection.UP;
|
||||
this.z = ForgeDirection.SOUTH;
|
||||
break;
|
||||
case UNKNOWN:
|
||||
default:
|
||||
this.x = ForgeDirection.EAST;
|
||||
this.y = ForgeDirection.UP;
|
||||
this.z = ForgeDirection.SOUTH;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isBBCollision()
|
||||
{
|
||||
return !this.isVisual;
|
||||
}
|
||||
|
||||
/**
|
||||
* pretty much useless...
|
||||
*/
|
||||
@@ -108,7 +106,7 @@ public class BusCollisionHelper implements IPartCollisionHelper
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addBox(double minX, double minY, double minZ, double maxX, double maxY, double maxZ)
|
||||
public void addBox( double minX, double minY, double minZ, double maxX, double maxY, double maxZ )
|
||||
{
|
||||
minX /= 16.0;
|
||||
minY /= 16.0;
|
||||
@@ -125,19 +123,19 @@ public class BusCollisionHelper implements IPartCollisionHelper
|
||||
double bY = maxX * this.x.offsetY + maxY * this.y.offsetY + maxZ * this.z.offsetY;
|
||||
double bZ = maxX * this.x.offsetZ + maxY * this.y.offsetZ + maxZ * this.z.offsetZ;
|
||||
|
||||
if ( this.x.offsetX + this.y.offsetX + this.z.offsetX < 0 )
|
||||
if( this.x.offsetX + this.y.offsetX + this.z.offsetX < 0 )
|
||||
{
|
||||
aX += 1;
|
||||
bX += 1;
|
||||
}
|
||||
|
||||
if ( this.x.offsetY + this.y.offsetY + this.z.offsetY < 0 )
|
||||
if( this.x.offsetY + this.y.offsetY + this.z.offsetY < 0 )
|
||||
{
|
||||
aY += 1;
|
||||
bY += 1;
|
||||
}
|
||||
|
||||
if ( this.x.offsetZ + this.y.offsetZ + this.z.offsetZ < 0 )
|
||||
if( this.x.offsetZ + this.y.offsetZ + this.z.offsetZ < 0 )
|
||||
{
|
||||
aZ += 1;
|
||||
bZ += 1;
|
||||
@@ -171,4 +169,9 @@ public class BusCollisionHelper implements IPartCollisionHelper
|
||||
return this.z;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isBBCollision()
|
||||
{
|
||||
return !this.isVisual;
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -18,12 +18,14 @@
|
||||
|
||||
package appeng.parts;
|
||||
|
||||
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
import appeng.api.implementations.parts.IPartCable;
|
||||
import appeng.api.parts.IFacadePart;
|
||||
import appeng.api.parts.IPart;
|
||||
|
||||
|
||||
/**
|
||||
* Thin data storage to optimize memory usage for cables.
|
||||
*/
|
||||
@@ -39,47 +41,81 @@ public class CableBusStorage
|
||||
return this.center;
|
||||
}
|
||||
|
||||
protected void setCenter(IPartCable center)
|
||||
protected void setCenter( IPartCable center )
|
||||
{
|
||||
this.center = center;
|
||||
}
|
||||
|
||||
protected IPart getSide(ForgeDirection side)
|
||||
protected IPart getSide( ForgeDirection side )
|
||||
{
|
||||
int x = side.ordinal();
|
||||
if ( this.sides != null && this.sides.length > x )
|
||||
if( this.sides != null && this.sides.length > x )
|
||||
return this.sides[x];
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
protected void setSide(ForgeDirection side, IPart part)
|
||||
protected void setSide( ForgeDirection side, IPart part )
|
||||
{
|
||||
int x = side.ordinal();
|
||||
|
||||
if ( this.sides != null && this.sides.length > x && part == null )
|
||||
if( this.sides != null && this.sides.length > x && part == null )
|
||||
{
|
||||
this.sides[x] = null;
|
||||
this.sides = this.shrink( this.sides, true );
|
||||
}
|
||||
else if ( part != null )
|
||||
else if( part != null )
|
||||
{
|
||||
this.sides = this.grow( this.sides, x, true );
|
||||
this.sides[x] = part;
|
||||
}
|
||||
}
|
||||
|
||||
public IFacadePart getFacade(int x)
|
||||
private <T> T[] shrink( T[] in, boolean parts )
|
||||
{
|
||||
if ( this.facades != null && this.facades.length > x )
|
||||
int newSize = -1;
|
||||
for( int x = 0; x < in.length; x++ )
|
||||
if( in[x] != null )
|
||||
newSize = x;
|
||||
|
||||
if( newSize == -1 )
|
||||
return null;
|
||||
|
||||
newSize++;
|
||||
if( newSize == in.length )
|
||||
return in;
|
||||
|
||||
T[] newArray = (T[]) ( parts ? new IPart[newSize] : new IFacadePart[newSize] );
|
||||
System.arraycopy( in, 0, newArray, 0, newSize );
|
||||
|
||||
return newArray;
|
||||
}
|
||||
|
||||
private <T> T[] grow( T[] in, int new_value, boolean parts )
|
||||
{
|
||||
if( in != null && in.length > new_value )
|
||||
return in;
|
||||
|
||||
int newSize = new_value + 1;
|
||||
|
||||
T[] newArray = (T[]) ( parts ? new IPart[newSize] : new IFacadePart[newSize] );
|
||||
if( in != null )
|
||||
System.arraycopy( in, 0, newArray, 0, in.length );
|
||||
|
||||
return newArray;
|
||||
}
|
||||
|
||||
public IFacadePart getFacade( int x )
|
||||
{
|
||||
if( this.facades != null && this.facades.length > x )
|
||||
return this.facades[x];
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public void setFacade(int x, IFacadePart facade)
|
||||
public void setFacade( int x, IFacadePart facade )
|
||||
{
|
||||
if ( this.facades != null && this.facades.length > x && facade == null )
|
||||
if( this.facades != null && this.facades.length > x && facade == null )
|
||||
{
|
||||
this.facades[x] = null;
|
||||
this.facades = this.shrink( this.facades, false );
|
||||
@@ -90,38 +126,4 @@ public class CableBusStorage
|
||||
this.facades[x] = facade;
|
||||
}
|
||||
}
|
||||
|
||||
private <T> T[] grow(T[] in, int new_value, boolean parts)
|
||||
{
|
||||
if ( in != null && in.length > new_value )
|
||||
return in;
|
||||
|
||||
int newSize = new_value + 1;
|
||||
|
||||
T[] newArray = (T[]) (parts ? new IPart[newSize] : new IFacadePart[newSize]);
|
||||
if ( in != null )
|
||||
System.arraycopy( in, 0, newArray, 0, in.length );
|
||||
|
||||
return newArray;
|
||||
}
|
||||
|
||||
private <T> T[] shrink(T[] in, boolean parts)
|
||||
{
|
||||
int newSize = -1;
|
||||
for (int x = 0; x < in.length; x++)
|
||||
if ( in[x] != null )
|
||||
newSize = x;
|
||||
|
||||
if ( newSize == -1 )
|
||||
return null;
|
||||
|
||||
newSize++;
|
||||
if ( newSize == in.length )
|
||||
return in;
|
||||
|
||||
T[] newArray = (T[]) (parts ? new IPart[newSize] : new IFacadePart[newSize]);
|
||||
System.arraycopy( in, 0, newArray, 0, newSize );
|
||||
|
||||
return newArray;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
|
||||
package appeng.parts;
|
||||
|
||||
|
||||
import java.util.EnumSet;
|
||||
import java.util.Random;
|
||||
|
||||
@@ -34,34 +35,34 @@ import cpw.mods.fml.relauncher.SideOnly;
|
||||
import appeng.api.parts.SelectedPart;
|
||||
import appeng.api.util.AEColor;
|
||||
|
||||
|
||||
public interface ICableBusContainer
|
||||
{
|
||||
|
||||
int isProvidingStrongPower(ForgeDirection opposite);
|
||||
int isProvidingStrongPower( ForgeDirection opposite );
|
||||
|
||||
int isProvidingWeakPower(ForgeDirection opposite);
|
||||
int isProvidingWeakPower( ForgeDirection opposite );
|
||||
|
||||
boolean canConnectRedstone(EnumSet<ForgeDirection> of);
|
||||
boolean canConnectRedstone( EnumSet<ForgeDirection> of );
|
||||
|
||||
void onEntityCollision(Entity e);
|
||||
void onEntityCollision( Entity e );
|
||||
|
||||
boolean activate(EntityPlayer player, Vec3 vecFromPool);
|
||||
boolean activate( EntityPlayer player, Vec3 vecFromPool );
|
||||
|
||||
void onNeighborChanged();
|
||||
|
||||
boolean isSolidOnSide(ForgeDirection side);
|
||||
boolean isSolidOnSide( ForgeDirection side );
|
||||
|
||||
boolean isEmpty();
|
||||
|
||||
SelectedPart selectPart(Vec3 v3);
|
||||
SelectedPart selectPart( Vec3 v3 );
|
||||
|
||||
boolean recolourBlock(ForgeDirection side, AEColor colour, EntityPlayer who);
|
||||
boolean recolourBlock( ForgeDirection side, AEColor colour, EntityPlayer who );
|
||||
|
||||
boolean isLadder(EntityLivingBase entity);
|
||||
boolean isLadder( EntityLivingBase entity );
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
void randomDisplayTick(World world, int x, int y, int z, Random r);
|
||||
@SideOnly( Side.CLIENT )
|
||||
void randomDisplayTick( World world, int x, int y, int z, Random r );
|
||||
|
||||
int getLightValue();
|
||||
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
|
||||
package appeng.parts;
|
||||
|
||||
|
||||
import java.util.EnumSet;
|
||||
import java.util.Random;
|
||||
|
||||
@@ -31,35 +32,36 @@ import net.minecraftforge.common.util.ForgeDirection;
|
||||
import appeng.api.parts.SelectedPart;
|
||||
import appeng.api.util.AEColor;
|
||||
|
||||
|
||||
public class NullCableBusContainer implements ICableBusContainer
|
||||
{
|
||||
|
||||
@Override
|
||||
public int isProvidingStrongPower(ForgeDirection opposite)
|
||||
public int isProvidingStrongPower( ForgeDirection opposite )
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int isProvidingWeakPower(ForgeDirection opposite)
|
||||
public int isProvidingWeakPower( ForgeDirection opposite )
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canConnectRedstone(EnumSet<ForgeDirection> of)
|
||||
public boolean canConnectRedstone( EnumSet<ForgeDirection> of )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEntityCollision(Entity e)
|
||||
public void onEntityCollision( Entity e )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean activate(EntityPlayer player, Vec3 vecFromPool)
|
||||
public boolean activate( EntityPlayer player, Vec3 vecFromPool )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@@ -71,7 +73,7 @@ public class NullCableBusContainer implements ICableBusContainer
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSolidOnSide(ForgeDirection side)
|
||||
public boolean isSolidOnSide( ForgeDirection side )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@@ -83,25 +85,25 @@ public class NullCableBusContainer implements ICableBusContainer
|
||||
}
|
||||
|
||||
@Override
|
||||
public SelectedPart selectPart(Vec3 v3)
|
||||
public SelectedPart selectPart( Vec3 v3 )
|
||||
{
|
||||
return new SelectedPart();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean recolourBlock(ForgeDirection side, AEColor colour, EntityPlayer who)
|
||||
public boolean recolourBlock( ForgeDirection side, AEColor colour, EntityPlayer who )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isLadder(EntityLivingBase entity)
|
||||
public boolean isLadder( EntityLivingBase entity )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void randomDisplayTick(World world, int x, int y, int z, Random r)
|
||||
public void randomDisplayTick( World world, int x, int y, int z, Random r )
|
||||
{
|
||||
|
||||
}
|
||||
@@ -111,5 +113,4 @@ public class NullCableBusContainer implements ICableBusContainer
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -81,13 +81,13 @@ public abstract class PartBasicState extends AEBasePart implements IPowerChannel
|
||||
|
||||
public void setColors( boolean hasChan, boolean hasPower )
|
||||
{
|
||||
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 );
|
||||
@@ -109,15 +109,15 @@ public abstract class PartBasicState extends AEBasePart implements IPowerChannel
|
||||
|
||||
try
|
||||
{
|
||||
if ( this.proxy.getEnergy().isNetworkPowered() )
|
||||
if( this.proxy.getEnergy().isNetworkPowered() )
|
||||
this.clientFlags |= this.POWERED_FLAG;
|
||||
|
||||
if ( this.proxy.getNode().meetsChannelRequirements() )
|
||||
if( this.proxy.getNode().meetsChannelRequirements() )
|
||||
this.clientFlags |= this.CHANNEL_FLAG;
|
||||
|
||||
this.clientFlags = this.populateFlags( this.clientFlags );
|
||||
}
|
||||
catch ( GridAccessException e )
|
||||
catch( GridAccessException e )
|
||||
{
|
||||
// meh
|
||||
}
|
||||
|
||||
@@ -75,52 +75,52 @@ public class PartPlacement
|
||||
|
||||
public static boolean place( ItemStack held, int x, int y, int z, int face, EntityPlayer player, World world, PlaceType pass, int depth )
|
||||
{
|
||||
if ( depth > 3 )
|
||||
if( depth > 3 )
|
||||
return false;
|
||||
|
||||
ForgeDirection side = ForgeDirection.getOrientation( face );
|
||||
|
||||
if ( held != null && Platform.isWrench( player, held, x, y, z ) && player.isSneaking() )
|
||||
if( held != null && Platform.isWrench( player, held, x, y, z ) && player.isSneaking() )
|
||||
{
|
||||
if ( !Platform.hasPermissions( new DimensionalCoord( world, x, y, z ), player ) )
|
||||
if( !Platform.hasPermissions( new DimensionalCoord( world, x, y, z ), player ) )
|
||||
return false;
|
||||
|
||||
Block block = world.getBlock( x, y, z );
|
||||
TileEntity tile = world.getTileEntity( x, y, z );
|
||||
IPartHost host = null;
|
||||
|
||||
if ( tile instanceof IPartHost )
|
||||
if( tile instanceof IPartHost )
|
||||
host = (IPartHost) tile;
|
||||
|
||||
if ( host != null )
|
||||
if( host != null )
|
||||
{
|
||||
if ( !world.isRemote )
|
||||
if( !world.isRemote )
|
||||
{
|
||||
LookDirection dir = Platform.getPlayerRay( player, getEyeOffset( player ) );
|
||||
MovingObjectPosition mop = block.collisionRayTrace( world, x, y, z, dir.a, dir.b );
|
||||
if ( mop != null )
|
||||
if( mop != null )
|
||||
{
|
||||
List<ItemStack> is = new LinkedList<ItemStack>();
|
||||
SelectedPart sp = selectPart( player, host, mop.hitVec.addVector( -mop.blockX, -mop.blockY, -mop.blockZ ) );
|
||||
|
||||
if ( sp.part != null )
|
||||
if( sp.part != null )
|
||||
{
|
||||
is.add( sp.part.getItemStack( PartItemStack.Wrench ) );
|
||||
sp.part.getDrops( is, true );
|
||||
host.removePart( sp.side, false );
|
||||
}
|
||||
|
||||
if ( sp.facade != null )
|
||||
if( sp.facade != null )
|
||||
{
|
||||
is.add( sp.facade.getItemStack() );
|
||||
host.getFacadeContainer().removeFacade( host, sp.side );
|
||||
Platform.notifyBlocksOfNeighbors( world, x, y, z );
|
||||
}
|
||||
|
||||
if ( host.isEmpty() )
|
||||
if( host.isEmpty() )
|
||||
host.cleanup();
|
||||
|
||||
if ( !is.isEmpty() )
|
||||
if( !is.isEmpty() )
|
||||
{
|
||||
Platform.spawnDrops( world, x, y, z, is );
|
||||
}
|
||||
@@ -140,30 +140,30 @@ public class PartPlacement
|
||||
TileEntity tile = world.getTileEntity( x, y, z );
|
||||
IPartHost host = null;
|
||||
|
||||
if ( tile instanceof IPartHost )
|
||||
if( tile instanceof IPartHost )
|
||||
host = (IPartHost) tile;
|
||||
|
||||
if ( held != null )
|
||||
if( held != null )
|
||||
{
|
||||
IFacadePart fp = isFacade( held, side );
|
||||
if ( fp != null )
|
||||
if( fp != null )
|
||||
{
|
||||
if ( host != null )
|
||||
if( host != null )
|
||||
{
|
||||
if ( !world.isRemote )
|
||||
if( !world.isRemote )
|
||||
{
|
||||
if ( host.getPart( ForgeDirection.UNKNOWN ) == null )
|
||||
if( host.getPart( ForgeDirection.UNKNOWN ) == null )
|
||||
return false;
|
||||
|
||||
if ( host.canAddPart( held, side ) )
|
||||
if( host.canAddPart( held, side ) )
|
||||
{
|
||||
if ( host.getFacadeContainer().addFacade( fp ) )
|
||||
if( host.getFacadeContainer().addFacade( fp ) )
|
||||
{
|
||||
host.markForUpdate();
|
||||
if ( !player.capabilities.isCreativeMode )
|
||||
if( !player.capabilities.isCreativeMode )
|
||||
{
|
||||
held.stackSize--;
|
||||
if ( held.stackSize == 0 )
|
||||
if( held.stackSize == 0 )
|
||||
{
|
||||
player.inventory.mainInventory[player.inventory.currentItem] = null;
|
||||
MinecraftForge.EVENT_BUS.post( new PlayerDestroyItemEvent( player, held ) );
|
||||
@@ -184,27 +184,27 @@ public class PartPlacement
|
||||
}
|
||||
}
|
||||
|
||||
if ( host == null && tile != null && AppEng.instance.isIntegrationEnabled( IntegrationType.FMP ) )
|
||||
if( host == null && tile != null && AppEng.instance.isIntegrationEnabled( IntegrationType.FMP ) )
|
||||
host = ( (IFMP) AppEng.instance.getIntegration( IntegrationType.FMP ) ).getOrCreateHost( tile );
|
||||
|
||||
if ( host == null && tile != null && AppEng.instance.isIntegrationEnabled( IntegrationType.ImmibisMicroblocks ) )
|
||||
if( host == null && tile != null && AppEng.instance.isIntegrationEnabled( IntegrationType.ImmibisMicroblocks ) )
|
||||
host = ( (IImmibisMicroblocks) AppEng.instance.getIntegration( IntegrationType.ImmibisMicroblocks ) ).getOrCreateHost( player, face, tile );
|
||||
|
||||
// if ( held == null )
|
||||
{
|
||||
Block block = world.getBlock( x, y, z );
|
||||
if ( host != null && player.isSneaking() && block != null )
|
||||
if( host != null && player.isSneaking() && block != null )
|
||||
{
|
||||
LookDirection dir = Platform.getPlayerRay( player, getEyeOffset( player ) );
|
||||
MovingObjectPosition mop = block.collisionRayTrace( world, x, y, z, dir.a, dir.b );
|
||||
if ( mop != null )
|
||||
if( mop != null )
|
||||
{
|
||||
mop.hitVec = mop.hitVec.addVector( -mop.blockX, -mop.blockY, -mop.blockZ );
|
||||
SelectedPart sPart = selectPart( player, host, mop.hitVec );
|
||||
if ( sPart != null && sPart.part != null )
|
||||
if ( sPart.part.onShiftActivate( player, mop.hitVec ) )
|
||||
if( sPart != null && sPart.part != null )
|
||||
if( sPart.part.onShiftActivate( player, mop.hitVec ) )
|
||||
{
|
||||
if ( world.isRemote )
|
||||
if( world.isRemote )
|
||||
{
|
||||
NetworkHandler.instance.sendToServer( new PacketPartPlacement( x, y, z, face, getEyeOffset( player ) ) );
|
||||
}
|
||||
@@ -214,7 +214,7 @@ public class PartPlacement
|
||||
}
|
||||
}
|
||||
|
||||
if ( held == null || !( held.getItem() instanceof IPartItem ) )
|
||||
if( held == null || !( held.getItem() instanceof IPartItem ) )
|
||||
return false;
|
||||
|
||||
int te_x = x;
|
||||
@@ -222,15 +222,15 @@ public class PartPlacement
|
||||
int te_z = z;
|
||||
|
||||
final IBlockDefinition multiPart = AEApi.instance().definitions().blocks().multiPart();
|
||||
if ( host == null && pass == PlaceType.PLACE_ITEM )
|
||||
if( host == null && pass == PlaceType.PLACE_ITEM )
|
||||
{
|
||||
ForgeDirection offset = ForgeDirection.UNKNOWN;
|
||||
|
||||
Block blkID = world.getBlock( x, y, z );
|
||||
if ( blkID != null && !blkID.isReplaceable( world, x, y, z ) )
|
||||
if( blkID != null && !blkID.isReplaceable( world, x, y, z ) )
|
||||
{
|
||||
offset = side;
|
||||
if ( Platform.isServer() )
|
||||
if( Platform.isServer() )
|
||||
side = side.getOpposite();
|
||||
}
|
||||
|
||||
@@ -239,13 +239,13 @@ public class PartPlacement
|
||||
te_z = z + offset.offsetZ;
|
||||
|
||||
tile = world.getTileEntity( te_x, te_y, te_z );
|
||||
if ( tile instanceof IPartHost )
|
||||
if( tile instanceof IPartHost )
|
||||
host = (IPartHost) tile;
|
||||
|
||||
if ( host == null && tile != null && AppEng.instance.isIntegrationEnabled( IntegrationType.FMP ) )
|
||||
if( host == null && tile != null && AppEng.instance.isIntegrationEnabled( IntegrationType.FMP ) )
|
||||
host = ( (IFMP) AppEng.instance.getIntegration( IntegrationType.FMP ) ).getOrCreateHost( tile );
|
||||
|
||||
if ( host == null && tile != null && AppEng.instance.isIntegrationEnabled( IntegrationType.ImmibisMicroblocks ) )
|
||||
if( host == null && tile != null && AppEng.instance.isIntegrationEnabled( IntegrationType.ImmibisMicroblocks ) )
|
||||
host = ( (IImmibisMicroblocks) AppEng.instance.getIntegration( IntegrationType.ImmibisMicroblocks ) ).getOrCreateHost( player, face, tile );
|
||||
|
||||
final Optional<ItemStack> maybeMultiPartStack = multiPart.maybeStack( 1 );
|
||||
@@ -256,13 +256,13 @@ public class PartPlacement
|
||||
final boolean multiPartPresent = maybeMultiPartBlock.isPresent() && maybeMultiPartStack.isPresent() && maybeMultiPartItemBlock.isPresent();
|
||||
final boolean canMultiPartBePlaced = maybeMultiPartBlock.get().canPlaceBlockAt( world, te_x, te_y, te_z );
|
||||
|
||||
if ( hostIsNotPresent && multiPartPresent && canMultiPartBePlaced && maybeMultiPartItemBlock.get().placeBlockAt( maybeMultiPartStack.get(), player, world, te_x, te_y, te_z, side.ordinal(), 0.5f, 0.5f, 0.5f, 0 ) )
|
||||
if( hostIsNotPresent && multiPartPresent && canMultiPartBePlaced && maybeMultiPartItemBlock.get().placeBlockAt( maybeMultiPartStack.get(), player, world, te_x, te_y, te_z, side.ordinal(), 0.5f, 0.5f, 0.5f, 0 ) )
|
||||
{
|
||||
if ( !world.isRemote )
|
||||
if( !world.isRemote )
|
||||
{
|
||||
tile = world.getTileEntity( te_x, te_y, te_z );
|
||||
|
||||
if ( tile instanceof IPartHost )
|
||||
if( tile instanceof IPartHost )
|
||||
host = (IPartHost) tile;
|
||||
|
||||
pass = PlaceType.INTERACT_SECOND_PASS;
|
||||
@@ -274,18 +274,18 @@ public class PartPlacement
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else if ( host != null && !host.canAddPart( held, side ) )
|
||||
else if( host != null && !host.canAddPart( held, side ) )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if ( host == null )
|
||||
if( host == null )
|
||||
return false;
|
||||
|
||||
if ( !host.canAddPart( held, side ) )
|
||||
if( !host.canAddPart( held, side ) )
|
||||
{
|
||||
if ( pass == PlaceType.INTERACT_FIRST_PASS || pass == PlaceType.PLACE_ITEM )
|
||||
if( pass == PlaceType.INTERACT_FIRST_PASS || pass == PlaceType.PLACE_ITEM )
|
||||
{
|
||||
te_x = x + side.offsetX;
|
||||
te_y = y + side.offsetY;
|
||||
@@ -294,49 +294,49 @@ public class PartPlacement
|
||||
Block blkID = world.getBlock( te_x, te_y, te_z );
|
||||
tile = world.getTileEntity( te_x, te_y, te_z );
|
||||
|
||||
if ( tile != null && AppEng.instance.isIntegrationEnabled( IntegrationType.FMP ) )
|
||||
if( tile != null && AppEng.instance.isIntegrationEnabled( IntegrationType.FMP ) )
|
||||
host = ( (IFMP) AppEng.instance.getIntegration( IntegrationType.FMP ) ).getOrCreateHost( tile );
|
||||
|
||||
if ( ( blkID == null || blkID.isReplaceable( world, te_x, te_y, te_z ) || host != null ) && side != ForgeDirection.UNKNOWN )
|
||||
if( ( blkID == null || blkID.isReplaceable( world, te_x, te_y, te_z ) || host != null ) && side != ForgeDirection.UNKNOWN )
|
||||
return place( held, te_x, te_y, te_z, side.getOpposite().ordinal(), player, world, pass == PlaceType.INTERACT_FIRST_PASS ? PlaceType.INTERACT_SECOND_PASS : PlaceType.PLACE_ITEM, depth + 1 );
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
if ( !world.isRemote )
|
||||
if( !world.isRemote )
|
||||
{
|
||||
Block block = world.getBlock( x, y, z );
|
||||
LookDirection dir = Platform.getPlayerRay( player, getEyeOffset( player ) );
|
||||
MovingObjectPosition mop = block.collisionRayTrace( world, x, y, z, dir.a, dir.b );
|
||||
if ( mop != null )
|
||||
if( mop != null )
|
||||
{
|
||||
SelectedPart sp = selectPart( player, host, mop.hitVec.addVector( -mop.blockX, -mop.blockY, -mop.blockZ ) );
|
||||
|
||||
if ( sp.part != null )
|
||||
if( sp.part != null )
|
||||
{
|
||||
if ( !player.isSneaking() && sp.part.onActivate( player, mop.hitVec ) )
|
||||
if( !player.isSneaking() && sp.part.onActivate( player, mop.hitVec ) )
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
DimensionalCoord dc = host.getLocation();
|
||||
if ( !Platform.hasPermissions( dc, player ) )
|
||||
if( !Platform.hasPermissions( dc, player ) )
|
||||
return false;
|
||||
|
||||
ForgeDirection mySide = host.addPart( held, side, player );
|
||||
if ( mySide != null )
|
||||
if( mySide != null )
|
||||
{
|
||||
for ( Block multiPartBlock : multiPart.maybeBlock().asSet() )
|
||||
for( Block multiPartBlock : multiPart.maybeBlock().asSet() )
|
||||
{
|
||||
final SoundType ss = multiPartBlock.stepSound;
|
||||
|
||||
world.playSoundEffect( 0.5 + x, 0.5 + y, 0.5 + z, ss.func_150496_b(), ( ss.getVolume() + 1.0F ) / 2.0F, ss.getPitch() * 0.8F );
|
||||
}
|
||||
|
||||
if ( !player.capabilities.isCreativeMode )
|
||||
if( !player.capabilities.isCreativeMode )
|
||||
{
|
||||
held.stackSize--;
|
||||
if ( held.stackSize == 0 )
|
||||
if( held.stackSize == 0 )
|
||||
{
|
||||
player.inventory.mainInventory[player.inventory.currentItem] = null;
|
||||
MinecraftForge.EVENT_BUS.post( new PlayerDestroyItemEvent( player, held ) );
|
||||
@@ -354,7 +354,7 @@ public class PartPlacement
|
||||
|
||||
private static float getEyeOffset( EntityPlayer p )
|
||||
{
|
||||
if ( p.worldObj.isRemote )
|
||||
if( p.worldObj.isRemote )
|
||||
return Platform.getEyeOffset( p );
|
||||
|
||||
return eyeHeight;
|
||||
@@ -371,13 +371,13 @@ public class PartPlacement
|
||||
|
||||
public static IFacadePart isFacade( ItemStack held, ForgeDirection side )
|
||||
{
|
||||
if ( held.getItem() instanceof IFacadeItem )
|
||||
if( held.getItem() instanceof IFacadeItem )
|
||||
return ( (IFacadeItem) held.getItem() ).createPartFromItemStack( held, side );
|
||||
|
||||
if ( AppEng.instance.isIntegrationEnabled( IntegrationType.BC ) )
|
||||
if( AppEng.instance.isIntegrationEnabled( IntegrationType.BC ) )
|
||||
{
|
||||
IBC bc = (IBC) AppEng.instance.getIntegration( IntegrationType.BC );
|
||||
if ( bc.isFacade( held ) )
|
||||
if( bc.isFacade( held ) )
|
||||
return bc.createFacadePart( held, side );
|
||||
}
|
||||
|
||||
@@ -393,7 +393,7 @@ public class PartPlacement
|
||||
@SubscribeEvent
|
||||
public void playerInteract( PlayerInteractEvent event )
|
||||
{
|
||||
if ( event.action == Action.RIGHT_CLICK_AIR && event.entityPlayer.worldObj.isRemote )
|
||||
if( event.action == Action.RIGHT_CLICK_AIR && event.entityPlayer.worldObj.isRemote )
|
||||
{
|
||||
// re-check to see if this event was already channeled, cause these two events are really stupid...
|
||||
MovingObjectPosition mop = Platform.rayTrace( event.entityPlayer, true, false );
|
||||
@@ -403,11 +403,11 @@ public class PartPlacement
|
||||
double d0 = mc.playerController.getBlockReachDistance();
|
||||
Vec3 vec3 = mc.renderViewEntity.getPosition( f );
|
||||
|
||||
if ( mop != null && mop.hitVec.distanceTo( vec3 ) < d0 )
|
||||
if( mop != null && mop.hitVec.distanceTo( vec3 ) < d0 )
|
||||
{
|
||||
World w = event.entity.worldObj;
|
||||
TileEntity te = w.getTileEntity( mop.blockX, mop.blockY, mop.blockZ );
|
||||
if ( te instanceof IPartHost && this.wasCanceled )
|
||||
if( te instanceof IPartHost && this.wasCanceled )
|
||||
event.setCanceled( true );
|
||||
}
|
||||
else
|
||||
@@ -418,21 +418,21 @@ public class PartPlacement
|
||||
boolean supportedItem = items.memoryCard().isSameAs( held );
|
||||
supportedItem |= items.colorApplicator().isSameAs( held );
|
||||
|
||||
if ( event.entityPlayer.isSneaking() && held != null && supportedItem )
|
||||
if( event.entityPlayer.isSneaking() && held != null && supportedItem )
|
||||
{
|
||||
NetworkHandler.instance.sendToServer( new PacketClick( event.x, event.y, event.z, event.face, 0, 0, 0 ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
else if ( event.action == Action.RIGHT_CLICK_BLOCK && event.entityPlayer.worldObj.isRemote )
|
||||
else if( event.action == Action.RIGHT_CLICK_BLOCK && event.entityPlayer.worldObj.isRemote )
|
||||
{
|
||||
if ( this.placing.get() != null )
|
||||
if( this.placing.get() != null )
|
||||
return;
|
||||
|
||||
this.placing.set( event );
|
||||
|
||||
ItemStack held = event.entityPlayer.getHeldItem();
|
||||
if ( place( held, event.x, event.y, event.z, event.face, event.entityPlayer, event.entityPlayer.worldObj, PlaceType.INTERACT_FIRST_PASS, 0 ) )
|
||||
if( place( held, event.x, event.y, event.z, event.face, event.entityPlayer, event.entityPlayer.worldObj, PlaceType.INTERACT_FIRST_PASS, 0 ) )
|
||||
{
|
||||
event.setCanceled( true );
|
||||
this.wasCanceled = true;
|
||||
|
||||
@@ -25,11 +25,11 @@ public class BlockUpgradeInventory extends UpgradeInventory
|
||||
{
|
||||
int max = 0;
|
||||
|
||||
for ( ItemStack is : upgrades.getSupported().keySet() )
|
||||
for( ItemStack is : upgrades.getSupported().keySet() )
|
||||
{
|
||||
final Item encodedItem = is.getItem();
|
||||
|
||||
if ( encodedItem instanceof ItemBlock && Block.getBlockFromItem( encodedItem ) == this.block )
|
||||
if( encodedItem instanceof ItemBlock && Block.getBlockFromItem( encodedItem ) == this.block )
|
||||
{
|
||||
max = upgrades.getSupported().get( is );
|
||||
break;
|
||||
|
||||
@@ -24,9 +24,9 @@ public final class DefinitionUpgradeInventory extends UpgradeInventory
|
||||
{
|
||||
int max = 0;
|
||||
|
||||
for ( ItemStack stack : upgrades.getSupported().keySet() )
|
||||
for( ItemStack stack : upgrades.getSupported().keySet() )
|
||||
{
|
||||
if ( this.definition.isSameAs( stack ) )
|
||||
if( this.definition.isSameAs( stack ) )
|
||||
{
|
||||
max = upgrades.getSupported().get( stack );
|
||||
break;
|
||||
|
||||
@@ -18,24 +18,27 @@
|
||||
|
||||
package appeng.parts.automation;
|
||||
|
||||
|
||||
import java.util.Iterator;
|
||||
|
||||
import scala.NotImplementedError;
|
||||
|
||||
|
||||
public class NonNullArrayIterator<E> implements Iterator<E>
|
||||
{
|
||||
|
||||
int offset = 0;
|
||||
final E[] g;
|
||||
int offset = 0;
|
||||
|
||||
public NonNullArrayIterator(E[] o) {
|
||||
public NonNullArrayIterator( E[] o )
|
||||
{
|
||||
this.g = o;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasNext()
|
||||
{
|
||||
while (this.offset < this.g.length && this.g[this.offset] == null)
|
||||
while( this.offset < this.g.length && this.g[this.offset] == null )
|
||||
this.offset++;
|
||||
|
||||
return this.offset != this.g.length;
|
||||
@@ -54,5 +57,4 @@ public class NonNullArrayIterator<E> implements Iterator<E>
|
||||
{
|
||||
throw new NotImplementedError();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -85,6 +85,51 @@ public class PartAnnihilationPlane extends PartBasicState implements IGridTickab
|
||||
return this.breakBlock( true );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getBoxes( IPartCollisionHelper bch )
|
||||
{
|
||||
int minX = 1;
|
||||
int minY = 1;
|
||||
int maxX = 15;
|
||||
int maxY = 15;
|
||||
|
||||
final IPartHost host = this.getHost();
|
||||
if( host != null )
|
||||
{
|
||||
final TileEntity te = host.getTile();
|
||||
|
||||
final int x = te.xCoord;
|
||||
final int y = te.yCoord;
|
||||
final int z = te.zCoord;
|
||||
|
||||
final ForgeDirection e = bch.getWorldX();
|
||||
final ForgeDirection u = bch.getWorldY();
|
||||
|
||||
if( this.isAnnihilationPlane( te.getWorldObj().getTileEntity( x - e.offsetX, y - e.offsetY, z - e.offsetZ ), this.side ) )
|
||||
{
|
||||
minX = 0;
|
||||
}
|
||||
|
||||
if( this.isAnnihilationPlane( te.getWorldObj().getTileEntity( x + e.offsetX, y + e.offsetY, z + e.offsetZ ), this.side ) )
|
||||
{
|
||||
maxX = 16;
|
||||
}
|
||||
|
||||
if( this.isAnnihilationPlane( te.getWorldObj().getTileEntity( x - u.offsetX, y - u.offsetY, z - u.offsetZ ), this.side ) )
|
||||
{
|
||||
minY = 0;
|
||||
}
|
||||
|
||||
if( this.isAnnihilationPlane( te.getWorldObj().getTileEntity( x + u.offsetX, y + u.offsetY, z + u.offsetZ ), this.side ) )
|
||||
{
|
||||
maxY = 16;
|
||||
}
|
||||
}
|
||||
|
||||
bch.addBox( 5, 5, 14, 11, 11, 15 );
|
||||
bch.addBox( minX, minY, 15, maxX, maxY, bch.isBBCollision() ? 15 : 16 );
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly( Side.CLIENT )
|
||||
public void renderInventory( IPartRenderHelper rh, RenderBlocks renderer )
|
||||
@@ -112,22 +157,22 @@ public class PartAnnihilationPlane extends PartBasicState implements IGridTickab
|
||||
|
||||
final TileEntity te = this.getHost().getTile();
|
||||
|
||||
if ( this.isAnnihilationPlane( te.getWorldObj().getTileEntity( x - e.offsetX, y - e.offsetY, z - e.offsetZ ), this.side ) )
|
||||
if( this.isAnnihilationPlane( te.getWorldObj().getTileEntity( x - e.offsetX, y - e.offsetY, z - e.offsetZ ), this.side ) )
|
||||
{
|
||||
minX = 0;
|
||||
}
|
||||
|
||||
if ( this.isAnnihilationPlane( te.getWorldObj().getTileEntity( x + e.offsetX, y + e.offsetY, z + e.offsetZ ), this.side ) )
|
||||
if( this.isAnnihilationPlane( te.getWorldObj().getTileEntity( x + e.offsetX, y + e.offsetY, z + e.offsetZ ), this.side ) )
|
||||
{
|
||||
maxX = 16;
|
||||
}
|
||||
|
||||
if ( this.isAnnihilationPlane( te.getWorldObj().getTileEntity( x - u.offsetX, y - u.offsetY, z - u.offsetZ ), this.side ) )
|
||||
if( this.isAnnihilationPlane( te.getWorldObj().getTileEntity( x - u.offsetX, y - u.offsetY, z - u.offsetZ ), this.side ) )
|
||||
{
|
||||
minY = 0;
|
||||
}
|
||||
|
||||
if ( this.isAnnihilationPlane( te.getWorldObj().getTileEntity( x + u.offsetX, y + u.offsetY, z + u.offsetZ ), this.side ) )
|
||||
if( this.isAnnihilationPlane( te.getWorldObj().getTileEntity( x + u.offsetX, y + u.offsetY, z + u.offsetZ ), this.side ) )
|
||||
{
|
||||
maxY = 16;
|
||||
}
|
||||
@@ -148,16 +193,6 @@ public class PartAnnihilationPlane extends PartBasicState implements IGridTickab
|
||||
this.renderLights( x, y, z, rh, renderer );
|
||||
}
|
||||
|
||||
private boolean isAnnihilationPlane( TileEntity blockTileEntity, ForgeDirection side )
|
||||
{
|
||||
if ( blockTileEntity instanceof IPartHost )
|
||||
{
|
||||
final IPart p = ( (IPartHost) blockTileEntity ).getPart( side );
|
||||
return p instanceof PartAnnihilationPlane;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNeighborChanged()
|
||||
{
|
||||
@@ -166,7 +201,7 @@ public class PartAnnihilationPlane extends PartBasicState implements IGridTickab
|
||||
{
|
||||
this.proxy.getTick().alertDevice( this.proxy.getNode() );
|
||||
}
|
||||
catch ( final GridAccessException e )
|
||||
catch( final GridAccessException e )
|
||||
{
|
||||
// :P
|
||||
}
|
||||
@@ -175,19 +210,19 @@ public class PartAnnihilationPlane extends PartBasicState implements IGridTickab
|
||||
@Override
|
||||
public void onEntityCollision( Entity entity )
|
||||
{
|
||||
if ( this.isAccepting && entity instanceof EntityItem && !entity.isDead && Platform.isServer() && this.proxy.isActive() )
|
||||
if( this.isAccepting && entity instanceof EntityItem && !entity.isDead && Platform.isServer() && this.proxy.isActive() )
|
||||
{
|
||||
boolean capture = false;
|
||||
|
||||
switch ( this.side )
|
||||
switch( this.side )
|
||||
{
|
||||
case DOWN:
|
||||
case UP:
|
||||
if ( entity.posX > this.tile.xCoord && entity.posX < this.tile.xCoord + 1 )
|
||||
if( entity.posX > this.tile.xCoord && entity.posX < this.tile.xCoord + 1 )
|
||||
{
|
||||
if ( entity.posZ > this.tile.zCoord && entity.posZ < this.tile.zCoord + 1 )
|
||||
if( entity.posZ > this.tile.zCoord && entity.posZ < this.tile.zCoord + 1 )
|
||||
{
|
||||
if ( ( entity.posY > this.tile.yCoord + 0.9 && this.side == ForgeDirection.UP ) || ( entity.posY < this.tile.yCoord + 0.1 && this.side == ForgeDirection.DOWN ) )
|
||||
if( ( entity.posY > this.tile.yCoord + 0.9 && this.side == ForgeDirection.UP ) || ( entity.posY < this.tile.yCoord + 0.1 && this.side == ForgeDirection.DOWN ) )
|
||||
{
|
||||
capture = true;
|
||||
}
|
||||
@@ -196,11 +231,11 @@ public class PartAnnihilationPlane extends PartBasicState implements IGridTickab
|
||||
break;
|
||||
case SOUTH:
|
||||
case NORTH:
|
||||
if ( entity.posX > this.tile.xCoord && entity.posX < this.tile.xCoord + 1 )
|
||||
if( entity.posX > this.tile.xCoord && entity.posX < this.tile.xCoord + 1 )
|
||||
{
|
||||
if ( entity.posY > this.tile.yCoord && entity.posY < this.tile.yCoord + 1 )
|
||||
if( entity.posY > this.tile.yCoord && entity.posY < this.tile.yCoord + 1 )
|
||||
{
|
||||
if ( ( entity.posZ > this.tile.zCoord + 0.9 && this.side == ForgeDirection.SOUTH ) || ( entity.posZ < this.tile.zCoord + 0.1 && this.side == ForgeDirection.NORTH ) )
|
||||
if( ( entity.posZ > this.tile.zCoord + 0.9 && this.side == ForgeDirection.SOUTH ) || ( entity.posZ < this.tile.zCoord + 0.1 && this.side == ForgeDirection.NORTH ) )
|
||||
{
|
||||
capture = true;
|
||||
}
|
||||
@@ -209,11 +244,11 @@ public class PartAnnihilationPlane extends PartBasicState implements IGridTickab
|
||||
break;
|
||||
case EAST:
|
||||
case WEST:
|
||||
if ( entity.posZ > this.tile.zCoord && entity.posZ < this.tile.zCoord + 1 )
|
||||
if( entity.posZ > this.tile.zCoord && entity.posZ < this.tile.zCoord + 1 )
|
||||
{
|
||||
if ( entity.posY > this.tile.yCoord && entity.posY < this.tile.yCoord + 1 )
|
||||
if( entity.posY > this.tile.yCoord && entity.posY < this.tile.yCoord + 1 )
|
||||
{
|
||||
if ( ( entity.posX > this.tile.xCoord + 0.9 && this.side == ForgeDirection.EAST ) || ( entity.posX < this.tile.xCoord + 0.1 && this.side == ForgeDirection.WEST ) )
|
||||
if( ( entity.posX > this.tile.xCoord + 0.9 && this.side == ForgeDirection.EAST ) || ( entity.posX < this.tile.xCoord + 0.1 && this.side == ForgeDirection.WEST ) )
|
||||
{
|
||||
capture = true;
|
||||
}
|
||||
@@ -225,7 +260,7 @@ public class PartAnnihilationPlane extends PartBasicState implements IGridTickab
|
||||
break;
|
||||
}
|
||||
|
||||
if ( capture )
|
||||
if( capture )
|
||||
{
|
||||
ServerHelper.proxy.sendToAllNearExcept( null, this.tile.xCoord, this.tile.yCoord, this.tile.zCoord, 64, this.tile.getWorldObj(), new PacketTransitionEffect( entity.posX, entity.posY, entity.posZ, this.side, false ) );
|
||||
this.storeEntityItem( (EntityItem) entity );
|
||||
@@ -233,69 +268,12 @@ public class PartAnnihilationPlane extends PartBasicState implements IGridTickab
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getBoxes( IPartCollisionHelper bch )
|
||||
{
|
||||
int minX = 1;
|
||||
int minY = 1;
|
||||
int maxX = 15;
|
||||
int maxY = 15;
|
||||
|
||||
final IPartHost host = this.getHost();
|
||||
if ( host != null )
|
||||
{
|
||||
final TileEntity te = host.getTile();
|
||||
|
||||
final int x = te.xCoord;
|
||||
final int y = te.yCoord;
|
||||
final int z = te.zCoord;
|
||||
|
||||
final ForgeDirection e = bch.getWorldX();
|
||||
final ForgeDirection u = bch.getWorldY();
|
||||
|
||||
if ( this.isAnnihilationPlane( te.getWorldObj().getTileEntity( x - e.offsetX, y - e.offsetY, z - e.offsetZ ), this.side ) )
|
||||
{
|
||||
minX = 0;
|
||||
}
|
||||
|
||||
if ( this.isAnnihilationPlane( te.getWorldObj().getTileEntity( x + e.offsetX, y + e.offsetY, z + e.offsetZ ), this.side ) )
|
||||
{
|
||||
maxX = 16;
|
||||
}
|
||||
|
||||
if ( this.isAnnihilationPlane( te.getWorldObj().getTileEntity( x - u.offsetX, y - u.offsetY, z - u.offsetZ ), this.side ) )
|
||||
{
|
||||
minY = 0;
|
||||
}
|
||||
|
||||
if ( this.isAnnihilationPlane( te.getWorldObj().getTileEntity( x + u.offsetX, y + u.offsetY, z + u.offsetZ ), this.side ) )
|
||||
{
|
||||
maxY = 16;
|
||||
}
|
||||
}
|
||||
|
||||
bch.addBox( 5, 5, 14, 11, 11, 15 );
|
||||
bch.addBox( minX, minY, 15, maxX, maxY, bch.isBBCollision() ? 15 : 16 );
|
||||
}
|
||||
|
||||
@Override
|
||||
public int cableConnectionRenderTo()
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* If the plane is accepting items.
|
||||
*
|
||||
* This might be improved if a performance problem shows up.
|
||||
*
|
||||
* @return true if planes accepts items.
|
||||
*/
|
||||
private boolean isAccepting()
|
||||
{
|
||||
return this.isAccepting;
|
||||
}
|
||||
|
||||
/**
|
||||
* Stores an {@link EntityItem} inside the network and either marks it as dead or sets it to the leftover stackSize.
|
||||
*
|
||||
@@ -303,7 +281,7 @@ public class PartAnnihilationPlane extends PartBasicState implements IGridTickab
|
||||
*/
|
||||
private void storeEntityItem( EntityItem entityItem )
|
||||
{
|
||||
if ( !entityItem.isDead )
|
||||
if( !entityItem.isDead )
|
||||
{
|
||||
this.storeItemStack( entityItem.getEntityItem() );
|
||||
entityItem.setDead();
|
||||
@@ -328,7 +306,7 @@ public class PartAnnihilationPlane extends PartBasicState implements IGridTickab
|
||||
|
||||
this.isAccepting = overflow == null;
|
||||
}
|
||||
catch ( final GridAccessException e1 )
|
||||
catch( final GridAccessException e1 )
|
||||
{
|
||||
// :P
|
||||
}
|
||||
@@ -336,7 +314,7 @@ public class PartAnnihilationPlane extends PartBasicState implements IGridTickab
|
||||
|
||||
private void spawnOverflowItemStack( IAEItemStack overflow )
|
||||
{
|
||||
if ( overflow == null )
|
||||
if( overflow == null )
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -351,6 +329,28 @@ public class PartAnnihilationPlane extends PartBasicState implements IGridTickab
|
||||
Platform.spawnDrops( world, x, y, z, Lists.newArrayList( overflow.getItemStack() ) );
|
||||
}
|
||||
|
||||
private boolean isAnnihilationPlane( TileEntity blockTileEntity, ForgeDirection side )
|
||||
{
|
||||
if( blockTileEntity instanceof IPartHost )
|
||||
{
|
||||
final IPart p = ( (IPartHost) blockTileEntity ).getPart( side );
|
||||
return p instanceof PartAnnihilationPlane;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* If the plane is accepting items.
|
||||
*
|
||||
* This might be improved if a performance problem shows up.
|
||||
*
|
||||
* @return true if planes accepts items.
|
||||
*/
|
||||
private boolean isAccepting()
|
||||
{
|
||||
return this.isAccepting;
|
||||
}
|
||||
|
||||
@Override
|
||||
@MENetworkEventSubscribe
|
||||
public void chanRender( MENetworkChannelsChanged c )
|
||||
@@ -369,7 +369,7 @@ public class PartAnnihilationPlane extends PartBasicState implements IGridTickab
|
||||
|
||||
public TickRateModulation breakBlock( boolean modulate )
|
||||
{
|
||||
if ( this.isAccepting && this.proxy.isActive() )
|
||||
if( this.isAccepting && this.proxy.isActive() )
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -387,16 +387,16 @@ public class PartAnnihilationPlane extends PartBasicState implements IGridTickab
|
||||
final Material mat = blk.getMaterial();
|
||||
final boolean ignore = mat == Material.air || mat == Material.lava || mat == Material.water || mat.isLiquid() || blk == Blocks.bedrock || blk == Blocks.end_portal || blk == Blocks.end_portal_frame || blk == Blocks.command_block;
|
||||
|
||||
if ( !ignore && !w.isAirBlock( x, y, z ) && w.blockExists( x, y, z ) && w.canMineBlock( Platform.getPlayer( w ), x, y, z ) )
|
||||
if( !ignore && !w.isAirBlock( x, y, z ) && w.blockExists( x, y, z ) && w.canMineBlock( Platform.getPlayer( w ), x, y, z ) )
|
||||
{
|
||||
final float hardness = blk.getBlockHardness( w, x, y, z );
|
||||
|
||||
if ( hardness >= 0.0 )
|
||||
if( hardness >= 0.0 )
|
||||
{
|
||||
final ItemStack[] out = Platform.getBlockDrops( w, x, y, z );
|
||||
|
||||
float total = 1 + hardness;
|
||||
for ( final ItemStack is : out )
|
||||
for( final ItemStack is : out )
|
||||
{
|
||||
total += is.stackSize;
|
||||
}
|
||||
@@ -404,24 +404,24 @@ public class PartAnnihilationPlane extends PartBasicState implements IGridTickab
|
||||
final boolean hasPower = energy.extractAEPower( total, Actionable.SIMULATE, PowerMultiplier.CONFIG ) > total - 0.1;
|
||||
final boolean canStore = this.canStoreItemStacks( out );
|
||||
|
||||
if ( hasPower && canStore )
|
||||
if( hasPower && canStore )
|
||||
{
|
||||
if ( modulate )
|
||||
if( modulate )
|
||||
{
|
||||
w.setBlock( x, y, z, Platform.AIR, 0, 3 );
|
||||
energy.extractAEPower( total, Actionable.MODULATE, PowerMultiplier.CONFIG );
|
||||
|
||||
final AxisAlignedBB box = AxisAlignedBB.getBoundingBox( x - 0.2, y - 0.2, z - 0.2, x + 1.2, y + 1.2, z + 1.2 );
|
||||
for ( final Object ei : w.getEntitiesWithinAABB( EntityItem.class, box ) )
|
||||
for( final Object ei : w.getEntitiesWithinAABB( EntityItem.class, box ) )
|
||||
{
|
||||
if ( ei instanceof EntityItem )
|
||||
if( ei instanceof EntityItem )
|
||||
{
|
||||
final EntityItem entityItem = (EntityItem) ei;
|
||||
this.storeEntityItem( entityItem );
|
||||
}
|
||||
}
|
||||
|
||||
for ( final ItemStack snaggedItem : out )
|
||||
for( final ItemStack snaggedItem : out )
|
||||
{
|
||||
this.storeItemStack( snaggedItem );
|
||||
}
|
||||
@@ -438,7 +438,7 @@ public class PartAnnihilationPlane extends PartBasicState implements IGridTickab
|
||||
}
|
||||
}
|
||||
}
|
||||
catch ( final GridAccessException e1 )
|
||||
catch( final GridAccessException e1 )
|
||||
{
|
||||
// :P
|
||||
}
|
||||
@@ -457,7 +457,7 @@ public class PartAnnihilationPlane extends PartBasicState implements IGridTickab
|
||||
@Override
|
||||
public TickRateModulation tickingRequest( IGridNode node, int ticksSinceLastCall )
|
||||
{
|
||||
if ( this.breaking )
|
||||
if( this.breaking )
|
||||
{
|
||||
return TickRateModulation.URGENT;
|
||||
}
|
||||
@@ -483,17 +483,17 @@ public class PartAnnihilationPlane extends PartBasicState implements IGridTickab
|
||||
{
|
||||
final IStorageGrid storage = this.proxy.getStorage();
|
||||
|
||||
for ( final ItemStack itemStack : itemStacks )
|
||||
for( final ItemStack itemStack : itemStacks )
|
||||
{
|
||||
final IAEItemStack itemToTest = AEItemStack.create( itemStack );
|
||||
final IAEItemStack overflow = storage.getItemInventory().injectItems( itemToTest, Actionable.SIMULATE, this.mySrc );
|
||||
if ( overflow == null || itemToTest.getStackSize() > overflow.getStackSize() )
|
||||
if( overflow == null || itemToTest.getStackSize() > overflow.getStackSize() )
|
||||
{
|
||||
canStore = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch ( final GridAccessException e )
|
||||
catch( final GridAccessException e )
|
||||
{
|
||||
// :P
|
||||
}
|
||||
|
||||
@@ -82,13 +82,6 @@ public class PartExportBus extends PartSharedItemBus implements ICraftingRequest
|
||||
this.mySrc = new MachineSource( this );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT( NBTTagCompound extra )
|
||||
{
|
||||
super.writeToNBT( extra );
|
||||
this.cratingTracker.writeToNBT( extra );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT( NBTTagCompound extra )
|
||||
{
|
||||
@@ -96,16 +89,23 @@ public class PartExportBus extends PartSharedItemBus implements ICraftingRequest
|
||||
this.cratingTracker.readFromNBT( extra );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT( NBTTagCompound extra )
|
||||
{
|
||||
super.writeToNBT( extra );
|
||||
this.cratingTracker.writeToNBT( extra );
|
||||
}
|
||||
|
||||
@Override
|
||||
TickRateModulation doBusWork()
|
||||
{
|
||||
if ( !this.proxy.isActive() )
|
||||
if( !this.proxy.isActive() )
|
||||
return TickRateModulation.IDLE;
|
||||
|
||||
this.itemToSend = 1;
|
||||
this.didSomething = false;
|
||||
|
||||
switch ( this.getInstalledUpgrades( Upgrades.SPEED ) )
|
||||
switch( this.getInstalledUpgrades( Upgrades.SPEED ) )
|
||||
{
|
||||
default:
|
||||
case 0:
|
||||
@@ -133,38 +133,38 @@ public class PartExportBus extends PartSharedItemBus implements ICraftingRequest
|
||||
ICraftingGrid cg = this.proxy.getCrafting();
|
||||
FuzzyMode fzMode = (FuzzyMode) this.getConfigManager().getSetting( Settings.FUZZY_MODE );
|
||||
|
||||
if ( d != null )
|
||||
if( d != null )
|
||||
{
|
||||
for ( int x = 0; x < this.availableSlots() && this.itemToSend > 0; x++ )
|
||||
for( int x = 0; x < this.availableSlots() && this.itemToSend > 0; x++ )
|
||||
{
|
||||
IAEItemStack ais = this.config.getAEStackInSlot( x );
|
||||
if ( ais == null || this.itemToSend <= 0 || this.craftOnly() )
|
||||
if( ais == null || this.itemToSend <= 0 || this.craftOnly() )
|
||||
{
|
||||
if ( this.isCraftingEnabled() )
|
||||
if( this.isCraftingEnabled() )
|
||||
this.didSomething = this.cratingTracker.handleCrafting( x, this.itemToSend, ais, d, this.getTile().getWorldObj(), this.proxy.getGrid(), cg, this.mySrc ) || this.didSomething;
|
||||
continue;
|
||||
}
|
||||
|
||||
long before = this.itemToSend;
|
||||
|
||||
if ( this.getInstalledUpgrades( Upgrades.FUZZY ) > 0 )
|
||||
if( this.getInstalledUpgrades( Upgrades.FUZZY ) > 0 )
|
||||
{
|
||||
for ( IAEItemStack o : ImmutableList.copyOf( inv.getStorageList().findFuzzy( ais, fzMode ) ) )
|
||||
for( IAEItemStack o : ImmutableList.copyOf( inv.getStorageList().findFuzzy( ais, fzMode ) ) )
|
||||
{
|
||||
this.pushItemIntoTarget( d, energy, inv, o );
|
||||
if ( this.itemToSend <= 0 )
|
||||
if( this.itemToSend <= 0 )
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
this.pushItemIntoTarget( d, energy, inv, ais );
|
||||
|
||||
if ( this.itemToSend == before && this.isCraftingEnabled() )
|
||||
if( this.itemToSend == before && this.isCraftingEnabled() )
|
||||
this.didSomething = this.cratingTracker.handleCrafting( x, this.itemToSend, ais, d, this.getTile().getWorldObj(), this.proxy.getGrid(), cg, this.mySrc ) || this.didSomething;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch ( GridAccessException e )
|
||||
catch( GridAccessException e )
|
||||
{
|
||||
// :P
|
||||
}
|
||||
@@ -172,6 +172,15 @@ public class PartExportBus extends PartSharedItemBus implements ICraftingRequest
|
||||
return this.didSomething ? TickRateModulation.FASTER : TickRateModulation.SLOWER;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getBoxes( IPartCollisionHelper bch )
|
||||
{
|
||||
bch.addBox( 4, 4, 12, 12, 12, 14 );
|
||||
bch.addBox( 5, 5, 14, 11, 11, 15 );
|
||||
bch.addBox( 6, 6, 15, 10, 10, 16 );
|
||||
bch.addBox( 6, 6, 11, 10, 10, 12 );
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly( Side.CLIENT )
|
||||
public void renderInventory( IPartRenderHelper rh, RenderBlocks renderer )
|
||||
@@ -213,15 +222,6 @@ public class PartExportBus extends PartSharedItemBus implements ICraftingRequest
|
||||
this.renderLights( x, y, z, rh, renderer );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getBoxes( IPartCollisionHelper bch )
|
||||
{
|
||||
bch.addBox( 4, 4, 12, 12, 12, 14 );
|
||||
bch.addBox( 5, 5, 14, 11, 11, 15 );
|
||||
bch.addBox( 6, 6, 15, 10, 10, 16 );
|
||||
bch.addBox( 6, 6, 11, 10, 10, 12 );
|
||||
}
|
||||
|
||||
@Override
|
||||
public int cableConnectionRenderTo()
|
||||
{
|
||||
@@ -231,9 +231,9 @@ public class PartExportBus extends PartSharedItemBus implements ICraftingRequest
|
||||
@Override
|
||||
public boolean onPartActivate( EntityPlayer player, Vec3 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_BUS );
|
||||
@@ -244,9 +244,9 @@ public class PartExportBus extends PartSharedItemBus implements ICraftingRequest
|
||||
}
|
||||
|
||||
@Override
|
||||
public RedstoneMode getRSMode()
|
||||
public TickingRequest getTickingRequest( IGridNode node )
|
||||
{
|
||||
return (RedstoneMode) this.getConfigManager().getSetting( Settings.REDSTONE_CONTROLLED );
|
||||
return new TickingRequest( TickRates.ExportBus.min, TickRates.ExportBus.max, this.isSleeping(), false );
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -256,9 +256,9 @@ public class PartExportBus extends PartSharedItemBus implements ICraftingRequest
|
||||
}
|
||||
|
||||
@Override
|
||||
public TickingRequest getTickingRequest( IGridNode node )
|
||||
public RedstoneMode getRSMode()
|
||||
{
|
||||
return new TickingRequest( TickRates.ExportBus.min, TickRates.ExportBus.max, this.isSleeping(), false );
|
||||
return (RedstoneMode) this.getConfigManager().getSetting( Settings.REDSTONE_CONTROLLED );
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -285,18 +285,18 @@ public class PartExportBus extends PartSharedItemBus implements ICraftingRequest
|
||||
ItemStack o = d.simulateAdd( is );
|
||||
long canFit = o == null ? this.itemToSend : this.itemToSend - o.stackSize;
|
||||
|
||||
if ( canFit > 0 )
|
||||
if( canFit > 0 )
|
||||
{
|
||||
ais = ais.copy();
|
||||
ais.setStackSize( canFit );
|
||||
IAEItemStack itemsToAdd = Platform.poweredExtraction( energy, inv, ais, this.mySrc );
|
||||
|
||||
if ( itemsToAdd != null )
|
||||
if( itemsToAdd != null )
|
||||
{
|
||||
this.itemToSend -= itemsToAdd.getStackSize();
|
||||
|
||||
ItemStack failed = d.addItems( itemsToAdd.getItemStack() );
|
||||
if ( failed != null )
|
||||
if( failed != null )
|
||||
{
|
||||
ais.setStackSize( failed.stackSize );
|
||||
inv.injectItems( ais, Actionable.MODULATE, this.mySrc );
|
||||
@@ -320,20 +320,20 @@ public class PartExportBus extends PartSharedItemBus implements ICraftingRequest
|
||||
|
||||
try
|
||||
{
|
||||
if ( d != null && this.proxy.isActive() )
|
||||
if( d != null && this.proxy.isActive() )
|
||||
{
|
||||
IEnergyGrid energy = this.proxy.getEnergy();
|
||||
|
||||
double power = items.getStackSize();
|
||||
if ( energy.extractAEPower( power, mode, PowerMultiplier.CONFIG ) > power - 0.01 )
|
||||
if( energy.extractAEPower( power, mode, PowerMultiplier.CONFIG ) > power - 0.01 )
|
||||
{
|
||||
if ( mode == Actionable.MODULATE )
|
||||
if( mode == Actionable.MODULATE )
|
||||
return AEItemStack.create( d.addItems( items.getItemStack() ) );
|
||||
return AEItemStack.create( d.simulateAdd( items.getItemStack() ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
catch ( GridAccessException e )
|
||||
catch( GridAccessException e )
|
||||
{
|
||||
AELog.error( e );
|
||||
}
|
||||
|
||||
@@ -100,7 +100,6 @@ public class PartFormationPlane extends PartUpgradeable implements ICellContaine
|
||||
this.updateHandler();
|
||||
}
|
||||
|
||||
|
||||
private void updateHandler()
|
||||
{
|
||||
this.myHandler.setBaseAccess( AccessRestriction.WRITE );
|
||||
@@ -111,14 +110,14 @@ public class PartFormationPlane extends PartUpgradeable implements ICellContaine
|
||||
IItemList<IAEItemStack> priorityList = AEApi.instance().storage().createItemList();
|
||||
|
||||
int slotsToUse = 18 + this.getInstalledUpgrades( Upgrades.CAPACITY ) * 9;
|
||||
for ( int x = 0; x < this.Config.getSizeInventory() && x < slotsToUse; x++ )
|
||||
for( int x = 0; x < this.Config.getSizeInventory() && x < slotsToUse; x++ )
|
||||
{
|
||||
IAEItemStack is = this.Config.getAEStackInSlot( x );
|
||||
if ( is != null )
|
||||
if( is != null )
|
||||
priorityList.add( is );
|
||||
}
|
||||
|
||||
if ( this.getInstalledUpgrades( Upgrades.FUZZY ) > 0 )
|
||||
if( this.getInstalledUpgrades( Upgrades.FUZZY ) > 0 )
|
||||
this.myHandler.setPartitionList( new FuzzyPriorityList( priorityList, (FuzzyMode) this.getConfigManager().getSetting( Settings.FUZZY_MODE ) ) );
|
||||
else
|
||||
this.myHandler.setPartitionList( new PrecisePriorityList( priorityList ) );
|
||||
@@ -127,28 +126,39 @@ public class PartFormationPlane extends PartUpgradeable implements ICellContaine
|
||||
{
|
||||
this.proxy.getGrid().postEvent( new MENetworkCellArrayUpdate() );
|
||||
}
|
||||
catch ( GridAccessException e )
|
||||
catch( GridAccessException e )
|
||||
{
|
||||
// :P
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected int getUpgradeSlots()
|
||||
{
|
||||
return 5;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void writeToNBT( NBTTagCompound data )
|
||||
public void updateSetting( IConfigManager manager, Enum settingName, Enum newValue )
|
||||
{
|
||||
super.writeToNBT( data );
|
||||
this.Config.writeToNBT( data, "config" );
|
||||
data.setInteger( "priority", this.priority );
|
||||
this.updateHandler();
|
||||
this.host.markForSave();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChangeInventory( IInventory inv, int slot, InvOperation mc, ItemStack removedStack, ItemStack newStack )
|
||||
{
|
||||
super.onChangeInventory( inv, slot, mc, removedStack, newStack );
|
||||
|
||||
if( inv == this.Config )
|
||||
this.updateHandler();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void upgradesChanged()
|
||||
{
|
||||
this.updateHandler();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT( NBTTagCompound data )
|
||||
@@ -159,48 +169,29 @@ public class PartFormationPlane extends PartUpgradeable implements ICellContaine
|
||||
this.updateHandler();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT( NBTTagCompound data )
|
||||
{
|
||||
super.writeToNBT( data );
|
||||
this.Config.writeToNBT( data, "config" );
|
||||
data.setInteger( "priority", this.priority );
|
||||
}
|
||||
|
||||
@Override
|
||||
public IInventory getInventoryByName( String name )
|
||||
{
|
||||
if ( name.equals( "config" ) )
|
||||
if( name.equals( "config" ) )
|
||||
return this.Config;
|
||||
|
||||
return super.getInventoryByName( name );
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void updateSetting( IConfigManager manager, Enum settingName, Enum newValue )
|
||||
{
|
||||
this.updateHandler();
|
||||
this.host.markForSave();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void upgradesChanged()
|
||||
{
|
||||
this.updateHandler();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onChangeInventory( IInventory inv, int slot, InvOperation mc, ItemStack removedStack, ItemStack newStack )
|
||||
{
|
||||
super.onChangeInventory( inv, slot, mc, removedStack, newStack );
|
||||
|
||||
if ( inv == this.Config )
|
||||
this.updateHandler();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
@MENetworkEventSubscribe
|
||||
public void powerRender( MENetworkPowerStatusChange c )
|
||||
{
|
||||
boolean currentActive = this.proxy.isActive();
|
||||
if ( this.wasActive != currentActive )
|
||||
if( this.wasActive != currentActive )
|
||||
{
|
||||
this.wasActive = currentActive;
|
||||
this.updateHandler();// proxy.getGrid().postEvent( new MENetworkCellArrayUpdate() );
|
||||
@@ -208,12 +199,11 @@ public class PartFormationPlane extends PartUpgradeable implements ICellContaine
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@MENetworkEventSubscribe
|
||||
public void updateChannels( MENetworkChannelsChanged changedChannels )
|
||||
{
|
||||
boolean currentActive = this.proxy.isActive();
|
||||
if ( this.wasActive != currentActive )
|
||||
if( this.wasActive != currentActive )
|
||||
{
|
||||
this.wasActive = currentActive;
|
||||
this.updateHandler();// proxy.getGrid().postEvent( new MENetworkCellArrayUpdate() );
|
||||
@@ -221,6 +211,42 @@ public class PartFormationPlane extends PartUpgradeable implements ICellContaine
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getBoxes( IPartCollisionHelper bch )
|
||||
{
|
||||
int minX = 1;
|
||||
int minY = 1;
|
||||
int maxX = 15;
|
||||
int maxY = 15;
|
||||
|
||||
IPartHost host = this.getHost();
|
||||
if( host != null )
|
||||
{
|
||||
TileEntity te = host.getTile();
|
||||
|
||||
int x = te.xCoord;
|
||||
int y = te.yCoord;
|
||||
int z = te.zCoord;
|
||||
|
||||
ForgeDirection e = bch.getWorldX();
|
||||
ForgeDirection u = bch.getWorldY();
|
||||
|
||||
if( this.isTransitionPlane( te.getWorldObj().getTileEntity( x - e.offsetX, y - e.offsetY, z - e.offsetZ ), this.side ) )
|
||||
minX = 0;
|
||||
|
||||
if( this.isTransitionPlane( te.getWorldObj().getTileEntity( x + e.offsetX, y + e.offsetY, z + e.offsetZ ), this.side ) )
|
||||
maxX = 16;
|
||||
|
||||
if( this.isTransitionPlane( te.getWorldObj().getTileEntity( x - u.offsetX, y - u.offsetY, z - u.offsetZ ), this.side ) )
|
||||
minY = 0;
|
||||
|
||||
if( this.isTransitionPlane( te.getWorldObj().getTileEntity( x + u.offsetX, y + u.offsetY, z + u.offsetZ ), this.side ) )
|
||||
maxY = 16;
|
||||
}
|
||||
|
||||
bch.addBox( 5, 5, 14, 11, 11, 15 );
|
||||
bch.addBox( minX, minY, 15, maxX, maxY, 16 );
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly( Side.CLIENT )
|
||||
@@ -235,7 +261,6 @@ public class PartFormationPlane extends PartUpgradeable implements ICellContaine
|
||||
rh.renderInventoryBox( renderer );
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
@SideOnly( Side.CLIENT )
|
||||
public void renderStatic( int x, int y, int z, IPartRenderHelper rh, RenderBlocks renderer )
|
||||
@@ -250,16 +275,16 @@ public class PartFormationPlane extends PartUpgradeable implements ICellContaine
|
||||
|
||||
TileEntity te = this.getHost().getTile();
|
||||
|
||||
if ( this.isTransitionPlane( te.getWorldObj().getTileEntity( x - e.offsetX, y - e.offsetY, z - e.offsetZ ), this.side ) )
|
||||
if( this.isTransitionPlane( te.getWorldObj().getTileEntity( x - e.offsetX, y - e.offsetY, z - e.offsetZ ), this.side ) )
|
||||
minX = 0;
|
||||
|
||||
if ( this.isTransitionPlane( te.getWorldObj().getTileEntity( x + e.offsetX, y + e.offsetY, z + e.offsetZ ), this.side ) )
|
||||
if( this.isTransitionPlane( te.getWorldObj().getTileEntity( x + e.offsetX, y + e.offsetY, z + e.offsetZ ), this.side ) )
|
||||
maxX = 16;
|
||||
|
||||
if ( this.isTransitionPlane( te.getWorldObj().getTileEntity( x - u.offsetX, y - u.offsetY, z - u.offsetZ ), this.side ) )
|
||||
if( this.isTransitionPlane( te.getWorldObj().getTileEntity( x - u.offsetX, y - u.offsetY, z - u.offsetZ ), this.side ) )
|
||||
minY = 0;
|
||||
|
||||
if ( this.isTransitionPlane( te.getWorldObj().getTileEntity( x + u.offsetX, y + u.offsetY, z + u.offsetZ ), this.side ) )
|
||||
if( this.isTransitionPlane( te.getWorldObj().getTileEntity( x + u.offsetX, y + u.offsetY, z + u.offsetZ ), this.side ) )
|
||||
maxY = 16;
|
||||
|
||||
boolean isActive = ( this.clientFlags & ( this.POWERED_FLAG | this.CHANNEL_FLAG ) ) == ( this.POWERED_FLAG | this.CHANNEL_FLAG );
|
||||
@@ -278,18 +303,6 @@ public class PartFormationPlane extends PartUpgradeable implements ICellContaine
|
||||
this.renderLights( x, y, z, rh, renderer );
|
||||
}
|
||||
|
||||
|
||||
private boolean isTransitionPlane( TileEntity blockTileEntity, ForgeDirection side )
|
||||
{
|
||||
if ( blockTileEntity instanceof IPartHost )
|
||||
{
|
||||
IPart p = ( (IPartHost) blockTileEntity ).getPart( side );
|
||||
return p instanceof PartFormationPlane;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onNeighborChanged()
|
||||
{
|
||||
@@ -304,58 +317,18 @@ public class PartFormationPlane extends PartUpgradeable implements ICellContaine
|
||||
this.blocked = !w.getBlock( x, y, z ).isReplaceable( w, x, y, z );
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void getBoxes( IPartCollisionHelper bch )
|
||||
{
|
||||
int minX = 1;
|
||||
int minY = 1;
|
||||
int maxX = 15;
|
||||
int maxY = 15;
|
||||
|
||||
IPartHost host = this.getHost();
|
||||
if ( host != null )
|
||||
{
|
||||
TileEntity te = host.getTile();
|
||||
|
||||
int x = te.xCoord;
|
||||
int y = te.yCoord;
|
||||
int z = te.zCoord;
|
||||
|
||||
ForgeDirection e = bch.getWorldX();
|
||||
ForgeDirection u = bch.getWorldY();
|
||||
|
||||
if ( this.isTransitionPlane( te.getWorldObj().getTileEntity( x - e.offsetX, y - e.offsetY, z - e.offsetZ ), this.side ) )
|
||||
minX = 0;
|
||||
|
||||
if ( this.isTransitionPlane( te.getWorldObj().getTileEntity( x + e.offsetX, y + e.offsetY, z + e.offsetZ ), this.side ) )
|
||||
maxX = 16;
|
||||
|
||||
if ( this.isTransitionPlane( te.getWorldObj().getTileEntity( x - u.offsetX, y - u.offsetY, z - u.offsetZ ), this.side ) )
|
||||
minY = 0;
|
||||
|
||||
if ( this.isTransitionPlane( te.getWorldObj().getTileEntity( x + u.offsetX, y + u.offsetY, z + u.offsetZ ), this.side ) )
|
||||
maxY = 16;
|
||||
}
|
||||
|
||||
bch.addBox( 5, 5, 14, 11, 11, 15 );
|
||||
bch.addBox( minX, minY, 15, maxX, maxY, 16 );
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int cableConnectionRenderTo()
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean onPartActivate( EntityPlayer player, Vec3 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_FORMATION_PLANE );
|
||||
@@ -365,11 +338,20 @@ public class PartFormationPlane extends PartUpgradeable implements ICellContaine
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean isTransitionPlane( TileEntity blockTileEntity, ForgeDirection side )
|
||||
{
|
||||
if( blockTileEntity instanceof IPartHost )
|
||||
{
|
||||
IPart p = ( (IPartHost) blockTileEntity ).getPart( side );
|
||||
return p instanceof PartFormationPlane;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<IMEInventoryHandler> getCellArray( StorageChannel channel )
|
||||
{
|
||||
if ( this.proxy.isActive() && channel == StorageChannel.ITEMS )
|
||||
if( this.proxy.isActive() && channel == StorageChannel.ITEMS )
|
||||
{
|
||||
List<IMEInventoryHandler> Handler = new ArrayList<IMEInventoryHandler>( 1 );
|
||||
Handler.add( this.myHandler );
|
||||
@@ -378,14 +360,12 @@ public class PartFormationPlane extends PartUpgradeable implements ICellContaine
|
||||
return new ArrayList<IMEInventoryHandler>();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int getPriority()
|
||||
{
|
||||
return this.priority;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void setPriority( int newValue )
|
||||
{
|
||||
@@ -394,18 +374,16 @@ public class PartFormationPlane extends PartUpgradeable implements ICellContaine
|
||||
this.updateHandler();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void blinkCell( int slot )
|
||||
{
|
||||
// :P
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public IAEItemStack injectItems( IAEItemStack input, Actionable type, BaseActionSource src )
|
||||
{
|
||||
if ( this.blocked || input == null || input.getStackSize() <= 0 )
|
||||
if( this.blocked || input == null || input.getStackSize() <= 0 )
|
||||
return input;
|
||||
|
||||
YesNo placeBlock = (YesNo) this.getConfigManager().getSetting( Settings.PLACE_BLOCK );
|
||||
@@ -424,40 +402,40 @@ public class PartFormationPlane extends PartUpgradeable implements ICellContaine
|
||||
int y = te.yCoord + side.offsetY;
|
||||
int z = te.zCoord + side.offsetZ;
|
||||
|
||||
if ( w.getBlock( x, y, z ).isReplaceable( w, x, y, z ) )
|
||||
if( w.getBlock( x, y, z ).isReplaceable( w, x, y, z ) )
|
||||
{
|
||||
if ( placeBlock == YesNo.YES && ( i instanceof ItemBlock || i instanceof IPlantable || i instanceof ItemSkull || i instanceof ItemFirework || i instanceof IPartItem || i instanceof ItemReed ) )
|
||||
if( placeBlock == YesNo.YES && ( i instanceof ItemBlock || i instanceof IPlantable || i instanceof ItemSkull || i instanceof ItemFirework || i instanceof IPartItem || i instanceof ItemReed ) )
|
||||
{
|
||||
EntityPlayer player = Platform.getPlayer( (WorldServer) w );
|
||||
Platform.configurePlayer( player, side, this.tile );
|
||||
|
||||
if ( i instanceof ItemFirework )
|
||||
if( i instanceof ItemFirework )
|
||||
{
|
||||
Chunk c = w.getChunkFromBlockCoords( x, z );
|
||||
int sum = 0;
|
||||
for ( List Z : c.entityLists )
|
||||
for( List Z : c.entityLists )
|
||||
sum += Z.size();
|
||||
if ( sum > 32 )
|
||||
if( sum > 32 )
|
||||
return input;
|
||||
}
|
||||
maxStorage = is.stackSize;
|
||||
worked = true;
|
||||
if ( type == Actionable.MODULATE )
|
||||
if( type == Actionable.MODULATE )
|
||||
{
|
||||
if ( i instanceof IPlantable || i instanceof ItemSkull || i instanceof ItemReed )
|
||||
if( i instanceof IPlantable || i instanceof ItemSkull || i instanceof ItemReed )
|
||||
{
|
||||
boolean Worked = false;
|
||||
|
||||
if ( side.offsetX == 0 && side.offsetZ == 0 )
|
||||
if( side.offsetX == 0 && side.offsetZ == 0 )
|
||||
Worked = i.onItemUse( is, player, w, x + side.offsetX, y + side.offsetY, z + side.offsetZ, side.getOpposite().ordinal(), side.offsetX, side.offsetY, side.offsetZ );
|
||||
|
||||
if ( !Worked && side.offsetX == 0 && side.offsetZ == 0 )
|
||||
if( !Worked && side.offsetX == 0 && side.offsetZ == 0 )
|
||||
Worked = i.onItemUse( is, player, w, x - side.offsetX, y - side.offsetY, z - side.offsetZ, side.ordinal(), side.offsetX, side.offsetY, side.offsetZ );
|
||||
|
||||
if ( !Worked && side.offsetY == 0 )
|
||||
if( !Worked && side.offsetY == 0 )
|
||||
Worked = i.onItemUse( is, player, w, x, y - 1, z, ForgeDirection.UP.ordinal(), side.offsetX, side.offsetY, side.offsetZ );
|
||||
|
||||
if ( !Worked )
|
||||
if( !Worked )
|
||||
i.onItemUse( is, player, w, x, y, z, side.getOpposite().ordinal(), side.offsetX, side.offsetY, side.offsetZ );
|
||||
|
||||
maxStorage -= is.stackSize;
|
||||
@@ -476,12 +454,12 @@ public class PartFormationPlane extends PartUpgradeable implements ICellContaine
|
||||
worked = true;
|
||||
Chunk c = w.getChunkFromBlockCoords( x, z );
|
||||
int sum = 0;
|
||||
for ( List Z : c.entityLists )
|
||||
for( List Z : c.entityLists )
|
||||
sum += Z.size();
|
||||
|
||||
if ( sum < AEConfig.instance.formationPlaneEntityLimit )
|
||||
if( sum < AEConfig.instance.formationPlaneEntityLimit )
|
||||
{
|
||||
if ( type == Actionable.MODULATE )
|
||||
if( type == Actionable.MODULATE )
|
||||
{
|
||||
|
||||
is.stackSize = (int) maxStorage;
|
||||
@@ -497,16 +475,16 @@ public class PartFormationPlane extends PartUpgradeable implements ICellContaine
|
||||
ei.motionY = side.offsetY * 0.2;
|
||||
ei.motionZ = side.offsetZ * 0.2;
|
||||
|
||||
if ( is.getItem().hasCustomEntity( is ) )
|
||||
if( is.getItem().hasCustomEntity( is ) )
|
||||
{
|
||||
result = is.getItem().createEntity( w, ei, is );
|
||||
if ( result != null )
|
||||
if( result != null )
|
||||
ei.setDead();
|
||||
else
|
||||
result = ei;
|
||||
}
|
||||
|
||||
if ( !w.spawnEntityInWorld( result ) )
|
||||
if( !w.spawnEntityInWorld( result ) )
|
||||
{
|
||||
result.setDead();
|
||||
worked = false;
|
||||
@@ -520,11 +498,11 @@ public class PartFormationPlane extends PartUpgradeable implements ICellContaine
|
||||
|
||||
this.blocked = !w.getBlock( x, y, z ).isReplaceable( w, x, y, z );
|
||||
|
||||
if ( worked )
|
||||
if( worked )
|
||||
{
|
||||
IAEItemStack out = input.copy();
|
||||
out.decStackSize( maxStorage );
|
||||
if ( out.getStackSize() == 0 )
|
||||
if( out.getStackSize() == 0 )
|
||||
return null;
|
||||
return out;
|
||||
}
|
||||
@@ -532,28 +510,24 @@ public class PartFormationPlane extends PartUpgradeable implements ICellContaine
|
||||
return input;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public IAEItemStack extractItems( IAEItemStack request, Actionable mode, BaseActionSource src )
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public IItemList<IAEItemStack> getAvailableItems( IItemList<IAEItemStack> out )
|
||||
{
|
||||
return out;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public StorageChannel getChannel()
|
||||
{
|
||||
return StorageChannel.ITEMS;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void saveChanges( IMEInventory cellInventory )
|
||||
{
|
||||
|
||||
@@ -77,15 +77,23 @@ public class PartImportBus extends PartSharedItemBus implements IInventoryDestin
|
||||
@Override
|
||||
public boolean canInsert( ItemStack stack )
|
||||
{
|
||||
if ( stack == null || stack.getItem() == null )
|
||||
if( stack == null || stack.getItem() == null )
|
||||
return false;
|
||||
|
||||
IAEItemStack out = this.destination.injectItems( this.lastItemChecked = AEApi.instance().storage().createItemStack( stack ), Actionable.SIMULATE, this.source );
|
||||
if ( out == null )
|
||||
if( out == null )
|
||||
return true;
|
||||
return out.getStackSize() != stack.stackSize;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getBoxes( IPartCollisionHelper bch )
|
||||
{
|
||||
bch.addBox( 6, 6, 11, 10, 10, 13 );
|
||||
bch.addBox( 5, 5, 13, 11, 11, 14 );
|
||||
bch.addBox( 4, 4, 14, 12, 12, 16 );
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly( Side.CLIENT )
|
||||
public void renderInventory( IPartRenderHelper rh, RenderBlocks renderer )
|
||||
@@ -125,14 +133,6 @@ public class PartImportBus extends PartSharedItemBus implements IInventoryDestin
|
||||
this.renderLights( x, y, z, rh, renderer );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getBoxes( IPartCollisionHelper bch )
|
||||
{
|
||||
bch.addBox( 6, 6, 11, 10, 10, 13 );
|
||||
bch.addBox( 5, 5, 13, 11, 11, 14 );
|
||||
bch.addBox( 4, 4, 14, 12, 12, 16 );
|
||||
}
|
||||
|
||||
@Override
|
||||
public int cableConnectionRenderTo()
|
||||
{
|
||||
@@ -142,9 +142,9 @@ public class PartImportBus extends PartSharedItemBus implements IInventoryDestin
|
||||
@Override
|
||||
public boolean onPartActivate( EntityPlayer player, Vec3 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_BUS );
|
||||
@@ -169,7 +169,7 @@ public class PartImportBus extends PartSharedItemBus implements IInventoryDestin
|
||||
@Override
|
||||
TickRateModulation doBusWork()
|
||||
{
|
||||
if ( !this.proxy.isActive() )
|
||||
if( !this.proxy.isActive() )
|
||||
return TickRateModulation.IDLE;
|
||||
|
||||
this.worked = false;
|
||||
@@ -177,11 +177,11 @@ public class PartImportBus extends PartSharedItemBus implements IInventoryDestin
|
||||
InventoryAdaptor myAdaptor = this.getHandler();
|
||||
FuzzyMode fzMode = (FuzzyMode) this.getConfigManager().getSetting( Settings.FUZZY_MODE );
|
||||
|
||||
if ( myAdaptor != null )
|
||||
if( myAdaptor != null )
|
||||
{
|
||||
try
|
||||
{
|
||||
switch ( this.getInstalledUpgrades( Upgrades.SPEED ) )
|
||||
switch( this.getInstalledUpgrades( Upgrades.SPEED ) )
|
||||
{
|
||||
default:
|
||||
case 0:
|
||||
@@ -206,30 +206,30 @@ public class PartImportBus extends PartSharedItemBus implements IInventoryDestin
|
||||
IEnergyGrid energy = this.proxy.getEnergy();
|
||||
|
||||
boolean Configured = false;
|
||||
for ( int x = 0; x < this.availableSlots(); x++ )
|
||||
for( int x = 0; x < this.availableSlots(); x++ )
|
||||
{
|
||||
IAEItemStack ais = this.config.getAEStackInSlot( x );
|
||||
if ( ais != null && this.itemToSend > 0 )
|
||||
if( ais != null && this.itemToSend > 0 )
|
||||
{
|
||||
Configured = true;
|
||||
while ( this.itemToSend > 0 )
|
||||
while( this.itemToSend > 0 )
|
||||
{
|
||||
if ( this.importStuff( myAdaptor, ais, inv, energy, fzMode ) )
|
||||
if( this.importStuff( myAdaptor, ais, inv, energy, fzMode ) )
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( !Configured )
|
||||
if( !Configured )
|
||||
{
|
||||
while ( this.itemToSend > 0 )
|
||||
while( this.itemToSend > 0 )
|
||||
{
|
||||
if ( this.importStuff( myAdaptor, null, inv, energy, fzMode ) )
|
||||
if( this.importStuff( myAdaptor, null, inv, energy, fzMode ) )
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch ( GridAccessException e )
|
||||
catch( GridAccessException e )
|
||||
{
|
||||
// :3
|
||||
}
|
||||
@@ -244,28 +244,28 @@ public class PartImportBus extends PartSharedItemBus implements IInventoryDestin
|
||||
{
|
||||
int toSend = this.itemToSend;
|
||||
|
||||
if ( toSend > 64 )
|
||||
if( toSend > 64 )
|
||||
toSend = 64;
|
||||
|
||||
ItemStack newItems;
|
||||
if ( this.getInstalledUpgrades( Upgrades.FUZZY ) > 0 )
|
||||
if( this.getInstalledUpgrades( Upgrades.FUZZY ) > 0 )
|
||||
newItems = myAdaptor.removeSimilarItems( toSend, whatToImport == null ? null : whatToImport.getItemStack(), fzMode, this.configDestination( inv ) );
|
||||
else
|
||||
newItems = myAdaptor.removeItems( toSend, whatToImport == null ? null : whatToImport.getItemStack(), this.configDestination( inv ) );
|
||||
|
||||
if ( newItems != null )
|
||||
if( newItems != null )
|
||||
{
|
||||
newItems.stackSize = (int) ( Math.min( newItems.stackSize, energy.extractAEPower( newItems.stackSize, Actionable.SIMULATE, PowerMultiplier.CONFIG ) ) + 0.01 );
|
||||
this.itemToSend -= newItems.stackSize;
|
||||
|
||||
if ( this.lastItemChecked == null || !this.lastItemChecked.isSameType( newItems ) )
|
||||
if( this.lastItemChecked == null || !this.lastItemChecked.isSameType( newItems ) )
|
||||
this.lastItemChecked = AEApi.instance().storage().createItemStack( newItems );
|
||||
else
|
||||
this.lastItemChecked.setStackSize( newItems.stackSize );
|
||||
|
||||
IAEItemStack failed = Platform.poweredInsert( energy, this.destination, this.lastItemChecked, this.source );
|
||||
// destination.injectItems( lastItemChecked, Actionable.MODULATE );
|
||||
if ( failed != null )
|
||||
if( failed != null )
|
||||
{
|
||||
myAdaptor.addItems( failed.getItemStack() );
|
||||
return true;
|
||||
@@ -285,15 +285,15 @@ public class PartImportBus extends PartSharedItemBus implements IInventoryDestin
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public RedstoneMode getRSMode()
|
||||
{
|
||||
return (RedstoneMode) this.getConfigManager().getSetting( Settings.REDSTONE_CONTROLLED );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean isSleeping()
|
||||
{
|
||||
return this.getHandler() == null || super.isSleeping();
|
||||
}
|
||||
|
||||
@Override
|
||||
public RedstoneMode getRSMode()
|
||||
{
|
||||
return (RedstoneMode) this.getConfigManager().getSetting( Settings.REDSTONE_CONTROLLED );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -80,8 +80,7 @@ import appeng.tile.inventory.InvOperation;
|
||||
import appeng.util.Platform;
|
||||
|
||||
|
||||
public class PartLevelEmitter extends PartUpgradeable
|
||||
implements IEnergyWatcherHost, IStackWatcherHost, ICraftingWatcherHost, IMEMonitorHandlerReceiver<IAEItemStack>, ICraftingProvider
|
||||
public class PartLevelEmitter extends PartUpgradeable implements IEnergyWatcherHost, IStackWatcherHost, ICraftingWatcherHost, IMEMonitorHandlerReceiver<IAEItemStack>, ICraftingProvider
|
||||
{
|
||||
|
||||
final int FLAG_ON = 4;
|
||||
@@ -120,7 +119,7 @@ public class PartLevelEmitter extends PartUpgradeable
|
||||
public void setReportingValue( long v )
|
||||
{
|
||||
this.reportingValue = v;
|
||||
if ( this.getConfigManager().getSetting( Settings.LEVEL_TYPE ) == LevelType.ENERGY_LEVEL )
|
||||
if( this.getConfigManager().getSetting( Settings.LEVEL_TYPE ) == LevelType.ENERGY_LEVEL )
|
||||
this.configureWatchers();
|
||||
else
|
||||
this.updateState();
|
||||
@@ -135,7 +134,7 @@ public class PartLevelEmitter extends PartUpgradeable
|
||||
private void updateState()
|
||||
{
|
||||
boolean isOn = this.isLevelEmitterOn();
|
||||
if ( this.prevState != isOn )
|
||||
if( this.prevState != isOn )
|
||||
{
|
||||
this.host.markForUpdate();
|
||||
TileEntity te = this.host.getTile();
|
||||
@@ -147,23 +146,23 @@ public class PartLevelEmitter extends PartUpgradeable
|
||||
|
||||
private boolean isLevelEmitterOn()
|
||||
{
|
||||
if ( Platform.isClient() )
|
||||
if( Platform.isClient() )
|
||||
{
|
||||
return ( this.clientFlags & this.FLAG_ON ) == this.FLAG_ON;
|
||||
}
|
||||
|
||||
if ( !this.proxy.isActive() )
|
||||
if( !this.proxy.isActive() )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if ( this.getInstalledUpgrades( Upgrades.CRAFTING ) > 0 )
|
||||
if( this.getInstalledUpgrades( Upgrades.CRAFTING ) > 0 )
|
||||
{
|
||||
try
|
||||
{
|
||||
return this.proxy.getCrafting().isRequesting( this.config.getAEStackInSlot( 0 ) );
|
||||
}
|
||||
catch ( GridAccessException e )
|
||||
catch( GridAccessException e )
|
||||
{
|
||||
// :P
|
||||
}
|
||||
@@ -206,41 +205,40 @@ public class PartLevelEmitter extends PartUpgradeable
|
||||
this.updateState();
|
||||
}
|
||||
|
||||
|
||||
// update the system...
|
||||
public void configureWatchers()
|
||||
{
|
||||
IAEItemStack myStack = this.config.getAEStackInSlot( 0 );
|
||||
|
||||
if ( this.myWatcher != null )
|
||||
if( this.myWatcher != null )
|
||||
this.myWatcher.clear();
|
||||
|
||||
if ( this.myEnergyWatcher != null )
|
||||
if( this.myEnergyWatcher != null )
|
||||
this.myEnergyWatcher.clear();
|
||||
|
||||
if ( this.myCraftingWatcher != null )
|
||||
if( this.myCraftingWatcher != null )
|
||||
this.myCraftingWatcher.clear();
|
||||
|
||||
try
|
||||
{
|
||||
this.proxy.getGrid().postEvent( new MENetworkCraftingPatternChange( this, this.proxy.getNode() ) );
|
||||
}
|
||||
catch ( GridAccessException e1 )
|
||||
catch( GridAccessException e1 )
|
||||
{
|
||||
// :/
|
||||
}
|
||||
|
||||
if ( this.getInstalledUpgrades( Upgrades.CRAFTING ) > 0 )
|
||||
if( this.getInstalledUpgrades( Upgrades.CRAFTING ) > 0 )
|
||||
{
|
||||
if ( this.myCraftingWatcher != null && myStack != null )
|
||||
if( this.myCraftingWatcher != null && myStack != null )
|
||||
this.myCraftingWatcher.add( myStack );
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if ( this.getConfigManager().getSetting( Settings.LEVEL_TYPE ) == LevelType.ENERGY_LEVEL )
|
||||
if( this.getConfigManager().getSetting( Settings.LEVEL_TYPE ) == LevelType.ENERGY_LEVEL )
|
||||
{
|
||||
if ( this.myEnergyWatcher != null )
|
||||
if( this.myEnergyWatcher != null )
|
||||
this.myEnergyWatcher.add( (double) this.reportingValue );
|
||||
|
||||
try
|
||||
@@ -252,7 +250,7 @@ public class PartLevelEmitter extends PartUpgradeable
|
||||
// no more item stuff..
|
||||
this.proxy.getStorage().getItemInventory().removeListener( this );
|
||||
}
|
||||
catch ( GridAccessException e )
|
||||
catch( GridAccessException e )
|
||||
{
|
||||
// :P
|
||||
}
|
||||
@@ -262,7 +260,7 @@ public class PartLevelEmitter extends PartUpgradeable
|
||||
|
||||
try
|
||||
{
|
||||
if ( this.getInstalledUpgrades( Upgrades.FUZZY ) > 0 || myStack == null )
|
||||
if( this.getInstalledUpgrades( Upgrades.FUZZY ) > 0 || myStack == null )
|
||||
{
|
||||
this.proxy.getStorage().getItemInventory().addListener( this, this.proxy.getGrid() );
|
||||
}
|
||||
@@ -270,41 +268,40 @@ public class PartLevelEmitter extends PartUpgradeable
|
||||
{
|
||||
this.proxy.getStorage().getItemInventory().removeListener( this );
|
||||
|
||||
if ( this.myWatcher != null )
|
||||
if( this.myWatcher != null )
|
||||
this.myWatcher.add( myStack );
|
||||
}
|
||||
|
||||
this.updateReportingValue( this.proxy.getStorage().getItemInventory() );
|
||||
}
|
||||
catch ( GridAccessException e )
|
||||
catch( GridAccessException e )
|
||||
{
|
||||
// >.>
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void updateReportingValue( IMEMonitor<IAEItemStack> monitor )
|
||||
{
|
||||
IAEItemStack myStack = this.config.getAEStackInSlot( 0 );
|
||||
|
||||
if ( myStack == null )
|
||||
if( myStack == null )
|
||||
{
|
||||
this.lastReportedValue = 0;
|
||||
for ( IAEItemStack st : monitor.getStorageList() )
|
||||
for( IAEItemStack st : monitor.getStorageList() )
|
||||
this.lastReportedValue += st.getStackSize();
|
||||
}
|
||||
else if ( this.getInstalledUpgrades( Upgrades.FUZZY ) > 0 )
|
||||
else if( this.getInstalledUpgrades( Upgrades.FUZZY ) > 0 )
|
||||
{
|
||||
this.lastReportedValue = 0;
|
||||
FuzzyMode fzMode = (FuzzyMode) this.getConfigManager().getSetting( Settings.FUZZY_MODE );
|
||||
Collection<IAEItemStack> fuzzyList = monitor.getStorageList().findFuzzy( myStack, fzMode );
|
||||
for ( IAEItemStack st : fuzzyList )
|
||||
for( IAEItemStack st : fuzzyList )
|
||||
this.lastReportedValue += st.getStackSize();
|
||||
}
|
||||
else
|
||||
{
|
||||
IAEItemStack r = monitor.getStorageList().findPrecise( myStack );
|
||||
if ( r == null )
|
||||
if( r == null )
|
||||
this.lastReportedValue = 0;
|
||||
else
|
||||
this.lastReportedValue = r.getStackSize();
|
||||
@@ -313,7 +310,6 @@ public class PartLevelEmitter extends PartUpgradeable
|
||||
this.updateState();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void updateWatcher( IStackWatcher newWatcher )
|
||||
{
|
||||
@@ -321,18 +317,16 @@ public class PartLevelEmitter extends PartUpgradeable
|
||||
this.configureWatchers();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onStackChange( IItemList o, IAEStack fullStack, IAEStack diffStack, BaseActionSource src, StorageChannel chan )
|
||||
{
|
||||
if ( chan == StorageChannel.ITEMS && fullStack.equals( this.config.getAEStackInSlot( 0 ) ) && this.getInstalledUpgrades( Upgrades.FUZZY ) == 0 )
|
||||
if( chan == StorageChannel.ITEMS && fullStack.equals( this.config.getAEStackInSlot( 0 ) ) && this.getInstalledUpgrades( Upgrades.FUZZY ) == 0 )
|
||||
{
|
||||
this.lastReportedValue = fullStack.getStackSize();
|
||||
this.updateState();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void updateWatcher( IEnergyWatcher newWatcher )
|
||||
{
|
||||
@@ -340,7 +334,6 @@ public class PartLevelEmitter extends PartUpgradeable
|
||||
this.configureWatchers();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onThresholdPass( IEnergyGrid energyGrid )
|
||||
{
|
||||
@@ -348,7 +341,6 @@ public class PartLevelEmitter extends PartUpgradeable
|
||||
this.updateState();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean isValid( Object effectiveGrid )
|
||||
{
|
||||
@@ -356,20 +348,18 @@ public class PartLevelEmitter extends PartUpgradeable
|
||||
{
|
||||
return this.proxy.getGrid() == effectiveGrid;
|
||||
}
|
||||
catch ( GridAccessException e )
|
||||
catch( GridAccessException e )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void postChange( IBaseMonitor<IAEItemStack> monitor, Iterable<IAEItemStack> change, BaseActionSource actionSource )
|
||||
{
|
||||
this.updateReportingValue( (IMEMonitor<IAEItemStack>) monitor );
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onListUpdate()
|
||||
{
|
||||
@@ -377,12 +367,23 @@ public class PartLevelEmitter extends PartUpgradeable
|
||||
{
|
||||
this.updateReportingValue( this.proxy.getStorage().getItemInventory() );
|
||||
}
|
||||
catch ( GridAccessException e )
|
||||
catch( GridAccessException e )
|
||||
{
|
||||
// ;P
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public AECableType getCableConnectionType( ForgeDirection dir )
|
||||
{
|
||||
return AECableType.SMART;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getBoxes( IPartCollisionHelper bch )
|
||||
{
|
||||
bch.addBox( 7, 7, 11, 9, 9, 16 );
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly( Side.CLIENT )
|
||||
@@ -396,7 +397,6 @@ public class PartLevelEmitter extends PartUpgradeable
|
||||
// rh.renderInventoryBox( renderer );
|
||||
}
|
||||
|
||||
|
||||
public void renderTorchAtAngle( double baseX, double baseY, double baseZ )
|
||||
{
|
||||
boolean isOn = this.isLevelEmitterOn();
|
||||
@@ -457,13 +457,13 @@ public class PartLevelEmitter extends PartUpgradeable
|
||||
|
||||
double toff = 0.0d;
|
||||
|
||||
if ( !isOn )
|
||||
if( !isOn )
|
||||
{
|
||||
toff = 1.0d / 16.0d;
|
||||
}
|
||||
|
||||
Tessellator var12 = Tessellator.instance;
|
||||
if ( isOn )
|
||||
if( isOn )
|
||||
{
|
||||
var12.setColorOpaque_F( 1.0F, 1.0F, 1.0F );
|
||||
var12.setBrightness( 11 << 20 | 11 << 4 );
|
||||
@@ -505,7 +505,6 @@ public class PartLevelEmitter extends PartUpgradeable
|
||||
this.addVertexWithUV( var36, baseY + 1.0D, baseZ - var44, var17, var18 );
|
||||
}
|
||||
|
||||
|
||||
public void addVertexWithUV( double x, double y, double z, double u, double v )
|
||||
{
|
||||
Tessellator var12 = Tessellator.instance;
|
||||
@@ -514,13 +513,13 @@ public class PartLevelEmitter extends PartUpgradeable
|
||||
y -= this.centerY;
|
||||
z -= this.centerZ;
|
||||
|
||||
if ( this.side == ForgeDirection.DOWN )
|
||||
if( this.side == ForgeDirection.DOWN )
|
||||
{
|
||||
y = -y;
|
||||
z = -z;
|
||||
}
|
||||
|
||||
if ( this.side == ForgeDirection.EAST )
|
||||
if( this.side == ForgeDirection.EAST )
|
||||
{
|
||||
double m = x;
|
||||
x = y;
|
||||
@@ -528,14 +527,14 @@ public class PartLevelEmitter extends PartUpgradeable
|
||||
y = -y;
|
||||
}
|
||||
|
||||
if ( this.side == ForgeDirection.WEST )
|
||||
if( this.side == ForgeDirection.WEST )
|
||||
{
|
||||
double m = x;
|
||||
x = -y;
|
||||
y = m;
|
||||
}
|
||||
|
||||
if ( this.side == ForgeDirection.SOUTH )
|
||||
if( this.side == ForgeDirection.SOUTH )
|
||||
{
|
||||
double m = z;
|
||||
z = y;
|
||||
@@ -543,7 +542,7 @@ public class PartLevelEmitter extends PartUpgradeable
|
||||
y = -y;
|
||||
}
|
||||
|
||||
if ( this.side == ForgeDirection.NORTH )
|
||||
if( this.side == ForgeDirection.NORTH )
|
||||
{
|
||||
double m = z;
|
||||
z = -y;
|
||||
@@ -557,7 +556,6 @@ public class PartLevelEmitter extends PartUpgradeable
|
||||
var12.addVertexWithUV( x, y, z, u, v );
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
@SideOnly( Side.CLIENT )
|
||||
public void renderStatic( int x, int y, int z, IPartRenderHelper rh, RenderBlocks renderer )
|
||||
@@ -587,32 +585,22 @@ public class PartLevelEmitter extends PartUpgradeable
|
||||
// super.renderWorldBlock( world, x, y, z, block, modelId, renderer );
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int isProvidingStrongPower()
|
||||
{
|
||||
return this.prevState ? 15 : 0;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int isProvidingWeakPower()
|
||||
{
|
||||
return this.prevState ? 15 : 0;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void getBoxes( IPartCollisionHelper bch )
|
||||
{
|
||||
bch.addBox( 7, 7, 11, 9, 9, 16 );
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void randomDisplayTick( World world, int x, int y, int z, Random r )
|
||||
{
|
||||
if ( this.isLevelEmitterOn() )
|
||||
if( this.isLevelEmitterOn() )
|
||||
{
|
||||
ForgeDirection d = this.side;
|
||||
|
||||
@@ -624,27 +612,18 @@ public class PartLevelEmitter extends PartUpgradeable
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public AECableType getCableConnectionType( ForgeDirection dir )
|
||||
{
|
||||
return AECableType.SMART;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int cableConnectionRenderTo()
|
||||
{
|
||||
return 16;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean onPartActivate( EntityPlayer player, Vec3 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_LEVEL_EMITTER );
|
||||
@@ -654,6 +633,26 @@ public class PartLevelEmitter extends PartUpgradeable
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateSetting( IConfigManager manager, Enum settingName, Enum newValue )
|
||||
{
|
||||
this.configureWatchers();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChangeInventory( IInventory inv, int slot, InvOperation mc, ItemStack removedStack, ItemStack newStack )
|
||||
{
|
||||
if( inv == this.config )
|
||||
this.configureWatchers();
|
||||
|
||||
super.onChangeInventory( inv, slot, mc, removedStack, newStack );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void upgradesChanged()
|
||||
{
|
||||
this.configureWatchers();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canConnectRedstone()
|
||||
@@ -661,18 +660,6 @@ public class PartLevelEmitter extends PartUpgradeable
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void writeToNBT( NBTTagCompound data )
|
||||
{
|
||||
super.writeToNBT( data );
|
||||
data.setLong( "lastReportedValue", this.lastReportedValue );
|
||||
data.setLong( "reportingValue", this.reportingValue );
|
||||
data.setBoolean( "prevState", this.prevState );
|
||||
this.config.writeToNBT( data, "config" );
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void readFromNBT( NBTTagCompound data )
|
||||
{
|
||||
@@ -683,40 +670,25 @@ public class PartLevelEmitter extends PartUpgradeable
|
||||
this.config.readFromNBT( data, "config" );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT( NBTTagCompound data )
|
||||
{
|
||||
super.writeToNBT( data );
|
||||
data.setLong( "lastReportedValue", this.lastReportedValue );
|
||||
data.setLong( "reportingValue", this.reportingValue );
|
||||
data.setBoolean( "prevState", this.prevState );
|
||||
this.config.writeToNBT( data, "config" );
|
||||
}
|
||||
|
||||
@Override
|
||||
public IInventory getInventoryByName( String name )
|
||||
{
|
||||
if ( name.equals( "config" ) )
|
||||
if( name.equals( "config" ) )
|
||||
return this.config;
|
||||
|
||||
return super.getInventoryByName( name );
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void updateSetting( IConfigManager manager, Enum settingName, Enum newValue )
|
||||
{
|
||||
this.configureWatchers();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void upgradesChanged()
|
||||
{
|
||||
this.configureWatchers();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onChangeInventory( IInventory inv, int slot, InvOperation mc, ItemStack removedStack, ItemStack newStack )
|
||||
{
|
||||
if ( inv == this.config )
|
||||
this.configureWatchers();
|
||||
|
||||
super.onChangeInventory( inv, slot, mc, removedStack, newStack );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean pushPattern( ICraftingPatternDetails patternDetails, InventoryCrafting table )
|
||||
{
|
||||
@@ -732,12 +704,12 @@ public class PartLevelEmitter extends PartUpgradeable
|
||||
@Override
|
||||
public void provideCrafting( ICraftingProviderHelper craftingTracker )
|
||||
{
|
||||
if ( this.getInstalledUpgrades( Upgrades.CRAFTING ) > 0 )
|
||||
if( this.getInstalledUpgrades( Upgrades.CRAFTING ) > 0 )
|
||||
{
|
||||
if ( this.getConfigManager().getSetting( Settings.CRAFT_VIA_REDSTONE ) == YesNo.YES )
|
||||
if( this.getConfigManager().getSetting( Settings.CRAFT_VIA_REDSTONE ) == YesNo.YES )
|
||||
{
|
||||
IAEItemStack what = this.config.getAEStackInSlot( 0 );
|
||||
if ( what != null )
|
||||
if( what != null )
|
||||
craftingTracker.setEmitable( what );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -53,10 +53,9 @@ public abstract class PartSharedItemBus extends PartUpgradeable implements IGrid
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT( net.minecraft.nbt.NBTTagCompound extra )
|
||||
public void upgradesChanged()
|
||||
{
|
||||
super.writeToNBT( extra );
|
||||
this.config.writeToNBT( extra, "config" );
|
||||
this.updateState();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -67,30 +66,31 @@ public abstract class PartSharedItemBus extends PartUpgradeable implements IGrid
|
||||
}
|
||||
|
||||
@Override
|
||||
public IInventory getInventoryByName( String name )
|
||||
public void writeToNBT( net.minecraft.nbt.NBTTagCompound extra )
|
||||
{
|
||||
if ( name.equals( "config" ) )
|
||||
return this.config;
|
||||
|
||||
return super.getInventoryByName( name );
|
||||
super.writeToNBT( extra );
|
||||
this.config.writeToNBT( extra, "config" );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void upgradesChanged()
|
||||
public IInventory getInventoryByName( String name )
|
||||
{
|
||||
this.updateState();
|
||||
if( name.equals( "config" ) )
|
||||
return this.config;
|
||||
|
||||
return super.getInventoryByName( name );
|
||||
}
|
||||
|
||||
private void updateState()
|
||||
{
|
||||
try
|
||||
{
|
||||
if ( !this.isSleeping() )
|
||||
if( !this.isSleeping() )
|
||||
this.proxy.getTick().wakeDevice( this.proxy.getNode() );
|
||||
else
|
||||
this.proxy.getTick().sleepDevice( this.proxy.getNode() );
|
||||
}
|
||||
catch ( GridAccessException e )
|
||||
catch( GridAccessException e )
|
||||
{
|
||||
// :P
|
||||
}
|
||||
@@ -103,7 +103,7 @@ public abstract class PartSharedItemBus extends PartUpgradeable implements IGrid
|
||||
|
||||
int newAdaptorHash = Platform.generateTileHash( target );
|
||||
|
||||
if ( this.adaptorHash == newAdaptorHash && newAdaptorHash != 0 )
|
||||
if( this.adaptorHash == newAdaptorHash && newAdaptorHash != 0 )
|
||||
return this.adaptor;
|
||||
|
||||
this.adaptorHash = newAdaptorHash;
|
||||
@@ -116,7 +116,7 @@ public abstract class PartSharedItemBus extends PartUpgradeable implements IGrid
|
||||
{
|
||||
World w = self.getWorldObj();
|
||||
|
||||
if ( w.getChunkProvider().chunkExists( x >> 4, z >> 4 ) )
|
||||
if( w.getChunkProvider().chunkExists( x >> 4, z >> 4 ) )
|
||||
{
|
||||
return w.getTileEntity( x, y, z );
|
||||
}
|
||||
@@ -128,10 +128,10 @@ public abstract class PartSharedItemBus extends PartUpgradeable implements IGrid
|
||||
public void onNeighborChanged()
|
||||
{
|
||||
this.updateState();
|
||||
if ( this.lastRedstone != this.host.hasRedstone( this.side ) )
|
||||
if( this.lastRedstone != this.host.hasRedstone( this.side ) )
|
||||
{
|
||||
this.lastRedstone = !this.lastRedstone;
|
||||
if ( this.lastRedstone && this.getRSMode() == RedstoneMode.SIGNAL_PULSE )
|
||||
if( this.lastRedstone && this.getRSMode() == RedstoneMode.SIGNAL_PULSE )
|
||||
this.doBusWork();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -52,6 +52,64 @@ public abstract class PartUpgradeable extends PartBasicState implements IAEAppEn
|
||||
return 4;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateSetting( IConfigManager manager, Enum settingName, Enum newValue )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChangeInventory( IInventory inv, int slot, InvOperation mc, ItemStack removedStack, ItemStack newStack )
|
||||
{
|
||||
if( inv == this.upgrades )
|
||||
{
|
||||
this.upgradesChanged();
|
||||
}
|
||||
}
|
||||
|
||||
public void upgradesChanged()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
protected boolean isSleeping()
|
||||
{
|
||||
if( this.getInstalledUpgrades( Upgrades.REDSTONE ) > 0 )
|
||||
{
|
||||
switch( this.getRSMode() )
|
||||
{
|
||||
case IGNORE:
|
||||
return false;
|
||||
|
||||
case HIGH_SIGNAL:
|
||||
if( this.host.hasRedstone( this.side ) )
|
||||
return false;
|
||||
|
||||
break;
|
||||
|
||||
case LOW_SIGNAL:
|
||||
if( !this.host.hasRedstone( this.side ) )
|
||||
return false;
|
||||
|
||||
break;
|
||||
|
||||
case SIGNAL_PULSE:
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getInstalledUpgrades( Upgrades u )
|
||||
{
|
||||
return this.upgrades.getInstalledUpgrades( u );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canConnectRedstone()
|
||||
{
|
||||
@@ -77,8 +135,8 @@ public abstract class PartUpgradeable extends PartBasicState implements IAEAppEn
|
||||
@Override
|
||||
public void getDrops( List<ItemStack> drops, boolean wrenched )
|
||||
{
|
||||
for ( ItemStack is : this.upgrades )
|
||||
if ( is != null )
|
||||
for( ItemStack is : this.upgrades )
|
||||
if( is != null )
|
||||
drops.add( is );
|
||||
}
|
||||
|
||||
@@ -91,70 +149,12 @@ public abstract class PartUpgradeable extends PartBasicState implements IAEAppEn
|
||||
@Override
|
||||
public IInventory getInventoryByName( String name )
|
||||
{
|
||||
if ( name.equals( "upgrades" ) )
|
||||
if( name.equals( "upgrades" ) )
|
||||
return this.upgrades;
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getInstalledUpgrades( Upgrades u )
|
||||
{
|
||||
return this.upgrades.getInstalledUpgrades( u );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateSetting( IConfigManager manager, Enum settingName, Enum newValue )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChangeInventory( IInventory inv, int slot, InvOperation mc, ItemStack removedStack, ItemStack newStack )
|
||||
{
|
||||
if ( inv == this.upgrades )
|
||||
{
|
||||
this.upgradesChanged();
|
||||
}
|
||||
}
|
||||
|
||||
public void upgradesChanged()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
protected boolean isSleeping()
|
||||
{
|
||||
if ( this.getInstalledUpgrades( Upgrades.REDSTONE ) > 0 )
|
||||
{
|
||||
switch ( this.getRSMode() )
|
||||
{
|
||||
case IGNORE:
|
||||
return false;
|
||||
|
||||
case HIGH_SIGNAL:
|
||||
if ( this.host.hasRedstone( this.side ) )
|
||||
return false;
|
||||
|
||||
break;
|
||||
|
||||
case LOW_SIGNAL:
|
||||
if ( !this.host.hasRedstone( this.side ) )
|
||||
return false;
|
||||
|
||||
break;
|
||||
|
||||
case SIGNAL_PULSE:
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public RedstoneMode getRSMode()
|
||||
{
|
||||
return null;
|
||||
|
||||
@@ -18,14 +18,13 @@ public class StackUpgradeInventory extends UpgradeInventory
|
||||
this.stack = stack;
|
||||
}
|
||||
|
||||
|
||||
public int getMaxInstalled( Upgrades upgrades )
|
||||
{
|
||||
int max = 0;
|
||||
|
||||
for ( ItemStack is : upgrades.getSupported().keySet() )
|
||||
for( ItemStack is : upgrades.getSupported().keySet() )
|
||||
{
|
||||
if ( Platform.isSameItem( this.stack, is ) )
|
||||
if( Platform.isSameItem( this.stack, is ) )
|
||||
{
|
||||
max = upgrades.getSupported().get( is );
|
||||
break;
|
||||
|
||||
@@ -66,13 +66,13 @@ public abstract class UpgradeInventory extends AppEngInternalInventory implement
|
||||
@Override
|
||||
public boolean isItemValidForSlot( int i, ItemStack itemstack )
|
||||
{
|
||||
if ( itemstack == null )
|
||||
if( itemstack == null )
|
||||
return false;
|
||||
Item it = itemstack.getItem();
|
||||
if ( it instanceof IUpgradeModule )
|
||||
if( it instanceof IUpgradeModule )
|
||||
{
|
||||
Upgrades u = ( (IUpgradeModule) it ).getType( itemstack );
|
||||
if ( u != null )
|
||||
if( u != null )
|
||||
{
|
||||
return this.getInstalledUpgrades( u ) < this.getMaxInstalled( u );
|
||||
}
|
||||
@@ -82,10 +82,10 @@ public abstract class UpgradeInventory extends AppEngInternalInventory implement
|
||||
|
||||
public int getInstalledUpgrades( Upgrades u )
|
||||
{
|
||||
if ( !this.cached )
|
||||
if( !this.cached )
|
||||
this.updateUpgradeInfo();
|
||||
|
||||
switch ( u )
|
||||
switch( u )
|
||||
{
|
||||
case CAPACITY:
|
||||
return this.capacityUpgrades;
|
||||
@@ -111,13 +111,13 @@ public abstract class UpgradeInventory extends AppEngInternalInventory implement
|
||||
this.cached = true;
|
||||
this.inverterUpgrades = this.capacityUpgrades = this.redstoneUpgrades = this.speedUpgrades = this.fuzzyUpgrades = this.craftingUpgrades = 0;
|
||||
|
||||
for ( ItemStack is : this )
|
||||
for( ItemStack is : this )
|
||||
{
|
||||
if ( is == null || is.getItem() == null || !( is.getItem() instanceof IUpgradeModule ) )
|
||||
if( is == null || is.getItem() == null || !( is.getItem() instanceof IUpgradeModule ) )
|
||||
continue;
|
||||
|
||||
Upgrades myUpgrade = ( (IUpgradeModule) is.getItem() ).getType( is );
|
||||
switch ( myUpgrade )
|
||||
switch( myUpgrade )
|
||||
{
|
||||
case CAPACITY:
|
||||
this.capacityUpgrades++;
|
||||
@@ -167,7 +167,7 @@ public abstract class UpgradeInventory extends AppEngInternalInventory implement
|
||||
public void onChangeInventory( IInventory inv, int slot, InvOperation mc, ItemStack removedStack, ItemStack newStack )
|
||||
{
|
||||
this.cached = false;
|
||||
if ( this.parent != null && Platform.isServer() )
|
||||
if( this.parent != null && Platform.isServer() )
|
||||
this.parent.onChangeInventory( inv, slot, mc, removedStack, newStack );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,12 +18,14 @@
|
||||
|
||||
package appeng.parts.layers;
|
||||
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.inventory.ISidedInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
|
||||
public class InvLayerData
|
||||
{
|
||||
|
||||
@@ -35,72 +37,74 @@ public class InvLayerData
|
||||
final private List<ISidedInventory> inventories;
|
||||
final private List<InvSot> slots;
|
||||
|
||||
public InvLayerData( int[][] a, List<ISidedInventory> b, List<InvSot> c) {
|
||||
public InvLayerData( int[][] a, List<ISidedInventory> b, List<InvSot> c )
|
||||
{
|
||||
this.sides = a;
|
||||
this.inventories = b;
|
||||
this.slots = c;
|
||||
}
|
||||
|
||||
public ItemStack decreaseStackSize( int slot, int amount )
|
||||
{
|
||||
if( this.isSlotValid( slot ) )
|
||||
return this.slots.get( slot ).decreaseStackSize( amount );
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* check if a slot index is valid, prevent crashes from bad code :)
|
||||
*
|
||||
* @param slot slot index
|
||||
*
|
||||
* @return true, if the slot exists.
|
||||
*/
|
||||
boolean isSlotValid(int slot)
|
||||
boolean isSlotValid( int slot )
|
||||
{
|
||||
return this.slots != null && slot >= 0 && slot < this.slots.size();
|
||||
}
|
||||
|
||||
public ItemStack decreaseStackSize(int slot, int amount)
|
||||
{
|
||||
if ( this.isSlotValid( slot ) )
|
||||
return this.slots.get( slot ).decreaseStackSize( amount );
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public int getSizeInventory()
|
||||
{
|
||||
if ( this.slots == null )
|
||||
if( this.slots == null )
|
||||
return 0;
|
||||
|
||||
return this.slots.size();
|
||||
}
|
||||
|
||||
public ItemStack getStackInSlot(int slot)
|
||||
public ItemStack getStackInSlot( int slot )
|
||||
{
|
||||
if ( this.isSlotValid( slot ) )
|
||||
if( this.isSlotValid( slot ) )
|
||||
return this.slots.get( slot ).getStackInSlot();
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public boolean isItemValidForSlot(int slot, ItemStack itemstack)
|
||||
public boolean isItemValidForSlot( int slot, ItemStack itemstack )
|
||||
{
|
||||
if ( this.isSlotValid( slot ) )
|
||||
if( this.isSlotValid( slot ) )
|
||||
return this.slots.get( slot ).isItemValidForSlot( itemstack );
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public void setInventorySlotContents(int slot, ItemStack itemstack)
|
||||
public void setInventorySlotContents( int slot, ItemStack itemstack )
|
||||
{
|
||||
if ( this.isSlotValid( slot ) )
|
||||
if( this.isSlotValid( slot ) )
|
||||
this.slots.get( slot ).setInventorySlotContents( itemstack );
|
||||
}
|
||||
|
||||
public boolean canExtractItem(int slot, ItemStack itemstack, int side)
|
||||
public boolean canExtractItem( int slot, ItemStack itemstack, int side )
|
||||
{
|
||||
if ( this.isSlotValid( slot ) )
|
||||
if( this.isSlotValid( slot ) )
|
||||
return this.slots.get( slot ).canExtractItem( itemstack, side );
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean canInsertItem(int slot, ItemStack itemstack, int side)
|
||||
public boolean canInsertItem( int slot, ItemStack itemstack, int side )
|
||||
{
|
||||
if ( this.isSlotValid( slot ) )
|
||||
if( this.isSlotValid( slot ) )
|
||||
return this.slots.get( slot ).canInsertItem( itemstack, side );
|
||||
|
||||
return false;
|
||||
@@ -108,18 +112,17 @@ public class InvLayerData
|
||||
|
||||
public void markDirty()
|
||||
{
|
||||
if ( this.inventories != null )
|
||||
if( this.inventories != null )
|
||||
{
|
||||
for (IInventory inv : this.inventories)
|
||||
for( IInventory inv : this.inventories )
|
||||
inv.markDirty();
|
||||
}
|
||||
}
|
||||
|
||||
public int[] getAccessibleSlotsFromSide(int side)
|
||||
public int[] getAccessibleSlotsFromSide( int side )
|
||||
{
|
||||
if ( this.sides == null || side < 0 || side > 5 )
|
||||
if( this.sides == null || side < 0 || side > 5 )
|
||||
return NULL_SIDES;
|
||||
return this.sides[side];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -18,21 +18,24 @@
|
||||
|
||||
package appeng.parts.layers;
|
||||
|
||||
|
||||
import net.minecraft.inventory.ISidedInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
|
||||
public class InvSot
|
||||
{
|
||||
|
||||
final public ISidedInventory partInv;
|
||||
final public int index;
|
||||
|
||||
public InvSot(ISidedInventory part, int slot) {
|
||||
public InvSot( ISidedInventory part, int slot )
|
||||
{
|
||||
this.partInv = part;
|
||||
this.index = slot;
|
||||
}
|
||||
|
||||
public ItemStack decreaseStackSize(int j)
|
||||
public ItemStack decreaseStackSize( int j )
|
||||
{
|
||||
return this.partInv.decrStackSize( this.index, j );
|
||||
}
|
||||
@@ -42,24 +45,23 @@ public class InvSot
|
||||
return this.partInv.getStackInSlot( this.index );
|
||||
}
|
||||
|
||||
public boolean isItemValidForSlot(ItemStack itemstack)
|
||||
public boolean isItemValidForSlot( ItemStack itemstack )
|
||||
{
|
||||
return this.partInv.isItemValidForSlot( this.index, itemstack );
|
||||
}
|
||||
|
||||
public void setInventorySlotContents(ItemStack itemstack)
|
||||
public void setInventorySlotContents( ItemStack itemstack )
|
||||
{
|
||||
this.partInv.setInventorySlotContents( this.index, itemstack );
|
||||
}
|
||||
|
||||
public boolean canExtractItem(ItemStack itemstack, int side)
|
||||
public boolean canExtractItem( ItemStack itemstack, int side )
|
||||
{
|
||||
return this.partInv.canExtractItem( this.index, itemstack, side );
|
||||
}
|
||||
|
||||
public boolean canInsertItem(ItemStack itemstack, int side)
|
||||
public boolean canInsertItem( ItemStack itemstack, int side )
|
||||
{
|
||||
return this.partInv.canInsertItem( this.index, itemstack, side );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
|
||||
package appeng.parts.layers;
|
||||
|
||||
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
import cofh.api.energy.IEnergyConnection;
|
||||
@@ -33,53 +34,52 @@ public class LayerIEnergyHandler extends LayerBase implements IEnergyHandler
|
||||
{
|
||||
|
||||
@Override
|
||||
public int receiveEnergy(ForgeDirection from, int maxReceive, boolean simulate)
|
||||
public int receiveEnergy( ForgeDirection from, int maxReceive, boolean simulate )
|
||||
{
|
||||
IPart part = this.getPart( from );
|
||||
if ( part instanceof IEnergyReceiver )
|
||||
return ((IEnergyReceiver) part).receiveEnergy( from, maxReceive, simulate );
|
||||
if( part instanceof IEnergyReceiver )
|
||||
return ( (IEnergyReceiver) part ).receiveEnergy( from, maxReceive, simulate );
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int extractEnergy(ForgeDirection from, int maxExtract, boolean simulate)
|
||||
public int extractEnergy( ForgeDirection from, int maxExtract, boolean simulate )
|
||||
{
|
||||
IPart part = this.getPart( from );
|
||||
if ( part instanceof IEnergyProvider )
|
||||
return ((IEnergyProvider) part).extractEnergy( from, maxExtract, simulate );
|
||||
if( part instanceof IEnergyProvider )
|
||||
return ( (IEnergyProvider) part ).extractEnergy( from, maxExtract, simulate );
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getEnergyStored(ForgeDirection from)
|
||||
public int getEnergyStored( ForgeDirection from )
|
||||
{
|
||||
IPart part = this.getPart( from );
|
||||
if ( part instanceof IEnergyProvider )
|
||||
return ((IEnergyProvider) part).getEnergyStored( from );
|
||||
if( part instanceof IEnergyProvider )
|
||||
return ( (IEnergyProvider) part ).getEnergyStored( from );
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxEnergyStored(ForgeDirection from)
|
||||
public int getMaxEnergyStored( ForgeDirection from )
|
||||
{
|
||||
IPart part = this.getPart( from );
|
||||
if ( part instanceof IEnergyProvider )
|
||||
return ((IEnergyProvider) part).getMaxEnergyStored( from );
|
||||
if( part instanceof IEnergyProvider )
|
||||
return ( (IEnergyProvider) part ).getMaxEnergyStored( from );
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canConnectEnergy(ForgeDirection from)
|
||||
public boolean canConnectEnergy( ForgeDirection from )
|
||||
{
|
||||
IPart part = this.getPart( from );
|
||||
if ( part instanceof IEnergyConnection )
|
||||
return ((IEnergyConnection) part).canConnectEnergy( from );
|
||||
if( part instanceof IEnergyConnection )
|
||||
return ( (IEnergyConnection) part ).canConnectEnergy( from );
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
|
||||
package appeng.parts.layers;
|
||||
|
||||
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
@@ -32,14 +33,10 @@ import appeng.api.parts.LayerBase;
|
||||
import appeng.api.parts.LayerFlags;
|
||||
import appeng.util.Platform;
|
||||
|
||||
|
||||
public class LayerIEnergySink extends LayerBase implements IEnergySink
|
||||
{
|
||||
|
||||
private boolean isInIC2()
|
||||
{
|
||||
return this.getLayerFlags().contains( LayerFlags.IC2_ENET );
|
||||
}
|
||||
|
||||
private TileEntity getEnergySinkTile()
|
||||
{
|
||||
IPartHost host = (IPartHost) this;
|
||||
@@ -48,7 +45,7 @@ public class LayerIEnergySink extends LayerBase implements IEnergySink
|
||||
|
||||
private World getEnergySinkWorld()
|
||||
{
|
||||
if ( this.getEnergySinkTile() == null )
|
||||
if( this.getEnergySinkTile() == null )
|
||||
return null;
|
||||
|
||||
return this.getEnergySinkTile().getWorldObj();
|
||||
@@ -58,7 +55,7 @@ public class LayerIEnergySink extends LayerBase implements IEnergySink
|
||||
{
|
||||
TileEntity te = this.getEnergySinkTile();
|
||||
|
||||
if ( te == null )
|
||||
if( te == null )
|
||||
return false;
|
||||
|
||||
return !te.isInvalid() && te.getWorldObj().blockExists( te.xCoord, te.yCoord, te.zCoord );
|
||||
@@ -66,13 +63,13 @@ public class LayerIEnergySink extends LayerBase implements IEnergySink
|
||||
|
||||
private void addToENet()
|
||||
{
|
||||
if ( this.getEnergySinkWorld() == null )
|
||||
if( this.getEnergySinkWorld() == null )
|
||||
return;
|
||||
|
||||
// re-add
|
||||
this.removeFromENet();
|
||||
|
||||
if ( !this.isInIC2() && Platform.isServer() && this.isTileValid() )
|
||||
if( !this.isInIC2() && Platform.isServer() && this.isTileValid() )
|
||||
{
|
||||
this.getLayerFlags().add( LayerFlags.IC2_ENET );
|
||||
MinecraftForge.EVENT_BUS.post( new ic2.api.energy.event.EnergyTileLoadEvent( (IEnergySink) this.getEnergySinkTile() ) );
|
||||
@@ -81,10 +78,10 @@ public class LayerIEnergySink extends LayerBase implements IEnergySink
|
||||
|
||||
private void removeFromENet()
|
||||
{
|
||||
if ( this.getEnergySinkWorld() == null )
|
||||
if( this.getEnergySinkWorld() == null )
|
||||
return;
|
||||
|
||||
if ( this.isInIC2() && Platform.isServer() )
|
||||
if( this.isInIC2() && Platform.isServer() )
|
||||
{
|
||||
this.getLayerFlags().remove( LayerFlags.IC2_ENET );
|
||||
MinecraftForge.EVENT_BUS.post( new ic2.api.energy.event.EnergyTileUnloadEvent( (IEnergySink) this.getEnergySinkTile() ) );
|
||||
@@ -93,14 +90,14 @@ public class LayerIEnergySink extends LayerBase implements IEnergySink
|
||||
|
||||
private boolean interestedInIC2()
|
||||
{
|
||||
if ( !((IPartHost) this).isInWorld() )
|
||||
if( !( (IPartHost) this ).isInWorld() )
|
||||
return false;
|
||||
|
||||
int interested = 0;
|
||||
for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS)
|
||||
for( ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS )
|
||||
{
|
||||
IPart part = this.getPart( dir );
|
||||
if ( part instanceof IEnergyTile )
|
||||
if( part instanceof IEnergyTile )
|
||||
{
|
||||
interested++;
|
||||
}
|
||||
@@ -113,67 +110,71 @@ public class LayerIEnergySink extends LayerBase implements IEnergySink
|
||||
{
|
||||
super.partChanged();
|
||||
|
||||
if ( this.interestedInIC2() )
|
||||
if( this.interestedInIC2() )
|
||||
this.addToENet();
|
||||
else
|
||||
this.removeFromENet();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean acceptsEnergyFrom(TileEntity emitter, ForgeDirection direction)
|
||||
public boolean acceptsEnergyFrom( TileEntity emitter, ForgeDirection direction )
|
||||
{
|
||||
if ( !this.isInIC2() )
|
||||
if( !this.isInIC2() )
|
||||
return false;
|
||||
|
||||
IPart part = this.getPart( direction );
|
||||
if ( part instanceof IEnergySink )
|
||||
return ((IEnergySink) part).acceptsEnergyFrom( emitter, direction );
|
||||
if( part instanceof IEnergySink )
|
||||
return ( (IEnergySink) part ).acceptsEnergyFrom( emitter, direction );
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean isInIC2()
|
||||
{
|
||||
return this.getLayerFlags().contains( LayerFlags.IC2_ENET );
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getDemandedEnergy()
|
||||
{
|
||||
if ( !this.isInIC2() )
|
||||
if( !this.isInIC2() )
|
||||
return 0;
|
||||
|
||||
// this is a flawed implementation, that requires a change to the IC2 API.
|
||||
|
||||
for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS)
|
||||
for( ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS )
|
||||
{
|
||||
IPart part = this.getPart( dir );
|
||||
if ( part instanceof IEnergySink )
|
||||
if( part instanceof IEnergySink )
|
||||
{
|
||||
// use lower number cause ic2 deletes power it sends that isn't received.
|
||||
return ((IEnergySink) part).getDemandedEnergy();
|
||||
return ( (IEnergySink) part ).getDemandedEnergy();
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double injectEnergy(ForgeDirection directionFrom, double amount, double voltage)
|
||||
{
|
||||
if ( !this.isInIC2() )
|
||||
return amount;
|
||||
|
||||
for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS)
|
||||
{
|
||||
IPart part = this.getPart( dir );
|
||||
if ( part instanceof IEnergySink )
|
||||
{
|
||||
return ((IEnergySink) part).injectEnergy( directionFrom, amount, voltage );
|
||||
}
|
||||
}
|
||||
|
||||
return amount;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSinkTier()
|
||||
{
|
||||
return Integer.MAX_VALUE; // no real options here...
|
||||
}
|
||||
|
||||
@Override
|
||||
public double injectEnergy( ForgeDirection directionFrom, double amount, double voltage )
|
||||
{
|
||||
if( !this.isInIC2() )
|
||||
return amount;
|
||||
|
||||
for( ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS )
|
||||
{
|
||||
IPart part = this.getPart( dir );
|
||||
if( part instanceof IEnergySink )
|
||||
{
|
||||
return ( (IEnergySink) part ).injectEnergy( directionFrom, amount, voltage );
|
||||
}
|
||||
}
|
||||
|
||||
return amount;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
|
||||
package appeng.parts.layers;
|
||||
|
||||
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
@@ -34,14 +35,10 @@ import appeng.api.parts.LayerBase;
|
||||
import appeng.api.parts.LayerFlags;
|
||||
import appeng.util.Platform;
|
||||
|
||||
|
||||
public class LayerIEnergySource extends LayerBase implements IEnergySource
|
||||
{
|
||||
|
||||
private boolean isInIC2()
|
||||
{
|
||||
return this.getLayerFlags().contains( LayerFlags.IC2_ENET );
|
||||
}
|
||||
|
||||
private TileEntity getEnergySourceTile()
|
||||
{
|
||||
IPartHost host = (IPartHost) this;
|
||||
@@ -50,7 +47,7 @@ public class LayerIEnergySource extends LayerBase implements IEnergySource
|
||||
|
||||
private World getEnergySourceWorld()
|
||||
{
|
||||
if ( this.getEnergySourceTile() == null )
|
||||
if( this.getEnergySourceTile() == null )
|
||||
return null;
|
||||
return this.getEnergySourceTile().getWorldObj();
|
||||
}
|
||||
@@ -58,20 +55,20 @@ public class LayerIEnergySource extends LayerBase implements IEnergySource
|
||||
private boolean isTileValid()
|
||||
{
|
||||
TileEntity te = this.getEnergySourceTile();
|
||||
if ( te == null )
|
||||
if( te == null )
|
||||
return false;
|
||||
return !te.isInvalid();
|
||||
}
|
||||
|
||||
private void addToENet()
|
||||
{
|
||||
if ( this.getEnergySourceWorld() == null )
|
||||
if( this.getEnergySourceWorld() == null )
|
||||
return;
|
||||
|
||||
// re-add
|
||||
this.removeFromENet();
|
||||
|
||||
if ( !this.isInIC2() && Platform.isServer() && this.isTileValid() )
|
||||
if( !this.isInIC2() && Platform.isServer() && this.isTileValid() )
|
||||
{
|
||||
this.getLayerFlags().add( LayerFlags.IC2_ENET );
|
||||
MinecraftForge.EVENT_BUS.post( new ic2.api.energy.event.EnergyTileLoadEvent( (IEnergySink) this.getEnergySourceTile() ) );
|
||||
@@ -80,10 +77,10 @@ public class LayerIEnergySource extends LayerBase implements IEnergySource
|
||||
|
||||
private void removeFromENet()
|
||||
{
|
||||
if ( this.getEnergySourceWorld() == null )
|
||||
if( this.getEnergySourceWorld() == null )
|
||||
return;
|
||||
|
||||
if ( this.isInIC2() && Platform.isServer() )
|
||||
if( this.isInIC2() && Platform.isServer() )
|
||||
{
|
||||
this.getLayerFlags().remove( LayerFlags.IC2_ENET );
|
||||
MinecraftForge.EVENT_BUS.post( new ic2.api.energy.event.EnergyTileUnloadEvent( (IEnergySink) this.getEnergySourceTile() ) );
|
||||
@@ -92,14 +89,14 @@ public class LayerIEnergySource extends LayerBase implements IEnergySource
|
||||
|
||||
private boolean interestedInIC2()
|
||||
{
|
||||
if ( !((IPartHost) this).isInWorld() )
|
||||
if( !( (IPartHost) this ).isInWorld() )
|
||||
return false;
|
||||
|
||||
int interested = 0;
|
||||
for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS)
|
||||
for( ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS )
|
||||
{
|
||||
IPart part = this.getPart( dir );
|
||||
if ( part instanceof IEnergyTile )
|
||||
if( part instanceof IEnergyTile )
|
||||
{
|
||||
interested++;
|
||||
}
|
||||
@@ -112,39 +109,44 @@ public class LayerIEnergySource extends LayerBase implements IEnergySource
|
||||
{
|
||||
super.partChanged();
|
||||
|
||||
if ( this.interestedInIC2() )
|
||||
if( this.interestedInIC2() )
|
||||
this.addToENet();
|
||||
else
|
||||
this.removeFromENet();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean emitsEnergyTo(TileEntity receiver, ForgeDirection direction)
|
||||
public boolean emitsEnergyTo( TileEntity receiver, ForgeDirection direction )
|
||||
{
|
||||
if ( !this.isInIC2() )
|
||||
if( !this.isInIC2() )
|
||||
return false;
|
||||
|
||||
IPart part = this.getPart( direction );
|
||||
if ( part instanceof IEnergySink )
|
||||
return ((IEnergyEmitter) part).emitsEnergyTo( receiver, direction );
|
||||
if( part instanceof IEnergySink )
|
||||
return ( (IEnergyEmitter) part ).emitsEnergyTo( receiver, direction );
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean isInIC2()
|
||||
{
|
||||
return this.getLayerFlags().contains( LayerFlags.IC2_ENET );
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getOfferedEnergy()
|
||||
{
|
||||
if ( !this.isInIC2() )
|
||||
if( !this.isInIC2() )
|
||||
return 0;
|
||||
|
||||
// this is a flawed implementation, that requires a change to the IC2 API.
|
||||
|
||||
for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS)
|
||||
for( ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS )
|
||||
{
|
||||
IPart part = this.getPart( dir );
|
||||
if ( part instanceof IEnergySource )
|
||||
if( part instanceof IEnergySource )
|
||||
{
|
||||
// use lower number cause ic2 deletes power it sends that isn't received.
|
||||
return ((IEnergySource) part).getOfferedEnergy();
|
||||
return ( (IEnergySource) part ).getOfferedEnergy();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -152,16 +154,16 @@ public class LayerIEnergySource extends LayerBase implements IEnergySource
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawEnergy(double amount)
|
||||
public void drawEnergy( double amount )
|
||||
{
|
||||
// this is a flawed implementation, that requires a change to the IC2 API.
|
||||
|
||||
for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS)
|
||||
for( ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS )
|
||||
{
|
||||
IPart part = this.getPart( dir );
|
||||
if ( part instanceof IEnergySource )
|
||||
if( part instanceof IEnergySource )
|
||||
{
|
||||
((IEnergySource) part).drawEnergy( amount );
|
||||
( (IEnergySource) part ).drawEnergy( amount );
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -172,16 +174,15 @@ public class LayerIEnergySource extends LayerBase implements IEnergySource
|
||||
{
|
||||
// this is a flawed implementation, that requires a change to the IC2 API.
|
||||
|
||||
for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS)
|
||||
for( ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS )
|
||||
{
|
||||
IPart part = this.getPart( dir );
|
||||
if ( part instanceof IEnergySource )
|
||||
if( part instanceof IEnergySource )
|
||||
{
|
||||
return ((IEnergySource) part).getSourceTier();
|
||||
return ( (IEnergySource) part ).getSourceTier();
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
|
||||
package appeng.parts.layers;
|
||||
|
||||
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.FluidTankInfo;
|
||||
@@ -26,63 +27,63 @@ import net.minecraftforge.fluids.IFluidHandler;
|
||||
import appeng.api.parts.IPart;
|
||||
import appeng.api.parts.LayerBase;
|
||||
|
||||
|
||||
public class LayerIFluidHandler extends LayerBase implements IFluidHandler
|
||||
{
|
||||
|
||||
static final FluidTankInfo[] EMPTY_LIST = new FluidTankInfo[0];
|
||||
|
||||
@Override
|
||||
public int fill(ForgeDirection from, FluidStack resource, boolean doFill)
|
||||
public int fill( ForgeDirection from, FluidStack resource, boolean doFill )
|
||||
{
|
||||
IPart part = this.getPart( from );
|
||||
if ( part instanceof IFluidHandler )
|
||||
return ((IFluidHandler) part).fill( from, resource, doFill );
|
||||
if( part instanceof IFluidHandler )
|
||||
return ( (IFluidHandler) part ).fill( from, resource, doFill );
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidStack drain(ForgeDirection from, FluidStack resource, boolean doDrain)
|
||||
public FluidStack drain( ForgeDirection from, FluidStack resource, boolean doDrain )
|
||||
{
|
||||
IPart part = this.getPart( from );
|
||||
if ( part instanceof IFluidHandler )
|
||||
return ((IFluidHandler) part).drain( from, resource, doDrain );
|
||||
if( part instanceof IFluidHandler )
|
||||
return ( (IFluidHandler) part ).drain( from, resource, doDrain );
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidStack drain(ForgeDirection from, int maxDrain, boolean doDrain)
|
||||
public FluidStack drain( ForgeDirection from, int maxDrain, boolean doDrain )
|
||||
{
|
||||
IPart part = this.getPart( from );
|
||||
if ( part instanceof IFluidHandler )
|
||||
return ((IFluidHandler) part).drain( from, maxDrain, doDrain );
|
||||
if( part instanceof IFluidHandler )
|
||||
return ( (IFluidHandler) part ).drain( from, maxDrain, doDrain );
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canFill(ForgeDirection from, net.minecraftforge.fluids.Fluid fluid)
|
||||
public boolean canFill( ForgeDirection from, net.minecraftforge.fluids.Fluid fluid )
|
||||
{
|
||||
IPart part = this.getPart( from );
|
||||
if ( part instanceof IFluidHandler )
|
||||
return ((IFluidHandler) part).canFill( from, fluid );
|
||||
if( part instanceof IFluidHandler )
|
||||
return ( (IFluidHandler) part ).canFill( from, fluid );
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canDrain(ForgeDirection from, net.minecraftforge.fluids.Fluid fluid)
|
||||
public boolean canDrain( ForgeDirection from, net.minecraftforge.fluids.Fluid fluid )
|
||||
{
|
||||
IPart part = this.getPart( from );
|
||||
if ( part instanceof IFluidHandler )
|
||||
return ((IFluidHandler) part).canDrain( from, fluid );
|
||||
if( part instanceof IFluidHandler )
|
||||
return ( (IFluidHandler) part ).canDrain( from, fluid );
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidTankInfo[] getTankInfo(ForgeDirection from)
|
||||
public FluidTankInfo[] getTankInfo( ForgeDirection from )
|
||||
{
|
||||
IPart part = this.getPart( from );
|
||||
if ( part instanceof IFluidHandler )
|
||||
return ((IFluidHandler) part).getTankInfo( from );
|
||||
if( part instanceof IFluidHandler )
|
||||
return ( (IFluidHandler) part ).getTankInfo( from );
|
||||
return EMPTY_LIST;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
|
||||
package appeng.parts.layers;
|
||||
|
||||
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
import buildcraft.api.transport.IPipeConnection;
|
||||
@@ -26,16 +27,16 @@ import buildcraft.api.transport.IPipeTile.PipeType;
|
||||
import appeng.api.parts.IPart;
|
||||
import appeng.api.parts.LayerBase;
|
||||
|
||||
|
||||
public class LayerIPipeConnection extends LayerBase implements IPipeConnection
|
||||
{
|
||||
|
||||
@Override
|
||||
public ConnectOverride overridePipeConnection(PipeType type, ForgeDirection with)
|
||||
public ConnectOverride overridePipeConnection( PipeType type, ForgeDirection with )
|
||||
{
|
||||
IPart part = this.getPart( with );
|
||||
if ( part instanceof IPipeConnection )
|
||||
return ((IPipeConnection) part).overridePipeConnection( type, with );
|
||||
if( part instanceof IPipeConnection )
|
||||
return ( (IPipeConnection) part ).overridePipeConnection( type, with );
|
||||
return ConnectOverride.DEFAULT;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
|
||||
package appeng.parts.layers;
|
||||
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
@@ -32,6 +33,7 @@ import appeng.api.parts.IPart;
|
||||
import appeng.api.parts.IPartHost;
|
||||
import appeng.api.parts.LayerBase;
|
||||
|
||||
|
||||
/**
|
||||
* Inventory wrapper for parts,
|
||||
*
|
||||
@@ -64,10 +66,10 @@ public class LayerISidedInventory extends LayerBase implements ISidedInventory
|
||||
inventories = new ArrayList<ISidedInventory>();
|
||||
int slotCount = 0;
|
||||
|
||||
for (ForgeDirection side : ForgeDirection.VALID_DIRECTIONS)
|
||||
for( ForgeDirection side : ForgeDirection.VALID_DIRECTIONS )
|
||||
{
|
||||
IPart bp = this.getPart( side );
|
||||
if ( bp instanceof ISidedInventory )
|
||||
if( bp instanceof ISidedInventory )
|
||||
{
|
||||
ISidedInventory part = (ISidedInventory) bp;
|
||||
slotCount += part.getSizeInventory();
|
||||
@@ -75,7 +77,7 @@ public class LayerISidedInventory extends LayerBase implements ISidedInventory
|
||||
}
|
||||
}
|
||||
|
||||
if ( inventories.isEmpty() || slotCount == 0 )
|
||||
if( inventories.isEmpty() || slotCount == 0 )
|
||||
{
|
||||
inventories = null;
|
||||
}
|
||||
@@ -86,21 +88,21 @@ public class LayerISidedInventory extends LayerBase implements ISidedInventory
|
||||
|
||||
int offsetForLayer = 0;
|
||||
int offsetForPart = 0;
|
||||
for (ISidedInventory sides : inventories)
|
||||
for( ISidedInventory sides : inventories )
|
||||
{
|
||||
offsetForPart = 0;
|
||||
slotCount = sides.getSizeInventory();
|
||||
|
||||
ForgeDirection currentSide = ForgeDirection.UNKNOWN;
|
||||
for (ForgeDirection side : ForgeDirection.VALID_DIRECTIONS)
|
||||
if ( this.getPart( side ) == sides )
|
||||
for( ForgeDirection side : ForgeDirection.VALID_DIRECTIONS )
|
||||
if( this.getPart( side ) == sides )
|
||||
{
|
||||
currentSide = side;
|
||||
break;
|
||||
}
|
||||
|
||||
int[] cSidesList = sideData[currentSide.ordinal()] = new int[slotCount];
|
||||
for (int cSlot = 0; cSlot < slotCount; cSlot++)
|
||||
for( int cSlot = 0; cSlot < slotCount; cSlot++ )
|
||||
{
|
||||
cSidesList[cSlot] = offsetForLayer;
|
||||
slots.set( offsetForLayer, new InvSot( sides, offsetForPart ) );
|
||||
@@ -110,7 +112,7 @@ public class LayerISidedInventory extends LayerBase implements ISidedInventory
|
||||
}
|
||||
}
|
||||
|
||||
if ( sideData == null || slots == null )
|
||||
if( sideData == null || slots == null )
|
||||
this.invLayer = null;
|
||||
else
|
||||
this.invLayer = new InvLayerData( sideData, inventories, slots );
|
||||
@@ -119,93 +121,48 @@ public class LayerISidedInventory extends LayerBase implements ISidedInventory
|
||||
super.notifyNeighbors();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack decrStackSize(int slot, int amount)
|
||||
{
|
||||
if ( this.invLayer == null )
|
||||
return null;
|
||||
|
||||
return this.invLayer.decreaseStackSize( slot, amount );
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSizeInventory()
|
||||
{
|
||||
if ( this.invLayer == null )
|
||||
if( this.invLayer == null )
|
||||
return 0;
|
||||
|
||||
return this.invLayer.getSizeInventory();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getStackInSlot(int slot)
|
||||
public ItemStack getStackInSlot( int slot )
|
||||
{
|
||||
if ( this.invLayer == null )
|
||||
if( this.invLayer == null )
|
||||
return null;
|
||||
|
||||
return this.invLayer.getStackInSlot( slot );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isItemValidForSlot(int slot, ItemStack itemstack)
|
||||
public ItemStack decrStackSize( int slot, int amount )
|
||||
{
|
||||
if ( this.invLayer == null )
|
||||
return false;
|
||||
if( this.invLayer == null )
|
||||
return null;
|
||||
|
||||
return this.invLayer.isItemValidForSlot( slot, itemstack );
|
||||
return this.invLayer.decreaseStackSize( slot, amount );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setInventorySlotContents(int slot, ItemStack itemstack)
|
||||
public ItemStack getStackInSlotOnClosing( int slot )
|
||||
{
|
||||
if ( this.invLayer == null )
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setInventorySlotContents( int slot, ItemStack itemstack )
|
||||
{
|
||||
if( this.invLayer == null )
|
||||
return;
|
||||
|
||||
this.invLayer.setInventorySlotContents( slot, itemstack );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canExtractItem(int slot, ItemStack itemstack, int side)
|
||||
{
|
||||
if ( this.invLayer == null )
|
||||
return false;
|
||||
|
||||
return this.invLayer.canExtractItem( slot, itemstack, side );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canInsertItem(int slot, ItemStack itemstack, int side)
|
||||
{
|
||||
if ( this.invLayer == null )
|
||||
return false;
|
||||
|
||||
return this.invLayer.canInsertItem( slot, itemstack, side );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void markDirty()
|
||||
{
|
||||
if ( this.invLayer != null )
|
||||
this.invLayer.markDirty();
|
||||
|
||||
super.markForSave();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int[] getAccessibleSlotsFromSide(int side)
|
||||
{
|
||||
if ( this.invLayer != null )
|
||||
return this.invLayer.getAccessibleSlotsFromSide( side );
|
||||
|
||||
return NULL_SIDES;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getInventoryStackLimit()
|
||||
{
|
||||
return 64; // no options here.
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getInventoryName()
|
||||
{
|
||||
@@ -219,24 +176,69 @@ public class LayerISidedInventory extends LayerBase implements ISidedInventory
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getStackInSlotOnClosing(int slot)
|
||||
public int getInventoryStackLimit()
|
||||
{
|
||||
return null;
|
||||
return 64; // no options here.
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isUseableByPlayer(EntityPlayer entityplayer)
|
||||
public boolean isUseableByPlayer( EntityPlayer entityplayer )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void openInventory()
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void closeInventory()
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void openInventory()
|
||||
public boolean isItemValidForSlot( int slot, ItemStack itemstack )
|
||||
{
|
||||
if( this.invLayer == null )
|
||||
return false;
|
||||
|
||||
return this.invLayer.isItemValidForSlot( slot, itemstack );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void markDirty()
|
||||
{
|
||||
if( this.invLayer != null )
|
||||
this.invLayer.markDirty();
|
||||
|
||||
super.markForSave();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int[] getAccessibleSlotsFromSide( int side )
|
||||
{
|
||||
if( this.invLayer != null )
|
||||
return this.invLayer.getAccessibleSlotsFromSide( side );
|
||||
|
||||
return NULL_SIDES;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canInsertItem( int slot, ItemStack itemstack, int side )
|
||||
{
|
||||
if( this.invLayer == null )
|
||||
return false;
|
||||
|
||||
return this.invLayer.canInsertItem( slot, itemstack, side );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canExtractItem( int slot, ItemStack itemstack, int side )
|
||||
{
|
||||
if( this.invLayer == null )
|
||||
return false;
|
||||
|
||||
return this.invLayer.canExtractItem( slot, itemstack, side );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
|
||||
package appeng.parts.layers;
|
||||
|
||||
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
import appeng.api.implementations.tiles.ITileStorageMonitorable;
|
||||
@@ -26,16 +27,16 @@ import appeng.api.parts.IPart;
|
||||
import appeng.api.parts.LayerBase;
|
||||
import appeng.api.storage.IStorageMonitorable;
|
||||
|
||||
|
||||
public class LayerITileStorageMonitorable extends LayerBase implements ITileStorageMonitorable
|
||||
{
|
||||
|
||||
@Override
|
||||
public IStorageMonitorable getMonitorable(ForgeDirection side, BaseActionSource src)
|
||||
public IStorageMonitorable getMonitorable( ForgeDirection side, BaseActionSource src )
|
||||
{
|
||||
IPart part = this.getPart( side );
|
||||
if ( part instanceof ITileStorageMonitorable )
|
||||
return ((ITileStorageMonitorable) part).getMonitorable( side, src );
|
||||
if( part instanceof ITileStorageMonitorable )
|
||||
return ( (ITileStorageMonitorable) part ).getMonitorable( side, src );
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
|
||||
package appeng.parts.misc;
|
||||
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
@@ -48,6 +49,7 @@ import appeng.api.parts.IPartRenderHelper;
|
||||
import appeng.api.parts.ISimplifiedBundle;
|
||||
import appeng.api.parts.PartItemStack;
|
||||
|
||||
|
||||
public class PartCableAnchor implements IPart
|
||||
{
|
||||
|
||||
@@ -56,35 +58,29 @@ public class PartCableAnchor implements IPart
|
||||
IPartHost host = null;
|
||||
ForgeDirection mySide = ForgeDirection.UP;
|
||||
|
||||
public PartCableAnchor(ItemStack is) {
|
||||
public PartCableAnchor( ItemStack is )
|
||||
{
|
||||
this.is = is;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void renderStatic(int x, int y, int z, IPartRenderHelper rh, RenderBlocks renderer)
|
||||
public void getBoxes( IPartCollisionHelper bch )
|
||||
{
|
||||
this.renderCache = rh.useSimplifiedRendering( x, y, z, this, this.renderCache );
|
||||
IIcon myIcon = this.is.getIconIndex();
|
||||
rh.setTexture( myIcon );
|
||||
if ( this.host != null && this.host.getFacadeContainer().getFacade( this.mySide ) != null )
|
||||
rh.setBounds( 7, 7, 10, 9, 9, 14 );
|
||||
if( this.host != null && this.host.getFacadeContainer().getFacade( this.mySide ) != null )
|
||||
bch.addBox( 7, 7, 10, 9, 9, 14 );
|
||||
else
|
||||
rh.setBounds( 7, 7, 10, 9, 9, 16 );
|
||||
rh.renderBlock( x, y, z, renderer );
|
||||
rh.setTexture( null );
|
||||
bch.addBox( 7, 7, 10, 9, 9, 16 );
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void randomDisplayTick(World world, int x, int y, int z, Random r)
|
||||
public ItemStack getItemStack( PartItemStack wrenched )
|
||||
{
|
||||
|
||||
return this.is;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void renderInventory(IPartRenderHelper instance, RenderBlocks renderer)
|
||||
@SideOnly( Side.CLIENT )
|
||||
public void renderInventory( IPartRenderHelper instance, RenderBlocks renderer )
|
||||
{
|
||||
instance.setTexture( this.is.getIconIndex() );
|
||||
instance.setBounds( 7, 7, 4, 9, 9, 14 );
|
||||
@@ -93,18 +89,31 @@ public class PartCableAnchor implements IPart
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getBoxes(IPartCollisionHelper bch)
|
||||
@SideOnly( Side.CLIENT )
|
||||
public void renderStatic( int x, int y, int z, IPartRenderHelper rh, RenderBlocks renderer )
|
||||
{
|
||||
if ( this.host != null && this.host.getFacadeContainer().getFacade( this.mySide ) != null )
|
||||
bch.addBox( 7, 7, 10, 9, 9, 14 );
|
||||
this.renderCache = rh.useSimplifiedRendering( x, y, z, this, this.renderCache );
|
||||
IIcon myIcon = this.is.getIconIndex();
|
||||
rh.setTexture( myIcon );
|
||||
if( this.host != null && this.host.getFacadeContainer().getFacade( this.mySide ) != null )
|
||||
rh.setBounds( 7, 7, 10, 9, 9, 14 );
|
||||
else
|
||||
bch.addBox( 7, 7, 10, 9, 9, 16 );
|
||||
rh.setBounds( 7, 7, 10, 9, 9, 16 );
|
||||
rh.renderBlock( x, y, z, renderer );
|
||||
rh.setTexture( null );
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getItemStack(PartItemStack wrenched)
|
||||
@SideOnly( Side.CLIENT )
|
||||
public void renderDynamic( double x, double y, double z, IPartRenderHelper rh, RenderBlocks renderer )
|
||||
{
|
||||
return this.is;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public IIcon getBreakingTexture()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -113,13 +122,6 @@ public class PartCableAnchor implements IPart
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void renderDynamic(double x, double y, double z, IPartRenderHelper rh, RenderBlocks renderer)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSolid()
|
||||
{
|
||||
@@ -133,13 +135,13 @@ public class PartCableAnchor implements IPart
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT(NBTTagCompound data)
|
||||
public void writeToNBT( NBTTagCompound data )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound data)
|
||||
public void readFromNBT( NBTTagCompound data )
|
||||
{
|
||||
|
||||
}
|
||||
@@ -150,6 +152,12 @@ public class PartCableAnchor implements IPart
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isLadder( EntityLivingBase entity )
|
||||
{
|
||||
return this.mySide.offsetY == 0 && ( entity.isCollidedHorizontally || !entity.onGround );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNeighborChanged()
|
||||
{
|
||||
@@ -169,13 +177,13 @@ public class PartCableAnchor implements IPart
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToStream(ByteBuf data) throws IOException
|
||||
public void writeToStream( ByteBuf data ) throws IOException
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean readFromStream(ByteBuf data) throws IOException
|
||||
public boolean readFromStream( ByteBuf data ) throws IOException
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@@ -187,7 +195,7 @@ public class PartCableAnchor implements IPart
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEntityCollision(Entity entity)
|
||||
public void onEntityCollision( Entity entity )
|
||||
{
|
||||
|
||||
}
|
||||
@@ -211,20 +219,26 @@ public class PartCableAnchor implements IPart
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPartHostInfo(ForgeDirection side, IPartHost host, TileEntity tile)
|
||||
public void setPartHostInfo( ForgeDirection side, IPartHost host, TileEntity tile )
|
||||
{
|
||||
this.host = host;
|
||||
this.mySide = side;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onActivate(EntityPlayer player, Vec3 pos)
|
||||
public boolean onActivate( EntityPlayer player, Vec3 pos )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getDrops(List<ItemStack> drops, boolean wrenched)
|
||||
public boolean onShiftActivate( EntityPlayer player, Vec3 pos )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getDrops( List<ItemStack> drops, boolean wrenched )
|
||||
{
|
||||
|
||||
}
|
||||
@@ -236,32 +250,21 @@ public class PartCableAnchor implements IPart
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isLadder(EntityLivingBase entity)
|
||||
{
|
||||
return this.mySide.offsetY == 0 && ( entity.isCollidedHorizontally || ! entity.onGround );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onShiftActivate(EntityPlayer player, Vec3 pos)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPlacement(EntityPlayer player, ItemStack held, ForgeDirection side)
|
||||
@SideOnly( Side.CLIENT )
|
||||
public void randomDisplayTick( World world, int x, int y, int z, Random r )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canBePlacedOn(BusSupport what)
|
||||
public void onPlacement( EntityPlayer player, ItemStack held, ForgeDirection side )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canBePlacedOn( BusSupport what )
|
||||
{
|
||||
return what == BusSupport.CABLE || what == BusSupport.DENSE_CABLE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IIcon getBreakingTexture()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -73,8 +73,7 @@ import appeng.util.Platform;
|
||||
import appeng.util.inv.IInventoryDestination;
|
||||
|
||||
|
||||
public class PartInterface extends PartBasicState
|
||||
implements IGridTickable, IStorageMonitorable, IInventoryDestination, IInterfaceHost, ISidedInventory, IAEAppEngInventory, ITileStorageMonitorable, IPriorityHost
|
||||
public class PartInterface extends PartBasicState implements IGridTickable, IStorageMonitorable, IInventoryDestination, IInterfaceHost, ISidedInventory, IAEAppEngInventory, ITileStorageMonitorable, IPriorityHost
|
||||
{
|
||||
|
||||
final DualityInterface duality = new DualityInterface( this.proxy, this );
|
||||
@@ -97,6 +96,19 @@ public class PartInterface extends PartBasicState
|
||||
this.duality.notifyNeighbors();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getBoxes( IPartCollisionHelper bch )
|
||||
{
|
||||
bch.addBox( 2, 2, 14, 14, 14, 16 );
|
||||
bch.addBox( 5, 5, 12, 11, 11, 14 );
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getInstalledUpgrades( Upgrades u )
|
||||
{
|
||||
return this.duality.getInstalledUpgrades( u );
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly( Side.CLIENT )
|
||||
public void renderInventory( IPartRenderHelper rh, RenderBlocks renderer )
|
||||
@@ -113,6 +125,12 @@ public class PartInterface extends PartBasicState
|
||||
rh.renderInventoryBox( renderer );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void gridChanged()
|
||||
{
|
||||
this.duality.gridChanged();
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly( Side.CLIENT )
|
||||
public void renderStatic( int x, int y, int z, IPartRenderHelper rh, RenderBlocks renderer )
|
||||
@@ -157,13 +175,6 @@ public class PartInterface extends PartBasicState
|
||||
this.duality.initialize();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getBoxes( IPartCollisionHelper bch )
|
||||
{
|
||||
bch.addBox( 2, 2, 14, 14, 14, 16 );
|
||||
bch.addBox( 5, 5, 12, 11, 11, 14 );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getDrops( List<ItemStack> drops, boolean wrenched )
|
||||
{
|
||||
@@ -176,12 +187,6 @@ public class PartInterface extends PartBasicState
|
||||
return 4;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void gridChanged()
|
||||
{
|
||||
this.duality.gridChanged();
|
||||
}
|
||||
|
||||
@Override
|
||||
public IConfigManager getConfigManager()
|
||||
{
|
||||
@@ -194,19 +199,13 @@ public class PartInterface extends PartBasicState
|
||||
return this.duality.getInventoryByName( name );
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getInstalledUpgrades( Upgrades u )
|
||||
{
|
||||
return this.duality.getInstalledUpgrades( u );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onPartActivate( EntityPlayer p, Vec3 pos )
|
||||
{
|
||||
if ( p.isSneaking() )
|
||||
if( p.isSneaking() )
|
||||
return false;
|
||||
|
||||
if ( Platform.isServer() )
|
||||
if( Platform.isServer() )
|
||||
Platform.openGUI( p, this.getTileEntity(), this.side, GuiBridge.GUI_INTERFACE );
|
||||
|
||||
return true;
|
||||
|
||||
@@ -91,8 +91,7 @@ import appeng.util.prioitylist.PrecisePriorityList;
|
||||
|
||||
|
||||
@Interface( iname = "BC", iface = "buildcraft.api.transport.IPipeConnection" )
|
||||
public class PartStorageBus extends PartUpgradeable
|
||||
implements IGridTickable, ICellContainer, IMEMonitorHandlerReceiver<IAEItemStack>, IPipeConnection, IPriorityHost
|
||||
public class PartStorageBus extends PartUpgradeable implements IGridTickable, ICellContainer, IMEMonitorHandlerReceiver<IAEItemStack>, IPipeConnection, IPriorityHost
|
||||
{
|
||||
final BaseActionSource mySrc;
|
||||
final AppEngInternalAEInventory Config = new AppEngInternalAEInventory( this, 63 );
|
||||
@@ -124,7 +123,7 @@ public class PartStorageBus extends PartUpgradeable
|
||||
private void updateStatus()
|
||||
{
|
||||
boolean currentActive = this.proxy.isActive();
|
||||
if ( this.wasActive != currentActive )
|
||||
if( this.wasActive != currentActive )
|
||||
{
|
||||
this.wasActive = currentActive;
|
||||
try
|
||||
@@ -132,7 +131,7 @@ public class PartStorageBus extends PartUpgradeable
|
||||
this.proxy.getGrid().postEvent( new MENetworkCellArrayUpdate() );
|
||||
this.host.markForUpdate();
|
||||
}
|
||||
catch ( GridAccessException e )
|
||||
catch( GridAccessException e )
|
||||
{
|
||||
// :P
|
||||
}
|
||||
@@ -152,11 +151,26 @@ public class PartStorageBus extends PartUpgradeable
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT( NBTTagCompound data )
|
||||
public void updateSetting( IConfigManager manager, Enum settingName, Enum newValue )
|
||||
{
|
||||
super.writeToNBT( data );
|
||||
this.Config.writeToNBT( data, "config" );
|
||||
data.setInteger( "priority", this.priority );
|
||||
this.resetCache( true );
|
||||
this.host.markForSave();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChangeInventory( IInventory inv, int slot, InvOperation mc, ItemStack removedStack, ItemStack newStack )
|
||||
{
|
||||
super.onChangeInventory( inv, slot, mc, removedStack, newStack );
|
||||
|
||||
if( inv == this.Config )
|
||||
this.resetCache( true );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void upgradesChanged()
|
||||
{
|
||||
super.upgradesChanged();
|
||||
this.resetCache( true );
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -167,36 +181,41 @@ public class PartStorageBus extends PartUpgradeable
|
||||
this.priority = data.getInteger( "priority" );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT( NBTTagCompound data )
|
||||
{
|
||||
super.writeToNBT( data );
|
||||
this.Config.writeToNBT( data, "config" );
|
||||
data.setInteger( "priority", this.priority );
|
||||
}
|
||||
|
||||
@Override
|
||||
public IInventory getInventoryByName( String name )
|
||||
{
|
||||
if ( name.equals( "config" ) )
|
||||
if( name.equals( "config" ) )
|
||||
return this.Config;
|
||||
|
||||
return super.getInventoryByName( name );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateSetting( IConfigManager manager, Enum settingName, Enum newValue )
|
||||
private void resetCache( boolean fullReset )
|
||||
{
|
||||
this.resetCache( true );
|
||||
this.host.markForSave();
|
||||
}
|
||||
if( this.host == null || this.host.getTile() == null || this.host.getTile().getWorldObj() == null || this.host.getTile().getWorldObj().isRemote )
|
||||
return;
|
||||
|
||||
@Override
|
||||
public void upgradesChanged()
|
||||
{
|
||||
super.upgradesChanged();
|
||||
this.resetCache( true );
|
||||
}
|
||||
if( fullReset )
|
||||
this.resetCacheLogic = 2;
|
||||
else
|
||||
this.resetCacheLogic = 1;
|
||||
|
||||
@Override
|
||||
public void onChangeInventory( IInventory inv, int slot, InvOperation mc, ItemStack removedStack, ItemStack newStack )
|
||||
{
|
||||
super.onChangeInventory( inv, slot, mc, removedStack, newStack );
|
||||
|
||||
if ( inv == this.Config )
|
||||
this.resetCache( true );
|
||||
try
|
||||
{
|
||||
this.proxy.getTick().alertDevice( this.proxy.getNode() );
|
||||
}
|
||||
catch( GridAccessException e )
|
||||
{
|
||||
// :P
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -210,10 +229,10 @@ public class PartStorageBus extends PartUpgradeable
|
||||
{
|
||||
try
|
||||
{
|
||||
if ( this.proxy.isActive() )
|
||||
if( this.proxy.isActive() )
|
||||
this.proxy.getStorage().postAlterationOfStoredItems( StorageChannel.ITEMS, change, this.mySrc );
|
||||
}
|
||||
catch ( GridAccessException e )
|
||||
catch( GridAccessException e )
|
||||
{
|
||||
// :(
|
||||
}
|
||||
@@ -225,6 +244,14 @@ public class PartStorageBus extends PartUpgradeable
|
||||
// not used here.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getBoxes( IPartCollisionHelper bch )
|
||||
{
|
||||
bch.addBox( 3, 3, 15, 13, 13, 16 );
|
||||
bch.addBox( 2, 2, 14, 14, 14, 15 );
|
||||
bch.addBox( 5, 5, 12, 11, 11, 14 );
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly( Side.CLIENT )
|
||||
public void renderInventory( IPartRenderHelper rh, RenderBlocks renderer )
|
||||
@@ -273,34 +300,6 @@ public class PartStorageBus extends PartUpgradeable
|
||||
this.resetCache( false );
|
||||
}
|
||||
|
||||
private void resetCache( boolean fullReset )
|
||||
{
|
||||
if ( this.host == null || this.host.getTile() == null || this.host.getTile().getWorldObj() == null || this.host.getTile().getWorldObj().isRemote )
|
||||
return;
|
||||
|
||||
if ( fullReset )
|
||||
this.resetCacheLogic = 2;
|
||||
else
|
||||
this.resetCacheLogic = 1;
|
||||
|
||||
try
|
||||
{
|
||||
this.proxy.getTick().alertDevice( this.proxy.getNode() );
|
||||
}
|
||||
catch ( GridAccessException e )
|
||||
{
|
||||
// :P
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getBoxes( IPartCollisionHelper bch )
|
||||
{
|
||||
bch.addBox( 3, 3, 15, 13, 13, 16 );
|
||||
bch.addBox( 2, 2, 14, 14, 14, 15 );
|
||||
bch.addBox( 5, 5, 12, 11, 11, 14 );
|
||||
}
|
||||
|
||||
@Override
|
||||
public int cableConnectionRenderTo()
|
||||
{
|
||||
@@ -310,9 +309,9 @@ public class PartStorageBus extends PartUpgradeable
|
||||
@Override
|
||||
public boolean onPartActivate( EntityPlayer player, Vec3 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_STORAGEBUS );
|
||||
@@ -331,10 +330,10 @@ public class PartStorageBus extends PartUpgradeable
|
||||
@Override
|
||||
public TickRateModulation tickingRequest( IGridNode node, int TicksSinceLastCall )
|
||||
{
|
||||
if ( this.resetCacheLogic != 0 )
|
||||
if( this.resetCacheLogic != 0 )
|
||||
this.resetCache();
|
||||
|
||||
if ( this.monitor != null )
|
||||
if( this.monitor != null )
|
||||
return this.monitor.onTick();
|
||||
|
||||
return TickRateModulation.SLEEP;
|
||||
@@ -347,20 +346,20 @@ public class PartStorageBus extends PartUpgradeable
|
||||
|
||||
IMEInventory<IAEItemStack> in = this.getInternalHandler();
|
||||
IItemList<IAEItemStack> before = AEApi.instance().storage().createItemList();
|
||||
if ( in != null )
|
||||
if( in != null )
|
||||
before = in.getAvailableItems( before );
|
||||
|
||||
this.cached = false;
|
||||
if ( fullReset )
|
||||
if( fullReset )
|
||||
this.handlerHash = 0;
|
||||
|
||||
IMEInventory<IAEItemStack> out = this.getInternalHandler();
|
||||
|
||||
if ( this.monitor != null )
|
||||
if( this.monitor != null )
|
||||
this.monitor.onTick();
|
||||
|
||||
IItemList<IAEItemStack> after = AEApi.instance().storage().createItemList();
|
||||
if ( out != null )
|
||||
if( out != null )
|
||||
after = out.getAvailableItems( after );
|
||||
|
||||
Platform.postListChanges( before, after, this, this.mySrc );
|
||||
@@ -368,7 +367,7 @@ public class PartStorageBus extends PartUpgradeable
|
||||
|
||||
public MEInventoryHandler getInternalHandler()
|
||||
{
|
||||
if ( this.cached )
|
||||
if( this.cached )
|
||||
return this.handler;
|
||||
|
||||
boolean wasSleeping = this.monitor == null;
|
||||
@@ -379,7 +378,7 @@ public class PartStorageBus extends PartUpgradeable
|
||||
|
||||
int newHandlerHash = Platform.generateTileHash( target );
|
||||
|
||||
if ( this.handlerHash == newHandlerHash && this.handlerHash != 0 )
|
||||
if( this.handlerHash == newHandlerHash && this.handlerHash != 0 )
|
||||
return this.handler;
|
||||
|
||||
try
|
||||
@@ -387,7 +386,7 @@ public class PartStorageBus extends PartUpgradeable
|
||||
// force grid to update handlers...
|
||||
this.proxy.getGrid().postEvent( new MENetworkCellArrayUpdate() );
|
||||
}
|
||||
catch ( GridAccessException e )
|
||||
catch( GridAccessException e )
|
||||
{
|
||||
// :3
|
||||
}
|
||||
@@ -395,66 +394,66 @@ public class PartStorageBus extends PartUpgradeable
|
||||
this.handlerHash = newHandlerHash;
|
||||
this.handler = null;
|
||||
this.monitor = null;
|
||||
if ( target != null )
|
||||
if( target != null )
|
||||
{
|
||||
IExternalStorageHandler esh = AEApi.instance().registries().externalStorage().getHandler( target, this.side.getOpposite(), StorageChannel.ITEMS, this.mySrc );
|
||||
if ( esh != null )
|
||||
if( esh != null )
|
||||
{
|
||||
IMEInventory inv = esh.getInventory( target, this.side.getOpposite(), StorageChannel.ITEMS, this.mySrc );
|
||||
|
||||
if ( inv instanceof MEMonitorIInventory )
|
||||
if( inv instanceof MEMonitorIInventory )
|
||||
{
|
||||
MEMonitorIInventory h = (MEMonitorIInventory) inv;
|
||||
h.mode = (StorageFilter) this.getConfigManager().getSetting( Settings.STORAGE_FILTER );
|
||||
h.mySource = new MachineSource( this );
|
||||
}
|
||||
|
||||
if ( inv instanceof MEMonitorIInventory )
|
||||
if( inv instanceof MEMonitorIInventory )
|
||||
this.monitor = (MEMonitorIInventory) inv;
|
||||
|
||||
if ( inv != null )
|
||||
if( inv != null )
|
||||
{
|
||||
this.checkInterfaceVsStorageBus( target, this.side.getOpposite() );
|
||||
|
||||
this.handler = new MEInventoryHandler( inv, StorageChannel.ITEMS );
|
||||
|
||||
this.handler.setBaseAccess( ( AccessRestriction ) this.getConfigManager().getSetting( Settings.ACCESS ) );
|
||||
this.handler.setBaseAccess( (AccessRestriction) this.getConfigManager().getSetting( Settings.ACCESS ) );
|
||||
this.handler.setWhitelist( this.getInstalledUpgrades( Upgrades.INVERTER ) > 0 ? IncludeExclude.BLACKLIST : IncludeExclude.WHITELIST );
|
||||
this.handler.setPriority( this.priority );
|
||||
|
||||
IItemList<IAEItemStack> priorityList = AEApi.instance().storage().createItemList();
|
||||
|
||||
int slotsToUse = 18 + this.getInstalledUpgrades( Upgrades.CAPACITY ) * 9;
|
||||
for ( int x = 0; x < this.Config.getSizeInventory() && x < slotsToUse; x++ )
|
||||
for( int x = 0; x < this.Config.getSizeInventory() && x < slotsToUse; x++ )
|
||||
{
|
||||
IAEItemStack is = this.Config.getAEStackInSlot( x );
|
||||
if ( is != null )
|
||||
if( is != null )
|
||||
priorityList.add( is );
|
||||
}
|
||||
|
||||
if ( this.getInstalledUpgrades( Upgrades.FUZZY ) > 0 )
|
||||
if( this.getInstalledUpgrades( Upgrades.FUZZY ) > 0 )
|
||||
this.handler.setPartitionList( new FuzzyPriorityList( priorityList, (FuzzyMode) this.getConfigManager().getSetting( Settings.FUZZY_MODE ) ) );
|
||||
else
|
||||
this.handler.setPartitionList( new PrecisePriorityList( priorityList ) );
|
||||
|
||||
if ( inv instanceof IMEMonitor )
|
||||
if( inv instanceof IMEMonitor )
|
||||
( (IMEMonitor) inv ).addListener( this, this.handler );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// update sleep state...
|
||||
if ( wasSleeping != ( this.monitor == null ) )
|
||||
if( wasSleeping != ( this.monitor == null ) )
|
||||
{
|
||||
try
|
||||
{
|
||||
ITickManager tm = this.proxy.getTick();
|
||||
if ( this.monitor == null )
|
||||
if( this.monitor == null )
|
||||
tm.sleepDevice( this.proxy.getNode() );
|
||||
else
|
||||
tm.wakeDevice( this.proxy.getNode() );
|
||||
}
|
||||
catch ( GridAccessException e )
|
||||
catch( GridAccessException e )
|
||||
{
|
||||
// :(
|
||||
}
|
||||
@@ -467,17 +466,17 @@ public class PartStorageBus extends PartUpgradeable
|
||||
{
|
||||
IInterfaceHost achievement = null;
|
||||
|
||||
if ( target instanceof IInterfaceHost )
|
||||
if( target instanceof IInterfaceHost )
|
||||
achievement = (IInterfaceHost) target;
|
||||
|
||||
if ( target instanceof IPartHost )
|
||||
if( target instanceof IPartHost )
|
||||
{
|
||||
Object part = ( (IPartHost) target ).getPart( side );
|
||||
if ( part instanceof IInterfaceHost )
|
||||
if( part instanceof IInterfaceHost )
|
||||
achievement = (IInterfaceHost) part;
|
||||
}
|
||||
|
||||
if ( achievement != null && achievement.getActionableNode() != null )
|
||||
if( achievement != null && achievement.getActionableNode() != null )
|
||||
{
|
||||
Platform.addStat( achievement.getActionableNode().getPlayerID(), Achievements.Recursive.getAchievement() );
|
||||
// Platform.addStat( getActionableNode().getPlayerID(), Achievements.Recursive.getAchievement() );
|
||||
@@ -487,13 +486,13 @@ public class PartStorageBus extends PartUpgradeable
|
||||
@Override
|
||||
public List<IMEInventoryHandler> getCellArray( StorageChannel channel )
|
||||
{
|
||||
if ( channel == StorageChannel.ITEMS )
|
||||
if( channel == StorageChannel.ITEMS )
|
||||
{
|
||||
IMEInventoryHandler out = this.proxy.isActive() ? this.getInternalHandler() : null;
|
||||
if ( out != null )
|
||||
if( out != null )
|
||||
return Collections.singletonList( out );
|
||||
}
|
||||
return Arrays.asList( new IMEInventoryHandler[] { } );
|
||||
return Arrays.asList( new IMEInventoryHandler[] {} );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -93,6 +93,31 @@ public class PartToggleBus extends PartBasicState
|
||||
return this.is.getIconIndex();
|
||||
}
|
||||
|
||||
@Override
|
||||
public AECableType getCableConnectionType( ForgeDirection dir )
|
||||
{
|
||||
return AECableType.GLASS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void securityBreak()
|
||||
{
|
||||
if( this.is.stackSize > 0 )
|
||||
{
|
||||
List<ItemStack> items = new ArrayList<ItemStack>();
|
||||
items.add( this.is.copy() );
|
||||
this.host.removePart( this.side, false );
|
||||
Platform.spawnDrops( this.tile.getWorldObj(), this.tile.xCoord, this.tile.yCoord, this.tile.zCoord, items );
|
||||
this.is.stackSize = 0;
|
||||
}
|
||||
}
|
||||
|
||||
@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 )
|
||||
@@ -145,7 +170,7 @@ public class PartToggleBus extends PartBasicState
|
||||
boolean oldHasRedstone = this.hasRedstone;
|
||||
this.hasRedstone = this.getHost().hasRedstone( this.side );
|
||||
|
||||
if ( this.hasRedstone != oldHasRedstone )
|
||||
if( this.hasRedstone != oldHasRedstone )
|
||||
{
|
||||
this.updateInternalState();
|
||||
this.getHost().markForUpdate();
|
||||
@@ -195,18 +220,6 @@ public class PartToggleBus extends PartBasicState
|
||||
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()
|
||||
{
|
||||
@@ -220,33 +233,20 @@ public class PartToggleBus extends PartBasicState
|
||||
this.outerProxy.setOwner( player );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void securityBreak()
|
||||
{
|
||||
if ( this.is.stackSize > 0 )
|
||||
{
|
||||
List<ItemStack> items = new ArrayList<ItemStack>();
|
||||
items.add( this.is.copy() );
|
||||
this.host.removePart( this.side, false );
|
||||
Platform.spawnDrops( this.tile.getWorldObj(), this.tile.xCoord, this.tile.yCoord, this.tile.zCoord, items );
|
||||
this.is.stackSize = 0;
|
||||
}
|
||||
}
|
||||
|
||||
private void updateInternalState()
|
||||
{
|
||||
boolean intention = this.getIntention();
|
||||
if ( intention == ( this.connection == null ) )
|
||||
if( intention == ( this.connection == null ) )
|
||||
{
|
||||
if ( this.proxy.getNode() != null && this.outerProxy.getNode() != null )
|
||||
if( this.proxy.getNode() != null && this.outerProxy.getNode() != null )
|
||||
{
|
||||
if ( intention )
|
||||
if( intention )
|
||||
{
|
||||
try
|
||||
{
|
||||
this.connection = AEApi.instance().createGridConnection( this.proxy.getNode(), this.outerProxy.getNode() );
|
||||
}
|
||||
catch ( FailedConnection e )
|
||||
catch( FailedConnection e )
|
||||
{
|
||||
// :(
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -67,12 +67,6 @@ public class PartCableCovered extends PartCable
|
||||
this.getHost().markForUpdate();
|
||||
}
|
||||
|
||||
@Override
|
||||
public IIcon getTexture( AEColor c )
|
||||
{
|
||||
return this.getCoveredTexture( c );
|
||||
}
|
||||
|
||||
@Override
|
||||
public AECableType getCableConnectionType()
|
||||
{
|
||||
@@ -84,18 +78,18 @@ public class PartCableCovered extends PartCable
|
||||
{
|
||||
bch.addBox( 5.0, 5.0, 5.0, 11.0, 11.0, 11.0 );
|
||||
|
||||
if ( Platform.isServer() )
|
||||
if( Platform.isServer() )
|
||||
{
|
||||
IGridNode n = this.getGridNode();
|
||||
if ( n != null )
|
||||
if( n != null )
|
||||
this.connections = n.getConnectedSides();
|
||||
else
|
||||
this.connections.clear();
|
||||
}
|
||||
|
||||
for ( ForgeDirection of : this.connections )
|
||||
for( ForgeDirection of : this.connections )
|
||||
{
|
||||
switch ( of )
|
||||
switch( of )
|
||||
{
|
||||
case DOWN:
|
||||
bch.addBox( 5.0, 0.0, 5.0, 11.0, 5.0, 11.0 );
|
||||
@@ -132,7 +126,7 @@ public class PartCableCovered extends PartCable
|
||||
|
||||
OffsetIcon main = new OffsetIcon( this.getTexture( this.getCableColor() ), offU, offV );
|
||||
|
||||
for ( ForgeDirection side : EnumSet.of( ForgeDirection.UP, ForgeDirection.DOWN ) )
|
||||
for( ForgeDirection side : EnumSet.of( ForgeDirection.UP, ForgeDirection.DOWN ) )
|
||||
{
|
||||
rh.renderInventoryFace( main, side, renderer );
|
||||
}
|
||||
@@ -141,14 +135,14 @@ public class PartCableCovered extends PartCable
|
||||
offV = 0;
|
||||
main = new OffsetIcon( this.getTexture( this.getCableColor() ), offU, offV );
|
||||
|
||||
for ( ForgeDirection side : EnumSet.of( ForgeDirection.EAST, ForgeDirection.WEST ) )
|
||||
for( ForgeDirection side : EnumSet.of( ForgeDirection.EAST, ForgeDirection.WEST ) )
|
||||
{
|
||||
rh.renderInventoryFace( main, side, renderer );
|
||||
}
|
||||
|
||||
main = new OffsetIcon( this.getTexture( this.getCableColor() ), 0, 0 );
|
||||
|
||||
for ( ForgeDirection side : EnumSet.of( ForgeDirection.SOUTH, ForgeDirection.NORTH ) )
|
||||
for( ForgeDirection side : EnumSet.of( ForgeDirection.SOUTH, ForgeDirection.NORTH ) )
|
||||
{
|
||||
rh.renderInventoryFace( main, side, renderer );
|
||||
}
|
||||
@@ -156,6 +150,12 @@ public class PartCableCovered extends PartCable
|
||||
rh.setTexture( null );
|
||||
}
|
||||
|
||||
@Override
|
||||
public IIcon getTexture( AEColor c )
|
||||
{
|
||||
return this.getCoveredTexture( c );
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly( Side.CLIENT )
|
||||
public void renderStatic( int x, int y, int z, IPartRenderHelper rh, RenderBlocks renderer )
|
||||
@@ -167,21 +167,21 @@ public class PartCableCovered extends PartCable
|
||||
|
||||
boolean hasBuses = false;
|
||||
IPartHost ph = this.getHost();
|
||||
for ( ForgeDirection of : EnumSet.complementOf( this.connections ) )
|
||||
for( ForgeDirection of : EnumSet.complementOf( this.connections ) )
|
||||
{
|
||||
IPart bp = ph.getPart( of );
|
||||
if ( bp instanceof IGridHost )
|
||||
if( bp instanceof IGridHost )
|
||||
{
|
||||
if ( of != ForgeDirection.UNKNOWN )
|
||||
if( of != ForgeDirection.UNKNOWN )
|
||||
{
|
||||
sides.add( of );
|
||||
hasBuses = true;
|
||||
}
|
||||
|
||||
int len = bp.cableConnectionRenderTo();
|
||||
if ( len < 8 )
|
||||
if( len < 8 )
|
||||
{
|
||||
switch ( of )
|
||||
switch( of )
|
||||
{
|
||||
case DOWN:
|
||||
rh.setBounds( 6, len, 6, 10, 5, 10 );
|
||||
@@ -209,9 +209,9 @@ public class PartCableCovered extends PartCable
|
||||
}
|
||||
}
|
||||
|
||||
if ( sides.size() != 2 || !this.nonLinear( sides ) || hasBuses )
|
||||
if( sides.size() != 2 || !this.nonLinear( sides ) || hasBuses )
|
||||
{
|
||||
for ( ForgeDirection of : this.connections )
|
||||
for( ForgeDirection of : this.connections )
|
||||
{
|
||||
this.renderCoveredConnection( x, y, z, rh, renderer, this.channelsOnSide[of.ordinal()], of );
|
||||
}
|
||||
@@ -224,9 +224,9 @@ public class PartCableCovered extends PartCable
|
||||
{
|
||||
IIcon def = this.getTexture( this.getCableColor() );
|
||||
IIcon off = new OffsetIcon( def, 0, -12 );
|
||||
for ( ForgeDirection of : this.connections )
|
||||
for( ForgeDirection of : this.connections )
|
||||
{
|
||||
switch ( of )
|
||||
switch( of )
|
||||
{
|
||||
case DOWN:
|
||||
case UP:
|
||||
|
||||
@@ -77,79 +77,23 @@ public class PartCableSmart extends PartCable
|
||||
return AECableType.SMART;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IIcon getTexture( AEColor c )
|
||||
{
|
||||
return this.getSmartTexture( c );
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly( Side.CLIENT )
|
||||
public void renderInventory( IPartRenderHelper rh, RenderBlocks renderer )
|
||||
{
|
||||
GL11.glTranslated( -0.0, -0.0, 0.3 );
|
||||
|
||||
float offU = 0;
|
||||
float offV = 9;
|
||||
|
||||
OffsetIcon main = new OffsetIcon( this.getTexture( this.getCableColor() ), offU, offV );
|
||||
OffsetIcon ch1 = new OffsetIcon( this.getChannelTex( 4, false ).getIcon(), offU, offV );
|
||||
OffsetIcon ch2 = new OffsetIcon( this.getChannelTex( 4, true ).getIcon(), offU, offV );
|
||||
|
||||
for ( ForgeDirection side : EnumSet.of( ForgeDirection.UP, ForgeDirection.DOWN ) )
|
||||
{
|
||||
rh.setBounds( 5.0f, 5.0f, 2.0f, 11.0f, 11.0f, 14.0f );
|
||||
rh.renderInventoryFace( main, side, renderer );
|
||||
rh.renderInventoryFace( ch1, side, renderer );
|
||||
rh.renderInventoryFace( ch2, side, renderer );
|
||||
}
|
||||
|
||||
offU = 9;
|
||||
offV = 0;
|
||||
main = new OffsetIcon( this.getTexture( this.getCableColor() ), offU, offV );
|
||||
ch1 = new OffsetIcon( this.getChannelTex( 4, false ).getIcon(), offU, offV );
|
||||
ch2 = new OffsetIcon( this.getChannelTex( 4, true ).getIcon(), offU, offV );
|
||||
|
||||
for ( ForgeDirection side : EnumSet.of( ForgeDirection.EAST, ForgeDirection.WEST ) )
|
||||
{
|
||||
rh.setBounds( 5.0f, 5.0f, 2.0f, 11.0f, 11.0f, 14.0f );
|
||||
rh.renderInventoryFace( main, side, renderer );
|
||||
rh.renderInventoryFace( ch1, side, renderer );
|
||||
rh.renderInventoryFace( ch2, side, renderer );
|
||||
}
|
||||
|
||||
main = new OffsetIcon( this.getTexture( this.getCableColor() ), 0, 0 );
|
||||
ch1 = new OffsetIcon( this.getChannelTex( 4, false ).getIcon(), 0, 0 );
|
||||
ch2 = new OffsetIcon( this.getChannelTex( 4, true ).getIcon(), 0, 0 );
|
||||
|
||||
for ( ForgeDirection side : EnumSet.of( ForgeDirection.SOUTH, ForgeDirection.NORTH ) )
|
||||
{
|
||||
rh.setBounds( 5.0f, 5.0f, 2.0f, 11.0f, 11.0f, 14.0f );
|
||||
rh.renderInventoryFace( main, side, renderer );
|
||||
rh.renderInventoryFace( ch1, side, renderer );
|
||||
rh.renderInventoryFace( ch2, side, renderer );
|
||||
}
|
||||
|
||||
rh.setTexture( null );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getBoxes( IPartCollisionHelper bch )
|
||||
{
|
||||
bch.addBox( 5.0, 5.0, 5.0, 11.0, 11.0, 11.0 );
|
||||
|
||||
if ( Platform.isServer() )
|
||||
if( Platform.isServer() )
|
||||
{
|
||||
IGridNode n = this.getGridNode();
|
||||
if ( n != null )
|
||||
if( n != null )
|
||||
this.connections = n.getConnectedSides();
|
||||
else
|
||||
this.connections.clear();
|
||||
}
|
||||
|
||||
for ( ForgeDirection of : this.connections )
|
||||
for( ForgeDirection of : this.connections )
|
||||
{
|
||||
switch ( of )
|
||||
switch( of )
|
||||
{
|
||||
case DOWN:
|
||||
bch.addBox( 5.0, 0.0, 5.0, 11.0, 5.0, 11.0 );
|
||||
@@ -174,6 +118,62 @@ public class PartCableSmart extends PartCable
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly( Side.CLIENT )
|
||||
public void renderInventory( IPartRenderHelper rh, RenderBlocks renderer )
|
||||
{
|
||||
GL11.glTranslated( -0.0, -0.0, 0.3 );
|
||||
|
||||
float offU = 0;
|
||||
float offV = 9;
|
||||
|
||||
OffsetIcon main = new OffsetIcon( this.getTexture( this.getCableColor() ), offU, offV );
|
||||
OffsetIcon ch1 = new OffsetIcon( this.getChannelTex( 4, false ).getIcon(), offU, offV );
|
||||
OffsetIcon ch2 = new OffsetIcon( this.getChannelTex( 4, true ).getIcon(), offU, offV );
|
||||
|
||||
for( ForgeDirection side : EnumSet.of( ForgeDirection.UP, ForgeDirection.DOWN ) )
|
||||
{
|
||||
rh.setBounds( 5.0f, 5.0f, 2.0f, 11.0f, 11.0f, 14.0f );
|
||||
rh.renderInventoryFace( main, side, renderer );
|
||||
rh.renderInventoryFace( ch1, side, renderer );
|
||||
rh.renderInventoryFace( ch2, side, renderer );
|
||||
}
|
||||
|
||||
offU = 9;
|
||||
offV = 0;
|
||||
main = new OffsetIcon( this.getTexture( this.getCableColor() ), offU, offV );
|
||||
ch1 = new OffsetIcon( this.getChannelTex( 4, false ).getIcon(), offU, offV );
|
||||
ch2 = new OffsetIcon( this.getChannelTex( 4, true ).getIcon(), offU, offV );
|
||||
|
||||
for( ForgeDirection side : EnumSet.of( ForgeDirection.EAST, ForgeDirection.WEST ) )
|
||||
{
|
||||
rh.setBounds( 5.0f, 5.0f, 2.0f, 11.0f, 11.0f, 14.0f );
|
||||
rh.renderInventoryFace( main, side, renderer );
|
||||
rh.renderInventoryFace( ch1, side, renderer );
|
||||
rh.renderInventoryFace( ch2, side, renderer );
|
||||
}
|
||||
|
||||
main = new OffsetIcon( this.getTexture( this.getCableColor() ), 0, 0 );
|
||||
ch1 = new OffsetIcon( this.getChannelTex( 4, false ).getIcon(), 0, 0 );
|
||||
ch2 = new OffsetIcon( this.getChannelTex( 4, true ).getIcon(), 0, 0 );
|
||||
|
||||
for( ForgeDirection side : EnumSet.of( ForgeDirection.SOUTH, ForgeDirection.NORTH ) )
|
||||
{
|
||||
rh.setBounds( 5.0f, 5.0f, 2.0f, 11.0f, 11.0f, 14.0f );
|
||||
rh.renderInventoryFace( main, side, renderer );
|
||||
rh.renderInventoryFace( ch1, side, renderer );
|
||||
rh.renderInventoryFace( ch2, side, renderer );
|
||||
}
|
||||
|
||||
rh.setTexture( null );
|
||||
}
|
||||
|
||||
@Override
|
||||
public IIcon getTexture( AEColor c )
|
||||
{
|
||||
return this.getSmartTexture( c );
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly( Side.CLIENT )
|
||||
public void renderStatic( int x, int y, int z, IPartRenderHelper rh, RenderBlocks renderer )
|
||||
@@ -185,21 +185,21 @@ public class PartCableSmart extends PartCable
|
||||
|
||||
boolean hasBuses = false;
|
||||
IPartHost ph = this.getHost();
|
||||
for ( ForgeDirection of : EnumSet.complementOf( this.connections ) )
|
||||
for( ForgeDirection of : EnumSet.complementOf( this.connections ) )
|
||||
{
|
||||
IPart bp = ph.getPart( of );
|
||||
if ( bp instanceof IGridHost )
|
||||
if( bp instanceof IGridHost )
|
||||
{
|
||||
if ( of != ForgeDirection.UNKNOWN )
|
||||
if( of != ForgeDirection.UNKNOWN )
|
||||
{
|
||||
sides.add( of );
|
||||
hasBuses = true;
|
||||
}
|
||||
|
||||
int len = bp.cableConnectionRenderTo();
|
||||
if ( len < 8 )
|
||||
if( len < 8 )
|
||||
{
|
||||
switch ( of )
|
||||
switch( of )
|
||||
{
|
||||
case DOWN:
|
||||
rh.setBounds( 6, len, 6, 10, 5, 10 );
|
||||
@@ -228,7 +228,7 @@ public class PartCableSmart extends PartCable
|
||||
IIcon firstIcon = new TaughtIcon( this.getChannelTex( this.channelsOnSide[of.ordinal()], false ).getIcon(), -0.2f );
|
||||
IIcon secondIcon = new TaughtIcon( this.getChannelTex( this.channelsOnSide[of.ordinal()], true ).getIcon(), -0.2f );
|
||||
|
||||
if ( of == ForgeDirection.EAST || of == ForgeDirection.WEST )
|
||||
if( of == ForgeDirection.EAST || of == ForgeDirection.WEST )
|
||||
{
|
||||
AEBaseBlock blk = (AEBaseBlock) rh.getBlock();
|
||||
FlippableIcon ico = blk.getRendererInstance().getTexture( ForgeDirection.EAST );
|
||||
@@ -251,9 +251,9 @@ public class PartCableSmart extends PartCable
|
||||
}
|
||||
}
|
||||
|
||||
if ( sides.size() != 2 || !this.nonLinear( sides ) || hasBuses )
|
||||
if( sides.size() != 2 || !this.nonLinear( sides ) || hasBuses )
|
||||
{
|
||||
for ( ForgeDirection of : this.connections )
|
||||
for( ForgeDirection of : this.connections )
|
||||
{
|
||||
this.renderSmartConnection( x, y, z, rh, renderer, this.channelsOnSide[of.ordinal()], of );
|
||||
}
|
||||
@@ -266,7 +266,7 @@ public class PartCableSmart extends PartCable
|
||||
{
|
||||
ForgeDirection selectedSide = ForgeDirection.UNKNOWN;
|
||||
|
||||
for ( ForgeDirection of : this.connections )
|
||||
for( ForgeDirection of : this.connections )
|
||||
{
|
||||
selectedSide = of;
|
||||
break;
|
||||
@@ -282,7 +282,7 @@ public class PartCableSmart extends PartCable
|
||||
IIcon secondTaughtIcon = new TaughtIcon( this.getChannelTex( channels, true ).getIcon(), -0.2f );
|
||||
IIcon secondOffsetIcon = new OffsetIcon( secondTaughtIcon, 0, -12 );
|
||||
|
||||
switch ( selectedSide )
|
||||
switch( selectedSide )
|
||||
{
|
||||
case DOWN:
|
||||
case UP:
|
||||
|
||||
@@ -71,17 +71,6 @@ public class PartDenseCable extends PartCable
|
||||
return BusSupport.DENSE_CABLE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IIcon getTexture( AEColor c )
|
||||
{
|
||||
if ( c == AEColor.Transparent )
|
||||
{
|
||||
return AEApi.instance().definitions().parts().cableSmart().stack( AEColor.Transparent, 1 ).getIconIndex();
|
||||
}
|
||||
|
||||
return this.getSmartTexture( c );
|
||||
}
|
||||
|
||||
@Override
|
||||
public AECableType getCableConnectionType()
|
||||
{
|
||||
@@ -97,20 +86,20 @@ public class PartDenseCable extends PartCable
|
||||
|
||||
bch.addBox( min, min, min, max, max, max );
|
||||
|
||||
if ( Platform.isServer() )
|
||||
if( Platform.isServer() )
|
||||
{
|
||||
IGridNode n = this.getGridNode();
|
||||
if ( n != null )
|
||||
if( n != null )
|
||||
this.connections = n.getConnectedSides();
|
||||
else
|
||||
this.connections.clear();
|
||||
}
|
||||
|
||||
for ( ForgeDirection of : this.connections )
|
||||
for( ForgeDirection of : this.connections )
|
||||
{
|
||||
if ( this.isDense( of ) )
|
||||
if( this.isDense( of ) )
|
||||
{
|
||||
switch ( of )
|
||||
switch( of )
|
||||
{
|
||||
case DOWN:
|
||||
bch.addBox( min, 0.0, min, max, min, max );
|
||||
@@ -135,7 +124,7 @@ public class PartDenseCable extends PartCable
|
||||
}
|
||||
else
|
||||
{
|
||||
switch ( of )
|
||||
switch( of )
|
||||
{
|
||||
case DOWN:
|
||||
bch.addBox( 5.0, 0.0, 5.0, 11.0, 5.0, 11.0 );
|
||||
@@ -175,7 +164,7 @@ public class PartDenseCable extends PartCable
|
||||
OffsetIcon ch1 = new OffsetIcon( this.getChannelTex( 4, false ).getIcon(), offU, offV );
|
||||
OffsetIcon ch2 = new OffsetIcon( this.getChannelTex( 4, true ).getIcon(), offU, offV );
|
||||
|
||||
for ( ForgeDirection side : EnumSet.of( ForgeDirection.UP, ForgeDirection.DOWN ) )
|
||||
for( ForgeDirection side : EnumSet.of( ForgeDirection.UP, ForgeDirection.DOWN ) )
|
||||
{
|
||||
rh.renderInventoryFace( main, side, renderer );
|
||||
rh.renderInventoryFace( ch1, side, renderer );
|
||||
@@ -188,7 +177,7 @@ public class PartDenseCable extends PartCable
|
||||
ch1 = new OffsetIcon( this.getChannelTex( 4, false ).getIcon(), offU, offV );
|
||||
ch2 = new OffsetIcon( this.getChannelTex( 4, true ).getIcon(), offU, offV );
|
||||
|
||||
for ( ForgeDirection side : EnumSet.of( ForgeDirection.EAST, ForgeDirection.WEST ) )
|
||||
for( ForgeDirection side : EnumSet.of( ForgeDirection.EAST, ForgeDirection.WEST ) )
|
||||
{
|
||||
rh.renderInventoryFace( main, side, renderer );
|
||||
rh.renderInventoryFace( ch1, side, renderer );
|
||||
@@ -199,7 +188,7 @@ public class PartDenseCable extends PartCable
|
||||
ch1 = new OffsetIcon( this.getChannelTex( 4, false ).getIcon(), 0, 0 );
|
||||
ch2 = new OffsetIcon( this.getChannelTex( 4, true ).getIcon(), 0, 0 );
|
||||
|
||||
for ( ForgeDirection side : EnumSet.of( ForgeDirection.SOUTH, ForgeDirection.NORTH ) )
|
||||
for( ForgeDirection side : EnumSet.of( ForgeDirection.SOUTH, ForgeDirection.NORTH ) )
|
||||
{
|
||||
rh.renderInventoryFace( main, side, renderer );
|
||||
rh.renderInventoryFace( ch1, side, renderer );
|
||||
@@ -209,6 +198,17 @@ public class PartDenseCable extends PartCable
|
||||
rh.setTexture( null );
|
||||
}
|
||||
|
||||
@Override
|
||||
public IIcon getTexture( AEColor c )
|
||||
{
|
||||
if( c == AEColor.Transparent )
|
||||
{
|
||||
return AEApi.instance().definitions().parts().cableSmart().stack( AEColor.Transparent, 1 ).getIconIndex();
|
||||
}
|
||||
|
||||
return this.getSmartTexture( c );
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly( Side.CLIENT )
|
||||
public void renderStatic( int x, int y, int z, IPartRenderHelper rh, RenderBlocks renderer )
|
||||
@@ -219,19 +219,19 @@ public class PartDenseCable extends PartCable
|
||||
EnumSet<ForgeDirection> sides = this.connections.clone();
|
||||
|
||||
boolean hasBuses = false;
|
||||
for ( ForgeDirection of : this.connections )
|
||||
for( ForgeDirection of : this.connections )
|
||||
{
|
||||
if ( !this.isDense( of ) )
|
||||
if( !this.isDense( of ) )
|
||||
hasBuses = true;
|
||||
}
|
||||
|
||||
if ( sides.size() != 2 || !this.nonLinear( sides ) || hasBuses )
|
||||
if( sides.size() != 2 || !this.nonLinear( sides ) || hasBuses )
|
||||
{
|
||||
for ( ForgeDirection of : this.connections )
|
||||
for( ForgeDirection of : this.connections )
|
||||
{
|
||||
if ( this.isDense( of ) )
|
||||
if( this.isDense( of ) )
|
||||
this.renderDenseConnection( x, y, z, rh, renderer, this.channelsOnSide[of.ordinal()], of );
|
||||
else if ( this.isSmart( of ) )
|
||||
else if( this.isSmart( of ) )
|
||||
this.renderSmartConnection( x, y, z, rh, renderer, this.channelsOnSide[of.ordinal()], of );
|
||||
else
|
||||
this.renderCoveredConnection( x, y, z, rh, renderer, this.channelsOnSide[of.ordinal()], of );
|
||||
@@ -245,7 +245,7 @@ public class PartDenseCable extends PartCable
|
||||
{
|
||||
ForgeDirection selectedSide = ForgeDirection.UNKNOWN;
|
||||
|
||||
for ( ForgeDirection of : this.connections )
|
||||
for( ForgeDirection of : this.connections )
|
||||
{
|
||||
selectedSide = of;
|
||||
break;
|
||||
@@ -261,7 +261,7 @@ public class PartDenseCable extends PartCable
|
||||
IIcon secondIcon = new TaughtIcon( this.getChannelTex( channels, true ).getIcon(), -0.2f );
|
||||
IIcon secondOffset = new OffsetIcon( secondIcon, 0, -12 );
|
||||
|
||||
switch ( selectedSide )
|
||||
switch( selectedSide )
|
||||
{
|
||||
case DOWN:
|
||||
case UP:
|
||||
@@ -387,12 +387,12 @@ public class PartDenseCable extends PartCable
|
||||
*/
|
||||
|
||||
rh.setFacesToRender( EnumSet.complementOf( EnumSet.of( of, of.getOpposite() ) ) );
|
||||
if ( ghh != null && partHost != null && ghh.getCableConnectionType( of ) != AECableType.GLASS && partHost.getColor() != AEColor.Transparent && partHost.getPart( of.getOpposite() ) == null )
|
||||
if( ghh != null && partHost != null && ghh.getCableConnectionType( of ) != AECableType.GLASS && partHost.getColor() != AEColor.Transparent && partHost.getPart( of.getOpposite() ) == null )
|
||||
rh.setTexture( this.getTexture( myColor = partHost.getColor() ) );
|
||||
else
|
||||
rh.setTexture( this.getTexture( this.getCableColor() ) );
|
||||
|
||||
switch ( of )
|
||||
switch( of )
|
||||
{
|
||||
case DOWN:
|
||||
rh.setBounds( 4, 0, 4, 12, 5, 12 );
|
||||
@@ -419,7 +419,7 @@ public class PartDenseCable extends PartCable
|
||||
rh.renderBlock( x, y, z, renderer );
|
||||
|
||||
rh.setFacesToRender( EnumSet.allOf( ForgeDirection.class ) );
|
||||
if ( !isGlass )
|
||||
if( !isGlass )
|
||||
{
|
||||
this.setSmartConnectionRotations( of, renderer );
|
||||
|
||||
@@ -442,7 +442,7 @@ public class PartDenseCable extends PartCable
|
||||
private boolean isSmart( ForgeDirection of )
|
||||
{
|
||||
TileEntity te = this.tile.getWorldObj().getTileEntity( this.tile.xCoord + of.offsetX, this.tile.yCoord + of.offsetY, this.tile.zCoord + of.offsetZ );
|
||||
if ( te instanceof IGridHost )
|
||||
if( te instanceof IGridHost )
|
||||
{
|
||||
AECableType t = ( (IGridHost) te ).getCableConnectionType( of.getOpposite() );
|
||||
return t == AECableType.SMART;
|
||||
@@ -452,7 +452,7 @@ public class PartDenseCable extends PartCable
|
||||
|
||||
private IIcon getDenseTexture( AEColor c )
|
||||
{
|
||||
switch ( c )
|
||||
switch( c )
|
||||
{
|
||||
case Black:
|
||||
return CableBusTextures.MEDense_Black.getIcon();
|
||||
@@ -495,7 +495,7 @@ public class PartDenseCable extends PartCable
|
||||
private boolean isDense( ForgeDirection of )
|
||||
{
|
||||
TileEntity te = this.tile.getWorldObj().getTileEntity( this.tile.xCoord + of.offsetX, this.tile.yCoord + of.offsetY, this.tile.zCoord + of.offsetZ );
|
||||
if ( te instanceof IGridHost )
|
||||
if( te instanceof IGridHost )
|
||||
{
|
||||
AECableType t = ( (IGridHost) te ).getCableConnectionType( of.getOpposite() );
|
||||
return t == AECableType.DENSE;
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
|
||||
package appeng.parts.networking;
|
||||
|
||||
|
||||
import java.util.EnumSet;
|
||||
import java.util.Set;
|
||||
|
||||
@@ -47,12 +48,14 @@ import appeng.me.GridAccessException;
|
||||
import appeng.me.helpers.AENetworkProxy;
|
||||
import appeng.parts.AEBasePart;
|
||||
|
||||
|
||||
public class PartQuartzFiber extends AEBasePart implements IEnergyGridProvider
|
||||
{
|
||||
|
||||
final AENetworkProxy outerProxy = new AENetworkProxy( this, "outer", this.proxy.getMachineRepresentation(), true );
|
||||
|
||||
public PartQuartzFiber(ItemStack is) {
|
||||
public PartQuartzFiber( ItemStack is )
|
||||
{
|
||||
super( is );
|
||||
this.proxy.setIdlePowerUsage( 0 );
|
||||
this.proxy.setFlags( GridFlags.CANNOT_CARRY );
|
||||
@@ -61,79 +64,20 @@ public class PartQuartzFiber extends AEBasePart implements IEnergyGridProvider
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPlacement(EntityPlayer player, ItemStack held, ForgeDirection side)
|
||||
{
|
||||
super.onPlacement( player, held, side );
|
||||
this.outerProxy.setOwner( player );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPartHostInfo(ForgeDirection side, IPartHost host, TileEntity tile)
|
||||
{
|
||||
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();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeFromWorld()
|
||||
{
|
||||
super.removeFromWorld();
|
||||
this.outerProxy.invalidate();
|
||||
}
|
||||
|
||||
@Override
|
||||
public IGridNode getExternalFacingNode()
|
||||
{
|
||||
return this.outerProxy.getNode();
|
||||
}
|
||||
|
||||
@Override
|
||||
public AECableType getCableConnectionType(ForgeDirection dir)
|
||||
public AECableType getCableConnectionType( ForgeDirection dir )
|
||||
{
|
||||
return AECableType.GLASS;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void renderStatic(int x, int y, int z, IPartRenderHelper rh, RenderBlocks renderer)
|
||||
{
|
||||
IIcon myIcon = this.is.getIconIndex();
|
||||
rh.setTexture( myIcon );
|
||||
rh.setBounds( 6, 6, 10, 10, 10, 16 );
|
||||
rh.renderBlock( x, y, z, renderer );
|
||||
rh.setTexture( null );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getBoxes(IPartCollisionHelper bch)
|
||||
public void getBoxes( IPartCollisionHelper bch )
|
||||
{
|
||||
bch.addBox( 6, 6, 10, 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 );
|
||||
|
||||
@@ -144,60 +88,55 @@ public class PartQuartzFiber extends AEBasePart implements IEnergyGridProvider
|
||||
}
|
||||
|
||||
@Override
|
||||
public double extractAEPower(double amt, Actionable mode, Set<IEnergyGrid> seen)
|
||||
@SideOnly( Side.CLIENT )
|
||||
public void renderStatic( int x, int y, int z, IPartRenderHelper rh, RenderBlocks renderer )
|
||||
{
|
||||
double acquiredPower = 0;
|
||||
|
||||
try
|
||||
{
|
||||
IEnergyGrid eg = this.proxy.getEnergy();
|
||||
acquiredPower += eg.extractAEPower( amt - acquiredPower, mode, seen );
|
||||
}
|
||||
catch (GridAccessException e)
|
||||
{
|
||||
// :P
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
IEnergyGrid eg = this.outerProxy.getEnergy();
|
||||
acquiredPower += eg.extractAEPower( amt - acquiredPower, mode, seen );
|
||||
}
|
||||
catch (GridAccessException e)
|
||||
{
|
||||
// :P
|
||||
}
|
||||
|
||||
return acquiredPower;
|
||||
IIcon myIcon = this.is.getIconIndex();
|
||||
rh.setTexture( myIcon );
|
||||
rh.setBounds( 6, 6, 10, 10, 10, 16 );
|
||||
rh.renderBlock( x, y, z, renderer );
|
||||
rh.setTexture( null );
|
||||
}
|
||||
|
||||
@Override
|
||||
public double injectAEPower(double amt, Actionable mode, Set<IEnergyGrid> seen)
|
||||
public void readFromNBT( NBTTagCompound extra )
|
||||
{
|
||||
super.readFromNBT( extra );
|
||||
this.outerProxy.readFromNBT( extra );
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
IEnergyGrid eg = this.proxy.getEnergy();
|
||||
if ( !seen.contains( eg ) )
|
||||
return eg.injectAEPower( amt, mode, seen );
|
||||
}
|
||||
catch (GridAccessException e)
|
||||
{
|
||||
// :P
|
||||
}
|
||||
@Override
|
||||
public void writeToNBT( NBTTagCompound extra )
|
||||
{
|
||||
super.writeToNBT( extra );
|
||||
this.outerProxy.writeToNBT( extra );
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
IEnergyGrid eg = this.outerProxy.getEnergy();
|
||||
if ( !seen.contains( eg ) )
|
||||
return eg.injectAEPower( amt, mode, seen );
|
||||
}
|
||||
catch (GridAccessException e)
|
||||
{
|
||||
// :P
|
||||
}
|
||||
@Override
|
||||
public void removeFromWorld()
|
||||
{
|
||||
super.removeFromWorld();
|
||||
this.outerProxy.invalidate();
|
||||
}
|
||||
|
||||
return amt;
|
||||
@Override
|
||||
public void addToWorld()
|
||||
{
|
||||
super.addToWorld();
|
||||
this.outerProxy.onReady();
|
||||
}
|
||||
|
||||
@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
|
||||
@@ -207,7 +146,71 @@ public class PartQuartzFiber extends AEBasePart implements IEnergyGridProvider
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getEnergyDemand(double amt, Set<IEnergyGrid> seen)
|
||||
public void onPlacement( EntityPlayer player, ItemStack held, ForgeDirection side )
|
||||
{
|
||||
super.onPlacement( player, held, side );
|
||||
this.outerProxy.setOwner( player );
|
||||
}
|
||||
|
||||
@Override
|
||||
public double extractAEPower( double amt, Actionable mode, Set<IEnergyGrid> seen )
|
||||
{
|
||||
double acquiredPower = 0;
|
||||
|
||||
try
|
||||
{
|
||||
IEnergyGrid eg = this.proxy.getEnergy();
|
||||
acquiredPower += eg.extractAEPower( amt - acquiredPower, mode, seen );
|
||||
}
|
||||
catch( GridAccessException e )
|
||||
{
|
||||
// :P
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
IEnergyGrid eg = this.outerProxy.getEnergy();
|
||||
acquiredPower += eg.extractAEPower( amt - acquiredPower, mode, seen );
|
||||
}
|
||||
catch( GridAccessException e )
|
||||
{
|
||||
// :P
|
||||
}
|
||||
|
||||
return acquiredPower;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double injectAEPower( double amt, Actionable mode, Set<IEnergyGrid> seen )
|
||||
{
|
||||
|
||||
try
|
||||
{
|
||||
IEnergyGrid eg = this.proxy.getEnergy();
|
||||
if( !seen.contains( eg ) )
|
||||
return eg.injectAEPower( amt, mode, seen );
|
||||
}
|
||||
catch( GridAccessException e )
|
||||
{
|
||||
// :P
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
IEnergyGrid eg = this.outerProxy.getEnergy();
|
||||
if( !seen.contains( eg ) )
|
||||
return eg.injectAEPower( amt, mode, seen );
|
||||
}
|
||||
catch( GridAccessException e )
|
||||
{
|
||||
// :P
|
||||
}
|
||||
|
||||
return amt;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getEnergyDemand( double amt, Set<IEnergyGrid> seen )
|
||||
{
|
||||
double demand = 0;
|
||||
|
||||
@@ -216,7 +219,7 @@ public class PartQuartzFiber extends AEBasePart implements IEnergyGridProvider
|
||||
IEnergyGrid eg = this.proxy.getEnergy();
|
||||
demand += eg.getEnergyDemand( amt - demand, seen );
|
||||
}
|
||||
catch (GridAccessException e)
|
||||
catch( GridAccessException e )
|
||||
{
|
||||
// :P
|
||||
}
|
||||
@@ -226,12 +229,11 @@ public class PartQuartzFiber extends AEBasePart implements IEnergyGridProvider
|
||||
IEnergyGrid eg = this.outerProxy.getEnergy();
|
||||
demand += eg.getEnergyDemand( amt - demand, seen );
|
||||
}
|
||||
catch (GridAccessException e)
|
||||
catch( GridAccessException e )
|
||||
{
|
||||
// :P
|
||||
}
|
||||
|
||||
return demand;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
|
||||
package appeng.parts.p2p;
|
||||
|
||||
|
||||
import java.util.LinkedList;
|
||||
|
||||
import net.minecraft.init.Blocks;
|
||||
@@ -37,35 +38,32 @@ import appeng.transformer.annotations.Integration.Interface;
|
||||
import appeng.transformer.annotations.Integration.InterfaceList;
|
||||
import appeng.util.Platform;
|
||||
|
||||
@InterfaceList(value = { @Interface(iface = "ic2.api.energy.tile.IEnergySink", iname = "IC2"),
|
||||
@Interface(iface = "ic2.api.energy.tile.IEnergySource", iname = "IC2") })
|
||||
|
||||
@InterfaceList( value = { @Interface( iface = "ic2.api.energy.tile.IEnergySink", iname = "IC2" ), @Interface( iface = "ic2.api.energy.tile.IEnergySource", iname = "IC2" ) } )
|
||||
public class PartP2PIC2Power extends PartP2PTunnel<PartP2PIC2Power> implements ic2.api.energy.tile.IEnergySink, ic2.api.energy.tile.IEnergySource
|
||||
{
|
||||
|
||||
public PartP2PIC2Power(ItemStack is) {
|
||||
super( is );
|
||||
}
|
||||
|
||||
// two packet buffering...
|
||||
double OutputEnergyA;
|
||||
double OutputEnergyB;
|
||||
|
||||
// two packet buffering...
|
||||
double OutputVoltageA;
|
||||
double OutputVoltageB;
|
||||
|
||||
@Override
|
||||
public void writeToNBT(NBTTagCompound tag)
|
||||
public PartP2PIC2Power( ItemStack is )
|
||||
{
|
||||
super.writeToNBT( tag );
|
||||
tag.setDouble( "OutputPacket", this.OutputEnergyA );
|
||||
tag.setDouble( "OutputPacket2", this.OutputEnergyB );
|
||||
tag.setDouble( "OutputVoltageA", this.OutputVoltageA );
|
||||
tag.setDouble( "OutputVoltageB", this.OutputVoltageB );
|
||||
super( is );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound tag)
|
||||
@SideOnly( Side.CLIENT )
|
||||
public IIcon getTypeTexture()
|
||||
{
|
||||
return Blocks.diamond_block.getBlockTextureFromSide( 0 );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT( NBTTagCompound tag )
|
||||
{
|
||||
super.readFromNBT( tag );
|
||||
this.OutputEnergyA = tag.getDouble( "OutputPacket" );
|
||||
@@ -75,50 +73,19 @@ public class PartP2PIC2Power extends PartP2PTunnel<PartP2PIC2Power> implements i
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public IIcon getTypeTexture()
|
||||
public void writeToNBT( NBTTagCompound tag )
|
||||
{
|
||||
return Blocks.diamond_block.getBlockTextureFromSide( 0 );
|
||||
super.writeToNBT( tag );
|
||||
tag.setDouble( "OutputPacket", this.OutputEnergyA );
|
||||
tag.setDouble( "OutputPacket2", this.OutputEnergyB );
|
||||
tag.setDouble( "OutputVoltageA", this.OutputVoltageA );
|
||||
tag.setDouble( "OutputVoltageB", this.OutputVoltageB );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean acceptsEnergyFrom(TileEntity emitter, ForgeDirection direction)
|
||||
public void onTunnelConfigChange()
|
||||
{
|
||||
if ( !this.output )
|
||||
return direction == this.side;
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean emitsEnergyTo(TileEntity receiver, ForgeDirection direction)
|
||||
{
|
||||
if ( this.output )
|
||||
return direction == this.side;
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getDemandedEnergy()
|
||||
{
|
||||
if ( this.output )
|
||||
return 0;
|
||||
|
||||
try
|
||||
{
|
||||
for (PartP2PIC2Power t : this.getOutputs())
|
||||
{
|
||||
if ( t.OutputEnergyA <= 0.0001 || t.OutputEnergyB <= 0.0001 )
|
||||
{
|
||||
return 2048;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (GridAccessException e)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
return 0;
|
||||
this.getHost().partChanged();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -128,58 +95,93 @@ public class PartP2PIC2Power extends PartP2PTunnel<PartP2PIC2Power> implements i
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTunnelConfigChange()
|
||||
public boolean acceptsEnergyFrom( TileEntity emitter, ForgeDirection direction )
|
||||
{
|
||||
this.getHost().partChanged();
|
||||
}
|
||||
|
||||
public float getPowerDrainPerTick()
|
||||
{
|
||||
return 0.5f;
|
||||
if( !this.output )
|
||||
return direction == this.side;
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double injectEnergy(ForgeDirection directionFrom, double amount, double voltage)
|
||||
public boolean emitsEnergyTo( TileEntity receiver, ForgeDirection direction )
|
||||
{
|
||||
if( this.output )
|
||||
return direction == this.side;
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getDemandedEnergy()
|
||||
{
|
||||
if( this.output )
|
||||
return 0;
|
||||
|
||||
try
|
||||
{
|
||||
for( PartP2PIC2Power t : this.getOutputs() )
|
||||
{
|
||||
if( t.OutputEnergyA <= 0.0001 || t.OutputEnergyB <= 0.0001 )
|
||||
{
|
||||
return 2048;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch( GridAccessException e )
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSinkTier()
|
||||
{
|
||||
return 4;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double injectEnergy( ForgeDirection directionFrom, double amount, double voltage )
|
||||
{
|
||||
TunnelCollection<PartP2PIC2Power> outs;
|
||||
try
|
||||
{
|
||||
outs = this.getOutputs();
|
||||
}
|
||||
catch (GridAccessException e)
|
||||
catch( GridAccessException e )
|
||||
{
|
||||
return amount;
|
||||
}
|
||||
|
||||
if ( outs.isEmpty() )
|
||||
if( outs.isEmpty() )
|
||||
return amount;
|
||||
|
||||
LinkedList<PartP2PIC2Power> Options = new LinkedList<PartP2PIC2Power>();
|
||||
for (PartP2PIC2Power o : outs)
|
||||
for( PartP2PIC2Power o : outs )
|
||||
{
|
||||
if ( o.OutputEnergyA <= 0.01 )
|
||||
if( o.OutputEnergyA <= 0.01 )
|
||||
Options.add( o );
|
||||
}
|
||||
|
||||
if ( Options.isEmpty() )
|
||||
if( Options.isEmpty() )
|
||||
{
|
||||
for (PartP2PIC2Power o : outs)
|
||||
if ( o.OutputEnergyB <= 0.01 )
|
||||
for( PartP2PIC2Power o : outs )
|
||||
if( o.OutputEnergyB <= 0.01 )
|
||||
Options.add( o );
|
||||
}
|
||||
|
||||
if ( Options.isEmpty() )
|
||||
if( Options.isEmpty() )
|
||||
{
|
||||
for (PartP2PIC2Power o : outs)
|
||||
for( PartP2PIC2Power o : outs )
|
||||
Options.add( o );
|
||||
}
|
||||
|
||||
if ( Options.isEmpty() )
|
||||
if( Options.isEmpty() )
|
||||
return amount;
|
||||
|
||||
PartP2PIC2Power x = Platform.pickRandom( Options );
|
||||
|
||||
if ( x != null && x.OutputEnergyA <= 0.001 )
|
||||
if( x != null && x.OutputEnergyA <= 0.001 )
|
||||
{
|
||||
this.QueueTunnelDrain( PowerUnits.EU, amount );
|
||||
x.OutputEnergyA = amount;
|
||||
@@ -187,7 +189,7 @@ public class PartP2PIC2Power extends PartP2PTunnel<PartP2PIC2Power> implements i
|
||||
return 0;
|
||||
}
|
||||
|
||||
if ( x != null && x.OutputEnergyB <= 0.001 )
|
||||
if( x != null && x.OutputEnergyB <= 0.001 )
|
||||
{
|
||||
this.QueueTunnelDrain( PowerUnits.EU, amount );
|
||||
x.OutputEnergyB = amount;
|
||||
@@ -198,25 +200,24 @@ public class PartP2PIC2Power extends PartP2PTunnel<PartP2PIC2Power> implements i
|
||||
return amount;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSinkTier()
|
||||
public float getPowerDrainPerTick()
|
||||
{
|
||||
return 4;
|
||||
return 0.5f;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getOfferedEnergy()
|
||||
{
|
||||
if ( this.output )
|
||||
if( this.output )
|
||||
return this.OutputEnergyA;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawEnergy(double amount)
|
||||
public void drawEnergy( double amount )
|
||||
{
|
||||
this.OutputEnergyA -= amount;
|
||||
if ( this.OutputEnergyA < 0.001 )
|
||||
if( this.OutputEnergyA < 0.001 )
|
||||
{
|
||||
this.OutputEnergyA = this.OutputEnergyB;
|
||||
this.OutputEnergyB = 0;
|
||||
@@ -229,14 +230,13 @@ public class PartP2PIC2Power extends PartP2PTunnel<PartP2PIC2Power> implements i
|
||||
@Override
|
||||
public int getSourceTier()
|
||||
{
|
||||
if ( this.output )
|
||||
if( this.output )
|
||||
return this.calculateTierFromVoltage( this.OutputVoltageA );
|
||||
return 4;
|
||||
}
|
||||
|
||||
private int calculateTierFromVoltage(double voltage)
|
||||
private int calculateTierFromVoltage( double voltage )
|
||||
{
|
||||
return ic2.api.energy.EnergyNet.instance.getTierFromPower( voltage );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
|
||||
package appeng.parts.p2p;
|
||||
|
||||
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
@@ -59,45 +60,89 @@ import appeng.util.inv.WrapperBCPipe;
|
||||
import appeng.util.inv.WrapperChainedInventory;
|
||||
import appeng.util.inv.WrapperMCISidedInventory;
|
||||
|
||||
@Interface(iface = "buildcraft.api.transport.IPipeConnection", iname = "BC")
|
||||
|
||||
@Interface( iface = "buildcraft.api.transport.IPipeConnection", iname = "BC" )
|
||||
public class PartP2PItems extends PartP2PTunnel<PartP2PItems> implements IPipeConnection, ISidedInventory, IGridTickable
|
||||
{
|
||||
|
||||
public PartP2PItems(ItemStack is) {
|
||||
super( is );
|
||||
}
|
||||
|
||||
final LinkedList<IInventory> which = new LinkedList<IInventory>();
|
||||
int oldSize = 0;
|
||||
boolean requested;
|
||||
IInventory cachedInv;
|
||||
|
||||
final LinkedList<IInventory> which = new LinkedList<IInventory>();
|
||||
public PartP2PItems( ItemStack is )
|
||||
{
|
||||
super( is );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNeighborChanged()
|
||||
{
|
||||
this.cachedInv = null;
|
||||
PartP2PItems input = this.getInput();
|
||||
if( input != null && this.output )
|
||||
input.onTunnelNetworkChange();
|
||||
}
|
||||
|
||||
IInventory getDestination()
|
||||
{
|
||||
this.requested = true;
|
||||
|
||||
if( this.cachedInv != null )
|
||||
return this.cachedInv;
|
||||
|
||||
List<IInventory> outs = new LinkedList<IInventory>();
|
||||
TunnelCollection<PartP2PItems> itemTunnels;
|
||||
|
||||
try
|
||||
{
|
||||
itemTunnels = this.getOutputs();
|
||||
}
|
||||
catch( GridAccessException e )
|
||||
{
|
||||
return new AppEngNullInventory();
|
||||
}
|
||||
|
||||
for( PartP2PItems t : itemTunnels )
|
||||
{
|
||||
IInventory inv = t.getOutputInv();
|
||||
if( inv != null )
|
||||
{
|
||||
if( Platform.getRandomInt() % 2 == 0 )
|
||||
outs.add( inv );
|
||||
else
|
||||
outs.add( 0, inv );
|
||||
}
|
||||
}
|
||||
|
||||
return this.cachedInv = new WrapperChainedInventory( outs );
|
||||
}
|
||||
|
||||
IInventory getOutputInv()
|
||||
{
|
||||
IInventory output = null;
|
||||
|
||||
if ( this.proxy.isActive() )
|
||||
if( this.proxy.isActive() )
|
||||
{
|
||||
TileEntity te = this.tile.getWorldObj().getTileEntity( this.tile.xCoord + this.side.offsetX, this.tile.yCoord + this.side.offsetY, this.tile.zCoord + this.side.offsetZ );
|
||||
|
||||
if ( this.which.contains( this ) )
|
||||
if( this.which.contains( this ) )
|
||||
return null;
|
||||
|
||||
this.which.add( this );
|
||||
|
||||
if ( AppEng.instance.isIntegrationEnabled( IntegrationType.BC ) )
|
||||
if( AppEng.instance.isIntegrationEnabled( IntegrationType.BC ) )
|
||||
{
|
||||
IBC buildcraft = (IBC) AppEng.instance.getIntegration( IntegrationType.BC );
|
||||
if ( buildcraft != null )
|
||||
if( buildcraft != null )
|
||||
{
|
||||
if ( buildcraft.isPipe( te, this.side.getOpposite() ) )
|
||||
if( buildcraft.isPipe( te, this.side.getOpposite() ) )
|
||||
{
|
||||
try
|
||||
{
|
||||
output = new WrapperBCPipe( te, this.side.getOpposite() );
|
||||
}
|
||||
catch (Throwable ignore)
|
||||
catch( Throwable ignore )
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -110,17 +155,17 @@ public class PartP2PItems extends PartP2PTunnel<PartP2PItems> implements IPipeCo
|
||||
* WrapperTEPipe( te, side.getOpposite() ); } catch (Throwable ignore) { } } } }
|
||||
*/
|
||||
|
||||
if ( output == null )
|
||||
if( output == null )
|
||||
{
|
||||
if ( te instanceof TileEntityChest )
|
||||
if( te instanceof TileEntityChest )
|
||||
{
|
||||
output = Platform.GetChestInv( te );
|
||||
}
|
||||
else if ( te instanceof ISidedInventory )
|
||||
else if( te instanceof ISidedInventory )
|
||||
{
|
||||
output = new WrapperMCISidedInventory( (ISidedInventory) te, this.side.getOpposite() );
|
||||
}
|
||||
else if ( te instanceof IInventory )
|
||||
else if( te instanceof IInventory )
|
||||
{
|
||||
output = (IInventory) te;
|
||||
}
|
||||
@@ -133,75 +178,32 @@ public class PartP2PItems extends PartP2PTunnel<PartP2PItems> implements IPipeCo
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNeighborChanged()
|
||||
{
|
||||
this.cachedInv = null;
|
||||
PartP2PItems input = this.getInput();
|
||||
if ( input != null && this.output )
|
||||
input.onTunnelNetworkChange();
|
||||
}
|
||||
|
||||
@Override
|
||||
public TickingRequest getTickingRequest(IGridNode node)
|
||||
public TickingRequest getTickingRequest( IGridNode node )
|
||||
{
|
||||
return new TickingRequest( TickRates.ItemTunnel.min, TickRates.ItemTunnel.max, false, false );
|
||||
}
|
||||
|
||||
@Override
|
||||
public TickRateModulation tickingRequest(IGridNode node, int TicksSinceLastCall)
|
||||
public TickRateModulation tickingRequest( IGridNode node, int TicksSinceLastCall )
|
||||
{
|
||||
boolean wasReq = this.requested;
|
||||
|
||||
if ( this.requested && this.cachedInv != null )
|
||||
((WrapperChainedInventory) this.cachedInv).cycleOrder();
|
||||
if( this.requested && this.cachedInv != null )
|
||||
( (WrapperChainedInventory) this.cachedInv ).cycleOrder();
|
||||
|
||||
this.requested = false;
|
||||
return wasReq ? TickRateModulation.FASTER : TickRateModulation.SLOWER;
|
||||
}
|
||||
|
||||
IInventory getDestination()
|
||||
{
|
||||
this.requested = true;
|
||||
|
||||
if ( this.cachedInv != null )
|
||||
return this.cachedInv;
|
||||
|
||||
List<IInventory> outs = new LinkedList<IInventory>();
|
||||
TunnelCollection<PartP2PItems> itemTunnels;
|
||||
|
||||
try
|
||||
{
|
||||
itemTunnels = this.getOutputs();
|
||||
}
|
||||
catch (GridAccessException e)
|
||||
{
|
||||
return new AppEngNullInventory();
|
||||
}
|
||||
|
||||
for (PartP2PItems t : itemTunnels)
|
||||
{
|
||||
IInventory inv = t.getOutputInv();
|
||||
if ( inv != null )
|
||||
{
|
||||
if ( Platform.getRandomInt() % 2 == 0 )
|
||||
outs.add( inv );
|
||||
else
|
||||
outs.add( 0, inv );
|
||||
}
|
||||
}
|
||||
|
||||
return this.cachedInv = new WrapperChainedInventory( outs );
|
||||
}
|
||||
|
||||
@MENetworkEventSubscribe
|
||||
public void changeStateA(MENetworkBootingStatusChange bs)
|
||||
public void changeStateA( MENetworkBootingStatusChange bs )
|
||||
{
|
||||
if ( !this.output )
|
||||
if( !this.output )
|
||||
{
|
||||
this.cachedInv = null;
|
||||
int olderSize = this.oldSize;
|
||||
this.oldSize = this.getDestination().getSizeInventory();
|
||||
if ( olderSize != this.oldSize )
|
||||
if( olderSize != this.oldSize )
|
||||
{
|
||||
this.getHost().notifyNeighbors();
|
||||
}
|
||||
@@ -209,14 +211,14 @@ public class PartP2PItems extends PartP2PTunnel<PartP2PItems> implements IPipeCo
|
||||
}
|
||||
|
||||
@MENetworkEventSubscribe
|
||||
public void changeStateB(MENetworkChannelsChanged bs)
|
||||
public void changeStateB( MENetworkChannelsChanged bs )
|
||||
{
|
||||
if ( !this.output )
|
||||
if( !this.output )
|
||||
{
|
||||
this.cachedInv = null;
|
||||
int olderSize = this.oldSize;
|
||||
this.oldSize = this.getDestination().getSizeInventory();
|
||||
if ( olderSize != this.oldSize )
|
||||
if( olderSize != this.oldSize )
|
||||
{
|
||||
this.getHost().notifyNeighbors();
|
||||
}
|
||||
@@ -224,29 +226,36 @@ public class PartP2PItems extends PartP2PTunnel<PartP2PItems> implements IPipeCo
|
||||
}
|
||||
|
||||
@MENetworkEventSubscribe
|
||||
public void changeStateC(MENetworkPowerStatusChange bs)
|
||||
public void changeStateC( MENetworkPowerStatusChange bs )
|
||||
{
|
||||
if ( !this.output )
|
||||
if( !this.output )
|
||||
{
|
||||
this.cachedInv = null;
|
||||
int olderSize = this.oldSize;
|
||||
this.oldSize = this.getDestination().getSizeInventory();
|
||||
if ( olderSize != this.oldSize )
|
||||
if( olderSize != this.oldSize )
|
||||
{
|
||||
this.getHost().notifyNeighbors();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly( Side.CLIENT )
|
||||
public IIcon getTypeTexture()
|
||||
{
|
||||
return Blocks.hopper.getBlockTextureFromSide( 0 );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTunnelNetworkChange()
|
||||
{
|
||||
if ( !this.output )
|
||||
if( !this.output )
|
||||
{
|
||||
this.cachedInv = null;
|
||||
int olderSize = this.oldSize;
|
||||
this.oldSize = this.getDestination().getSizeInventory();
|
||||
if ( olderSize != this.oldSize )
|
||||
if( olderSize != this.oldSize )
|
||||
{
|
||||
this.getHost().notifyNeighbors();
|
||||
}
|
||||
@@ -254,16 +263,18 @@ public class PartP2PItems extends PartP2PTunnel<PartP2PItems> implements IPipeCo
|
||||
else
|
||||
{
|
||||
PartP2PItems input = this.getInput();
|
||||
if ( input != null )
|
||||
if( input != null )
|
||||
input.getHost().notifyNeighbors();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public IIcon getTypeTexture()
|
||||
public int[] getAccessibleSlotsFromSide( int var1 )
|
||||
{
|
||||
return Blocks.hopper.getBlockTextureFromSide( 0 );
|
||||
int[] slots = new int[this.getSizeInventory()];
|
||||
for( int x = 0; x < this.getSizeInventory(); x++ )
|
||||
slots[x] = x;
|
||||
return slots;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -273,25 +284,25 @@ public class PartP2PItems extends PartP2PTunnel<PartP2PItems> implements IPipeCo
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getStackInSlot(int i)
|
||||
public ItemStack getStackInSlot( int i )
|
||||
{
|
||||
return this.getDestination().getStackInSlot( i );
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack decrStackSize(int i, int j)
|
||||
public ItemStack decrStackSize( int i, int j )
|
||||
{
|
||||
return this.getDestination().decrStackSize( i, j );
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getStackInSlotOnClosing(int i)
|
||||
public ItemStack getStackInSlotOnClosing( int i )
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setInventorySlotContents(int i, ItemStack itemstack)
|
||||
public void setInventorySlotContents( int i, ItemStack itemstack )
|
||||
{
|
||||
this.getDestination().setInventorySlotContents( i, itemstack );
|
||||
}
|
||||
@@ -314,6 +325,18 @@ public class PartP2PItems extends PartP2PTunnel<PartP2PItems> implements IPipeCo
|
||||
return this.getDestination().getInventoryStackLimit();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void markDirty()
|
||||
{
|
||||
// eh?
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isUseableByPlayer( EntityPlayer entityplayer )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void openInventory()
|
||||
{
|
||||
@@ -325,18 +348,21 @@ public class PartP2PItems extends PartP2PTunnel<PartP2PItems> implements IPipeCo
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isItemValidForSlot(int i, net.minecraft.item.ItemStack itemstack)
|
||||
public boolean isItemValidForSlot( int i, net.minecraft.item.ItemStack itemstack )
|
||||
{
|
||||
return this.getDestination().isItemValidForSlot( i, itemstack );
|
||||
}
|
||||
|
||||
@Override
|
||||
public int[] getAccessibleSlotsFromSide(int var1)
|
||||
public boolean canInsertItem( int i, ItemStack itemstack, int j )
|
||||
{
|
||||
int[] slots = new int[this.getSizeInventory()];
|
||||
for (int x = 0; x < this.getSizeInventory(); x++)
|
||||
slots[x] = x;
|
||||
return slots;
|
||||
return this.getDestination().isItemValidForSlot( i, itemstack );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canExtractItem( int i, ItemStack itemstack, int j )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public float getPowerDrainPerTick()
|
||||
@@ -345,34 +371,9 @@ public class PartP2PItems extends PartP2PTunnel<PartP2PItems> implements IPipeCo
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canInsertItem(int i, ItemStack itemstack, int j)
|
||||
{
|
||||
return this.getDestination().isItemValidForSlot( i, itemstack );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canExtractItem(int i, ItemStack itemstack, int j)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isUseableByPlayer(EntityPlayer entityplayer)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Method(iname = "BC")
|
||||
public ConnectOverride overridePipeConnection(PipeType type, ForgeDirection with)
|
||||
@Method( iname = "BC" )
|
||||
public ConnectOverride overridePipeConnection( PipeType type, ForgeDirection with )
|
||||
{
|
||||
return this.side == with && type == PipeType.ITEM ? ConnectOverride.CONNECT : ConnectOverride.DEFAULT;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void markDirty()
|
||||
{
|
||||
// eh?
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
|
||||
package appeng.parts.p2p;
|
||||
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
@@ -41,75 +42,73 @@ import appeng.api.networking.ticking.TickingRequest;
|
||||
import appeng.core.settings.TickRates;
|
||||
import appeng.me.GridAccessException;
|
||||
|
||||
|
||||
public class PartP2PLight extends PartP2PTunnel<PartP2PLight> implements IGridTickable
|
||||
{
|
||||
|
||||
public PartP2PLight(ItemStack is) {
|
||||
super( is );
|
||||
}
|
||||
|
||||
int lastValue = 0;
|
||||
float opacity = -1;
|
||||
|
||||
public void setLightLevel(int out)
|
||||
public PartP2PLight( ItemStack is )
|
||||
{
|
||||
this.lastValue = out;
|
||||
this.getHost().markForUpdate();
|
||||
super( is );
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getLightLevel()
|
||||
{
|
||||
if ( this.output && this.isPowered() )
|
||||
return this.blockLight( this.lastValue );
|
||||
|
||||
return 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 void chanRender(MENetworkChannelsChanged c)
|
||||
public void chanRender( MENetworkChannelsChanged c )
|
||||
{
|
||||
this.onTunnelNetworkChange();
|
||||
super.chanRender( c );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void powerRender(MENetworkPowerStatusChange c)
|
||||
public void powerRender( MENetworkPowerStatusChange c )
|
||||
{
|
||||
this.onTunnelNetworkChange();
|
||||
super.powerRender( c );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTunnelNetworkChange()
|
||||
public void writeToStream( ByteBuf data ) throws IOException
|
||||
{
|
||||
if ( this.output )
|
||||
{
|
||||
PartP2PLight src = this.getInput();
|
||||
if ( src != null && src.proxy.isActive() )
|
||||
this.setLightLevel( src.lastValue );
|
||||
else
|
||||
this.getHost().markForUpdate();
|
||||
}
|
||||
else
|
||||
this.doWork();
|
||||
super.writeToStream( data );
|
||||
data.writeInt( this.output ? this.lastValue : 0 );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTunnelConfigChange()
|
||||
public boolean readFromStream( ByteBuf data ) throws IOException
|
||||
{
|
||||
this.onTunnelNetworkChange();
|
||||
super.readFromStream( data );
|
||||
this.lastValue = data.readInt();
|
||||
this.output = this.lastValue > 0;
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean doWork()
|
||||
{
|
||||
if( this.output )
|
||||
return false;
|
||||
|
||||
TileEntity te = this.getTile();
|
||||
World w = te.getWorldObj();
|
||||
|
||||
int newLevel = w.getBlockLightValue( te.xCoord + this.side.offsetX, te.yCoord + this.side.offsetY, te.zCoord + this.side.offsetZ );
|
||||
|
||||
if( this.lastValue != newLevel && this.proxy.isActive() )
|
||||
{
|
||||
this.lastValue = newLevel;
|
||||
try
|
||||
{
|
||||
for( PartP2PLight out : this.getOutputs() )
|
||||
out.setLightLevel( this.lastValue );
|
||||
}
|
||||
catch( GridAccessException e )
|
||||
{
|
||||
// :P
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -119,12 +118,54 @@ public class PartP2PLight extends PartP2PTunnel<PartP2PLight> implements IGridTi
|
||||
|
||||
this.doWork();
|
||||
|
||||
if ( this.output )
|
||||
if( this.output )
|
||||
this.getHost().markForUpdate();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT(NBTTagCompound tag)
|
||||
public int getLightLevel()
|
||||
{
|
||||
if( this.output && this.isPowered() )
|
||||
return this.blockLight( this.lastValue );
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
public void setLightLevel( int out )
|
||||
{
|
||||
this.lastValue = out;
|
||||
this.getHost().markForUpdate();
|
||||
}
|
||||
|
||||
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
|
||||
@SideOnly( Side.CLIENT )
|
||||
public IIcon getTypeTexture()
|
||||
{
|
||||
return Blocks.quartz_block.getBlockTextureFromSide( 0 );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT( NBTTagCompound tag )
|
||||
{
|
||||
super.readFromNBT( tag );
|
||||
if( tag.hasKey( "opacity" ) )
|
||||
this.opacity = tag.getFloat( "opacity" );
|
||||
this.lastValue = tag.getInteger( "lastValue" );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT( NBTTagCompound tag )
|
||||
{
|
||||
super.writeToNBT( tag );
|
||||
tag.setFloat( "opacity", this.opacity );
|
||||
@@ -132,78 +173,40 @@ public class PartP2PLight extends PartP2PTunnel<PartP2PLight> implements IGridTi
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound tag)
|
||||
public void onTunnelConfigChange()
|
||||
{
|
||||
super.readFromNBT( tag );
|
||||
if ( tag.hasKey( "opacity" ) )
|
||||
this.opacity = tag.getFloat( "opacity" );
|
||||
this.lastValue = tag.getInteger( "lastValue" );
|
||||
this.onTunnelNetworkChange();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean readFromStream(ByteBuf data) throws IOException
|
||||
public void onTunnelNetworkChange()
|
||||
{
|
||||
super.readFromStream( data );
|
||||
this.lastValue = data.readInt();
|
||||
this.output = this.lastValue > 0;
|
||||
return false;
|
||||
if( this.output )
|
||||
{
|
||||
PartP2PLight src = this.getInput();
|
||||
if( src != null && src.proxy.isActive() )
|
||||
this.setLightLevel( src.lastValue );
|
||||
else
|
||||
this.getHost().markForUpdate();
|
||||
}
|
||||
else
|
||||
this.doWork();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToStream(ByteBuf data) throws IOException
|
||||
{
|
||||
super.writeToStream( data );
|
||||
data.writeInt( this.output ? this.lastValue : 0 );
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public IIcon getTypeTexture()
|
||||
{
|
||||
return Blocks.quartz_block.getBlockTextureFromSide( 0 );
|
||||
}
|
||||
|
||||
@Override
|
||||
public TickingRequest getTickingRequest(IGridNode node)
|
||||
public TickingRequest getTickingRequest( IGridNode node )
|
||||
{
|
||||
return new TickingRequest( TickRates.LightTunnel.min, TickRates.LightTunnel.max, false, false );
|
||||
}
|
||||
|
||||
private boolean doWork()
|
||||
@Override
|
||||
public TickRateModulation tickingRequest( IGridNode node, int TicksSinceLastCall )
|
||||
{
|
||||
if ( this.output )
|
||||
return false;
|
||||
|
||||
TileEntity te = this.getTile();
|
||||
World w = te.getWorldObj();
|
||||
|
||||
int newLevel = w.getBlockLightValue( te.xCoord + this.side.offsetX, te.yCoord + this.side.offsetY, te.zCoord + this.side.offsetZ );
|
||||
|
||||
if ( this.lastValue != newLevel && this.proxy.isActive() )
|
||||
{
|
||||
this.lastValue = newLevel;
|
||||
try
|
||||
{
|
||||
for (PartP2PLight out : this.getOutputs())
|
||||
out.setLightLevel( this.lastValue );
|
||||
}
|
||||
catch (GridAccessException e)
|
||||
{
|
||||
// :P
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
return this.doWork() ? TickRateModulation.FASTER : TickRateModulation.SLOWER;
|
||||
}
|
||||
|
||||
public float getPowerDrainPerTick()
|
||||
{
|
||||
return 0.5f;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TickRateModulation tickingRequest(IGridNode node, int TicksSinceLastCall)
|
||||
{
|
||||
return this.doWork() ? TickRateModulation.FASTER : TickRateModulation.SLOWER;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
|
||||
package appeng.parts.p2p;
|
||||
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
@@ -38,131 +39,58 @@ import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
import appeng.me.GridAccessException;
|
||||
|
||||
|
||||
public class PartP2PLiquids extends PartP2PTunnel<PartP2PLiquids> implements IFluidHandler
|
||||
{
|
||||
|
||||
static final ThreadLocal<Stack<PartP2PLiquids>> DEPTH = new ThreadLocal<Stack<PartP2PLiquids>>();
|
||||
private final static FluidTankInfo[] ACTIVE_TANK = new FluidTankInfo[] { new FluidTankInfo( null, 10000 ) };
|
||||
private final static FluidTankInfo[] INACTIVE_TANK = new FluidTankInfo[] { new FluidTankInfo( null, 0 ) };
|
||||
IFluidHandler cachedTank;
|
||||
private int tmpUsed;
|
||||
|
||||
public PartP2PLiquids(ItemStack is) {
|
||||
public PartP2PLiquids( ItemStack is )
|
||||
{
|
||||
super( is );
|
||||
}
|
||||
|
||||
private FluidTankInfo[] getTank()
|
||||
{
|
||||
if ( this.output )
|
||||
{
|
||||
PartP2PLiquids tun = this.getInput();
|
||||
if ( tun != null )
|
||||
return ACTIVE_TANK;
|
||||
}
|
||||
else
|
||||
{
|
||||
try
|
||||
{
|
||||
if ( !this.getOutputs().isEmpty() )
|
||||
return ACTIVE_TANK;
|
||||
}
|
||||
catch (GridAccessException e)
|
||||
{
|
||||
// :(
|
||||
}
|
||||
}
|
||||
return INACTIVE_TANK;
|
||||
}
|
||||
|
||||
IFluidHandler cachedTank;
|
||||
|
||||
public float getPowerDrainPerTick()
|
||||
{
|
||||
return 2.0f;
|
||||
}
|
||||
|
||||
private int tmpUsed;
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
@SideOnly( Side.CLIENT )
|
||||
public IIcon getTypeTexture()
|
||||
{
|
||||
return Blocks.lapis_block.getBlockTextureFromSide( 0 );
|
||||
}
|
||||
|
||||
List<PartP2PLiquids> getOutputs(Fluid input)
|
||||
{
|
||||
List<PartP2PLiquids> outs = new LinkedList<PartP2PLiquids>();
|
||||
|
||||
try
|
||||
{
|
||||
for (PartP2PLiquids l : this.getOutputs())
|
||||
{
|
||||
IFluidHandler handler = l.getTarget();
|
||||
if ( handler != null )
|
||||
{
|
||||
if ( handler.canFill( l.side.getOpposite(), input ) )
|
||||
outs.add( l );
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (GridAccessException e)
|
||||
{
|
||||
// :P
|
||||
}
|
||||
|
||||
return outs;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNeighborChanged()
|
||||
{
|
||||
this.cachedTank = null;
|
||||
if ( this.output )
|
||||
{
|
||||
PartP2PLiquids in = this.getInput();
|
||||
if ( in != null )
|
||||
in.onTunnelNetworkChange();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTunnelNetworkChange()
|
||||
{
|
||||
this.cachedTank = null;
|
||||
}
|
||||
|
||||
IFluidHandler getTarget()
|
||||
@Override
|
||||
public void onNeighborChanged()
|
||||
{
|
||||
if ( !this.proxy.isActive() )
|
||||
return null;
|
||||
|
||||
if ( this.cachedTank != null )
|
||||
return this.cachedTank;
|
||||
|
||||
TileEntity te = this.tile.getWorldObj().getTileEntity( this.tile.xCoord + this.side.offsetX, this.tile.yCoord + this.side.offsetY, this.tile.zCoord + this.side.offsetZ );
|
||||
if ( te instanceof IFluidHandler )
|
||||
return this.cachedTank = (IFluidHandler) te;
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
static final ThreadLocal<Stack<PartP2PLiquids>> DEPTH = new ThreadLocal<Stack<PartP2PLiquids>>();
|
||||
|
||||
private Stack<PartP2PLiquids> getDepth()
|
||||
{
|
||||
Stack<PartP2PLiquids> s = DEPTH.get();
|
||||
|
||||
if ( s == null )
|
||||
DEPTH.set( s = new Stack<PartP2PLiquids>() );
|
||||
|
||||
return s;
|
||||
this.cachedTank = null;
|
||||
if( this.output )
|
||||
{
|
||||
PartP2PLiquids in = this.getInput();
|
||||
if( in != null )
|
||||
in.onTunnelNetworkChange();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int fill(ForgeDirection from, FluidStack resource, boolean doFill)
|
||||
public int fill( ForgeDirection from, FluidStack resource, boolean doFill )
|
||||
{
|
||||
Stack<PartP2PLiquids> stack = this.getDepth();
|
||||
|
||||
for (PartP2PLiquids t : stack)
|
||||
if ( t == this )
|
||||
for( PartP2PLiquids t : stack )
|
||||
if( t == this )
|
||||
return 0;
|
||||
|
||||
stack.push( this );
|
||||
@@ -171,32 +99,32 @@ public class PartP2PLiquids extends PartP2PTunnel<PartP2PLiquids> implements IFl
|
||||
int requestTotal = 0;
|
||||
|
||||
Iterator<PartP2PLiquids> i = list.iterator();
|
||||
while (i.hasNext())
|
||||
while( i.hasNext() )
|
||||
{
|
||||
PartP2PLiquids l = i.next();
|
||||
IFluidHandler tank = l.getTarget();
|
||||
if ( tank != null )
|
||||
if( tank != null )
|
||||
l.tmpUsed = tank.fill( l.side.getOpposite(), resource.copy(), false );
|
||||
else
|
||||
l.tmpUsed = 0;
|
||||
|
||||
if ( l.tmpUsed <= 0 )
|
||||
if( l.tmpUsed <= 0 )
|
||||
i.remove();
|
||||
else
|
||||
requestTotal += l.tmpUsed;
|
||||
}
|
||||
|
||||
if ( requestTotal <= 0 )
|
||||
if( requestTotal <= 0 )
|
||||
{
|
||||
if ( stack.pop() != this )
|
||||
if( stack.pop() != this )
|
||||
throw new RuntimeException( "Invalid Recursion detected." );
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
if ( !doFill )
|
||||
if( !doFill )
|
||||
{
|
||||
if ( stack.pop() != this )
|
||||
if( stack.pop() != this )
|
||||
throw new RuntimeException( "Invalid Recursion detected." );
|
||||
|
||||
return Math.min( resource.amount, requestTotal );
|
||||
@@ -206,17 +134,17 @@ public class PartP2PLiquids extends PartP2PTunnel<PartP2PLiquids> implements IFl
|
||||
int used = 0;
|
||||
|
||||
i = list.iterator();
|
||||
while (i.hasNext())
|
||||
while( i.hasNext() )
|
||||
{
|
||||
PartP2PLiquids l = i.next();
|
||||
|
||||
FluidStack insert = resource.copy();
|
||||
insert.amount = (int) Math.ceil( insert.amount * ((double) l.tmpUsed / (double) requestTotal) );
|
||||
if ( insert.amount > available )
|
||||
insert.amount = (int) Math.ceil( insert.amount * ( (double) l.tmpUsed / (double) requestTotal ) );
|
||||
if( insert.amount > available )
|
||||
insert.amount = available;
|
||||
|
||||
IFluidHandler tank = l.getTarget();
|
||||
if ( tank != null )
|
||||
if( tank != null )
|
||||
l.tmpUsed = tank.fill( l.side.getOpposite(), insert.copy(), true );
|
||||
else
|
||||
l.tmpUsed = 0;
|
||||
@@ -225,42 +153,113 @@ public class PartP2PLiquids extends PartP2PTunnel<PartP2PLiquids> implements IFl
|
||||
used += insert.amount;
|
||||
}
|
||||
|
||||
if ( stack.pop() != this )
|
||||
if( stack.pop() != this )
|
||||
throw new RuntimeException( "Invalid Recursion detected." );
|
||||
|
||||
return used;
|
||||
}
|
||||
|
||||
private Stack<PartP2PLiquids> getDepth()
|
||||
{
|
||||
Stack<PartP2PLiquids> s = DEPTH.get();
|
||||
|
||||
if( s == null )
|
||||
DEPTH.set( s = new Stack<PartP2PLiquids>() );
|
||||
|
||||
return s;
|
||||
}
|
||||
|
||||
List<PartP2PLiquids> getOutputs( Fluid input )
|
||||
{
|
||||
List<PartP2PLiquids> outs = new LinkedList<PartP2PLiquids>();
|
||||
|
||||
try
|
||||
{
|
||||
for( PartP2PLiquids l : this.getOutputs() )
|
||||
{
|
||||
IFluidHandler handler = l.getTarget();
|
||||
if( handler != null )
|
||||
{
|
||||
if( handler.canFill( l.side.getOpposite(), input ) )
|
||||
outs.add( l );
|
||||
}
|
||||
}
|
||||
}
|
||||
catch( GridAccessException e )
|
||||
{
|
||||
// :P
|
||||
}
|
||||
|
||||
return outs;
|
||||
}
|
||||
|
||||
IFluidHandler getTarget()
|
||||
{
|
||||
if( !this.proxy.isActive() )
|
||||
return null;
|
||||
|
||||
if( this.cachedTank != null )
|
||||
return this.cachedTank;
|
||||
|
||||
TileEntity te = this.tile.getWorldObj().getTileEntity( this.tile.xCoord + this.side.offsetX, this.tile.yCoord + this.side.offsetY, this.tile.zCoord + this.side.offsetZ );
|
||||
if( te instanceof IFluidHandler )
|
||||
return this.cachedTank = (IFluidHandler) te;
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canFill(ForgeDirection from, Fluid fluid)
|
||||
public FluidStack drain( ForgeDirection from, FluidStack resource, boolean doDrain )
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidStack drain( ForgeDirection from, int maxDrain, boolean doDrain )
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canFill( ForgeDirection from, Fluid fluid )
|
||||
{
|
||||
return !this.output && from == this.side && !this.getOutputs( fluid ).isEmpty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidStack drain(ForgeDirection from, FluidStack resource, boolean doDrain)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidStack drain(ForgeDirection from, int maxDrain, boolean doDrain)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canDrain(ForgeDirection from, Fluid fluid)
|
||||
public boolean canDrain( ForgeDirection from, Fluid fluid )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidTankInfo[] getTankInfo(ForgeDirection from)
|
||||
public FluidTankInfo[] getTankInfo( ForgeDirection from )
|
||||
{
|
||||
if ( from == this.side )
|
||||
if( from == this.side )
|
||||
return this.getTank();
|
||||
return new FluidTankInfo[0];
|
||||
}
|
||||
|
||||
private FluidTankInfo[] getTank()
|
||||
{
|
||||
if( this.output )
|
||||
{
|
||||
PartP2PLiquids tun = this.getInput();
|
||||
if( tun != null )
|
||||
return ACTIVE_TANK;
|
||||
}
|
||||
else
|
||||
{
|
||||
try
|
||||
{
|
||||
if( !this.getOutputs().isEmpty() )
|
||||
return ACTIVE_TANK;
|
||||
}
|
||||
catch( GridAccessException e )
|
||||
{
|
||||
// :(
|
||||
}
|
||||
}
|
||||
return INACTIVE_TANK;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -56,12 +56,6 @@ public class PartP2PRFPower extends PartP2PTunnel<PartP2PRFPower> implements IEn
|
||||
super( is );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTunnelNetworkChange()
|
||||
{
|
||||
this.getHost().notifyNeighbors();
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly( Side.CLIENT )
|
||||
public IIcon getTypeTexture()
|
||||
@@ -69,6 +63,12 @@ public class PartP2PRFPower extends PartP2PTunnel<PartP2PRFPower> implements IEn
|
||||
return Blocks.iron_block.getBlockTextureFromSide( 0 );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTunnelNetworkChange()
|
||||
{
|
||||
this.getHost().notifyNeighbors();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNeighborChanged()
|
||||
{
|
||||
@@ -80,15 +80,15 @@ public class PartP2PRFPower extends PartP2PTunnel<PartP2PRFPower> implements IEn
|
||||
@Override
|
||||
public int receiveEnergy( ForgeDirection from, int maxReceive, boolean simulate )
|
||||
{
|
||||
if ( this.output )
|
||||
if( this.output )
|
||||
return 0;
|
||||
|
||||
if ( this.isActive() )
|
||||
if( this.isActive() )
|
||||
{
|
||||
Stack<PartP2PRFPower> stack = this.getDepth();
|
||||
|
||||
for ( PartP2PRFPower t : stack )
|
||||
if ( t == this )
|
||||
for( PartP2PRFPower t : stack )
|
||||
if( t == this )
|
||||
return 0;
|
||||
|
||||
stack.push( this );
|
||||
@@ -97,39 +97,39 @@ public class PartP2PRFPower extends PartP2PTunnel<PartP2PRFPower> implements IEn
|
||||
|
||||
try
|
||||
{
|
||||
for ( PartP2PRFPower t : this.getOutputs() )
|
||||
for( PartP2PRFPower t : this.getOutputs() )
|
||||
{
|
||||
if ( Platform.getRandomInt() % 2 > 0 )
|
||||
if( Platform.getRandomInt() % 2 > 0 )
|
||||
{
|
||||
int receiver = t.getOutput().receiveEnergy( t.side.getOpposite(), maxReceive, simulate );
|
||||
maxReceive -= receiver;
|
||||
total += receiver;
|
||||
|
||||
if ( maxReceive <= 0 )
|
||||
if( maxReceive <= 0 )
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if ( maxReceive > 0 )
|
||||
if( maxReceive > 0 )
|
||||
{
|
||||
for ( PartP2PRFPower t : this.getOutputs() )
|
||||
for( PartP2PRFPower t : this.getOutputs() )
|
||||
{
|
||||
int receiver = t.getOutput().receiveEnergy( t.side.getOpposite(), maxReceive, simulate );
|
||||
maxReceive -= receiver;
|
||||
total += receiver;
|
||||
|
||||
if ( maxReceive <= 0 )
|
||||
if( maxReceive <= 0 )
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
this.QueueTunnelDrain( PowerUnits.RF, total );
|
||||
}
|
||||
catch ( GridAccessException ignored )
|
||||
catch( GridAccessException ignored )
|
||||
{
|
||||
}
|
||||
|
||||
if ( stack.pop() != this )
|
||||
if( stack.pop() != this )
|
||||
throw new RuntimeException( "Invalid Recursion detected." );
|
||||
|
||||
return total;
|
||||
@@ -142,7 +142,7 @@ public class PartP2PRFPower extends PartP2PTunnel<PartP2PRFPower> implements IEn
|
||||
{
|
||||
Stack<PartP2PRFPower> s = THREAD_STACK.get();
|
||||
|
||||
if ( s == null )
|
||||
if( s == null )
|
||||
THREAD_STACK.set( s = new Stack<PartP2PRFPower>() );
|
||||
|
||||
return s;
|
||||
@@ -150,17 +150,17 @@ public class PartP2PRFPower extends PartP2PTunnel<PartP2PRFPower> implements IEn
|
||||
|
||||
private IEnergyReceiver getOutput()
|
||||
{
|
||||
if ( this.output )
|
||||
if( this.output )
|
||||
{
|
||||
if ( !this.cachedTarget )
|
||||
if( !this.cachedTarget )
|
||||
{
|
||||
TileEntity self = this.getTile();
|
||||
TileEntity te = self.getWorldObj().getTileEntity( self.xCoord + this.side.offsetX, self.yCoord + this.side.offsetY, self.zCoord + this.side.offsetZ );
|
||||
this.outputTarget = te instanceof IEnergyReceiver ? ( IEnergyReceiver ) te : null;
|
||||
this.outputTarget = te instanceof IEnergyReceiver ? (IEnergyReceiver) te : null;
|
||||
this.cachedTarget = true;
|
||||
}
|
||||
|
||||
if ( this.outputTarget == null || !this.outputTarget.canConnectEnergy( this.side.getOpposite() ) )
|
||||
if( this.outputTarget == null || !this.outputTarget.canConnectEnergy( this.side.getOpposite() ) )
|
||||
return NULL_HANDLER;
|
||||
|
||||
return this.outputTarget;
|
||||
@@ -171,32 +171,32 @@ public class PartP2PRFPower extends PartP2PTunnel<PartP2PRFPower> implements IEn
|
||||
@Override
|
||||
public int getEnergyStored( ForgeDirection from )
|
||||
{
|
||||
if ( this.output || !this.isActive() )
|
||||
if( this.output || !this.isActive() )
|
||||
return 0;
|
||||
|
||||
int total = 0;
|
||||
|
||||
Stack<PartP2PRFPower> stack = this.getDepth();
|
||||
|
||||
for ( PartP2PRFPower t : stack )
|
||||
if ( t == this )
|
||||
for( PartP2PRFPower t : stack )
|
||||
if( t == this )
|
||||
return 0;
|
||||
|
||||
stack.push( this );
|
||||
|
||||
try
|
||||
{
|
||||
for ( PartP2PRFPower t : this.getOutputs() )
|
||||
for( PartP2PRFPower t : this.getOutputs() )
|
||||
{
|
||||
total += t.getOutput().getEnergyStored( t.side.getOpposite() );
|
||||
}
|
||||
}
|
||||
catch ( GridAccessException e )
|
||||
catch( GridAccessException e )
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
if ( stack.pop() != this )
|
||||
if( stack.pop() != this )
|
||||
throw new RuntimeException( "Invalid Recursion detected." );
|
||||
|
||||
return total;
|
||||
@@ -205,32 +205,32 @@ public class PartP2PRFPower extends PartP2PTunnel<PartP2PRFPower> implements IEn
|
||||
@Override
|
||||
public int getMaxEnergyStored( ForgeDirection from )
|
||||
{
|
||||
if ( this.output || !this.isActive() )
|
||||
if( this.output || !this.isActive() )
|
||||
return 0;
|
||||
|
||||
int total = 0;
|
||||
|
||||
Stack<PartP2PRFPower> stack = this.getDepth();
|
||||
|
||||
for ( PartP2PRFPower t : stack )
|
||||
if ( t == this )
|
||||
for( PartP2PRFPower t : stack )
|
||||
if( t == this )
|
||||
return 0;
|
||||
|
||||
stack.push( this );
|
||||
|
||||
try
|
||||
{
|
||||
for ( PartP2PRFPower t : this.getOutputs() )
|
||||
for( PartP2PRFPower t : this.getOutputs() )
|
||||
{
|
||||
total += t.getOutput().getMaxEnergyStored( t.side.getOpposite() );
|
||||
}
|
||||
}
|
||||
catch ( GridAccessException e )
|
||||
catch( GridAccessException e )
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
if ( stack.pop() != this )
|
||||
if( stack.pop() != this )
|
||||
throw new RuntimeException( "Invalid Recursion detected." );
|
||||
|
||||
return total;
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
|
||||
package appeng.parts.p2p;
|
||||
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockRedstoneWire;
|
||||
import net.minecraft.init.Blocks;
|
||||
@@ -36,86 +37,50 @@ import appeng.api.networking.events.MENetworkPowerStatusChange;
|
||||
import appeng.me.GridAccessException;
|
||||
import appeng.util.Platform;
|
||||
|
||||
|
||||
public class PartP2PRedstone extends PartP2PTunnel<PartP2PRedstone>
|
||||
{
|
||||
|
||||
public PartP2PRedstone(ItemStack is) {
|
||||
int power;
|
||||
boolean recursive = false;
|
||||
|
||||
public PartP2PRedstone( ItemStack is )
|
||||
{
|
||||
super( is );
|
||||
}
|
||||
|
||||
int power;
|
||||
|
||||
@Override
|
||||
public boolean canConnectRedstone()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int isProvidingStrongPower()
|
||||
{
|
||||
return this.output ? this.power : 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int isProvidingWeakPower()
|
||||
{
|
||||
return this.output ? this.power : 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTunnelNetworkChange()
|
||||
{
|
||||
this.setNetworkReady();
|
||||
}
|
||||
|
||||
@MENetworkEventSubscribe
|
||||
public void changeStateA(MENetworkBootingStatusChange bs)
|
||||
{
|
||||
this.setNetworkReady();
|
||||
}
|
||||
|
||||
@MENetworkEventSubscribe
|
||||
public void changeStateB(MENetworkChannelsChanged bs)
|
||||
{
|
||||
this.setNetworkReady();
|
||||
}
|
||||
|
||||
@MENetworkEventSubscribe
|
||||
public void changeStateC(MENetworkPowerStatusChange bs)
|
||||
public void changeStateA( MENetworkBootingStatusChange bs )
|
||||
{
|
||||
this.setNetworkReady();
|
||||
}
|
||||
|
||||
public void setNetworkReady()
|
||||
{
|
||||
if ( this.output )
|
||||
if( this.output )
|
||||
{
|
||||
PartP2PRedstone in = this.getInput();
|
||||
if ( in != null )
|
||||
if( in != null )
|
||||
this.putInput( in.power );
|
||||
}
|
||||
}
|
||||
|
||||
boolean recursive = false;
|
||||
|
||||
protected void putInput(Object o)
|
||||
protected void putInput( Object o )
|
||||
{
|
||||
if ( this.recursive )
|
||||
if( this.recursive )
|
||||
return;
|
||||
|
||||
this.recursive = true;
|
||||
if ( this.output && this.proxy.isActive() )
|
||||
if( this.output && this.proxy.isActive() )
|
||||
{
|
||||
int newPower = (Integer) o;
|
||||
if ( this.power != newPower )
|
||||
if( this.power != newPower )
|
||||
{
|
||||
this.power = newPower;
|
||||
this.notifyNeighbors();
|
||||
}
|
||||
}
|
||||
this.recursive = false;
|
||||
|
||||
}
|
||||
|
||||
public void notifyNeighbors()
|
||||
@@ -137,25 +102,43 @@ public class PartP2PRedstone extends PartP2PTunnel<PartP2PRedstone>
|
||||
Platform.notifyBlocksOfNeighbors( worldObj, xCoord + 1, yCoord, zCoord );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT(NBTTagCompound tag)
|
||||
@MENetworkEventSubscribe
|
||||
public void changeStateB( MENetworkChannelsChanged bs )
|
||||
{
|
||||
super.writeToNBT( tag );
|
||||
tag.setInteger( "power", this.power );
|
||||
this.setNetworkReady();
|
||||
}
|
||||
|
||||
@MENetworkEventSubscribe
|
||||
public void changeStateC( MENetworkPowerStatusChange bs )
|
||||
{
|
||||
this.setNetworkReady();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound tag)
|
||||
@SideOnly( Side.CLIENT )
|
||||
public IIcon getTypeTexture()
|
||||
{
|
||||
return Blocks.redstone_block.getBlockTextureFromSide( 0 );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT( NBTTagCompound tag )
|
||||
{
|
||||
super.readFromNBT( tag );
|
||||
this.power = tag.getInteger( "power" );
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public IIcon getTypeTexture()
|
||||
public void writeToNBT( NBTTagCompound tag )
|
||||
{
|
||||
return Blocks.redstone_block.getBlockTextureFromSide( 0 );
|
||||
super.writeToNBT( tag );
|
||||
tag.setInteger( "power", this.power );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTunnelNetworkChange()
|
||||
{
|
||||
this.setNetworkReady();
|
||||
}
|
||||
|
||||
public float getPowerDrainPerTick()
|
||||
@@ -166,17 +149,17 @@ public class PartP2PRedstone extends PartP2PTunnel<PartP2PRedstone>
|
||||
@Override
|
||||
public void onNeighborChanged()
|
||||
{
|
||||
if ( !this.output )
|
||||
if( !this.output )
|
||||
{
|
||||
int x = this.tile.xCoord + this.side.offsetX;
|
||||
int y = this.tile.yCoord + this.side.offsetY;
|
||||
int z = this.tile.zCoord + this.side.offsetZ;
|
||||
|
||||
Block b = this.tile.getWorldObj().getBlock( x, y, z );
|
||||
if ( b != null && !this.output )
|
||||
if( b != null && !this.output )
|
||||
{
|
||||
int srcSide = this.side.ordinal();
|
||||
if ( b instanceof BlockRedstoneWire )
|
||||
if( b instanceof BlockRedstoneWire )
|
||||
srcSide = 1;
|
||||
this.power = b.isProvidingStrongPower( this.tile.getWorldObj(), x, y, z, srcSide );
|
||||
this.power = Math.max( this.power, b.isProvidingWeakPower( this.tile.getWorldObj(), x, y, z, srcSide ) );
|
||||
@@ -187,19 +170,36 @@ public class PartP2PRedstone extends PartP2PTunnel<PartP2PRedstone>
|
||||
}
|
||||
}
|
||||
|
||||
private void sendToOutput(int power)
|
||||
@Override
|
||||
public boolean canConnectRedstone()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int isProvidingStrongPower()
|
||||
{
|
||||
return this.output ? this.power : 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int isProvidingWeakPower()
|
||||
{
|
||||
return this.output ? this.power : 0;
|
||||
}
|
||||
|
||||
private void sendToOutput( int power )
|
||||
{
|
||||
try
|
||||
{
|
||||
for (PartP2PRedstone rs : this.getOutputs())
|
||||
for( PartP2PRedstone rs : this.getOutputs() )
|
||||
{
|
||||
rs.putInput( power );
|
||||
}
|
||||
}
|
||||
catch (GridAccessException e)
|
||||
catch( GridAccessException e )
|
||||
{
|
||||
// :P
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -72,7 +72,7 @@ public abstract class PartP2PTunnel<T extends PartP2PTunnel> extends PartBasicSt
|
||||
|
||||
public TunnelCollection<T> getCollection( Collection<PartP2PTunnel> collection, Class<? extends PartP2PTunnel> c )
|
||||
{
|
||||
if ( this.type.matches( c ) )
|
||||
if( this.type.matches( c ) )
|
||||
{
|
||||
this.type.setSource( collection );
|
||||
return this.type;
|
||||
@@ -83,17 +83,17 @@ public abstract class PartP2PTunnel<T extends PartP2PTunnel> extends PartBasicSt
|
||||
|
||||
public T getInput()
|
||||
{
|
||||
if ( this.freq == 0 )
|
||||
if( this.freq == 0 )
|
||||
return null;
|
||||
|
||||
PartP2PTunnel tunnel;
|
||||
try
|
||||
{
|
||||
tunnel = this.proxy.getP2P().getInput( this.freq );
|
||||
if ( this.getClass().isInstance( tunnel ) )
|
||||
if( this.getClass().isInstance( tunnel ) )
|
||||
return (T) tunnel;
|
||||
}
|
||||
catch ( GridAccessException e )
|
||||
catch( GridAccessException e )
|
||||
{
|
||||
// :P
|
||||
}
|
||||
@@ -102,11 +102,19 @@ public abstract class PartP2PTunnel<T extends PartP2PTunnel> extends PartBasicSt
|
||||
|
||||
public TunnelCollection<T> getOutputs() throws GridAccessException
|
||||
{
|
||||
if ( this.proxy.isActive() )
|
||||
if( this.proxy.isActive() )
|
||||
return (TunnelCollection<T>) this.proxy.getP2P().getOutputs( this.freq, this.getClass() );
|
||||
return new TunnelCollection( new ArrayList(), this.getClass() );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getBoxes( IPartCollisionHelper bch )
|
||||
{
|
||||
bch.addBox( 5, 5, 12, 11, 11, 13 );
|
||||
bch.addBox( 3, 3, 13, 13, 13, 14 );
|
||||
bch.addBox( 2, 2, 14, 14, 14, 16 );
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly( Side.CLIENT )
|
||||
public void renderInventory( IPartRenderHelper rh, RenderBlocks renderer )
|
||||
@@ -128,7 +136,7 @@ public abstract class PartP2PTunnel<T extends PartP2PTunnel> extends PartBasicSt
|
||||
protected IIcon getTypeTexture()
|
||||
{
|
||||
final Optional<Block> maybeBlock = AEApi.instance().definitions().blocks().quartz().maybeBlock();
|
||||
if ( maybeBlock.isPresent() )
|
||||
if( maybeBlock.isPresent() )
|
||||
{
|
||||
return maybeBlock.get().getIcon( 0, 0 );
|
||||
}
|
||||
@@ -170,11 +178,11 @@ public abstract class PartP2PTunnel<T extends PartP2PTunnel> extends PartBasicSt
|
||||
@Override
|
||||
public ItemStack getItemStack( PartItemStack type )
|
||||
{
|
||||
if ( type == PartItemStack.World || type == PartItemStack.Network || type == PartItemStack.Wrench || type == PartItemStack.Pick )
|
||||
if( type == PartItemStack.World || type == PartItemStack.Network || type == PartItemStack.Wrench || type == PartItemStack.Pick )
|
||||
return super.getItemStack( type );
|
||||
|
||||
final Optional<ItemStack> maybeMEStack = AEApi.instance().definitions().parts().p2PTunnelME().maybeStack( 1 );
|
||||
if ( maybeMEStack.isPresent() )
|
||||
if( maybeMEStack.isPresent() )
|
||||
{
|
||||
return maybeMEStack.get();
|
||||
}
|
||||
@@ -198,14 +206,6 @@ public abstract class PartP2PTunnel<T extends PartP2PTunnel> extends PartBasicSt
|
||||
data.setLong( "freq", this.freq );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getBoxes( IPartCollisionHelper bch )
|
||||
{
|
||||
bch.addBox( 5, 5, 12, 11, 11, 13 );
|
||||
bch.addBox( 3, 3, 13, 13, 13, 14 );
|
||||
bch.addBox( 2, 2, 14, 14, 14, 16 );
|
||||
}
|
||||
|
||||
@Override
|
||||
public int cableConnectionRenderTo()
|
||||
{
|
||||
@@ -227,7 +227,7 @@ public abstract class PartP2PTunnel<T extends PartP2PTunnel> extends PartBasicSt
|
||||
// AELog.info( "ID:" + id.toString() + " : " + is.getItemDamage() );
|
||||
|
||||
TunnelType tt = AEApi.instance().registries().p2pTunnel().getTunnelTypeByItem( is );
|
||||
if ( is != null && is.getItem() instanceof IMemoryCard )
|
||||
if( is != null && is.getItem() instanceof IMemoryCard )
|
||||
{
|
||||
IMemoryCard mc = (IMemoryCard) is.getItem();
|
||||
NBTTagCompound data = mc.getData( is );
|
||||
@@ -235,18 +235,18 @@ public abstract class PartP2PTunnel<T extends PartP2PTunnel> extends PartBasicSt
|
||||
ItemStack newType = ItemStack.loadItemStackFromNBT( data );
|
||||
long freq = data.getLong( "freq" );
|
||||
|
||||
if ( newType != null )
|
||||
if( newType != null )
|
||||
{
|
||||
if ( newType.getItem() instanceof IPartItem )
|
||||
if( newType.getItem() instanceof IPartItem )
|
||||
{
|
||||
IPart testPart = ( (IPartItem) newType.getItem() ).createPartFromItemStack( newType );
|
||||
if ( testPart instanceof PartP2PTunnel )
|
||||
if( testPart instanceof PartP2PTunnel )
|
||||
{
|
||||
this.getHost().removePart( this.side, true );
|
||||
ForgeDirection dir = this.getHost().addPart( newType, this.side, player );
|
||||
IPart newBus = this.getHost().getPart( dir );
|
||||
|
||||
if ( newBus instanceof PartP2PTunnel )
|
||||
if( newBus instanceof PartP2PTunnel )
|
||||
{
|
||||
PartP2PTunnel newTunnel = (PartP2PTunnel) newBus;
|
||||
newTunnel.output = true;
|
||||
@@ -256,7 +256,7 @@ public abstract class PartP2PTunnel<T extends PartP2PTunnel> extends PartBasicSt
|
||||
P2PCache p2p = newTunnel.proxy.getP2P();
|
||||
p2p.updateFreq( newTunnel, freq );
|
||||
}
|
||||
catch ( GridAccessException e )
|
||||
catch( GridAccessException e )
|
||||
{
|
||||
// :P
|
||||
}
|
||||
@@ -271,58 +271,58 @@ public abstract class PartP2PTunnel<T extends PartP2PTunnel> extends PartBasicSt
|
||||
}
|
||||
mc.notifyUser( player, MemoryCardMessages.INVALID_MACHINE );
|
||||
}
|
||||
else if ( tt != null ) // attunement
|
||||
else if( tt != null ) // attunement
|
||||
{
|
||||
ItemStack newType = null;
|
||||
|
||||
final IParts parts = AEApi.instance().definitions().parts();
|
||||
|
||||
switch ( tt )
|
||||
switch( tt )
|
||||
{
|
||||
case LIGHT:
|
||||
for ( ItemStack stack : parts.p2PTunnelLight().maybeStack( 1 ).asSet() )
|
||||
for( ItemStack stack : parts.p2PTunnelLight().maybeStack( 1 ).asSet() )
|
||||
{
|
||||
newType = stack;
|
||||
}
|
||||
break;
|
||||
|
||||
case RF_POWER:
|
||||
for ( ItemStack stack : parts.p2PTunnelRF().maybeStack( 1 ).asSet() )
|
||||
for( ItemStack stack : parts.p2PTunnelRF().maybeStack( 1 ).asSet() )
|
||||
{
|
||||
newType = stack;
|
||||
}
|
||||
break;
|
||||
|
||||
case FLUID:
|
||||
for ( ItemStack stack : parts.p2PTunnelLiquids().maybeStack( 1 ).asSet() )
|
||||
for( ItemStack stack : parts.p2PTunnelLiquids().maybeStack( 1 ).asSet() )
|
||||
{
|
||||
newType = stack;
|
||||
}
|
||||
break;
|
||||
|
||||
case IC2_POWER:
|
||||
for ( ItemStack stack : parts.p2PTunnelEU().maybeStack( 1 ).asSet() )
|
||||
for( ItemStack stack : parts.p2PTunnelEU().maybeStack( 1 ).asSet() )
|
||||
{
|
||||
newType = stack;
|
||||
}
|
||||
break;
|
||||
|
||||
case ITEM:
|
||||
for ( ItemStack stack : parts.p2PTunnelItems().maybeStack( 1 ).asSet() )
|
||||
for( ItemStack stack : parts.p2PTunnelItems().maybeStack( 1 ).asSet() )
|
||||
{
|
||||
newType = stack;
|
||||
}
|
||||
break;
|
||||
|
||||
case ME:
|
||||
for ( ItemStack stack : parts.p2PTunnelME().maybeStack( 1 ).asSet() )
|
||||
for( ItemStack stack : parts.p2PTunnelME().maybeStack( 1 ).asSet() )
|
||||
{
|
||||
newType = stack;
|
||||
}
|
||||
break;
|
||||
|
||||
case REDSTONE:
|
||||
for ( ItemStack stack : parts.p2PTunnelRedstone().maybeStack( 1 ).asSet() )
|
||||
for( ItemStack stack : parts.p2PTunnelRedstone().maybeStack( 1 ).asSet() )
|
||||
{
|
||||
newType = stack;
|
||||
}
|
||||
@@ -332,7 +332,7 @@ public abstract class PartP2PTunnel<T extends PartP2PTunnel> extends PartBasicSt
|
||||
break;
|
||||
}
|
||||
|
||||
if ( newType != null && !Platform.isSameItem( newType, this.is ) )
|
||||
if( newType != null && !Platform.isSameItem( newType, this.is ) )
|
||||
{
|
||||
boolean oldOutput = this.output;
|
||||
long myFreq = this.freq;
|
||||
@@ -341,7 +341,7 @@ public abstract class PartP2PTunnel<T extends PartP2PTunnel> extends PartBasicSt
|
||||
ForgeDirection dir = this.getHost().addPart( newType, this.side, player );
|
||||
IPart newBus = this.getHost().getPart( dir );
|
||||
|
||||
if ( newBus instanceof PartP2PTunnel )
|
||||
if( newBus instanceof PartP2PTunnel )
|
||||
{
|
||||
PartP2PTunnel newTunnel = (PartP2PTunnel) newBus;
|
||||
newTunnel.output = oldOutput;
|
||||
@@ -352,7 +352,7 @@ public abstract class PartP2PTunnel<T extends PartP2PTunnel> extends PartBasicSt
|
||||
P2PCache p2p = newTunnel.proxy.getP2P();
|
||||
p2p.updateFreq( newTunnel, myFreq );
|
||||
}
|
||||
catch ( GridAccessException e )
|
||||
catch( GridAccessException e )
|
||||
{
|
||||
// :P
|
||||
}
|
||||
@@ -370,7 +370,7 @@ public abstract class PartP2PTunnel<T extends PartP2PTunnel> extends PartBasicSt
|
||||
public boolean onPartShiftActivate( EntityPlayer player, Vec3 pos )
|
||||
{
|
||||
ItemStack is = player.inventory.getCurrentItem();
|
||||
if ( is != null && is.getItem() instanceof IMemoryCard )
|
||||
if( is != null && is.getItem() instanceof IMemoryCard )
|
||||
{
|
||||
IMemoryCard mc = (IMemoryCard) is.getItem();
|
||||
NBTTagCompound data = new NBTTagCompound();
|
||||
@@ -379,14 +379,14 @@ public abstract class PartP2PTunnel<T extends PartP2PTunnel> extends PartBasicSt
|
||||
boolean wasOutput = this.output;
|
||||
this.output = false;
|
||||
|
||||
if ( wasOutput || this.freq == 0 )
|
||||
if( wasOutput || this.freq == 0 )
|
||||
newFreq = System.currentTimeMillis();
|
||||
|
||||
try
|
||||
{
|
||||
this.proxy.getP2P().updateFreq( this, newFreq );
|
||||
}
|
||||
catch ( GridAccessException e )
|
||||
catch( GridAccessException e )
|
||||
{
|
||||
// :P
|
||||
}
|
||||
@@ -430,7 +430,7 @@ public abstract class PartP2PTunnel<T extends PartP2PTunnel> extends PartBasicSt
|
||||
{
|
||||
this.proxy.getEnergy().extractAEPower( ae_to_tax, Actionable.MODULATE, PowerMultiplier.ONE );
|
||||
}
|
||||
catch ( GridAccessException e )
|
||||
catch( GridAccessException e )
|
||||
{
|
||||
// :P
|
||||
}
|
||||
|
||||
@@ -50,8 +50,8 @@ import appeng.me.helpers.AENetworkProxy;
|
||||
public class PartP2PTunnelME extends PartP2PTunnel<PartP2PTunnelME> implements IGridTickable
|
||||
{
|
||||
|
||||
final AENetworkProxy outerProxy = new AENetworkProxy( this, "outer", null, true );
|
||||
public final Connections connection = new Connections( this );
|
||||
final AENetworkProxy outerProxy = new AENetworkProxy( this, "outer", null, true );
|
||||
|
||||
public PartP2PTunnelME( ItemStack is )
|
||||
{
|
||||
@@ -60,13 +60,6 @@ public class PartP2PTunnelME extends PartP2PTunnel<PartP2PTunnelME> implements I
|
||||
this.outerProxy.setFlags( GridFlags.DENSE_CAPACITY, GridFlags.CANNOT_CARRY_COMPRESSED );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPartHostInfo( ForgeDirection side, IPartHost host, TileEntity tile )
|
||||
{
|
||||
super.setPartHostInfo( side, host, tile );
|
||||
this.outerProxy.setValidSides( EnumSet.of( side ) );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT( NBTTagCompound extra )
|
||||
{
|
||||
@@ -82,10 +75,26 @@ public class PartP2PTunnelME extends PartP2PTunnel<PartP2PTunnelME> implements I
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addToWorld()
|
||||
public void onTunnelNetworkChange()
|
||||
{
|
||||
super.addToWorld();
|
||||
this.outerProxy.onReady();
|
||||
super.onTunnelNetworkChange();
|
||||
if( !this.output )
|
||||
{
|
||||
try
|
||||
{
|
||||
this.proxy.getTick().wakeDevice( this.proxy.getNode() );
|
||||
}
|
||||
catch( GridAccessException e )
|
||||
{
|
||||
// :P
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public AECableType getCableConnectionType( ForgeDirection dir )
|
||||
{
|
||||
return AECableType.DENSE;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -95,6 +104,20 @@ public class PartP2PTunnelME extends PartP2PTunnel<PartP2PTunnelME> implements I
|
||||
this.outerProxy.invalidate();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addToWorld()
|
||||
{
|
||||
super.addToWorld();
|
||||
this.outerProxy.onReady();
|
||||
}
|
||||
|
||||
@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()
|
||||
{
|
||||
@@ -102,26 +125,10 @@ public class PartP2PTunnelME extends PartP2PTunnel<PartP2PTunnelME> implements I
|
||||
}
|
||||
|
||||
@Override
|
||||
public AECableType getCableConnectionType( ForgeDirection dir )
|
||||
public void onPlacement( EntityPlayer player, ItemStack held, ForgeDirection side )
|
||||
{
|
||||
return AECableType.DENSE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTunnelNetworkChange()
|
||||
{
|
||||
super.onTunnelNetworkChange();
|
||||
if ( !this.output )
|
||||
{
|
||||
try
|
||||
{
|
||||
this.proxy.getTick().wakeDevice( this.proxy.getNode() );
|
||||
}
|
||||
catch ( GridAccessException e )
|
||||
{
|
||||
// :P
|
||||
}
|
||||
}
|
||||
super.onPlacement( player, held, side );
|
||||
this.outerProxy.setOwner( player );
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -136,16 +143,16 @@ public class PartP2PTunnelME extends PartP2PTunnel<PartP2PTunnelME> implements I
|
||||
// just move on...
|
||||
try
|
||||
{
|
||||
if ( !this.proxy.getPath().isNetworkBooting() )
|
||||
if( !this.proxy.getPath().isNetworkBooting() )
|
||||
{
|
||||
if ( !this.proxy.getEnergy().isNetworkPowered() )
|
||||
if( !this.proxy.getEnergy().isNetworkPowered() )
|
||||
{
|
||||
this.connection.markDestroy();
|
||||
TickHandler.INSTANCE.addCallable( this.tile.getWorldObj(), this.connection );
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( this.proxy.isActive() )
|
||||
if( this.proxy.isActive() )
|
||||
{
|
||||
this.connection.markCreate();
|
||||
TickHandler.INSTANCE.addCallable( this.tile.getWorldObj(), this.connection );
|
||||
@@ -160,7 +167,7 @@ public class PartP2PTunnelME extends PartP2PTunnel<PartP2PTunnelME> implements I
|
||||
return TickRateModulation.SLEEP;
|
||||
}
|
||||
}
|
||||
catch ( GridAccessException e )
|
||||
catch( GridAccessException e )
|
||||
{
|
||||
// meh?
|
||||
}
|
||||
@@ -168,43 +175,36 @@ public class PartP2PTunnelME extends PartP2PTunnel<PartP2PTunnelME> implements I
|
||||
return TickRateModulation.IDLE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPlacement( EntityPlayer player, ItemStack held, ForgeDirection side )
|
||||
{
|
||||
super.onPlacement( player, held, side );
|
||||
this.outerProxy.setOwner( player );
|
||||
}
|
||||
|
||||
public void updateConnections( Connections connections )
|
||||
{
|
||||
if ( connections.destroy )
|
||||
if( connections.destroy )
|
||||
{
|
||||
for ( TunnelConnection cw : this.connection.connections.values() )
|
||||
for( TunnelConnection cw : this.connection.connections.values() )
|
||||
cw.c.destroy();
|
||||
|
||||
this.connection.connections.clear();
|
||||
}
|
||||
else if ( connections.create )
|
||||
else if( connections.create )
|
||||
{
|
||||
|
||||
Iterator<TunnelConnection> i = this.connection.connections.values().iterator();
|
||||
while ( i.hasNext() )
|
||||
while( i.hasNext() )
|
||||
{
|
||||
TunnelConnection cw = i.next();
|
||||
try
|
||||
{
|
||||
if ( cw.tunnel.proxy.getGrid() != this.proxy.getGrid() )
|
||||
if( cw.tunnel.proxy.getGrid() != this.proxy.getGrid() )
|
||||
{
|
||||
cw.c.destroy();
|
||||
i.remove();
|
||||
}
|
||||
else if ( !cw.tunnel.proxy.isActive() )
|
||||
else if( !cw.tunnel.proxy.isActive() )
|
||||
{
|
||||
cw.c.destroy();
|
||||
i.remove();
|
||||
}
|
||||
}
|
||||
catch ( GridAccessException e )
|
||||
catch( GridAccessException e )
|
||||
{
|
||||
// :P
|
||||
}
|
||||
@@ -213,22 +213,21 @@ public class PartP2PTunnelME extends PartP2PTunnel<PartP2PTunnelME> implements I
|
||||
LinkedList<PartP2PTunnelME> newSides = new LinkedList<PartP2PTunnelME>();
|
||||
try
|
||||
{
|
||||
for ( PartP2PTunnelME me : this.getOutputs() )
|
||||
for( PartP2PTunnelME me : this.getOutputs() )
|
||||
{
|
||||
if ( me.proxy.isActive() && connections.connections.get( me.getGridNode() ) == null )
|
||||
if( me.proxy.isActive() && connections.connections.get( me.getGridNode() ) == null )
|
||||
{
|
||||
newSides.add( me );
|
||||
}
|
||||
}
|
||||
|
||||
for ( PartP2PTunnelME me : newSides )
|
||||
for( PartP2PTunnelME me : newSides )
|
||||
{
|
||||
try
|
||||
{
|
||||
connections.connections.put( me.getGridNode(),
|
||||
new TunnelConnection( me, AEApi.instance().createGridConnection( this.outerProxy.getNode(), me.outerProxy.getNode() ) ) );
|
||||
connections.connections.put( me.getGridNode(), new TunnelConnection( me, AEApi.instance().createGridConnection( this.outerProxy.getNode(), me.outerProxy.getNode() ) ) );
|
||||
}
|
||||
catch ( FailedConnection e )
|
||||
catch( FailedConnection e )
|
||||
{
|
||||
final TileEntity start = this.getTile();
|
||||
final TileEntity end = me.getTile();
|
||||
@@ -237,7 +236,7 @@ public class PartP2PTunnelME extends PartP2PTunnel<PartP2PTunnelME> implements I
|
||||
}
|
||||
}
|
||||
}
|
||||
catch ( GridAccessException e )
|
||||
catch( GridAccessException e )
|
||||
{
|
||||
AELog.error( e );
|
||||
}
|
||||
|
||||
@@ -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