Fixes #675 No disabled feature should log spam or crash anymore.
Deprecates the old usage of the AEItemDefinitions via the direct method access of * blocks() * parts() * items() * materials() and thus use the new re-direct via definitions(). All definitions are now initialized, no matter what. But SubItems, Items and Blocks are not registered, if by chance are disabled.
This commit is contained in:
@@ -0,0 +1,41 @@
|
||||
package appeng.parts.automation;
|
||||
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemBlock;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import appeng.api.config.Upgrades;
|
||||
import appeng.tile.inventory.IAEAppEngInventory;
|
||||
|
||||
|
||||
public class BlockUpgradeInventory extends UpgradeInventory
|
||||
{
|
||||
private final Block block;
|
||||
|
||||
public BlockUpgradeInventory( Block block, IAEAppEngInventory parent, int s )
|
||||
{
|
||||
super( parent, s );
|
||||
this.block = block;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxInstalled( Upgrades upgrades )
|
||||
{
|
||||
int max = 0;
|
||||
|
||||
for ( ItemStack is : upgrades.getSupported().keySet() )
|
||||
{
|
||||
final Item encodedItem = is.getItem();
|
||||
|
||||
if ( encodedItem instanceof ItemBlock && Block.getBlockFromItem( encodedItem ) == this.block )
|
||||
{
|
||||
max = upgrades.getSupported().get( is );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return max;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
package appeng.parts.automation;
|
||||
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import appeng.api.config.Upgrades;
|
||||
import appeng.api.definitions.IItemDefinition;
|
||||
import appeng.tile.inventory.IAEAppEngInventory;
|
||||
|
||||
|
||||
public final class DefinitionUpgradeInventory extends UpgradeInventory
|
||||
{
|
||||
private final IItemDefinition definition;
|
||||
|
||||
public DefinitionUpgradeInventory( IItemDefinition definition, IAEAppEngInventory parent, int s )
|
||||
{
|
||||
super( parent, s );
|
||||
|
||||
this.definition = definition;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxInstalled( Upgrades upgrades )
|
||||
{
|
||||
int max = 0;
|
||||
|
||||
for ( ItemStack stack : upgrades.getSupported().keySet() )
|
||||
{
|
||||
if ( this.definition.isSameAs( stack ) )
|
||||
{
|
||||
max = upgrades.getSupported().get( stack );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return max;
|
||||
}
|
||||
}
|
||||
@@ -69,14 +69,13 @@ import appeng.util.item.AEItemStack;
|
||||
|
||||
public class PartAnnihilationPlane extends PartBasicState implements IGridTickable, Callable<TickRateModulation>
|
||||
{
|
||||
|
||||
private boolean isAccepting = true;
|
||||
private final BaseActionSource mySrc = new MachineSource( this );
|
||||
private boolean isAccepting = true;
|
||||
private boolean breaking = false;
|
||||
|
||||
public PartAnnihilationPlane( ItemStack is )
|
||||
{
|
||||
super( PartAnnihilationPlane.class, is );
|
||||
super( is );
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -90,9 +89,7 @@ public class PartAnnihilationPlane extends PartBasicState implements IGridTickab
|
||||
@SideOnly( Side.CLIENT )
|
||||
public void renderInventory( IPartRenderHelper rh, RenderBlocks renderer )
|
||||
{
|
||||
rh.setTexture( CableBusTextures.PartPlaneSides.getIcon(), CableBusTextures.PartPlaneSides.getIcon(),
|
||||
CableBusTextures.PartTransitionPlaneBack.getIcon(), this.is.getIconIndex(), CableBusTextures.PartPlaneSides.getIcon(),
|
||||
CableBusTextures.PartPlaneSides.getIcon() );
|
||||
rh.setTexture( CableBusTextures.PartPlaneSides.getIcon(), CableBusTextures.PartPlaneSides.getIcon(), CableBusTextures.PartTransitionPlaneBack.getIcon(), this.is.getIconIndex(), CableBusTextures.PartPlaneSides.getIcon(), CableBusTextures.PartPlaneSides.getIcon() );
|
||||
|
||||
rh.setBounds( 1, 1, 15, 15, 15, 16 );
|
||||
rh.renderInventoryBox( renderer );
|
||||
@@ -138,16 +135,12 @@ public class PartAnnihilationPlane extends PartBasicState implements IGridTickab
|
||||
final boolean isActive = ( this.clientFlags & ( this.POWERED_FLAG | this.CHANNEL_FLAG ) ) == ( this.POWERED_FLAG | this.CHANNEL_FLAG );
|
||||
|
||||
this.renderCache = rh.useSimplifiedRendering( x, y, z, this, this.renderCache );
|
||||
rh.setTexture( CableBusTextures.PartPlaneSides.getIcon(), CableBusTextures.PartPlaneSides.getIcon(),
|
||||
CableBusTextures.PartTransitionPlaneBack.getIcon(), isActive ? CableBusTextures.BlockAnnihilationPlaneOn.getIcon() : this.is.getIconIndex(),
|
||||
CableBusTextures.PartPlaneSides.getIcon(), CableBusTextures.PartPlaneSides.getIcon() );
|
||||
rh.setTexture( CableBusTextures.PartPlaneSides.getIcon(), CableBusTextures.PartPlaneSides.getIcon(), CableBusTextures.PartTransitionPlaneBack.getIcon(), isActive ? CableBusTextures.BlockAnnihilationPlaneOn.getIcon() : this.is.getIconIndex(), CableBusTextures.PartPlaneSides.getIcon(), CableBusTextures.PartPlaneSides.getIcon() );
|
||||
|
||||
rh.setBounds( minX, minY, 15, maxX, maxY, 16 );
|
||||
rh.renderBlock( x, y, z, renderer );
|
||||
|
||||
rh.setTexture( CableBusTextures.PartMonitorSidesStatus.getIcon(), CableBusTextures.PartMonitorSidesStatus.getIcon(),
|
||||
CableBusTextures.PartTransitionPlaneBack.getIcon(), isActive ? CableBusTextures.BlockAnnihilationPlaneOn.getIcon() : this.is.getIconIndex(),
|
||||
CableBusTextures.PartMonitorSidesStatus.getIcon(), CableBusTextures.PartMonitorSidesStatus.getIcon() );
|
||||
rh.setTexture( CableBusTextures.PartMonitorSidesStatus.getIcon(), CableBusTextures.PartMonitorSidesStatus.getIcon(), CableBusTextures.PartTransitionPlaneBack.getIcon(), isActive ? CableBusTextures.BlockAnnihilationPlaneOn.getIcon() : this.is.getIconIndex(), CableBusTextures.PartMonitorSidesStatus.getIcon(), CableBusTextures.PartMonitorSidesStatus.getIcon() );
|
||||
|
||||
rh.setBounds( 5, 5, 14, 11, 11, 15 );
|
||||
rh.renderBlock( x, y, z, renderer );
|
||||
@@ -159,12 +152,87 @@ public class PartAnnihilationPlane extends PartBasicState implements IGridTickab
|
||||
{
|
||||
if ( blockTileEntity instanceof IPartHost )
|
||||
{
|
||||
final IPart p = ( ( IPartHost ) blockTileEntity ).getPart( side );
|
||||
final IPart p = ( (IPartHost) blockTileEntity ).getPart( side );
|
||||
return p instanceof PartAnnihilationPlane;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNeighborChanged()
|
||||
{
|
||||
this.isAccepting = true;
|
||||
try
|
||||
{
|
||||
this.proxy.getTick().alertDevice( this.proxy.getNode() );
|
||||
}
|
||||
catch ( final GridAccessException e )
|
||||
{
|
||||
// :P
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEntityCollision( Entity entity )
|
||||
{
|
||||
if ( this.isAccepting && entity instanceof EntityItem && !entity.isDead && Platform.isServer() && this.proxy.isActive() )
|
||||
{
|
||||
boolean capture = false;
|
||||
|
||||
switch ( this.side )
|
||||
{
|
||||
case DOWN:
|
||||
case UP:
|
||||
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.posY > this.tile.yCoord + 0.9 && this.side == ForgeDirection.UP ) || ( entity.posY < this.tile.yCoord + 0.1 && this.side == ForgeDirection.DOWN ) )
|
||||
{
|
||||
capture = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
case SOUTH:
|
||||
case NORTH:
|
||||
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.posZ > this.tile.zCoord + 0.9 && this.side == ForgeDirection.SOUTH ) || ( entity.posZ < this.tile.zCoord + 0.1 && this.side == ForgeDirection.NORTH ) )
|
||||
{
|
||||
capture = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
case EAST:
|
||||
case WEST:
|
||||
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.posX > this.tile.xCoord + 0.9 && this.side == ForgeDirection.EAST ) || ( entity.posX < this.tile.xCoord + 0.1 && this.side == ForgeDirection.WEST ) )
|
||||
{
|
||||
capture = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
// umm?
|
||||
break;
|
||||
}
|
||||
|
||||
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 );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getBoxes( IPartCollisionHelper bch )
|
||||
{
|
||||
@@ -228,6 +296,61 @@ public class PartAnnihilationPlane extends PartBasicState implements IGridTickab
|
||||
return this.isAccepting;
|
||||
}
|
||||
|
||||
/**
|
||||
* Stores an {@link EntityItem} inside the network and either marks it as dead or sets it to the leftover stackSize.
|
||||
*
|
||||
* @param entityItem {@link EntityItem} to store
|
||||
*/
|
||||
private void storeEntityItem( EntityItem entityItem )
|
||||
{
|
||||
if ( !entityItem.isDead )
|
||||
{
|
||||
this.storeItemStack( entityItem.getEntityItem() );
|
||||
entityItem.setDead();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Stores an {@link ItemStack} inside the network.
|
||||
*
|
||||
* @param item {@link ItemStack} to store
|
||||
*/
|
||||
private void storeItemStack( ItemStack item )
|
||||
{
|
||||
final IAEItemStack itemToStore = AEItemStack.create( item );
|
||||
try
|
||||
{
|
||||
final IStorageGrid storage = this.proxy.getStorage();
|
||||
final IEnergyGrid energy = this.proxy.getEnergy();
|
||||
final IAEItemStack overflow = Platform.poweredInsert( energy, storage.getItemInventory(), itemToStore, this.mySrc );
|
||||
|
||||
this.spawnOverflowItemStack( overflow );
|
||||
|
||||
this.isAccepting = overflow == null;
|
||||
}
|
||||
catch ( final GridAccessException e1 )
|
||||
{
|
||||
// :P
|
||||
}
|
||||
}
|
||||
|
||||
private void spawnOverflowItemStack( IAEItemStack overflow )
|
||||
{
|
||||
if ( overflow == null )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
final TileEntity tileEntity = this.getTile();
|
||||
final WorldServer world = (WorldServer) tileEntity.getWorldObj();
|
||||
|
||||
final int x = tileEntity.xCoord + this.side.offsetX;
|
||||
final int y = tileEntity.yCoord + this.side.offsetY;
|
||||
final int z = tileEntity.zCoord + this.side.offsetZ;
|
||||
|
||||
Platform.spawnDrops( world, x, y, z, Lists.newArrayList( overflow.getItemStack() ) );
|
||||
}
|
||||
|
||||
@Override
|
||||
@MENetworkEventSubscribe
|
||||
public void chanRender( MENetworkChannelsChanged c )
|
||||
@@ -251,7 +374,7 @@ public class PartAnnihilationPlane extends PartBasicState implements IGridTickab
|
||||
try
|
||||
{
|
||||
final TileEntity te = this.getTile();
|
||||
final WorldServer w = ( WorldServer ) te.getWorldObj();
|
||||
final WorldServer w = (WorldServer) te.getWorldObj();
|
||||
|
||||
final int x = te.xCoord + this.side.offsetX;
|
||||
final int y = te.yCoord + this.side.offsetY;
|
||||
@@ -262,8 +385,7 @@ public class PartAnnihilationPlane extends PartBasicState implements IGridTickab
|
||||
final IEnergyGrid energy = this.proxy.getEnergy();
|
||||
|
||||
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;
|
||||
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 ) )
|
||||
{
|
||||
@@ -294,7 +416,7 @@ public class PartAnnihilationPlane extends PartBasicState implements IGridTickab
|
||||
{
|
||||
if ( ei instanceof EntityItem )
|
||||
{
|
||||
final EntityItem entityItem = ( EntityItem ) ei;
|
||||
final EntityItem entityItem = (EntityItem) ei;
|
||||
this.storeEntityItem( entityItem );
|
||||
}
|
||||
}
|
||||
@@ -333,85 +455,7 @@ public class PartAnnihilationPlane extends PartBasicState implements IGridTickab
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNeighborChanged()
|
||||
{
|
||||
this.isAccepting = true;
|
||||
try
|
||||
{
|
||||
this.proxy.getTick().alertDevice( this.proxy.getNode() );
|
||||
}
|
||||
catch ( final GridAccessException e )
|
||||
{
|
||||
// :P
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEntityCollision( Entity entity )
|
||||
{
|
||||
if ( this.isAccepting && entity instanceof EntityItem && !entity.isDead && Platform.isServer() && this.proxy.isActive() )
|
||||
{
|
||||
boolean capture = false;
|
||||
|
||||
switch ( this.side )
|
||||
{
|
||||
case DOWN:
|
||||
case UP:
|
||||
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.posY > this.tile.yCoord + 0.9 && this.side == ForgeDirection.UP ) || ( entity.posY < this.tile.yCoord + 0.1 && this.side == ForgeDirection.DOWN ) )
|
||||
{
|
||||
capture = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
case SOUTH:
|
||||
case NORTH:
|
||||
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.posZ > this.tile.zCoord + 0.9 && this.side == ForgeDirection.SOUTH )
|
||||
|| ( entity.posZ < this.tile.zCoord + 0.1 && this.side == ForgeDirection.NORTH ) )
|
||||
{
|
||||
capture = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
case EAST:
|
||||
case WEST:
|
||||
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.posX > this.tile.xCoord + 0.9 && this.side == ForgeDirection.EAST )
|
||||
|| ( entity.posX < this.tile.xCoord + 0.1 && this.side == ForgeDirection.WEST ) )
|
||||
{
|
||||
capture = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
// umm?
|
||||
break;
|
||||
}
|
||||
|
||||
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 );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public TickRateModulation tickingRequest( IGridNode node, int TicksSinceLastCall )
|
||||
public TickRateModulation tickingRequest( IGridNode node, int ticksSinceLastCall )
|
||||
{
|
||||
if ( this.breaking )
|
||||
{
|
||||
@@ -428,6 +472,7 @@ public class PartAnnihilationPlane extends PartBasicState implements IGridTickab
|
||||
* It also sets isAccepting to false, if the item can not be stored.
|
||||
*
|
||||
* @param itemStacks an array of {@link ItemStack} to test
|
||||
*
|
||||
* @return true, if the network can store at least a single item of all drops or no drops are reported
|
||||
*/
|
||||
private boolean canStoreItemStacks( ItemStack[] itemStacks )
|
||||
@@ -456,63 +501,4 @@ public class PartAnnihilationPlane extends PartBasicState implements IGridTickab
|
||||
this.isAccepting = canStore;
|
||||
return canStore;
|
||||
}
|
||||
|
||||
/**
|
||||
* Stores an {@link ItemStack} inside the network.
|
||||
*
|
||||
* @param item {@link ItemStack} to store
|
||||
* @return null or leftover {@link IAEItemStack}
|
||||
*/
|
||||
private boolean storeItemStack( ItemStack item )
|
||||
{
|
||||
final IAEItemStack itemToStore = AEItemStack.create( item );
|
||||
try
|
||||
{
|
||||
final IStorageGrid storage = this.proxy.getStorage();
|
||||
final IEnergyGrid energy = this.proxy.getEnergy();
|
||||
final IAEItemStack overflow = Platform.poweredInsert( energy, storage.getItemInventory(), itemToStore, this.mySrc );
|
||||
|
||||
this.spawnOverflowItemStack( overflow );
|
||||
|
||||
this.isAccepting = overflow == null;
|
||||
return overflow == null || item.stackSize < overflow.getStackSize();
|
||||
}
|
||||
catch ( final GridAccessException e1 )
|
||||
{
|
||||
// :P
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Stores an {@link EntityItem} inside the network and either marks it as dead or sets it to the leftover stackSize.
|
||||
*
|
||||
* @param entityItem {@link EntityItem} to store
|
||||
*/
|
||||
private void storeEntityItem( EntityItem entityItem )
|
||||
{
|
||||
if ( !entityItem.isDead )
|
||||
{
|
||||
this.storeItemStack( entityItem.getEntityItem() );
|
||||
entityItem.setDead();
|
||||
}
|
||||
}
|
||||
|
||||
private void spawnOverflowItemStack( IAEItemStack overflow )
|
||||
{
|
||||
if ( overflow == null )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
final TileEntity tileEntity = this.getTile();
|
||||
final WorldServer world = ( WorldServer ) tileEntity.getWorldObj();
|
||||
|
||||
final int x = tileEntity.xCoord + this.side.offsetX;
|
||||
final int y = tileEntity.yCoord + this.side.offsetY;
|
||||
final int z = tileEntity.zCoord + this.side.offsetZ;
|
||||
|
||||
Platform.spawnDrops( world, x, y, z, Lists.newArrayList( overflow.getItemStack() ) );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -18,8 +18,6 @@
|
||||
|
||||
package appeng.parts.automation;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
|
||||
import net.minecraft.client.renderer.RenderBlocks;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
@@ -30,6 +28,9 @@ import net.minecraft.util.Vec3;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
|
||||
import appeng.api.config.Actionable;
|
||||
import appeng.api.config.FuzzyMode;
|
||||
import appeng.api.config.PowerMultiplier;
|
||||
@@ -56,42 +57,179 @@ import appeng.core.AELog;
|
||||
import appeng.core.settings.TickRates;
|
||||
import appeng.core.sync.GuiBridge;
|
||||
import appeng.helpers.MultiCraftingTracker;
|
||||
import appeng.helpers.Reflected;
|
||||
import appeng.me.GridAccessException;
|
||||
import appeng.util.InventoryAdaptor;
|
||||
import appeng.util.Platform;
|
||||
import appeng.util.item.AEItemStack;
|
||||
|
||||
|
||||
public class PartExportBus extends PartSharedItemBus implements ICraftingRequester
|
||||
{
|
||||
|
||||
final MultiCraftingTracker cratingTracker = new MultiCraftingTracker( this, 9 );
|
||||
final BaseActionSource mySrc;
|
||||
long itemToSend = 1;
|
||||
boolean didSomething = false;
|
||||
|
||||
public PartExportBus(ItemStack is)
|
||||
@Reflected
|
||||
public PartExportBus( ItemStack is )
|
||||
{
|
||||
super( PartExportBus.class, is );
|
||||
this.settings.registerSetting( Settings.REDSTONE_CONTROLLED, RedstoneMode.IGNORE );
|
||||
this.settings.registerSetting( Settings.FUZZY_MODE, FuzzyMode.IGNORE_ALL );
|
||||
this.settings.registerSetting( Settings.CRAFT_ONLY, YesNo.NO );
|
||||
super( is );
|
||||
|
||||
this.getConfigManager().registerSetting( Settings.REDSTONE_CONTROLLED, RedstoneMode.IGNORE );
|
||||
this.getConfigManager().registerSetting( Settings.FUZZY_MODE, FuzzyMode.IGNORE_ALL );
|
||||
this.getConfigManager().registerSetting( Settings.CRAFT_ONLY, YesNo.NO );
|
||||
this.mySrc = new MachineSource( this );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound extra)
|
||||
{
|
||||
super.readFromNBT( extra );
|
||||
this.cratingTracker.readFromNBT( extra );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT(NBTTagCompound extra)
|
||||
public void writeToNBT( NBTTagCompound extra )
|
||||
{
|
||||
super.writeToNBT( extra );
|
||||
this.cratingTracker.writeToNBT( extra );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onPartActivate(EntityPlayer player, Vec3 pos)
|
||||
public void readFromNBT( NBTTagCompound extra )
|
||||
{
|
||||
super.readFromNBT( extra );
|
||||
this.cratingTracker.readFromNBT( extra );
|
||||
}
|
||||
|
||||
@Override
|
||||
TickRateModulation doBusWork()
|
||||
{
|
||||
if ( !this.proxy.isActive() )
|
||||
return TickRateModulation.IDLE;
|
||||
|
||||
this.itemToSend = 1;
|
||||
this.didSomething = false;
|
||||
|
||||
switch ( this.getInstalledUpgrades( Upgrades.SPEED ) )
|
||||
{
|
||||
default:
|
||||
case 0:
|
||||
this.itemToSend = 1;
|
||||
break;
|
||||
case 1:
|
||||
this.itemToSend = 8;
|
||||
break;
|
||||
case 2:
|
||||
this.itemToSend = 32;
|
||||
break;
|
||||
case 3:
|
||||
this.itemToSend = 64;
|
||||
break;
|
||||
case 4:
|
||||
this.itemToSend = 96;
|
||||
break;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
InventoryAdaptor d = this.getHandler();
|
||||
IMEMonitor<IAEItemStack> inv = this.proxy.getStorage().getItemInventory();
|
||||
IEnergyGrid energy = this.proxy.getEnergy();
|
||||
ICraftingGrid cg = this.proxy.getCrafting();
|
||||
FuzzyMode fzMode = (FuzzyMode) this.getConfigManager().getSetting( Settings.FUZZY_MODE );
|
||||
|
||||
if ( d != null )
|
||||
{
|
||||
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 ( 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 )
|
||||
{
|
||||
for ( IAEItemStack o : ImmutableList.copyOf( inv.getStorageList().findFuzzy( ais, fzMode ) ) )
|
||||
{
|
||||
this.pushItemIntoTarget( d, energy, inv, o );
|
||||
if ( this.itemToSend <= 0 )
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
this.pushItemIntoTarget( d, energy, inv, ais );
|
||||
|
||||
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 )
|
||||
{
|
||||
// :P
|
||||
}
|
||||
|
||||
return this.didSomething ? TickRateModulation.FASTER : TickRateModulation.SLOWER;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly( Side.CLIENT )
|
||||
public void renderInventory( IPartRenderHelper rh, RenderBlocks renderer )
|
||||
{
|
||||
|
||||
rh.setTexture( CableBusTextures.PartExportSides.getIcon(), CableBusTextures.PartExportSides.getIcon(), CableBusTextures.PartMonitorBack.getIcon(), this.is.getIconIndex(), CableBusTextures.PartExportSides.getIcon(), CableBusTextures.PartExportSides.getIcon() );
|
||||
|
||||
rh.setBounds( 4, 4, 12, 12, 12, 14 );
|
||||
rh.renderInventoryBox( renderer );
|
||||
|
||||
rh.setBounds( 5, 5, 14, 11, 11, 15 );
|
||||
rh.renderInventoryBox( renderer );
|
||||
|
||||
rh.setBounds( 6, 6, 15, 10, 10, 16 );
|
||||
rh.renderInventoryBox( renderer );
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly( Side.CLIENT )
|
||||
public void renderStatic( int x, int y, int z, IPartRenderHelper rh, RenderBlocks renderer )
|
||||
{
|
||||
this.renderCache = rh.useSimplifiedRendering( x, y, z, this, this.renderCache );
|
||||
rh.setTexture( CableBusTextures.PartExportSides.getIcon(), CableBusTextures.PartExportSides.getIcon(), CableBusTextures.PartMonitorBack.getIcon(), this.is.getIconIndex(), CableBusTextures.PartExportSides.getIcon(), CableBusTextures.PartExportSides.getIcon() );
|
||||
|
||||
rh.setBounds( 4, 4, 12, 12, 12, 14 );
|
||||
rh.renderBlock( x, y, z, renderer );
|
||||
|
||||
rh.setBounds( 5, 5, 14, 11, 11, 15 );
|
||||
rh.renderBlock( x, y, z, renderer );
|
||||
|
||||
rh.setBounds( 6, 6, 15, 10, 10, 16 );
|
||||
rh.renderBlock( x, y, z, renderer );
|
||||
|
||||
rh.setTexture( CableBusTextures.PartMonitorSidesStatus.getIcon(), CableBusTextures.PartMonitorSidesStatus.getIcon(), CableBusTextures.PartMonitorBack.getIcon(), this.is.getIconIndex(), CableBusTextures.PartMonitorSidesStatus.getIcon(), CableBusTextures.PartMonitorSidesStatus.getIcon() );
|
||||
|
||||
rh.setBounds( 6, 6, 11, 10, 10, 12 );
|
||||
rh.renderBlock( x, y, z, renderer );
|
||||
|
||||
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()
|
||||
{
|
||||
return 5;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onPartActivate( EntityPlayer player, Vec3 pos )
|
||||
{
|
||||
if ( !player.isSneaking() )
|
||||
{
|
||||
@@ -106,145 +244,27 @@ public class PartExportBus extends PartSharedItemBus implements ICraftingRequest
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void renderInventory(IPartRenderHelper rh, RenderBlocks renderer)
|
||||
public RedstoneMode getRSMode()
|
||||
{
|
||||
|
||||
rh.setTexture( CableBusTextures.PartExportSides.getIcon(), CableBusTextures.PartExportSides.getIcon(), CableBusTextures.PartMonitorBack.getIcon(),
|
||||
this.is.getIconIndex(), CableBusTextures.PartExportSides.getIcon(), CableBusTextures.PartExportSides.getIcon() );
|
||||
|
||||
rh.setBounds( 4, 4, 12, 12, 12, 14 );
|
||||
rh.renderInventoryBox( renderer );
|
||||
|
||||
rh.setBounds( 5, 5, 14, 11, 11, 15 );
|
||||
rh.renderInventoryBox( renderer );
|
||||
|
||||
rh.setBounds( 6, 6, 15, 10, 10, 16 );
|
||||
rh.renderInventoryBox( renderer );
|
||||
return (RedstoneMode) this.getConfigManager().getSetting( Settings.REDSTONE_CONTROLLED );
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void renderStatic(int x, int y, int z, IPartRenderHelper rh, RenderBlocks renderer)
|
||||
protected boolean isSleeping()
|
||||
{
|
||||
this.renderCache = rh.useSimplifiedRendering( x, y, z, this, this.renderCache );
|
||||
rh.setTexture( CableBusTextures.PartExportSides.getIcon(), CableBusTextures.PartExportSides.getIcon(), CableBusTextures.PartMonitorBack.getIcon(),
|
||||
this.is.getIconIndex(), CableBusTextures.PartExportSides.getIcon(), CableBusTextures.PartExportSides.getIcon() );
|
||||
|
||||
rh.setBounds( 4, 4, 12, 12, 12, 14 );
|
||||
rh.renderBlock( x, y, z, renderer );
|
||||
|
||||
rh.setBounds( 5, 5, 14, 11, 11, 15 );
|
||||
rh.renderBlock( x, y, z, renderer );
|
||||
|
||||
rh.setBounds( 6, 6, 15, 10, 10, 16 );
|
||||
rh.renderBlock( x, y, z, renderer );
|
||||
|
||||
rh.setTexture( CableBusTextures.PartMonitorSidesStatus.getIcon(), CableBusTextures.PartMonitorSidesStatus.getIcon(),
|
||||
CableBusTextures.PartMonitorBack.getIcon(), this.is.getIconIndex(), CableBusTextures.PartMonitorSidesStatus.getIcon(),
|
||||
CableBusTextures.PartMonitorSidesStatus.getIcon() );
|
||||
|
||||
rh.setBounds( 6, 6, 11, 10, 10, 12 );
|
||||
rh.renderBlock( x, y, z, renderer );
|
||||
|
||||
this.renderLights( x, y, z, rh, renderer );
|
||||
return this.getHandler() == null || super.isSleeping();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int cableConnectionRenderTo()
|
||||
public TickingRequest getTickingRequest( IGridNode node )
|
||||
{
|
||||
return 5;
|
||||
return new TickingRequest( TickRates.ExportBus.min, TickRates.ExportBus.max, this.isSleeping(), false );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getBoxes(IPartCollisionHelper bch)
|
||||
public TickRateModulation tickingRequest( IGridNode node, int TicksSinceLastCall )
|
||||
{
|
||||
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 );
|
||||
}
|
||||
|
||||
long itemToSend = 1;
|
||||
boolean didSomething = false;
|
||||
|
||||
@Override
|
||||
TickRateModulation doBusWork()
|
||||
{
|
||||
if ( !this.proxy.isActive() )
|
||||
return TickRateModulation.IDLE;
|
||||
|
||||
this.itemToSend = 1;
|
||||
this.didSomething = false;
|
||||
|
||||
switch (this.getInstalledUpgrades( Upgrades.SPEED ))
|
||||
{
|
||||
default:
|
||||
case 0:
|
||||
this.itemToSend = 1;
|
||||
break;
|
||||
case 1:
|
||||
this.itemToSend = 8;
|
||||
break;
|
||||
case 2:
|
||||
this.itemToSend = 32;
|
||||
break;
|
||||
case 3:
|
||||
this.itemToSend = 64;
|
||||
break;
|
||||
case 4:
|
||||
this.itemToSend = 96;
|
||||
break;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
InventoryAdaptor d = this.getHandler();
|
||||
IMEMonitor<IAEItemStack> inv = this.proxy.getStorage().getItemInventory();
|
||||
IEnergyGrid energy = this.proxy.getEnergy();
|
||||
ICraftingGrid cg = this.proxy.getCrafting();
|
||||
FuzzyMode fzMode = (FuzzyMode) this.getConfigManager().getSetting( Settings.FUZZY_MODE );
|
||||
|
||||
if ( d != null )
|
||||
{
|
||||
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 ( 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 )
|
||||
{
|
||||
for (IAEItemStack o : ImmutableList.copyOf( inv.getStorageList().findFuzzy( ais, fzMode ) ))
|
||||
{
|
||||
this.pushItemIntoTarget( d, energy, inv, o );
|
||||
if ( this.itemToSend <= 0 )
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
this.pushItemIntoTarget( d, energy, inv, ais );
|
||||
|
||||
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)
|
||||
{
|
||||
// :P
|
||||
}
|
||||
|
||||
return this.didSomething ? TickRateModulation.FASTER : TickRateModulation.SLOWER;
|
||||
return this.doBusWork();
|
||||
}
|
||||
|
||||
private boolean craftOnly()
|
||||
@@ -257,7 +277,7 @@ public class PartExportBus extends PartSharedItemBus implements ICraftingRequest
|
||||
return this.getInstalledUpgrades( Upgrades.CRAFTING ) > 0;
|
||||
}
|
||||
|
||||
private void pushItemIntoTarget(InventoryAdaptor d, IEnergyGrid energy, IMEInventory<IAEItemStack> inv, IAEItemStack ais)
|
||||
private void pushItemIntoTarget( InventoryAdaptor d, IEnergyGrid energy, IMEInventory<IAEItemStack> inv, IAEItemStack ais )
|
||||
{
|
||||
ItemStack is = ais.getItemStack();
|
||||
is.stackSize = (int) this.itemToSend;
|
||||
@@ -284,12 +304,17 @@ public class PartExportBus extends PartSharedItemBus implements ICraftingRequest
|
||||
else
|
||||
this.didSomething = true;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public IAEItemStack injectCraftedItems(ICraftingLink link, IAEItemStack items, Actionable mode)
|
||||
public ImmutableSet<ICraftingLink> getRequestedJobs()
|
||||
{
|
||||
return this.cratingTracker.getRequestedJobs();
|
||||
}
|
||||
|
||||
@Override
|
||||
public IAEItemStack injectCraftedItems( ICraftingLink link, IAEItemStack items, Actionable mode )
|
||||
{
|
||||
InventoryAdaptor d = this.getHandler();
|
||||
|
||||
@@ -308,7 +333,7 @@ public class PartExportBus extends PartSharedItemBus implements ICraftingRequest
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (GridAccessException e)
|
||||
catch ( GridAccessException e )
|
||||
{
|
||||
AELog.error( e );
|
||||
}
|
||||
@@ -317,39 +342,8 @@ public class PartExportBus extends PartSharedItemBus implements ICraftingRequest
|
||||
}
|
||||
|
||||
@Override
|
||||
public TickRateModulation tickingRequest(IGridNode node, int TicksSinceLastCall)
|
||||
{
|
||||
return this.doBusWork();
|
||||
}
|
||||
|
||||
@Override
|
||||
public RedstoneMode getRSMode()
|
||||
{
|
||||
return (RedstoneMode) this.settings.getSetting( Settings.REDSTONE_CONTROLLED );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean isSleeping()
|
||||
{
|
||||
return this.getHandler() == null || super.isSleeping();
|
||||
}
|
||||
|
||||
@Override
|
||||
public TickingRequest getTickingRequest(IGridNode node)
|
||||
{
|
||||
return new TickingRequest( TickRates.ExportBus.min, TickRates.ExportBus.max, this.isSleeping(), false );
|
||||
}
|
||||
|
||||
@Override
|
||||
public ImmutableSet<ICraftingLink> getRequestedJobs()
|
||||
{
|
||||
return this.cratingTracker.getRequestedJobs();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void jobStateChange(ICraftingLink link)
|
||||
public void jobStateChange( ICraftingLink link )
|
||||
{
|
||||
this.cratingTracker.jobStateChange( link );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -85,42 +85,81 @@ import appeng.util.prioitylist.PrecisePriorityList;
|
||||
|
||||
public class PartFormationPlane extends PartUpgradeable implements ICellContainer, IPriorityHost, IMEInventory<IAEItemStack>
|
||||
{
|
||||
|
||||
final MEInventoryHandler myHandler = new MEInventoryHandler( this, StorageChannel.ITEMS );
|
||||
final AppEngInternalAEInventory Config = new AppEngInternalAEInventory( this, 63 );
|
||||
int priority = 0;
|
||||
boolean wasActive = false;
|
||||
boolean blocked = false;
|
||||
final MEInventoryHandler myHandler = new MEInventoryHandler( this, StorageChannel.ITEMS );
|
||||
final AppEngInternalAEInventory Config = new AppEngInternalAEInventory( this, 63 );
|
||||
|
||||
public PartFormationPlane( ItemStack is )
|
||||
{
|
||||
super( PartFormationPlane.class, is );
|
||||
this.settings.registerSetting( Settings.FUZZY_MODE, FuzzyMode.IGNORE_ALL );
|
||||
this.settings.registerSetting( Settings.PLACE_BLOCK, YesNo.YES );
|
||||
super( is );
|
||||
|
||||
this.getConfigManager().registerSetting( Settings.FUZZY_MODE, FuzzyMode.IGNORE_ALL );
|
||||
this.getConfigManager().registerSetting( Settings.PLACE_BLOCK, YesNo.YES );
|
||||
this.updateHandler();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onPartActivate( EntityPlayer player, Vec3 pos )
|
||||
{
|
||||
if ( !player.isSneaking() )
|
||||
{
|
||||
if ( Platform.isClient() )
|
||||
return true;
|
||||
|
||||
Platform.openGUI( player, this.getHost().getTile(), this.side, GuiBridge.GUI_FORMATION_PLANE );
|
||||
return true;
|
||||
private void updateHandler()
|
||||
{
|
||||
this.myHandler.setBaseAccess( AccessRestriction.WRITE );
|
||||
;
|
||||
this.myHandler.setWhitelist( this.getInstalledUpgrades( Upgrades.INVERTER ) > 0 ? IncludeExclude.BLACKLIST : IncludeExclude.WHITELIST );
|
||||
this.myHandler.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++ )
|
||||
{
|
||||
IAEItemStack is = this.Config.getAEStackInSlot( x );
|
||||
if ( is != null )
|
||||
priorityList.add( is );
|
||||
}
|
||||
|
||||
return false;
|
||||
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 ) );
|
||||
|
||||
try
|
||||
{
|
||||
this.proxy.getGrid().postEvent( new MENetworkCellArrayUpdate() );
|
||||
}
|
||||
catch ( GridAccessException e )
|
||||
{
|
||||
// :P
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected int getUpgradeSlots()
|
||||
{
|
||||
return 5;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void writeToNBT( NBTTagCompound data )
|
||||
{
|
||||
super.writeToNBT( data );
|
||||
this.Config.writeToNBT( data, "config" );
|
||||
data.setInteger( "priority", this.priority );
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void readFromNBT( NBTTagCompound data )
|
||||
{
|
||||
super.readFromNBT( data );
|
||||
this.Config.readFromNBT( data, "config" );
|
||||
this.priority = data.getInteger( "priority" );
|
||||
this.updateHandler();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public IInventory getInventoryByName( String name )
|
||||
{
|
||||
@@ -130,6 +169,32 @@ public class PartFormationPlane extends PartUpgradeable implements ICellContaine
|
||||
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 )
|
||||
@@ -143,6 +208,7 @@ public class PartFormationPlane extends PartUpgradeable implements ICellContaine
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@MENetworkEventSubscribe
|
||||
public void updateChannels( MENetworkChannelsChanged changedChannels )
|
||||
{
|
||||
@@ -155,13 +221,12 @@ public class PartFormationPlane extends PartUpgradeable implements ICellContaine
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
@SideOnly( Side.CLIENT )
|
||||
public void renderInventory( IPartRenderHelper rh, RenderBlocks renderer )
|
||||
{
|
||||
rh.setTexture( CableBusTextures.PartPlaneSides.getIcon(), CableBusTextures.PartPlaneSides.getIcon(),
|
||||
CableBusTextures.PartTransitionPlaneBack.getIcon(), this.is.getIconIndex(), CableBusTextures.PartPlaneSides.getIcon(),
|
||||
CableBusTextures.PartPlaneSides.getIcon() );
|
||||
rh.setTexture( CableBusTextures.PartPlaneSides.getIcon(), CableBusTextures.PartPlaneSides.getIcon(), CableBusTextures.PartTransitionPlaneBack.getIcon(), this.is.getIconIndex(), CableBusTextures.PartPlaneSides.getIcon(), CableBusTextures.PartPlaneSides.getIcon() );
|
||||
|
||||
rh.setBounds( 1, 1, 15, 15, 15, 16 );
|
||||
rh.renderInventoryBox( renderer );
|
||||
@@ -170,6 +235,7 @@ 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 )
|
||||
@@ -199,16 +265,12 @@ public class PartFormationPlane extends PartUpgradeable implements ICellContaine
|
||||
boolean isActive = ( this.clientFlags & ( this.POWERED_FLAG | this.CHANNEL_FLAG ) ) == ( this.POWERED_FLAG | this.CHANNEL_FLAG );
|
||||
|
||||
this.renderCache = rh.useSimplifiedRendering( x, y, z, this, this.renderCache );
|
||||
rh.setTexture( CableBusTextures.PartPlaneSides.getIcon(), CableBusTextures.PartPlaneSides.getIcon(),
|
||||
CableBusTextures.PartTransitionPlaneBack.getIcon(), isActive ? CableBusTextures.BlockFormPlaneOn.getIcon() : this.is.getIconIndex(),
|
||||
CableBusTextures.PartPlaneSides.getIcon(), CableBusTextures.PartPlaneSides.getIcon() );
|
||||
rh.setTexture( CableBusTextures.PartPlaneSides.getIcon(), CableBusTextures.PartPlaneSides.getIcon(), CableBusTextures.PartTransitionPlaneBack.getIcon(), isActive ? CableBusTextures.BlockFormPlaneOn.getIcon() : this.is.getIconIndex(), CableBusTextures.PartPlaneSides.getIcon(), CableBusTextures.PartPlaneSides.getIcon() );
|
||||
|
||||
rh.setBounds( minX, minY, 15, maxX, maxY, 16 );
|
||||
rh.renderBlock( x, y, z, renderer );
|
||||
|
||||
rh.setTexture( CableBusTextures.PartMonitorSidesStatus.getIcon(), CableBusTextures.PartMonitorSidesStatus.getIcon(),
|
||||
CableBusTextures.PartTransitionPlaneBack.getIcon(), isActive ? CableBusTextures.BlockFormPlaneOn.getIcon() : this.is.getIconIndex(),
|
||||
CableBusTextures.PartMonitorSidesStatus.getIcon(), CableBusTextures.PartMonitorSidesStatus.getIcon() );
|
||||
rh.setTexture( CableBusTextures.PartMonitorSidesStatus.getIcon(), CableBusTextures.PartMonitorSidesStatus.getIcon(), CableBusTextures.PartTransitionPlaneBack.getIcon(), isActive ? CableBusTextures.BlockFormPlaneOn.getIcon() : this.is.getIconIndex(), CableBusTextures.PartMonitorSidesStatus.getIcon(), CableBusTextures.PartMonitorSidesStatus.getIcon() );
|
||||
|
||||
rh.setBounds( 5, 5, 14, 11, 11, 15 );
|
||||
rh.renderBlock( x, y, z, renderer );
|
||||
@@ -216,16 +278,33 @@ 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 );
|
||||
IPart p = ( (IPartHost) blockTileEntity ).getPart( side );
|
||||
return p instanceof PartFormationPlane;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onNeighborChanged()
|
||||
{
|
||||
TileEntity te = this.host.getTile();
|
||||
World w = te.getWorldObj();
|
||||
ForgeDirection side = this.side;
|
||||
|
||||
int x = te.xCoord + side.offsetX;
|
||||
int y = te.yCoord + side.offsetY;
|
||||
int z = te.zCoord + side.offsetZ;
|
||||
|
||||
this.blocked = !w.getBlock( x, y, z ).isReplaceable( w, x, y, z );
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void getBoxes( IPartCollisionHelper bch )
|
||||
{
|
||||
@@ -263,12 +342,30 @@ public class PartFormationPlane extends PartUpgradeable implements ICellContaine
|
||||
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 ( Platform.isClient() )
|
||||
return true;
|
||||
|
||||
Platform.openGUI( player, this.getHost().getTile(), this.side, GuiBridge.GUI_FORMATION_PLANE );
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public List<IMEInventoryHandler> getCellArray( StorageChannel channel )
|
||||
{
|
||||
@@ -281,13 +378,14 @@ public class PartFormationPlane extends PartUpgradeable implements ICellContaine
|
||||
return new ArrayList<IMEInventoryHandler>();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void updateSetting( IConfigManager manager, Enum settingName, Enum newValue )
|
||||
public int getPriority()
|
||||
{
|
||||
this.updateHandler();
|
||||
this.host.markForSave();
|
||||
return this.priority;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void setPriority( int newValue )
|
||||
{
|
||||
@@ -296,92 +394,6 @@ public class PartFormationPlane extends PartUpgradeable implements ICellContaine
|
||||
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
|
||||
public void upgradesChanged()
|
||||
{
|
||||
this.updateHandler();
|
||||
}
|
||||
|
||||
private void updateHandler()
|
||||
{
|
||||
this.myHandler.setBaseAccess( AccessRestriction.WRITE );
|
||||
this.myHandler.setWhitelist( this.getInstalledUpgrades( Upgrades.INVERTER ) > 0 ? IncludeExclude.BLACKLIST : IncludeExclude.WHITELIST );
|
||||
this.myHandler.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++ )
|
||||
{
|
||||
IAEItemStack is = this.Config.getAEStackInSlot( x );
|
||||
if ( is != null )
|
||||
priorityList.add( is );
|
||||
}
|
||||
|
||||
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 ) );
|
||||
|
||||
try
|
||||
{
|
||||
this.proxy.getGrid().postEvent( new MENetworkCellArrayUpdate() );
|
||||
}
|
||||
catch ( GridAccessException e )
|
||||
{
|
||||
// :P
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT( NBTTagCompound data )
|
||||
{
|
||||
super.writeToNBT( data );
|
||||
this.Config.writeToNBT( data, "config" );
|
||||
data.setInteger( "priority", this.priority );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT( NBTTagCompound data )
|
||||
{
|
||||
super.readFromNBT( data );
|
||||
this.Config.readFromNBT( data, "config" );
|
||||
this.priority = data.getInteger( "priority" );
|
||||
this.updateHandler();
|
||||
}
|
||||
|
||||
@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 int getPriority()
|
||||
{
|
||||
return this.priority;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void blinkCell( int slot )
|
||||
@@ -389,19 +401,6 @@ public class PartFormationPlane extends PartUpgradeable implements ICellContaine
|
||||
// :P
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNeighborChanged()
|
||||
{
|
||||
TileEntity te = this.host.getTile();
|
||||
World w = te.getWorldObj();
|
||||
ForgeDirection side = this.side;
|
||||
|
||||
int x = te.xCoord + side.offsetX;
|
||||
int y = te.yCoord + side.offsetY;
|
||||
int z = te.zCoord + side.offsetZ;
|
||||
|
||||
this.blocked = !w.getBlock( x, y, z ).isReplaceable( w, x, y, z );
|
||||
}
|
||||
|
||||
@Override
|
||||
public IAEItemStack injectItems( IAEItemStack input, Actionable type, BaseActionSource src )
|
||||
@@ -409,7 +408,7 @@ public class PartFormationPlane extends PartUpgradeable implements ICellContaine
|
||||
if ( this.blocked || input == null || input.getStackSize() <= 0 )
|
||||
return input;
|
||||
|
||||
YesNo placeBlock = ( YesNo ) this.getConfigManager().getSetting( Settings.PLACE_BLOCK );
|
||||
YesNo placeBlock = (YesNo) this.getConfigManager().getSetting( Settings.PLACE_BLOCK );
|
||||
|
||||
ItemStack is = input.getItemStack();
|
||||
Item i = is.getItem();
|
||||
@@ -427,10 +426,9 @@ public class PartFormationPlane extends PartUpgradeable implements ICellContaine
|
||||
|
||||
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 );
|
||||
EntityPlayer player = Platform.getPlayer( (WorldServer) w );
|
||||
Platform.configurePlayer( player, side, this.tile );
|
||||
|
||||
if ( i instanceof ItemFirework )
|
||||
@@ -451,12 +449,10 @@ public class PartFormationPlane extends PartUpgradeable implements ICellContaine
|
||||
boolean Worked = false;
|
||||
|
||||
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 );
|
||||
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 )
|
||||
Worked = i.onItemUse( is, player, w, x - side.offsetX, y - side.offsetY, z - side.offsetZ, side.ordinal(), side.offsetX,
|
||||
side.offsetY, side.offsetZ );
|
||||
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 )
|
||||
Worked = i.onItemUse( is, player, w, x, y - 1, z, ForgeDirection.UP.ordinal(), side.offsetX, side.offsetY, side.offsetZ );
|
||||
@@ -488,12 +484,12 @@ public class PartFormationPlane extends PartUpgradeable implements ICellContaine
|
||||
if ( type == Actionable.MODULATE )
|
||||
{
|
||||
|
||||
is.stackSize = ( int ) maxStorage;
|
||||
is.stackSize = (int) maxStorage;
|
||||
EntityItem ei = new EntityItem( w, // w
|
||||
( ( side.offsetX != 0 ? 0.0 : 0.7 ) * ( Platform.getRandomFloat() - 0.5f ) ) + 0.5 + side.offsetX * -0.3 + x, // spawn
|
||||
( ( side.offsetY != 0 ? 0.0 : 0.7 ) * ( Platform.getRandomFloat() - 0.5f ) ) + 0.5 + side.offsetY * -0.3 + y, // spawn
|
||||
( ( side.offsetZ != 0 ? 0.0 : 0.7 ) * ( Platform.getRandomFloat() - 0.5f ) ) + 0.5 + side.offsetZ * -0.3 + z, // spawn
|
||||
is.copy() );
|
||||
( ( side.offsetX != 0 ? 0.0 : 0.7 ) * ( Platform.getRandomFloat() - 0.5f ) ) + 0.5 + side.offsetX * -0.3 + x, // spawn
|
||||
( ( side.offsetY != 0 ? 0.0 : 0.7 ) * ( Platform.getRandomFloat() - 0.5f ) ) + 0.5 + side.offsetY * -0.3 + y, // spawn
|
||||
( ( side.offsetZ != 0 ? 0.0 : 0.7 ) * ( Platform.getRandomFloat() - 0.5f ) ) + 0.5 + side.offsetZ * -0.3 + z, // spawn
|
||||
is.copy() );
|
||||
|
||||
Entity result = ei;
|
||||
|
||||
@@ -515,7 +511,6 @@ public class PartFormationPlane extends PartUpgradeable implements ICellContaine
|
||||
result.setDead();
|
||||
worked = false;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -537,6 +532,28 @@ 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 )
|
||||
{
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
|
||||
package appeng.parts.automation;
|
||||
|
||||
|
||||
import net.minecraft.client.renderer.RenderBlocks;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
@@ -48,27 +49,98 @@ import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.client.texture.CableBusTextures;
|
||||
import appeng.core.settings.TickRates;
|
||||
import appeng.core.sync.GuiBridge;
|
||||
import appeng.helpers.Reflected;
|
||||
import appeng.me.GridAccessException;
|
||||
import appeng.util.InventoryAdaptor;
|
||||
import appeng.util.Platform;
|
||||
import appeng.util.inv.IInventoryDestination;
|
||||
|
||||
|
||||
public class PartImportBus extends PartSharedItemBus implements IInventoryDestination
|
||||
{
|
||||
|
||||
final BaseActionSource mySrc;
|
||||
private final BaseActionSource source;
|
||||
IMEInventory<IAEItemStack> destination = null;
|
||||
IAEItemStack lastItemChecked = null;
|
||||
private int itemToSend; // used in tickingRequest
|
||||
private boolean worked; // used in tickingRequest
|
||||
|
||||
public PartImportBus(ItemStack is) {
|
||||
super( PartImportBus.class, is );
|
||||
this.settings.registerSetting( Settings.REDSTONE_CONTROLLED, RedstoneMode.IGNORE );
|
||||
this.settings.registerSetting( Settings.FUZZY_MODE, FuzzyMode.IGNORE_ALL );
|
||||
this.mySrc = new MachineSource( this );
|
||||
@Reflected
|
||||
public PartImportBus( ItemStack is )
|
||||
{
|
||||
super( is );
|
||||
|
||||
this.getConfigManager().registerSetting( Settings.REDSTONE_CONTROLLED, RedstoneMode.IGNORE );
|
||||
this.getConfigManager().registerSetting( Settings.FUZZY_MODE, FuzzyMode.IGNORE_ALL );
|
||||
this.source = new MachineSource( this );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onPartActivate(EntityPlayer player, Vec3 pos)
|
||||
public boolean canInsert( ItemStack stack )
|
||||
{
|
||||
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 )
|
||||
return true;
|
||||
return out.getStackSize() != stack.stackSize;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly( Side.CLIENT )
|
||||
public void renderInventory( IPartRenderHelper rh, RenderBlocks renderer )
|
||||
{
|
||||
rh.setTexture( CableBusTextures.PartImportSides.getIcon(), CableBusTextures.PartImportSides.getIcon(), CableBusTextures.PartMonitorBack.getIcon(), this.is.getIconIndex(), CableBusTextures.PartImportSides.getIcon(), CableBusTextures.PartImportSides.getIcon() );
|
||||
|
||||
rh.setBounds( 3, 3, 15, 13, 13, 16 );
|
||||
rh.renderInventoryBox( renderer );
|
||||
|
||||
rh.setBounds( 4, 4, 14, 12, 12, 15 );
|
||||
rh.renderInventoryBox( renderer );
|
||||
|
||||
rh.setBounds( 5, 5, 13, 11, 11, 14 );
|
||||
rh.renderInventoryBox( renderer );
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly( Side.CLIENT )
|
||||
public void renderStatic( int x, int y, int z, IPartRenderHelper rh, RenderBlocks renderer )
|
||||
{
|
||||
this.renderCache = rh.useSimplifiedRendering( x, y, z, this, this.renderCache );
|
||||
rh.setTexture( CableBusTextures.PartImportSides.getIcon(), CableBusTextures.PartImportSides.getIcon(), CableBusTextures.PartMonitorBack.getIcon(), this.is.getIconIndex(), CableBusTextures.PartImportSides.getIcon(), CableBusTextures.PartImportSides.getIcon() );
|
||||
|
||||
rh.setBounds( 4, 4, 14, 12, 12, 16 );
|
||||
rh.renderBlock( x, y, z, renderer );
|
||||
|
||||
rh.setBounds( 5, 5, 13, 11, 11, 14 );
|
||||
rh.renderBlock( x, y, z, renderer );
|
||||
|
||||
rh.setBounds( 6, 6, 12, 10, 10, 13 );
|
||||
rh.renderBlock( x, y, z, renderer );
|
||||
rh.setTexture( CableBusTextures.PartMonitorSidesStatus.getIcon(), CableBusTextures.PartMonitorSidesStatus.getIcon(), CableBusTextures.PartMonitorBack.getIcon(), this.is.getIconIndex(), CableBusTextures.PartMonitorSidesStatus.getIcon(), CableBusTextures.PartMonitorSidesStatus.getIcon() );
|
||||
|
||||
rh.setBounds( 6, 6, 11, 10, 10, 12 );
|
||||
rh.renderBlock( x, y, z, renderer );
|
||||
|
||||
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()
|
||||
{
|
||||
return 5;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onPartActivate( EntityPlayer player, Vec3 pos )
|
||||
{
|
||||
if ( !player.isSneaking() )
|
||||
{
|
||||
@@ -83,88 +155,16 @@ public class PartImportBus extends PartSharedItemBus implements IInventoryDestin
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canInsert(ItemStack stack)
|
||||
{
|
||||
if ( stack == null || stack.getItem() == null )
|
||||
return false;
|
||||
|
||||
IAEItemStack out = this.destination.injectItems( this.lastItemChecked = AEApi.instance().storage().createItemStack( stack ), Actionable.SIMULATE, this.mySrc );
|
||||
if ( out == null )
|
||||
return true;
|
||||
return out.getStackSize() != stack.stackSize;
|
||||
}
|
||||
|
||||
private IInventoryDestination configDestination( IMEMonitor<IAEItemStack> itemInventory )
|
||||
{
|
||||
this.destination = itemInventory;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void renderInventory(IPartRenderHelper rh, RenderBlocks renderer)
|
||||
{
|
||||
rh.setTexture( CableBusTextures.PartImportSides.getIcon(), CableBusTextures.PartImportSides.getIcon(), CableBusTextures.PartMonitorBack.getIcon(),
|
||||
this.is.getIconIndex(), CableBusTextures.PartImportSides.getIcon(), CableBusTextures.PartImportSides.getIcon() );
|
||||
|
||||
rh.setBounds( 3, 3, 15, 13, 13, 16 );
|
||||
rh.renderInventoryBox( renderer );
|
||||
|
||||
rh.setBounds( 4, 4, 14, 12, 12, 15 );
|
||||
rh.renderInventoryBox( renderer );
|
||||
|
||||
rh.setBounds( 5, 5, 13, 11, 11, 14 );
|
||||
rh.renderInventoryBox( renderer );
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void renderStatic(int x, int y, int z, IPartRenderHelper rh, RenderBlocks renderer)
|
||||
{
|
||||
this.renderCache = rh.useSimplifiedRendering( x, y, z, this, this.renderCache );
|
||||
rh.setTexture( CableBusTextures.PartImportSides.getIcon(), CableBusTextures.PartImportSides.getIcon(), CableBusTextures.PartMonitorBack.getIcon(),
|
||||
this.is.getIconIndex(), CableBusTextures.PartImportSides.getIcon(), CableBusTextures.PartImportSides.getIcon() );
|
||||
|
||||
rh.setBounds( 4, 4, 14, 12, 12, 16 );
|
||||
rh.renderBlock( x, y, z, renderer );
|
||||
|
||||
rh.setBounds( 5, 5, 13, 11, 11, 14 );
|
||||
rh.renderBlock( x, y, z, renderer );
|
||||
|
||||
rh.setBounds( 6, 6, 12, 10, 10, 13 );
|
||||
rh.renderBlock( x, y, z, renderer );
|
||||
rh.setTexture( CableBusTextures.PartMonitorSidesStatus.getIcon(), CableBusTextures.PartMonitorSidesStatus.getIcon(),
|
||||
CableBusTextures.PartMonitorBack.getIcon(), this.is.getIconIndex(), CableBusTextures.PartMonitorSidesStatus.getIcon(),
|
||||
CableBusTextures.PartMonitorSidesStatus.getIcon() );
|
||||
|
||||
rh.setBounds( 6, 6, 11, 10, 10, 12 );
|
||||
rh.renderBlock( x, y, z, renderer );
|
||||
|
||||
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()
|
||||
{
|
||||
return 5;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TickingRequest getTickingRequest(IGridNode node)
|
||||
public TickingRequest getTickingRequest( IGridNode node )
|
||||
{
|
||||
return new TickingRequest( TickRates.ImportBus.min, TickRates.ImportBus.max, this.getHandler() == null, false );
|
||||
}
|
||||
|
||||
private int itemToSend; // used in tickingRequest
|
||||
private boolean worked; // used in tickingRequest
|
||||
@Override
|
||||
public TickRateModulation tickingRequest( IGridNode node, int TicksSinceLastCall )
|
||||
{
|
||||
return this.doBusWork();
|
||||
}
|
||||
|
||||
@Override
|
||||
TickRateModulation doBusWork()
|
||||
@@ -181,38 +181,38 @@ public class PartImportBus extends PartSharedItemBus implements IInventoryDestin
|
||||
{
|
||||
try
|
||||
{
|
||||
switch (this.getInstalledUpgrades( Upgrades.SPEED ))
|
||||
switch ( this.getInstalledUpgrades( Upgrades.SPEED ) )
|
||||
{
|
||||
default:
|
||||
case 0:
|
||||
this.itemToSend = 1;
|
||||
break;
|
||||
case 1:
|
||||
this.itemToSend = 8;
|
||||
break;
|
||||
case 2:
|
||||
this.itemToSend = 32;
|
||||
break;
|
||||
case 3:
|
||||
this.itemToSend = 64;
|
||||
break;
|
||||
case 4:
|
||||
this.itemToSend = 96;
|
||||
break;
|
||||
default:
|
||||
case 0:
|
||||
this.itemToSend = 1;
|
||||
break;
|
||||
case 1:
|
||||
this.itemToSend = 8;
|
||||
break;
|
||||
case 2:
|
||||
this.itemToSend = 32;
|
||||
break;
|
||||
case 3:
|
||||
this.itemToSend = 64;
|
||||
break;
|
||||
case 4:
|
||||
this.itemToSend = 96;
|
||||
break;
|
||||
}
|
||||
|
||||
this.itemToSend = Math.min( this.itemToSend, (int) (0.01 + this.proxy.getEnergy().extractAEPower( this.itemToSend, Actionable.SIMULATE, PowerMultiplier.CONFIG )) );
|
||||
this.itemToSend = Math.min( this.itemToSend, (int) ( 0.01 + this.proxy.getEnergy().extractAEPower( this.itemToSend, Actionable.SIMULATE, PowerMultiplier.CONFIG ) ) );
|
||||
IMEMonitor<IAEItemStack> inv = this.proxy.getStorage().getItemInventory();
|
||||
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 )
|
||||
{
|
||||
Configured = true;
|
||||
while (this.itemToSend > 0)
|
||||
while ( this.itemToSend > 0 )
|
||||
{
|
||||
if ( this.importStuff( myAdaptor, ais, inv, energy, fzMode ) )
|
||||
break;
|
||||
@@ -222,14 +222,14 @@ public class PartImportBus extends PartSharedItemBus implements IInventoryDestin
|
||||
|
||||
if ( !Configured )
|
||||
{
|
||||
while (this.itemToSend > 0)
|
||||
while ( this.itemToSend > 0 )
|
||||
{
|
||||
if ( this.importStuff( myAdaptor, null, inv, energy, fzMode ) )
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (GridAccessException e)
|
||||
catch ( GridAccessException e )
|
||||
{
|
||||
// :3
|
||||
}
|
||||
@@ -240,13 +240,7 @@ public class PartImportBus extends PartSharedItemBus implements IInventoryDestin
|
||||
return this.worked ? TickRateModulation.FASTER : TickRateModulation.SLOWER;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TickRateModulation tickingRequest(IGridNode node, int TicksSinceLastCall)
|
||||
{
|
||||
return this.doBusWork();
|
||||
}
|
||||
|
||||
private boolean importStuff(InventoryAdaptor myAdaptor, IAEItemStack whatToImport, IMEMonitor<IAEItemStack> inv, IEnergySource energy, FuzzyMode fzMode)
|
||||
private boolean importStuff( InventoryAdaptor myAdaptor, IAEItemStack whatToImport, IMEMonitor<IAEItemStack> inv, IEnergySource energy, FuzzyMode fzMode )
|
||||
{
|
||||
int toSend = this.itemToSend;
|
||||
|
||||
@@ -261,7 +255,7 @@ public class PartImportBus extends PartSharedItemBus implements IInventoryDestin
|
||||
|
||||
if ( newItems != null )
|
||||
{
|
||||
newItems.stackSize = (int) (Math.min( newItems.stackSize, energy.extractAEPower( newItems.stackSize, Actionable.SIMULATE, PowerMultiplier.CONFIG ) ) + 0.01);
|
||||
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 ) )
|
||||
@@ -269,7 +263,7 @@ public class PartImportBus extends PartSharedItemBus implements IInventoryDestin
|
||||
else
|
||||
this.lastItemChecked.setStackSize( newItems.stackSize );
|
||||
|
||||
IAEItemStack failed = Platform.poweredInsert( energy, this.destination, this.lastItemChecked, this.mySrc );
|
||||
IAEItemStack failed = Platform.poweredInsert( energy, this.destination, this.lastItemChecked, this.source );
|
||||
// destination.injectItems( lastItemChecked, Actionable.MODULATE );
|
||||
if ( failed != null )
|
||||
{
|
||||
@@ -285,10 +279,16 @@ public class PartImportBus extends PartSharedItemBus implements IInventoryDestin
|
||||
return false;
|
||||
}
|
||||
|
||||
private IInventoryDestination configDestination( IMEMonitor<IAEItemStack> itemInventory )
|
||||
{
|
||||
this.destination = itemInventory;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public RedstoneMode getRSMode()
|
||||
{
|
||||
return (RedstoneMode) this.settings.getSetting( Settings.REDSTONE_CONTROLLED );
|
||||
return (RedstoneMode) this.getConfigManager().getSetting( Settings.REDSTONE_CONTROLLED );
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -296,5 +296,4 @@ public class PartImportBus extends PartSharedItemBus implements IInventoryDestin
|
||||
{
|
||||
return this.getHandler() == null || super.isSleeping();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -73,14 +73,15 @@ import appeng.api.util.AECableType;
|
||||
import appeng.api.util.IConfigManager;
|
||||
import appeng.client.texture.CableBusTextures;
|
||||
import appeng.core.sync.GuiBridge;
|
||||
import appeng.helpers.Reflected;
|
||||
import appeng.me.GridAccessException;
|
||||
import appeng.tile.inventory.AppEngInternalAEInventory;
|
||||
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;
|
||||
@@ -95,6 +96,21 @@ public class PartLevelEmitter extends PartUpgradeable implements IEnergyWatcherH
|
||||
IStackWatcher myWatcher;
|
||||
IEnergyWatcher myEnergyWatcher;
|
||||
ICraftingWatcher myCraftingWatcher;
|
||||
double centerX;
|
||||
double centerY;
|
||||
double centerZ;
|
||||
boolean status = false;
|
||||
|
||||
@Reflected
|
||||
public PartLevelEmitter( ItemStack is )
|
||||
{
|
||||
super( is );
|
||||
|
||||
this.getConfigManager().registerSetting( Settings.REDSTONE_EMITTER, RedstoneMode.HIGH_SIGNAL );
|
||||
this.getConfigManager().registerSetting( Settings.FUZZY_MODE, FuzzyMode.IGNORE_ALL );
|
||||
this.getConfigManager().registerSetting( Settings.LEVEL_TYPE, LevelType.ITEM_LEVEL );
|
||||
this.getConfigManager().registerSetting( Settings.CRAFT_VIA_REDSTONE, YesNo.NO );
|
||||
}
|
||||
|
||||
public long getReportingValue()
|
||||
{
|
||||
@@ -116,24 +132,6 @@ public class PartLevelEmitter extends PartUpgradeable implements IEnergyWatcherH
|
||||
this.updateState();
|
||||
}
|
||||
|
||||
@MENetworkEventSubscribe
|
||||
public void channelChanged( MENetworkChannelsChanged c )
|
||||
{
|
||||
this.updateState();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void upgradesChanged()
|
||||
{
|
||||
this.configureWatchers();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateSetting( IConfigManager manager, Enum settingName, Enum newValue )
|
||||
{
|
||||
this.configureWatchers();
|
||||
}
|
||||
|
||||
private void updateState()
|
||||
{
|
||||
boolean isOn = this.isLevelEmitterOn();
|
||||
@@ -147,24 +145,40 @@ public class PartLevelEmitter extends PartUpgradeable implements IEnergyWatcherH
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT( NBTTagCompound data )
|
||||
private boolean isLevelEmitterOn()
|
||||
{
|
||||
super.writeToNBT( data );
|
||||
data.setLong( "lastReportedValue", this.lastReportedValue );
|
||||
data.setLong( "reportingValue", this.reportingValue );
|
||||
data.setBoolean( "prevState", this.prevState );
|
||||
this.config.writeToNBT( data, "config" );
|
||||
if ( Platform.isClient() )
|
||||
{
|
||||
return ( this.clientFlags & this.FLAG_ON ) == this.FLAG_ON;
|
||||
}
|
||||
|
||||
if ( !this.proxy.isActive() )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if ( this.getInstalledUpgrades( Upgrades.CRAFTING ) > 0 )
|
||||
{
|
||||
try
|
||||
{
|
||||
return this.proxy.getCrafting().isRequesting( this.config.getAEStackInSlot( 0 ) );
|
||||
}
|
||||
catch ( GridAccessException e )
|
||||
{
|
||||
// :P
|
||||
}
|
||||
|
||||
return this.prevState;
|
||||
}
|
||||
|
||||
boolean flipState = this.getConfigManager().getSetting( Settings.REDSTONE_EMITTER ) == RedstoneMode.LOW_SIGNAL;
|
||||
return flipState ? this.reportingValue >= this.lastReportedValue + 1 : this.reportingValue < this.lastReportedValue + 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT( NBTTagCompound data )
|
||||
@MENetworkEventSubscribe
|
||||
public void channelChanged( MENetworkChannelsChanged c )
|
||||
{
|
||||
super.readFromNBT( data );
|
||||
this.lastReportedValue = data.getLong( "lastReportedValue" );
|
||||
this.reportingValue = data.getLong( "reportingValue" );
|
||||
this.prevState = data.getBoolean( "prevState" );
|
||||
this.config.readFromNBT( data, "config" );
|
||||
this.updateState();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -173,6 +187,12 @@ public class PartLevelEmitter extends PartUpgradeable implements IEnergyWatcherH
|
||||
return cf | ( this.prevState ? this.FLAG_ON : 0 );
|
||||
}
|
||||
|
||||
@Override
|
||||
public IIcon getBreakingTexture()
|
||||
{
|
||||
return this.is.getIconIndex();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateWatcher( ICraftingWatcher newWatcher )
|
||||
{
|
||||
@@ -181,18 +201,11 @@ public class PartLevelEmitter extends PartUpgradeable implements IEnergyWatcherH
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateWatcher( IStackWatcher newWatcher )
|
||||
public void onRequestChange( ICraftingGrid craftingGrid, IAEItemStack what )
|
||||
{
|
||||
this.myWatcher = newWatcher;
|
||||
this.configureWatchers();
|
||||
this.updateState();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateWatcher( IEnergyWatcher newWatcher )
|
||||
{
|
||||
this.myEnergyWatcher = newWatcher;
|
||||
this.configureWatchers();
|
||||
}
|
||||
|
||||
// update the system...
|
||||
public void configureWatchers()
|
||||
@@ -228,12 +241,12 @@ public class PartLevelEmitter extends PartUpgradeable implements IEnergyWatcherH
|
||||
if ( this.getConfigManager().getSetting( Settings.LEVEL_TYPE ) == LevelType.ENERGY_LEVEL )
|
||||
{
|
||||
if ( this.myEnergyWatcher != null )
|
||||
this.myEnergyWatcher.add( ( double ) this.reportingValue );
|
||||
this.myEnergyWatcher.add( (double) this.reportingValue );
|
||||
|
||||
try
|
||||
{
|
||||
// update to power...
|
||||
this.lastReportedValue = ( long ) this.proxy.getEnergy().getStoredPower();
|
||||
this.lastReportedValue = (long) this.proxy.getEnergy().getStoredPower();
|
||||
this.updateState();
|
||||
|
||||
// no more item stuff..
|
||||
@@ -269,35 +282,6 @@ public class PartLevelEmitter extends PartUpgradeable implements IEnergyWatcherH
|
||||
}
|
||||
}
|
||||
|
||||
@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 postChange( IBaseMonitor<IAEItemStack> monitor, Iterable<IAEItemStack> change, BaseActionSource actionSource )
|
||||
{
|
||||
this.updateReportingValue( ( IMEMonitor<IAEItemStack> ) monitor );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onPartActivate( EntityPlayer player, Vec3 pos )
|
||||
{
|
||||
if ( !player.isSneaking() )
|
||||
{
|
||||
if ( Platform.isClient() )
|
||||
return true;
|
||||
|
||||
Platform.openGUI( player, this.getHost().getTile(), this.side, GuiBridge.GUI_LEVEL_EMITTER );
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private void updateReportingValue( IMEMonitor<IAEItemStack> monitor )
|
||||
{
|
||||
@@ -312,7 +296,7 @@ public class PartLevelEmitter extends PartUpgradeable implements IEnergyWatcherH
|
||||
else if ( this.getInstalledUpgrades( Upgrades.FUZZY ) > 0 )
|
||||
{
|
||||
this.lastReportedValue = 0;
|
||||
FuzzyMode fzMode = ( FuzzyMode ) this.getConfigManager().getSetting( Settings.FUZZY_MODE );
|
||||
FuzzyMode fzMode = (FuzzyMode) this.getConfigManager().getSetting( Settings.FUZZY_MODE );
|
||||
Collection<IAEItemStack> fuzzyList = monitor.getStorageList().findFuzzy( myStack, fzMode );
|
||||
for ( IAEItemStack st : fuzzyList )
|
||||
this.lastReportedValue += st.getStackSize();
|
||||
@@ -329,6 +313,42 @@ public class PartLevelEmitter extends PartUpgradeable implements IEnergyWatcherH
|
||||
this.updateState();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void updateWatcher( IStackWatcher newWatcher )
|
||||
{
|
||||
this.myWatcher = newWatcher;
|
||||
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 )
|
||||
{
|
||||
this.lastReportedValue = fullStack.getStackSize();
|
||||
this.updateState();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void updateWatcher( IEnergyWatcher newWatcher )
|
||||
{
|
||||
this.myEnergyWatcher = newWatcher;
|
||||
this.configureWatchers();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onThresholdPass( IEnergyGrid energyGrid )
|
||||
{
|
||||
this.lastReportedValue = (long) energyGrid.getStoredPower();
|
||||
this.updateState();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean isValid( Object effectiveGrid )
|
||||
{
|
||||
@@ -342,37 +362,27 @@ public class PartLevelEmitter extends PartUpgradeable implements IEnergyWatcherH
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRequestChange( ICraftingGrid craftingGrid, IAEItemStack what )
|
||||
{
|
||||
this.updateState();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onThresholdPass( IEnergyGrid energyGrid )
|
||||
public void postChange( IBaseMonitor<IAEItemStack> monitor, Iterable<IAEItemStack> change, BaseActionSource actionSource )
|
||||
{
|
||||
this.lastReportedValue = ( long ) energyGrid.getStoredPower();
|
||||
this.updateState();
|
||||
this.updateReportingValue( (IMEMonitor<IAEItemStack>) monitor );
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onStackChange( IItemList o, IAEStack fullStack, IAEStack diffStack, BaseActionSource src, StorageChannel chan )
|
||||
public void onListUpdate()
|
||||
{
|
||||
if ( chan == StorageChannel.ITEMS && fullStack.equals( this.config.getAEStackInSlot( 0 ) ) && this.getInstalledUpgrades( Upgrades.FUZZY ) == 0 )
|
||||
try
|
||||
{
|
||||
this.lastReportedValue = fullStack.getStackSize();
|
||||
this.updateState();
|
||||
this.updateReportingValue( this.proxy.getStorage().getItemInventory() );
|
||||
}
|
||||
catch ( GridAccessException e )
|
||||
{
|
||||
// ;P
|
||||
}
|
||||
}
|
||||
|
||||
public PartLevelEmitter( ItemStack is )
|
||||
{
|
||||
super( PartLevelEmitter.class, is );
|
||||
this.getConfigManager().registerSetting( Settings.REDSTONE_EMITTER, RedstoneMode.HIGH_SIGNAL );
|
||||
this.getConfigManager().registerSetting( Settings.FUZZY_MODE, FuzzyMode.IGNORE_ALL );
|
||||
this.getConfigManager().registerSetting( Settings.LEVEL_TYPE, LevelType.ITEM_LEVEL );
|
||||
this.getConfigManager().registerSetting( Settings.CRAFT_VIA_REDSTONE, YesNo.NO );
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly( Side.CLIENT )
|
||||
@@ -386,75 +396,6 @@ public class PartLevelEmitter extends PartUpgradeable implements IEnergyWatcherH
|
||||
// rh.renderInventoryBox( renderer );
|
||||
}
|
||||
|
||||
double centerX;
|
||||
double centerY;
|
||||
double centerZ;
|
||||
|
||||
public void addVertexWithUV( double x, double y, double z, double u, double v )
|
||||
{
|
||||
Tessellator var12 = Tessellator.instance;
|
||||
|
||||
x -= this.centerX;
|
||||
y -= this.centerY;
|
||||
z -= this.centerZ;
|
||||
|
||||
if ( this.side == ForgeDirection.DOWN )
|
||||
{
|
||||
y = -y;
|
||||
z = -z;
|
||||
}
|
||||
|
||||
if ( this.side == ForgeDirection.EAST )
|
||||
{
|
||||
double m = x;
|
||||
x = y;
|
||||
y = m;
|
||||
y = -y;
|
||||
}
|
||||
|
||||
if ( this.side == ForgeDirection.WEST )
|
||||
{
|
||||
double m = x;
|
||||
x = -y;
|
||||
y = m;
|
||||
}
|
||||
|
||||
if ( this.side == ForgeDirection.SOUTH )
|
||||
{
|
||||
double m = z;
|
||||
z = y;
|
||||
y = m;
|
||||
y = -y;
|
||||
}
|
||||
|
||||
if ( this.side == ForgeDirection.NORTH )
|
||||
{
|
||||
double m = z;
|
||||
z = -y;
|
||||
y = m;
|
||||
}
|
||||
|
||||
x += this.centerX;// + orientation.offsetX * 0.4;
|
||||
y += this.centerY;// + orientation.offsetY * 0.4;
|
||||
z += this.centerZ;// + orientation.offsetZ * 0.4;
|
||||
|
||||
var12.addVertexWithUV( x, y, z, u, v );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void randomDisplayTick( World world, int x, int y, int z, Random r )
|
||||
{
|
||||
if ( this.isLevelEmitterOn() )
|
||||
{
|
||||
ForgeDirection d = this.side;
|
||||
|
||||
double d0 = d.offsetX * 0.45F + ( r.nextFloat() - 0.5F ) * 0.2D;
|
||||
double d1 = d.offsetY * 0.45F + ( r.nextFloat() - 0.5F ) * 0.2D;
|
||||
double d2 = d.offsetZ * 0.45F + ( r.nextFloat() - 0.5F ) * 0.2D;
|
||||
|
||||
world.spawnParticle( "reddust", 0.5 + x + d0, 0.5 + y + d1, 0.5 + z + d2, 0.0D, 0.0D, 0.0D );
|
||||
}
|
||||
}
|
||||
|
||||
public void renderTorchAtAngle( double baseX, double baseY, double baseZ )
|
||||
{
|
||||
@@ -564,38 +505,59 @@ public class PartLevelEmitter extends PartUpgradeable implements IEnergyWatcherH
|
||||
this.addVertexWithUV( var36, baseY + 1.0D, baseZ - var44, var17, var18 );
|
||||
}
|
||||
|
||||
boolean status = false;
|
||||
|
||||
private boolean isLevelEmitterOn()
|
||||
public void addVertexWithUV( double x, double y, double z, double u, double v )
|
||||
{
|
||||
if ( Platform.isClient() )
|
||||
Tessellator var12 = Tessellator.instance;
|
||||
|
||||
x -= this.centerX;
|
||||
y -= this.centerY;
|
||||
z -= this.centerZ;
|
||||
|
||||
if ( this.side == ForgeDirection.DOWN )
|
||||
{
|
||||
return ( this.clientFlags & this.FLAG_ON ) == this.FLAG_ON;
|
||||
y = -y;
|
||||
z = -z;
|
||||
}
|
||||
|
||||
if ( !this.proxy.isActive() )
|
||||
if ( this.side == ForgeDirection.EAST )
|
||||
{
|
||||
return false;
|
||||
double m = x;
|
||||
x = y;
|
||||
y = m;
|
||||
y = -y;
|
||||
}
|
||||
|
||||
if ( this.getInstalledUpgrades( Upgrades.CRAFTING ) > 0 )
|
||||
if ( this.side == ForgeDirection.WEST )
|
||||
{
|
||||
try
|
||||
{
|
||||
return this.proxy.getCrafting().isRequesting( this.config.getAEStackInSlot( 0 ) );
|
||||
}
|
||||
catch ( GridAccessException e )
|
||||
{
|
||||
// :P
|
||||
}
|
||||
|
||||
return this.prevState;
|
||||
double m = x;
|
||||
x = -y;
|
||||
y = m;
|
||||
}
|
||||
|
||||
boolean flipState = this.getConfigManager().getSetting( Settings.REDSTONE_EMITTER ) == RedstoneMode.LOW_SIGNAL;
|
||||
return flipState ? this.reportingValue >= this.lastReportedValue + 1 : this.reportingValue < this.lastReportedValue + 1;
|
||||
if ( this.side == ForgeDirection.SOUTH )
|
||||
{
|
||||
double m = z;
|
||||
z = y;
|
||||
y = m;
|
||||
y = -y;
|
||||
}
|
||||
|
||||
if ( this.side == ForgeDirection.NORTH )
|
||||
{
|
||||
double m = z;
|
||||
z = -y;
|
||||
y = m;
|
||||
}
|
||||
|
||||
x += this.centerX;// + orientation.offsetX * 0.4;
|
||||
y += this.centerY;// + orientation.offsetY * 0.4;
|
||||
z += this.centerZ;// + orientation.offsetZ * 0.4;
|
||||
|
||||
var12.addVertexWithUV( x, y, z, u, v );
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
@SideOnly( Side.CLIENT )
|
||||
public void renderStatic( int x, int y, int z, IPartRenderHelper rh, RenderBlocks renderer )
|
||||
@@ -625,35 +587,6 @@ public class PartLevelEmitter extends PartUpgradeable implements IEnergyWatcherH
|
||||
// super.renderWorldBlock( world, x, y, z, block, modelId, renderer );
|
||||
}
|
||||
|
||||
@Override
|
||||
public IIcon getBreakingTexture()
|
||||
{
|
||||
return this.is.getIconIndex();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getBoxes( IPartCollisionHelper bch )
|
||||
{
|
||||
bch.addBox( 7, 7, 11, 9, 9, 16 );
|
||||
}
|
||||
|
||||
@Override
|
||||
public AECableType getCableConnectionType( ForgeDirection dir )
|
||||
{
|
||||
return AECableType.SMART;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int cableConnectionRenderTo()
|
||||
{
|
||||
return 16;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canConnectRedstone()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int isProvidingStrongPower()
|
||||
@@ -661,12 +594,96 @@ public class PartLevelEmitter extends PartUpgradeable implements IEnergyWatcherH
|
||||
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() )
|
||||
{
|
||||
ForgeDirection d = this.side;
|
||||
|
||||
double d0 = d.offsetX * 0.45F + ( r.nextFloat() - 0.5F ) * 0.2D;
|
||||
double d1 = d.offsetY * 0.45F + ( r.nextFloat() - 0.5F ) * 0.2D;
|
||||
double d2 = d.offsetZ * 0.45F + ( r.nextFloat() - 0.5F ) * 0.2D;
|
||||
|
||||
world.spawnParticle( "reddust", 0.5 + x + d0, 0.5 + y + d1, 0.5 + z + d2, 0.0D, 0.0D, 0.0D );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@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 ( Platform.isClient() )
|
||||
return true;
|
||||
|
||||
Platform.openGUI( player, this.getHost().getTile(), this.side, GuiBridge.GUI_LEVEL_EMITTER );
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean canConnectRedstone()
|
||||
{
|
||||
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 )
|
||||
{
|
||||
super.readFromNBT( data );
|
||||
this.lastReportedValue = data.getLong( "lastReportedValue" );
|
||||
this.reportingValue = data.getLong( "reportingValue" );
|
||||
this.prevState = data.getBoolean( "prevState" );
|
||||
this.config.readFromNBT( data, "config" );
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public IInventory getInventoryByName( String name )
|
||||
{
|
||||
@@ -676,17 +693,28 @@ public class PartLevelEmitter extends PartUpgradeable implements IEnergyWatcherH
|
||||
return super.getInventoryByName( name );
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onListUpdate()
|
||||
public void updateSetting( IConfigManager manager, Enum settingName, Enum newValue )
|
||||
{
|
||||
try
|
||||
{
|
||||
this.updateReportingValue( this.proxy.getStorage().getItemInventory() );
|
||||
}
|
||||
catch ( GridAccessException e )
|
||||
{
|
||||
// ;P
|
||||
}
|
||||
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
|
||||
@@ -706,7 +734,7 @@ public class PartLevelEmitter extends PartUpgradeable implements IEnergyWatcherH
|
||||
{
|
||||
if ( this.getInstalledUpgrades( Upgrades.CRAFTING ) > 0 )
|
||||
{
|
||||
if ( this.settings.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 )
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
|
||||
package appeng.parts.automation;
|
||||
|
||||
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
@@ -32,29 +33,18 @@ import appeng.tile.inventory.AppEngInternalAEInventory;
|
||||
import appeng.util.InventoryAdaptor;
|
||||
import appeng.util.Platform;
|
||||
|
||||
|
||||
public abstract class PartSharedItemBus extends PartUpgradeable implements IGridTickable
|
||||
{
|
||||
|
||||
private TileEntity getTileEntity(TileEntity self, int x, int y, int z)
|
||||
final AppEngInternalAEInventory config = new AppEngInternalAEInventory( this, 9 );
|
||||
int adaptorHash = 0;
|
||||
InventoryAdaptor adaptor;
|
||||
boolean lastRedstone = false;
|
||||
|
||||
public PartSharedItemBus( ItemStack is )
|
||||
{
|
||||
World w = self.getWorldObj();
|
||||
|
||||
if ( w.getChunkProvider().chunkExists( x >> 4, z >> 4 ) )
|
||||
{
|
||||
return w.getTileEntity( x, y, z );
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public PartSharedItemBus(Class c, ItemStack is) {
|
||||
super( c, is );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void upgradesChanged()
|
||||
{
|
||||
this.updateState();
|
||||
super( is );
|
||||
}
|
||||
|
||||
protected int availableSlots()
|
||||
@@ -63,23 +53,48 @@ public abstract class PartSharedItemBus extends PartUpgradeable implements IGrid
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT(net.minecraft.nbt.NBTTagCompound extra)
|
||||
public void writeToNBT( net.minecraft.nbt.NBTTagCompound extra )
|
||||
{
|
||||
super.writeToNBT( extra );
|
||||
this.config.writeToNBT( extra, "config" );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(net.minecraft.nbt.NBTTagCompound extra)
|
||||
public void readFromNBT( net.minecraft.nbt.NBTTagCompound extra )
|
||||
{
|
||||
super.readFromNBT( extra );
|
||||
this.config.readFromNBT( extra, "config" );
|
||||
}
|
||||
|
||||
final AppEngInternalAEInventory config = new AppEngInternalAEInventory( this, 9 );
|
||||
@Override
|
||||
public IInventory getInventoryByName( String name )
|
||||
{
|
||||
if ( name.equals( "config" ) )
|
||||
return this.config;
|
||||
|
||||
int adaptorHash = 0;
|
||||
InventoryAdaptor adaptor;
|
||||
return super.getInventoryByName( name );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void upgradesChanged()
|
||||
{
|
||||
this.updateState();
|
||||
}
|
||||
|
||||
private void updateState()
|
||||
{
|
||||
try
|
||||
{
|
||||
if ( !this.isSleeping() )
|
||||
this.proxy.getTick().wakeDevice( this.proxy.getNode() );
|
||||
else
|
||||
this.proxy.getTick().sleepDevice( this.proxy.getNode() );
|
||||
}
|
||||
catch ( GridAccessException e )
|
||||
{
|
||||
// :P
|
||||
}
|
||||
}
|
||||
|
||||
InventoryAdaptor getHandler()
|
||||
{
|
||||
@@ -97,9 +112,17 @@ public abstract class PartSharedItemBus extends PartUpgradeable implements IGrid
|
||||
return this.adaptor;
|
||||
}
|
||||
|
||||
boolean lastRedstone = false;
|
||||
private TileEntity getTileEntity( TileEntity self, int x, int y, int z )
|
||||
{
|
||||
World w = self.getWorldObj();
|
||||
|
||||
abstract TickRateModulation doBusWork();
|
||||
if ( w.getChunkProvider().chunkExists( x >> 4, z >> 4 ) )
|
||||
{
|
||||
return w.getTileEntity( x, y, z );
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNeighborChanged()
|
||||
@@ -113,28 +136,5 @@ public abstract class PartSharedItemBus extends PartUpgradeable implements IGrid
|
||||
}
|
||||
}
|
||||
|
||||
private void updateState()
|
||||
{
|
||||
try
|
||||
{
|
||||
if ( !this.isSleeping() )
|
||||
this.proxy.getTick().wakeDevice( this.proxy.getNode() );
|
||||
else
|
||||
this.proxy.getTick().sleepDevice( this.proxy.getNode() );
|
||||
}
|
||||
catch (GridAccessException e)
|
||||
{
|
||||
// :P
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public IInventory getInventoryByName(String name)
|
||||
{
|
||||
if ( name.equals( "config" ) )
|
||||
return this.config;
|
||||
|
||||
return super.getInventoryByName( name );
|
||||
}
|
||||
|
||||
abstract TickRateModulation doBusWork();
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
|
||||
package appeng.parts.automation;
|
||||
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.inventory.IInventory;
|
||||
@@ -32,22 +33,18 @@ import appeng.tile.inventory.InvOperation;
|
||||
import appeng.util.ConfigManager;
|
||||
import appeng.util.IConfigManagerHost;
|
||||
|
||||
public class PartUpgradeable extends PartBasicState implements IAEAppEngInventory, IConfigManagerHost
|
||||
|
||||
public abstract class PartUpgradeable extends PartBasicState implements IAEAppEngInventory, IConfigManagerHost
|
||||
{
|
||||
private final IConfigManager manager;
|
||||
private final UpgradeInventory upgrades;
|
||||
|
||||
final IConfigManager settings = new ConfigManager( this );
|
||||
private final UpgradeInventory upgrades = new UpgradeInventory( this.is, this, this.getUpgradeSlots() );
|
||||
|
||||
@Override
|
||||
public int getInstalledUpgrades(Upgrades u)
|
||||
public PartUpgradeable( ItemStack is )
|
||||
{
|
||||
return this.upgrades.getInstalledUpgrades( u );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canConnectRedstone()
|
||||
{
|
||||
return this.upgrades.getMaxInstalled( Upgrades.REDSTONE ) > 0;
|
||||
super( is );
|
||||
this.upgrades = new StackUpgradeInventory( this.is, this, this.getUpgradeSlots() );
|
||||
this.upgrades.setMaxStackSize( 1 );
|
||||
this.manager = new ConfigManager( this );
|
||||
}
|
||||
|
||||
protected int getUpgradeSlots()
|
||||
@@ -56,42 +53,43 @@ public class PartUpgradeable extends PartBasicState implements IAEAppEngInventor
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getDrops(List<ItemStack> drops, boolean wrenched)
|
||||
public boolean canConnectRedstone()
|
||||
{
|
||||
for (ItemStack is : this.upgrades)
|
||||
return this.upgrades.getMaxInstalled( Upgrades.REDSTONE ) > 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT( net.minecraft.nbt.NBTTagCompound extra )
|
||||
{
|
||||
super.readFromNBT( extra );
|
||||
this.manager.readFromNBT( extra );
|
||||
this.upgrades.readFromNBT( extra, "upgrades" );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT( net.minecraft.nbt.NBTTagCompound extra )
|
||||
{
|
||||
super.writeToNBT( extra );
|
||||
this.manager.writeToNBT( extra );
|
||||
this.upgrades.writeToNBT( extra, "upgrades" );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getDrops( List<ItemStack> drops, boolean wrenched )
|
||||
{
|
||||
for ( ItemStack is : this.upgrades )
|
||||
if ( is != null )
|
||||
drops.add( is );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT(net.minecraft.nbt.NBTTagCompound extra)
|
||||
{
|
||||
super.writeToNBT( extra );
|
||||
this.settings.writeToNBT( extra );
|
||||
this.upgrades.writeToNBT( extra, "upgrades" );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(net.minecraft.nbt.NBTTagCompound extra)
|
||||
{
|
||||
super.readFromNBT( extra );
|
||||
this.settings.readFromNBT( extra );
|
||||
this.upgrades.readFromNBT( extra, "upgrades" );
|
||||
}
|
||||
|
||||
public PartUpgradeable(Class c, ItemStack is) {
|
||||
super( c, is );
|
||||
this.upgrades.setMaxStackSize( 1 );
|
||||
}
|
||||
|
||||
@Override
|
||||
public IConfigManager getConfigManager()
|
||||
{
|
||||
return this.settings;
|
||||
return this.manager;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IInventory getInventoryByName(String name)
|
||||
public IInventory getInventoryByName( String name )
|
||||
{
|
||||
if ( name.equals( "upgrades" ) )
|
||||
return this.upgrades;
|
||||
@@ -100,18 +98,19 @@ public class PartUpgradeable extends PartBasicState implements IAEAppEngInventor
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateSetting(IConfigManager manager, Enum settingName, Enum newValue)
|
||||
public int getInstalledUpgrades( Upgrades u )
|
||||
{
|
||||
|
||||
return this.upgrades.getInstalledUpgrades( u );
|
||||
}
|
||||
|
||||
public void upgradesChanged()
|
||||
@Override
|
||||
public void updateSetting( IConfigManager manager, Enum settingName, Enum newValue )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChangeInventory(IInventory inv, int slot, InvOperation mc, ItemStack removedStack, ItemStack newStack)
|
||||
public void onChangeInventory( IInventory inv, int slot, InvOperation mc, ItemStack removedStack, ItemStack newStack )
|
||||
{
|
||||
if ( inv == this.upgrades )
|
||||
{
|
||||
@@ -119,36 +118,35 @@ public class PartUpgradeable extends PartBasicState implements IAEAppEngInventor
|
||||
}
|
||||
}
|
||||
|
||||
public RedstoneMode getRSMode()
|
||||
public void upgradesChanged()
|
||||
{
|
||||
return null;
|
||||
|
||||
}
|
||||
|
||||
protected boolean isSleeping()
|
||||
{
|
||||
if ( this.getInstalledUpgrades( Upgrades.REDSTONE ) > 0 )
|
||||
{
|
||||
switch (this.getRSMode())
|
||||
switch ( this.getRSMode() )
|
||||
{
|
||||
case IGNORE:
|
||||
return false;
|
||||
|
||||
case HIGH_SIGNAL:
|
||||
if ( this.host.hasRedstone( this.side ) )
|
||||
case IGNORE:
|
||||
return false;
|
||||
|
||||
break;
|
||||
case HIGH_SIGNAL:
|
||||
if ( this.host.hasRedstone( this.side ) )
|
||||
return false;
|
||||
|
||||
case LOW_SIGNAL:
|
||||
if ( !this.host.hasRedstone( this.side ) )
|
||||
return false;
|
||||
break;
|
||||
|
||||
break;
|
||||
case LOW_SIGNAL:
|
||||
if ( !this.host.hasRedstone( this.side ) )
|
||||
return false;
|
||||
|
||||
case SIGNAL_PULSE:
|
||||
default:
|
||||
break;
|
||||
break;
|
||||
|
||||
case SIGNAL_PULSE:
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return true;
|
||||
@@ -156,4 +154,9 @@ public class PartUpgradeable extends PartBasicState implements IAEAppEngInventor
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public RedstoneMode getRSMode()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
package appeng.parts.automation;
|
||||
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import appeng.api.config.Upgrades;
|
||||
import appeng.tile.inventory.IAEAppEngInventory;
|
||||
import appeng.util.Platform;
|
||||
|
||||
|
||||
public class StackUpgradeInventory extends UpgradeInventory
|
||||
{
|
||||
private final ItemStack stack;
|
||||
|
||||
public StackUpgradeInventory( ItemStack stack, IAEAppEngInventory inventory, int s )
|
||||
{
|
||||
super( inventory, s );
|
||||
this.stack = stack;
|
||||
}
|
||||
|
||||
|
||||
public int getMaxInstalled( Upgrades upgrades )
|
||||
{
|
||||
int max = 0;
|
||||
|
||||
for ( ItemStack is : upgrades.getSupported().keySet() )
|
||||
{
|
||||
if ( Platform.isSameItem( this.stack, is ) )
|
||||
{
|
||||
max = upgrades.getSupported().get( is );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return max;
|
||||
}
|
||||
}
|
||||
@@ -18,10 +18,9 @@
|
||||
|
||||
package appeng.parts.automation;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemBlock;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
||||
@@ -32,25 +31,24 @@ import appeng.tile.inventory.IAEAppEngInventory;
|
||||
import appeng.tile.inventory.InvOperation;
|
||||
import appeng.util.Platform;
|
||||
|
||||
public class UpgradeInventory extends AppEngInternalInventory implements IAEAppEngInventory
|
||||
{
|
||||
|
||||
private final Object itemOrBlock;
|
||||
public abstract class UpgradeInventory extends AppEngInternalInventory implements IAEAppEngInventory
|
||||
{
|
||||
private final IAEAppEngInventory parent;
|
||||
|
||||
private boolean cached = false;
|
||||
private int FuzzyUpgrades = 0;
|
||||
private int SpeedUpgrades = 0;
|
||||
private int RedstoneUpgrades = 0;
|
||||
private int CapacityUpgrades = 0;
|
||||
private int InverterUpgrades = 0;
|
||||
private int CraftingUpgrades = 0;
|
||||
private int fuzzyUpgrades = 0;
|
||||
private int speedUpgrades = 0;
|
||||
private int redstoneUpgrades = 0;
|
||||
private int capacityUpgrades = 0;
|
||||
private int inverterUpgrades = 0;
|
||||
private int craftingUpgrades = 0;
|
||||
|
||||
public UpgradeInventory(Object itemOrBlock, IAEAppEngInventory _te, int s) {
|
||||
public UpgradeInventory( IAEAppEngInventory parent, int s )
|
||||
{
|
||||
super( null, s );
|
||||
this.te = this;
|
||||
this.parent = _te;
|
||||
this.itemOrBlock = itemOrBlock;
|
||||
this.parent = parent;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -60,14 +58,20 @@ public class UpgradeInventory extends AppEngInternalInventory implements IAEAppE
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isItemValidForSlot(int i, ItemStack itemstack)
|
||||
public int getInventoryStackLimit()
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isItemValidForSlot( int i, ItemStack itemstack )
|
||||
{
|
||||
if ( itemstack == null )
|
||||
return false;
|
||||
Item it = itemstack.getItem();
|
||||
if ( it instanceof IUpgradeModule )
|
||||
{
|
||||
Upgrades u = ((IUpgradeModule) it).getType( itemstack );
|
||||
Upgrades u = ( (IUpgradeModule) it ).getType( itemstack );
|
||||
if ( u != null )
|
||||
{
|
||||
return this.getInstalledUpgrades( u ) < this.getMaxInstalled( u );
|
||||
@@ -76,120 +80,81 @@ public class UpgradeInventory extends AppEngInternalInventory implements IAEAppE
|
||||
return false;
|
||||
}
|
||||
|
||||
public int getMaxInstalled(Upgrades u)
|
||||
{
|
||||
Integer max = null;
|
||||
for (ItemStack is : u.getSupported().keySet())
|
||||
{
|
||||
if ( is.getItem() == this.itemOrBlock )
|
||||
{
|
||||
max = u.getSupported().get( is );
|
||||
break;
|
||||
}
|
||||
else if ( is.getItem() instanceof ItemBlock && Block.getBlockFromItem( is.getItem() ) == this.itemOrBlock )
|
||||
{
|
||||
max = u.getSupported().get( is );
|
||||
break;
|
||||
}
|
||||
else if ( this.itemOrBlock instanceof ItemStack && Platform.isSameItem( (ItemStack) this.itemOrBlock, is ) )
|
||||
{
|
||||
max = u.getSupported().get( is );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if ( max == null )
|
||||
return 0;
|
||||
return max;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getInventoryStackLimit()
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
private void updateUpgradeInfo()
|
||||
{
|
||||
this.cached = true;
|
||||
this.InverterUpgrades = this.CapacityUpgrades = this.RedstoneUpgrades = this.SpeedUpgrades = this.FuzzyUpgrades = this.CraftingUpgrades = 0;
|
||||
|
||||
for (ItemStack is : this)
|
||||
{
|
||||
if ( is == null || is.getItem() == null || !(is.getItem() instanceof IUpgradeModule) )
|
||||
continue;
|
||||
|
||||
Upgrades myUpgrade = ((IUpgradeModule) is.getItem()).getType( is );
|
||||
switch (myUpgrade)
|
||||
{
|
||||
case CAPACITY:
|
||||
this.CapacityUpgrades++;
|
||||
break;
|
||||
case FUZZY:
|
||||
this.FuzzyUpgrades++;
|
||||
break;
|
||||
case REDSTONE:
|
||||
this.RedstoneUpgrades++;
|
||||
break;
|
||||
case SPEED:
|
||||
this.SpeedUpgrades++;
|
||||
break;
|
||||
case INVERTER:
|
||||
this.InverterUpgrades++;
|
||||
break;
|
||||
case CRAFTING:
|
||||
this.CraftingUpgrades++;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
this.CapacityUpgrades = Math.min( this.CapacityUpgrades, this.getMaxInstalled( Upgrades.CAPACITY ) );
|
||||
this.FuzzyUpgrades = Math.min( this.FuzzyUpgrades, this.getMaxInstalled( Upgrades.FUZZY ) );
|
||||
this.RedstoneUpgrades = Math.min( this.RedstoneUpgrades, this.getMaxInstalled( Upgrades.REDSTONE ) );
|
||||
this.SpeedUpgrades = Math.min( this.SpeedUpgrades, this.getMaxInstalled( Upgrades.SPEED ) );
|
||||
this.InverterUpgrades = Math.min( this.InverterUpgrades, this.getMaxInstalled( Upgrades.INVERTER ) );
|
||||
this.CraftingUpgrades = Math.min( this.CraftingUpgrades, this.getMaxInstalled( Upgrades.CRAFTING ) );
|
||||
}
|
||||
|
||||
public int getInstalledUpgrades(Upgrades u)
|
||||
public int getInstalledUpgrades( Upgrades u )
|
||||
{
|
||||
if ( !this.cached )
|
||||
this.updateUpgradeInfo();
|
||||
|
||||
switch (u)
|
||||
switch ( u )
|
||||
{
|
||||
case CAPACITY:
|
||||
return this.CapacityUpgrades;
|
||||
case FUZZY:
|
||||
return this.FuzzyUpgrades;
|
||||
case REDSTONE:
|
||||
return this.RedstoneUpgrades;
|
||||
case SPEED:
|
||||
return this.SpeedUpgrades;
|
||||
case INVERTER:
|
||||
return this.InverterUpgrades;
|
||||
case CRAFTING:
|
||||
return this.CraftingUpgrades;
|
||||
default:
|
||||
return 0;
|
||||
case CAPACITY:
|
||||
return this.capacityUpgrades;
|
||||
case FUZZY:
|
||||
return this.fuzzyUpgrades;
|
||||
case REDSTONE:
|
||||
return this.redstoneUpgrades;
|
||||
case SPEED:
|
||||
return this.speedUpgrades;
|
||||
case INVERTER:
|
||||
return this.inverterUpgrades;
|
||||
case CRAFTING:
|
||||
return this.craftingUpgrades;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound target)
|
||||
public abstract int getMaxInstalled( Upgrades upgrades );
|
||||
|
||||
private void updateUpgradeInfo()
|
||||
{
|
||||
super.readFromNBT( target );
|
||||
this.updateUpgradeInfo();
|
||||
this.cached = true;
|
||||
this.inverterUpgrades = this.capacityUpgrades = this.redstoneUpgrades = this.speedUpgrades = this.fuzzyUpgrades = this.craftingUpgrades = 0;
|
||||
|
||||
for ( ItemStack is : this )
|
||||
{
|
||||
if ( is == null || is.getItem() == null || !( is.getItem() instanceof IUpgradeModule ) )
|
||||
continue;
|
||||
|
||||
Upgrades myUpgrade = ( (IUpgradeModule) is.getItem() ).getType( is );
|
||||
switch ( myUpgrade )
|
||||
{
|
||||
case CAPACITY:
|
||||
this.capacityUpgrades++;
|
||||
break;
|
||||
case FUZZY:
|
||||
this.fuzzyUpgrades++;
|
||||
break;
|
||||
case REDSTONE:
|
||||
this.redstoneUpgrades++;
|
||||
break;
|
||||
case SPEED:
|
||||
this.speedUpgrades++;
|
||||
break;
|
||||
case INVERTER:
|
||||
this.inverterUpgrades++;
|
||||
break;
|
||||
case CRAFTING:
|
||||
this.craftingUpgrades++;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
this.capacityUpgrades = Math.min( this.capacityUpgrades, this.getMaxInstalled( Upgrades.CAPACITY ) );
|
||||
this.fuzzyUpgrades = Math.min( this.fuzzyUpgrades, this.getMaxInstalled( Upgrades.FUZZY ) );
|
||||
this.redstoneUpgrades = Math.min( this.redstoneUpgrades, this.getMaxInstalled( Upgrades.REDSTONE ) );
|
||||
this.speedUpgrades = Math.min( this.speedUpgrades, this.getMaxInstalled( Upgrades.SPEED ) );
|
||||
this.inverterUpgrades = Math.min( this.inverterUpgrades, this.getMaxInstalled( Upgrades.INVERTER ) );
|
||||
this.craftingUpgrades = Math.min( this.craftingUpgrades, this.getMaxInstalled( Upgrades.CRAFTING ) );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChangeInventory(IInventory inv, int slot, InvOperation mc, ItemStack removedStack, ItemStack newStack)
|
||||
public void readFromNBT( NBTTagCompound target )
|
||||
{
|
||||
this.cached = false;
|
||||
if ( this.parent != null && Platform.isServer() )
|
||||
this.parent.onChangeInventory( inv, slot, mc, removedStack, newStack );
|
||||
super.readFromNBT( target );
|
||||
this.updateUpgradeInfo();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -198,4 +163,11 @@ public class UpgradeInventory extends AppEngInternalInventory implements IAEAppE
|
||||
this.parent.saveChanges();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChangeInventory( IInventory inv, int slot, InvOperation mc, ItemStack removedStack, ItemStack newStack )
|
||||
{
|
||||
this.cached = false;
|
||||
if ( this.parent != null && Platform.isServer() )
|
||||
this.parent.onChangeInventory( inv, slot, mc, removedStack, newStack );
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user