Basic reformat, hit once, hope never again
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user