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:
thatsIch
2015-01-03 02:53:14 +01:00
parent 3dd81433ac
commit 9986ffc458
385 changed files with 12477 additions and 8292 deletions
+11 -4
View File
@@ -45,6 +45,7 @@ import cpw.mods.fml.relauncher.SideOnly;
import appeng.api.AEApi;
import appeng.api.config.Upgrades;
import appeng.api.definitions.IDefinitions;
import appeng.api.implementations.IUpgradeableHost;
import appeng.api.implementations.items.IMemoryCard;
import appeng.api.implementations.items.MemoryCardMessages;
@@ -70,7 +71,7 @@ import appeng.tile.inventory.AppEngInternalAEInventory;
import appeng.util.Platform;
import appeng.util.SettingsFrom;
public class AEBasePart implements IPart, IGridProxyable, IActionHost, IUpgradeableHost, ICustomNameObject
public abstract class AEBasePart implements IPart, IGridProxyable, IActionHost, IUpgradeableHost, ICustomNameObject
{
protected ISimplifiedBundle renderCache = null;
@@ -82,7 +83,7 @@ public class AEBasePart implements IPart, IGridProxyable, IActionHost, IUpgradea
protected final ItemStack is;
public AEBasePart(Class c, ItemStack is) {
public AEBasePart(ItemStack is) {
this.is = is;
this.proxy = new AENetworkProxy( this, "part", is, this instanceof PartCable );
this.proxy.setValidSides( EnumSet.noneOf( ForgeDirection.class ) );
@@ -386,8 +387,14 @@ public class AEBasePart implements IPart, IGridProxyable, IActionHost, IUpgradea
ItemStack is = this.getItemStack( PartItemStack.Network );
// Blocks and parts share the same soul!
if ( AEApi.instance().parts().partInterface.sameAsStack( is ) )
is = AEApi.instance().blocks().blockInterface.stack( 1 );
final IDefinitions definitions = AEApi.instance().definitions();
if ( definitions.parts().iface().isSameAs( is ) )
{
for ( ItemStack iface : definitions.blocks().iface().maybeStack( 1 ).asSet() )
{
is = iface;
}
}
String name = is.getUnlocalizedName();
+34 -31
View File
@@ -18,6 +18,7 @@
package appeng.parts;
import java.io.IOException;
import io.netty.buffer.ByteBuf;
@@ -40,7 +41,8 @@ import appeng.api.parts.IPartRenderHelper;
import appeng.client.texture.CableBusTextures;
import appeng.me.GridAccessException;
public class PartBasicState extends AEBasePart implements IPowerChannelState
public abstract class PartBasicState extends AEBasePart implements IPowerChannelState
{
protected final int POWERED_FLAG = 1;
@@ -48,19 +50,36 @@ public class PartBasicState extends AEBasePart implements IPowerChannelState
protected int clientFlags = 0; // sent as byte.
public PartBasicState( ItemStack is )
{
super( is );
this.proxy.setFlags( GridFlags.REQUIRE_CHANNEL );
}
@MENetworkEventSubscribe
public void chanRender(MENetworkChannelsChanged c)
public void chanRender( MENetworkChannelsChanged c )
{
this.getHost().markForUpdate();
}
@MENetworkEventSubscribe
public void powerRender(MENetworkPowerStatusChange c)
public void powerRender( MENetworkPowerStatusChange c )
{
this.getHost().markForUpdate();
}
public void setColors(boolean hasChan, boolean hasPower)
@SideOnly( Side.CLIENT )
public void renderLights( int x, int y, int z, IPartRenderHelper rh, RenderBlocks renderer )
{
rh.normalRendering();
this.setColors( ( this.clientFlags & ( this.POWERED_FLAG | this.CHANNEL_FLAG ) ) == ( this.POWERED_FLAG | this.CHANNEL_FLAG ), ( this.clientFlags & this.POWERED_FLAG ) == this.POWERED_FLAG );
rh.renderFace( x, y, z, CableBusTextures.PartMonitorSidesStatusLights.getIcon(), ForgeDirection.EAST, renderer );
rh.renderFace( x, y, z, CableBusTextures.PartMonitorSidesStatusLights.getIcon(), ForgeDirection.WEST, renderer );
rh.renderFace( x, y, z, CableBusTextures.PartMonitorSidesStatusLights.getIcon(), ForgeDirection.UP, renderer );
rh.renderFace( x, y, z, CableBusTextures.PartMonitorSidesStatusLights.getIcon(), ForgeDirection.DOWN, renderer );
}
public void setColors( boolean hasChan, boolean hasPower )
{
if ( hasChan )
{
@@ -81,19 +100,8 @@ public class PartBasicState extends AEBasePart implements IPowerChannelState
}
}
@SideOnly(Side.CLIENT)
public void renderLights(int x, int y, int z, IPartRenderHelper rh, RenderBlocks renderer)
{
rh.normalRendering();
this.setColors( (this.clientFlags & (this.POWERED_FLAG | this.CHANNEL_FLAG)) == (this.POWERED_FLAG | this.CHANNEL_FLAG), (this.clientFlags & this.POWERED_FLAG) == this.POWERED_FLAG );
rh.renderFace( x, y, z, CableBusTextures.PartMonitorSidesStatusLights.getIcon(), ForgeDirection.EAST, renderer );
rh.renderFace( x, y, z, CableBusTextures.PartMonitorSidesStatusLights.getIcon(), ForgeDirection.WEST, renderer );
rh.renderFace( x, y, z, CableBusTextures.PartMonitorSidesStatusLights.getIcon(), ForgeDirection.UP, renderer );
rh.renderFace( x, y, z, CableBusTextures.PartMonitorSidesStatusLights.getIcon(), ForgeDirection.DOWN, renderer );
}
@Override
public void writeToStream(ByteBuf data) throws IOException
public void writeToStream( ByteBuf data ) throws IOException
{
super.writeToStream( data );
@@ -109,7 +117,7 @@ public class PartBasicState extends AEBasePart implements IPowerChannelState
this.clientFlags = this.populateFlags( this.clientFlags );
}
catch (GridAccessException e)
catch ( GridAccessException e )
{
// meh
}
@@ -117,13 +125,13 @@ public class PartBasicState extends AEBasePart implements IPowerChannelState
data.writeByte( (byte) this.clientFlags );
}
protected int populateFlags(int cf)
protected int populateFlags( int cf )
{
return cf;
}
@Override
public boolean readFromStream(ByteBuf data) throws IOException
public boolean readFromStream( ByteBuf data ) throws IOException
{
boolean eh = super.readFromStream( data );
@@ -133,27 +141,22 @@ public class PartBasicState extends AEBasePart implements IPowerChannelState
return eh || old != this.clientFlags;
}
public PartBasicState(Class c, ItemStack is) {
super( c, is );
this.proxy.setFlags( GridFlags.REQUIRE_CHANNEL );
@Override
@SideOnly( Side.CLIENT )
public IIcon getBreakingTexture()
{
return CableBusTextures.PartTransitionPlaneBack.getIcon();
}
@Override
public boolean isPowered()
{
return (this.clientFlags & this.POWERED_FLAG) == this.POWERED_FLAG;
return ( this.clientFlags & this.POWERED_FLAG ) == this.POWERED_FLAG;
}
@Override
public boolean isActive()
{
return (this.clientFlags & this.CHANNEL_FLAG) == this.CHANNEL_FLAG;
}
@Override
@SideOnly(Side.CLIENT)
public IIcon getBreakingTexture()
{
return CableBusTextures.PartTransitionPlaneBack.getIcon();
return ( this.clientFlags & this.CHANNEL_FLAG ) == this.CHANNEL_FLAG;
}
}
+99 -90
View File
@@ -18,6 +18,7 @@
package appeng.parts;
import java.util.LinkedList;
import java.util.List;
@@ -40,8 +41,11 @@ import net.minecraftforge.event.entity.player.PlayerInteractEvent.Action;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import cpw.mods.fml.common.gameevent.TickEvent;
import com.google.common.base.Optional;
import appeng.api.AEApi;
import appeng.api.definitions.Items;
import appeng.api.definitions.IBlockDefinition;
import appeng.api.definitions.IItems;
import appeng.api.parts.IFacadePart;
import appeng.api.parts.IPartHost;
import appeng.api.parts.IPartItem;
@@ -61,78 +65,15 @@ import appeng.integration.abstraction.IImmibisMicroblocks;
import appeng.util.LookDirection;
import appeng.util.Platform;
public class PartPlacement
{
public static float eyeHeight = 0.0f;
private final ThreadLocal<Object> placing = new ThreadLocal<Object>();
private boolean wasCanceled = false;
@SubscribeEvent
public void playerInteract(TickEvent.ClientTickEvent event)
{
this.wasCanceled = false;
}
@SubscribeEvent
public void playerInteract(PlayerInteractEvent event)
{
if ( event.action == Action.RIGHT_CLICK_AIR && event.entityPlayer.worldObj.isRemote )
{
// re-check to see if this event was already channeled, cause these two events are really stupid...
MovingObjectPosition mop = Platform.rayTrace( event.entityPlayer, true, false );
Minecraft mc = Minecraft.getMinecraft();
float f = 1.0F;
double d0 = mc.playerController.getBlockReachDistance();
Vec3 vec3 = mc.renderViewEntity.getPosition( f );
if ( mop != null && mop.hitVec.distanceTo( vec3 ) < d0 )
{
World w = event.entity.worldObj;
TileEntity te = w.getTileEntity( mop.blockX, mop.blockY, mop.blockZ );
if ( te instanceof IPartHost && this.wasCanceled )
event.setCanceled( true );
}
else
{
ItemStack held = event.entityPlayer.getHeldItem();
final Items items = AEApi.instance().items();
final boolean sameAsMemoryCard = items.itemMemoryCard != null && items.itemMemoryCard.sameAsStack( held );
final boolean sameAsColorApp = items.itemColorApplicator != null && items.itemColorApplicator.sameAsStack( held );
final boolean supportedItem = sameAsMemoryCard || sameAsColorApp;
if ( event.entityPlayer.isSneaking() && held != null && supportedItem )
{
NetworkHandler.instance.sendToServer( new PacketClick( event.x, event.y, event.z, event.face, 0, 0, 0 ) );
}
}
}
else if ( event.action == Action.RIGHT_CLICK_BLOCK && event.entityPlayer.worldObj.isRemote )
{
if ( this.placing.get() != null )
return;
this.placing.set( event );
ItemStack held = event.entityPlayer.getHeldItem();
if ( place( held, event.x, event.y, event.z, event.face, event.entityPlayer, event.entityPlayer.worldObj, PlaceType.INTERACT_FIRST_PASS, 0 ) )
{
event.setCanceled( true );
this.wasCanceled = true;
}
this.placing.set( null );
}
}
public enum PlaceType
{
PLACE_ITEM, INTERACT_FIRST_PASS, INTERACT_SECOND_PASS
}
public static boolean place(ItemStack held, int x, int y, int z, int face, EntityPlayer player, World world, PlaceType pass, int depth)
public static boolean place( ItemStack held, int x, int y, int z, int face, EntityPlayer player, World world, PlaceType pass, int depth )
{
if ( depth > 3 )
return false;
@@ -244,10 +185,10 @@ public class PartPlacement
}
if ( host == null && tile != null && AppEng.instance.isIntegrationEnabled( IntegrationType.FMP ) )
host = ((IFMP) AppEng.instance.getIntegration( IntegrationType.FMP )).getOrCreateHost( tile );
host = ( (IFMP) AppEng.instance.getIntegration( IntegrationType.FMP ) ).getOrCreateHost( tile );
if ( host == null && tile != null && AppEng.instance.isIntegrationEnabled( IntegrationType.ImmibisMicroblocks ) )
host = ((IImmibisMicroblocks) AppEng.instance.getIntegration( IntegrationType.ImmibisMicroblocks )).getOrCreateHost( player, face, tile );
host = ( (IImmibisMicroblocks) AppEng.instance.getIntegration( IntegrationType.ImmibisMicroblocks ) ).getOrCreateHost( player, face, tile );
// if ( held == null )
{
@@ -271,20 +212,18 @@ public class PartPlacement
}
}
}
}
if ( held == null || !(held.getItem() instanceof IPartItem) )
if ( held == null || !( held.getItem() instanceof IPartItem ) )
return false;
int te_x = x;
int te_y = y;
int te_z = z;
final IBlockDefinition multiPart = AEApi.instance().definitions().blocks().multiPart();
if ( host == null && pass == PlaceType.PLACE_ITEM )
{
ItemStack is = AEApi.instance().blocks().blockMultiPart.stack( 1 );
ItemBlock ib = (ItemBlock) is.getItem();
ForgeDirection offset = ForgeDirection.UNKNOWN;
Block blkID = world.getBlock( x, y, z );
@@ -304,13 +243,20 @@ public class PartPlacement
host = (IPartHost) tile;
if ( host == null && tile != null && AppEng.instance.isIntegrationEnabled( IntegrationType.FMP ) )
host = ((IFMP) AppEng.instance.getIntegration( IntegrationType.FMP )).getOrCreateHost( tile );
host = ( (IFMP) AppEng.instance.getIntegration( IntegrationType.FMP ) ).getOrCreateHost( tile );
if ( host == null && tile != null && AppEng.instance.isIntegrationEnabled( IntegrationType.ImmibisMicroblocks ) )
host = ((IImmibisMicroblocks) AppEng.instance.getIntegration( IntegrationType.ImmibisMicroblocks )).getOrCreateHost( player, face, tile );
host = ( (IImmibisMicroblocks) AppEng.instance.getIntegration( IntegrationType.ImmibisMicroblocks ) ).getOrCreateHost( player, face, tile );
if ( host == null && AEApi.instance().blocks().blockMultiPart.block().canPlaceBlockAt( world, te_x, te_y, te_z )
&& ib.placeBlockAt( is, player, world, te_x, te_y, te_z, side.ordinal(), 0.5f, 0.5f, 0.5f, 0 ) )
final Optional<ItemStack> maybeMultiPartStack = multiPart.maybeStack( 1 );
final Optional<Block> maybeMultiPartBlock = multiPart.maybeBlock();
final Optional<ItemBlock> maybeMultiPartItemBlock = multiPart.maybeItemBlock();
final boolean hostIsNotPresent = host == null;
final boolean multiPartPresent = maybeMultiPartBlock.isPresent() && maybeMultiPartStack.isPresent() && maybeMultiPartItemBlock.isPresent();
final boolean canMultiPartBePlaced = maybeMultiPartBlock.get().canPlaceBlockAt( world, te_x, te_y, te_z );
if ( hostIsNotPresent && multiPartPresent && canMultiPartBePlaced && maybeMultiPartItemBlock.get().placeBlockAt( maybeMultiPartStack.get(), player, world, te_x, te_y, te_z, side.ordinal(), 0.5f, 0.5f, 0.5f, 0 ) )
{
if ( !world.isRemote )
{
@@ -329,7 +275,9 @@ public class PartPlacement
}
}
else if ( host != null && !host.canAddPart( held, side ) )
{
return false;
}
}
if ( host == null )
@@ -347,11 +295,10 @@ public class PartPlacement
tile = world.getTileEntity( te_x, te_y, te_z );
if ( tile != null && AppEng.instance.isIntegrationEnabled( IntegrationType.FMP ) )
host = ((IFMP) AppEng.instance.getIntegration( IntegrationType.FMP )).getOrCreateHost( tile );
host = ( (IFMP) AppEng.instance.getIntegration( IntegrationType.FMP ) ).getOrCreateHost( tile );
if ( (blkID == null || blkID.isReplaceable( world, te_x, te_y, te_z ) || host != null) && side != ForgeDirection.UNKNOWN )
return place( held, te_x, te_y, te_z, side.getOpposite().ordinal(), player, world,
pass == PlaceType.INTERACT_FIRST_PASS ? PlaceType.INTERACT_SECOND_PASS : PlaceType.PLACE_ITEM, depth + 1 );
if ( ( blkID == null || blkID.isReplaceable( world, te_x, te_y, te_z ) || host != null ) && side != ForgeDirection.UNKNOWN )
return place( held, te_x, te_y, te_z, side.getOpposite().ordinal(), player, world, pass == PlaceType.INTERACT_FIRST_PASS ? PlaceType.INTERACT_SECOND_PASS : PlaceType.PLACE_ITEM, depth + 1 );
}
return false;
}
@@ -379,10 +326,12 @@ public class PartPlacement
ForgeDirection mySide = host.addPart( held, side, player );
if ( mySide != null )
{
SoundType ss = AEApi.instance().blocks().blockMultiPart.block().stepSound;
for ( Block multiPartBlock : multiPart.maybeBlock().asSet() )
{
final SoundType ss = multiPartBlock.stepSound;
// ss.getPlaceSound()
world.playSoundEffect( 0.5 + x, 0.5 + y, 0.5 + z, ss.func_150496_b(), (ss.getVolume() + 1.0F) / 2.0F, ss.getPitch() * 0.8F );
world.playSoundEffect( 0.5 + x, 0.5 + y, 0.5 + z, ss.func_150496_b(), ( ss.getVolume() + 1.0F ) / 2.0F, ss.getPitch() * 0.8F );
}
if ( !player.capabilities.isCreativeMode )
{
@@ -403,9 +352,7 @@ public class PartPlacement
return true;
}
public static float eyeHeight = 0.0f;
private static float getEyeOffset(EntityPlayer p)
private static float getEyeOffset( EntityPlayer p )
{
if ( p.worldObj.isRemote )
return Platform.getEyeOffset( p );
@@ -413,7 +360,7 @@ public class PartPlacement
return eyeHeight;
}
private static SelectedPart selectPart(EntityPlayer player, IPartHost host, Vec3 pos)
private static SelectedPart selectPart( EntityPlayer player, IPartHost host, Vec3 pos )
{
CommonHelper.proxy.updateRenderMode( player );
SelectedPart sp = host.selectPart( pos );
@@ -422,10 +369,10 @@ public class PartPlacement
return sp;
}
public static IFacadePart isFacade(ItemStack held, ForgeDirection side)
public static IFacadePart isFacade( ItemStack held, ForgeDirection side )
{
if ( held.getItem() instanceof IFacadeItem )
return ((IFacadeItem) held.getItem()).createPartFromItemStack( held, side );
return ( (IFacadeItem) held.getItem() ).createPartFromItemStack( held, side );
if ( AppEng.instance.isIntegrationEnabled( IntegrationType.BC ) )
{
@@ -437,4 +384,66 @@ public class PartPlacement
return null;
}
@SubscribeEvent
public void playerInteract( TickEvent.ClientTickEvent event )
{
this.wasCanceled = false;
}
@SubscribeEvent
public void playerInteract( PlayerInteractEvent event )
{
if ( event.action == Action.RIGHT_CLICK_AIR && event.entityPlayer.worldObj.isRemote )
{
// re-check to see if this event was already channeled, cause these two events are really stupid...
MovingObjectPosition mop = Platform.rayTrace( event.entityPlayer, true, false );
Minecraft mc = Minecraft.getMinecraft();
float f = 1.0F;
double d0 = mc.playerController.getBlockReachDistance();
Vec3 vec3 = mc.renderViewEntity.getPosition( f );
if ( mop != null && mop.hitVec.distanceTo( vec3 ) < d0 )
{
World w = event.entity.worldObj;
TileEntity te = w.getTileEntity( mop.blockX, mop.blockY, mop.blockZ );
if ( te instanceof IPartHost && this.wasCanceled )
event.setCanceled( true );
}
else
{
ItemStack held = event.entityPlayer.getHeldItem();
final IItems items = AEApi.instance().definitions().items();
boolean supportedItem = items.memoryCard().isSameAs( held );
supportedItem |= items.colorApplicator().isSameAs( held );
if ( event.entityPlayer.isSneaking() && held != null && supportedItem )
{
NetworkHandler.instance.sendToServer( new PacketClick( event.x, event.y, event.z, event.face, 0, 0, 0 ) );
}
}
}
else if ( event.action == Action.RIGHT_CLICK_BLOCK && event.entityPlayer.worldObj.isRemote )
{
if ( this.placing.get() != null )
return;
this.placing.set( event );
ItemStack held = event.entityPlayer.getHeldItem();
if ( place( held, event.x, event.y, event.z, event.face, event.entityPlayer, event.entityPlayer.worldObj, PlaceType.INTERACT_FIRST_PASS, 0 ) )
{
event.setCanceled( true );
this.wasCanceled = true;
}
this.placing.set( null );
}
}
public enum PlaceType
{
PLACE_ITEM, INTERACT_FIRST_PASS, INTERACT_SECOND_PASS
}
}
@@ -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 );
}
}
+110 -111
View File
@@ -18,11 +18,10 @@
package appeng.parts.misc;
import java.util.EnumSet;
import java.util.List;
import com.google.common.collect.ImmutableSet;
import net.minecraft.client.renderer.RenderBlocks;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory;
@@ -38,6 +37,8 @@ import net.minecraftforge.common.util.ForgeDirection;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import com.google.common.collect.ImmutableSet;
import appeng.api.config.Actionable;
import appeng.api.config.Upgrades;
import appeng.api.implementations.tiles.ITileStorageMonitorable;
@@ -64,73 +65,43 @@ import appeng.core.sync.GuiBridge;
import appeng.helpers.DualityInterface;
import appeng.helpers.IInterfaceHost;
import appeng.helpers.IPriorityHost;
import appeng.helpers.Reflected;
import appeng.parts.PartBasicState;
import appeng.tile.inventory.IAEAppEngInventory;
import appeng.tile.inventory.InvOperation;
import appeng.util.Platform;
import appeng.util.inv.IInventoryDestination;
public class PartInterface extends PartBasicState implements IGridTickable, IStorageMonitorable, IInventoryDestination, IInterfaceHost,
ISidedInventory, IAEAppEngInventory, ITileStorageMonitorable, IPriorityHost
public class PartInterface extends PartBasicState
implements IGridTickable, IStorageMonitorable, IInventoryDestination, IInterfaceHost, ISidedInventory, IAEAppEngInventory, ITileStorageMonitorable, IPriorityHost
{
final DualityInterface duality = new DualityInterface( this.proxy, this );
public PartInterface(ItemStack is) {
super( PartInterface.class, is );
}
@Override
public void addToWorld()
@Reflected
public PartInterface( ItemStack is )
{
super.addToWorld();
this.duality.initialize();
super( is );
}
@MENetworkEventSubscribe
public void stateChange(MENetworkChannelsChanged c)
public void stateChange( MENetworkChannelsChanged c )
{
this.duality.notifyNeighbors();
}
@MENetworkEventSubscribe
public void stateChange(MENetworkPowerStatusChange c)
public void stateChange( MENetworkPowerStatusChange c )
{
this.duality.notifyNeighbors();
}
@Override
public void gridChanged()
@SideOnly( Side.CLIENT )
public void renderInventory( IPartRenderHelper rh, RenderBlocks renderer )
{
this.duality.gridChanged();
}
@Override
public void writeToNBT(NBTTagCompound data)
{
super.writeToNBT( data );
this.duality.writeToNBT( data );
}
@Override
public void readFromNBT(NBTTagCompound data)
{
super.readFromNBT( data );
this.duality.readFromNBT( data );
}
@Override
public void getDrops(List<ItemStack> drops, boolean wrenched)
{
this.duality.addDrops( drops );
}
@Override
@SideOnly(Side.CLIENT)
public void renderInventory(IPartRenderHelper rh, RenderBlocks renderer)
{
rh.setTexture( CableBusTextures.PartMonitorSides.getIcon(), CableBusTextures.PartMonitorSides.getIcon(), CableBusTextures.PartMonitorBack.getIcon(),
this.is.getIconIndex(), CableBusTextures.PartMonitorSides.getIcon(), CableBusTextures.PartMonitorSides.getIcon() );
rh.setTexture( CableBusTextures.PartMonitorSides.getIcon(), CableBusTextures.PartMonitorSides.getIcon(), CableBusTextures.PartMonitorBack.getIcon(), this.is.getIconIndex(), CableBusTextures.PartMonitorSides.getIcon(), CableBusTextures.PartMonitorSides.getIcon() );
rh.setBounds( 3, 3, 15, 13, 13, 16 );
rh.renderInventoryBox( renderer );
@@ -143,25 +114,21 @@ public class PartInterface extends PartBasicState implements IGridTickable, ISto
}
@Override
@SideOnly(Side.CLIENT)
public void renderStatic(int x, int y, int z, IPartRenderHelper rh, RenderBlocks renderer)
@SideOnly( Side.CLIENT )
public void renderStatic( int x, int y, int z, IPartRenderHelper rh, RenderBlocks renderer )
{
this.renderCache = rh.useSimplifiedRendering( x, y, z, this, this.renderCache );
rh.setTexture( CableBusTextures.PartMonitorSides.getIcon(), CableBusTextures.PartMonitorSides.getIcon(), CableBusTextures.PartMonitorBack.getIcon(),
this.is.getIconIndex(), CableBusTextures.PartMonitorSides.getIcon(), CableBusTextures.PartMonitorSides.getIcon() );
rh.setTexture( CableBusTextures.PartMonitorSides.getIcon(), CableBusTextures.PartMonitorSides.getIcon(), CableBusTextures.PartMonitorBack.getIcon(), this.is.getIconIndex(), CableBusTextures.PartMonitorSides.getIcon(), CableBusTextures.PartMonitorSides.getIcon() );
rh.setBounds( 2, 2, 14, 14, 14, 16 );
rh.renderBlock( x, y, z, renderer );
rh.setTexture( CableBusTextures.PartMonitorSides.getIcon(), CableBusTextures.PartMonitorSides.getIcon(), CableBusTextures.PartMonitorBack.getIcon(),
this.is.getIconIndex(), CableBusTextures.PartMonitorSides.getIcon(), CableBusTextures.PartMonitorSides.getIcon() );
rh.setTexture( CableBusTextures.PartMonitorSides.getIcon(), CableBusTextures.PartMonitorSides.getIcon(), CableBusTextures.PartMonitorBack.getIcon(), this.is.getIconIndex(), CableBusTextures.PartMonitorSides.getIcon(), CableBusTextures.PartMonitorSides.getIcon() );
rh.setBounds( 5, 5, 12, 11, 11, 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.setTexture( CableBusTextures.PartMonitorSidesStatus.getIcon(), CableBusTextures.PartMonitorSidesStatus.getIcon(), CableBusTextures.PartMonitorBack.getIcon(), this.is.getIconIndex(), CableBusTextures.PartMonitorSidesStatus.getIcon(), CableBusTextures.PartMonitorSidesStatus.getIcon() );
rh.setBounds( 5, 5, 13, 11, 11, 14 );
rh.renderBlock( x, y, z, renderer );
@@ -170,18 +137,39 @@ public class PartInterface extends PartBasicState implements IGridTickable, ISto
}
@Override
public IIcon getBreakingTexture()
public void readFromNBT( NBTTagCompound data )
{
return this.is.getIconIndex();
super.readFromNBT( data );
this.duality.readFromNBT( data );
}
@Override
public void getBoxes(IPartCollisionHelper bch)
public void writeToNBT( NBTTagCompound data )
{
super.writeToNBT( data );
this.duality.writeToNBT( data );
}
@Override
public void addToWorld()
{
super.addToWorld();
this.duality.initialize();
}
@Override
public void getBoxes( IPartCollisionHelper bch )
{
bch.addBox( 2, 2, 14, 14, 14, 16 );
bch.addBox( 5, 5, 12, 11, 11, 14 );
}
@Override
public void getDrops( List<ItemStack> drops, boolean wrenched )
{
this.duality.addDrops( drops );
}
@Override
public int cableConnectionRenderTo()
{
@@ -189,13 +177,49 @@ public class PartInterface extends PartBasicState implements IGridTickable, ISto
}
@Override
public TileEntity getTileEntity()
public void gridChanged()
{
return super.getHost().getTile();
this.duality.gridChanged();
}
@Override
public boolean canInsert(ItemStack stack)
public IConfigManager getConfigManager()
{
return this.duality.getConfigManager();
}
@Override
public IInventory getInventoryByName( String name )
{
return this.duality.getInventoryByName( name );
}
@Override
public int getInstalledUpgrades( Upgrades u )
{
return this.duality.getInstalledUpgrades( u );
}
@Override
public boolean onPartActivate( EntityPlayer p, Vec3 pos )
{
if ( p.isSneaking() )
return false;
if ( Platform.isServer() )
Platform.openGUI( p, this.getTileEntity(), this.side, GuiBridge.GUI_INTERFACE );
return true;
}
@Override
public IIcon getBreakingTexture()
{
return this.is.getIconIndex();
}
@Override
public boolean canInsert( ItemStack stack )
{
return this.duality.canInsert( stack );
}
@@ -213,13 +237,13 @@ public class PartInterface extends PartBasicState implements IGridTickable, ISto
}
@Override
public TickingRequest getTickingRequest(IGridNode node)
public TickingRequest getTickingRequest( IGridNode node )
{
return this.duality.getTickingRequest( node );
}
@Override
public TickRateModulation tickingRequest(IGridNode node, int TicksSinceLastCall)
public TickRateModulation tickingRequest( IGridNode node, int TicksSinceLastCall )
{
return this.duality.tickingRequest( node, TicksSinceLastCall );
}
@@ -231,25 +255,25 @@ public class PartInterface extends PartBasicState implements IGridTickable, ISto
}
@Override
public ItemStack getStackInSlot(int i)
public ItemStack getStackInSlot( int i )
{
return this.duality.getStorage().getStackInSlot( i );
}
@Override
public ItemStack decrStackSize(int i, int j)
public ItemStack decrStackSize( int i, int j )
{
return this.duality.getStorage().decrStackSize( i, j );
}
@Override
public ItemStack getStackInSlotOnClosing(int i)
public ItemStack getStackInSlotOnClosing( int i )
{
return this.duality.getStorage().getStackInSlotOnClosing( i );
}
@Override
public void setInventorySlotContents(int i, ItemStack itemstack)
public void setInventorySlotContents( int i, ItemStack itemstack )
{
this.duality.getStorage().setInventorySlotContents( i, itemstack );
}
@@ -272,18 +296,6 @@ public class PartInterface extends PartBasicState implements IGridTickable, ISto
return this.duality.getStorage().getInventoryStackLimit();
}
@Override
public IConfigManager getConfigManager()
{
return this.duality.getConfigManager();
}
@Override
public IInventory getInventoryByName(String name)
{
return this.duality.getInventoryByName( name );
}
@Override
public void markDirty()
{
@@ -291,7 +303,7 @@ public class PartInterface extends PartBasicState implements IGridTickable, ISto
}
@Override
public boolean isUseableByPlayer(EntityPlayer entityplayer)
public boolean isUseableByPlayer( EntityPlayer entityplayer )
{
return this.duality.getStorage().isUseableByPlayer( entityplayer );
}
@@ -309,31 +321,31 @@ public class PartInterface extends PartBasicState implements IGridTickable, ISto
}
@Override
public boolean isItemValidForSlot(int i, ItemStack itemstack)
public boolean isItemValidForSlot( int i, ItemStack itemstack )
{
return this.duality.getStorage().isItemValidForSlot( i, itemstack );
}
@Override
public int[] getAccessibleSlotsFromSide(int s)
public int[] getAccessibleSlotsFromSide( int s )
{
return this.duality.getAccessibleSlotsFromSide( s );
}
@Override
public boolean canInsertItem(int i, ItemStack itemstack, int j)
public boolean canInsertItem( int i, ItemStack itemstack, int j )
{
return true;
}
@Override
public boolean canExtractItem(int i, ItemStack itemstack, int j)
public boolean canExtractItem( int i, ItemStack itemstack, int j )
{
return true;
}
@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 )
{
this.duality.onChangeInventory( inv, slot, mc, removedStack, newStack );
}
@@ -345,41 +357,29 @@ public class PartInterface extends PartBasicState implements IGridTickable, ISto
}
@Override
public boolean onPartActivate(EntityPlayer p, Vec3 pos)
public EnumSet<ForgeDirection> getTargets()
{
if ( p.isSneaking() )
return false;
if ( Platform.isServer() )
Platform.openGUI( p, this.getTileEntity(), this.side, GuiBridge.GUI_INTERFACE );
return true;
return EnumSet.of( this.side );
}
@Override
public IStorageMonitorable getMonitorable(ForgeDirection side, BaseActionSource src)
public TileEntity getTileEntity()
{
return super.getHost().getTile();
}
@Override
public IStorageMonitorable getMonitorable( ForgeDirection side, BaseActionSource src )
{
return this.duality.getMonitorable( side, src, this );
}
@Override
public boolean pushPattern(ICraftingPatternDetails patternDetails, InventoryCrafting table)
public boolean pushPattern( ICraftingPatternDetails patternDetails, InventoryCrafting table )
{
return this.duality.pushPattern( patternDetails, table );
}
@Override
public void provideCrafting(ICraftingProviderHelper craftingTracker)
{
this.duality.provideCrafting( craftingTracker );
}
@Override
public EnumSet<ForgeDirection> getTargets()
{
return EnumSet.of( this.side );
}
@Override
public boolean isBusy()
{
@@ -387,9 +387,9 @@ public class PartInterface extends PartBasicState implements IGridTickable, ISto
}
@Override
public int getInstalledUpgrades(Upgrades u)
public void provideCrafting( ICraftingProviderHelper craftingTracker )
{
return this.duality.getInstalledUpgrades( u );
this.duality.provideCrafting( craftingTracker );
}
@Override
@@ -399,13 +399,13 @@ public class PartInterface extends PartBasicState implements IGridTickable, ISto
}
@Override
public IAEItemStack injectCraftedItems(ICraftingLink link, IAEItemStack items, Actionable mode)
public IAEItemStack injectCraftedItems( ICraftingLink link, IAEItemStack items, Actionable mode )
{
return this.duality.injectCraftedItems( link, items, mode );
}
@Override
public void jobStateChange(ICraftingLink link)
public void jobStateChange( ICraftingLink link )
{
this.duality.jobStateChange( link );
}
@@ -417,9 +417,8 @@ public class PartInterface extends PartBasicState implements IGridTickable, ISto
}
@Override
public void setPriority(int newValue)
public void setPriority( int newValue )
{
this.duality.setPriority( newValue );
}
}
@@ -18,13 +18,18 @@
package appeng.parts.misc;
import net.minecraft.item.ItemStack;
import appeng.helpers.Reflected;
public class PartInvertedToggleBus extends PartToggleBus
{
public PartInvertedToggleBus(ItemStack is) {
super( PartInvertedToggleBus.class, is );
@Reflected
public PartInvertedToggleBus( ItemStack is )
{
super( is );
this.proxy.setIdlePowerUsage( 0.0 );
this.outerProxy.setIdlePowerUsage( 0.0 );
this.proxy.setFlags();
@@ -36,5 +41,4 @@ public class PartInvertedToggleBus extends PartToggleBus
{
return !super.getIntention();
}
}
@@ -76,6 +76,7 @@ import appeng.core.stats.Achievements;
import appeng.core.sync.GuiBridge;
import appeng.helpers.IInterfaceHost;
import appeng.helpers.IPriorityHost;
import appeng.helpers.Reflected;
import appeng.me.GridAccessException;
import appeng.me.storage.MEInventoryHandler;
import appeng.me.storage.MEMonitorIInventory;
@@ -90,31 +91,29 @@ import appeng.util.prioitylist.PrecisePriorityList;
@Interface( iname = "BC", iface = "buildcraft.api.transport.IPipeConnection" )
public class PartStorageBus
extends PartUpgradeable
public class PartStorageBus extends PartUpgradeable
implements IGridTickable, ICellContainer, IMEMonitorHandlerReceiver<IAEItemStack>, IPipeConnection, IPriorityHost
{
int priority = 0;
final BaseActionSource mySrc;
final AppEngInternalAEInventory Config = new AppEngInternalAEInventory( this, 63 );
int priority = 0;
boolean cached = false;
MEMonitorIInventory monitor = null;
MEInventoryHandler handler = null;
int handlerHash = 0;
boolean wasActive = false;
private byte resetCacheLogic = 0;
@Reflected
public PartStorageBus( ItemStack is )
{
super( PartStorageBus.class, is );
super( is );
this.getConfigManager().registerSetting( Settings.ACCESS, AccessRestriction.READ_WRITE );
this.getConfigManager().registerSetting( Settings.FUZZY_MODE, FuzzyMode.IGNORE_ALL );
this.getConfigManager().registerSetting( Settings.STORAGE_FILTER, StorageFilter.EXTRACTABLE_ONLY );
this.mySrc = new MachineSource( this );
}
boolean cached = false;
MEMonitorIInventory monitor = null;
MEInventoryHandler handler = null;
int handlerHash = 0;
boolean wasActive = false;
@Override
@MENetworkEventSubscribe
public void powerRender( MENetworkPowerStatusChange c )
@@ -122,12 +121,6 @@ public class PartStorageBus
this.updateStatus();
}
@MENetworkEventSubscribe
public void updateChannels( MENetworkChannelsChanged changedChannels )
{
this.updateStatus();
}
private void updateStatus()
{
boolean currentActive = this.proxy.isActive();
@@ -146,19 +139,10 @@ public class PartStorageBus
}
}
@Override
public boolean onPartActivate( EntityPlayer player, Vec3 pos )
@MENetworkEventSubscribe
public void updateChannels( MENetworkChannelsChanged changedChannels )
{
if ( !player.isSneaking() )
{
if ( Platform.isClient() )
return true;
Platform.openGUI( player, this.getHost().getTile(), this.side, GuiBridge.GUI_STORAGEBUS );
return true;
}
return false;
this.updateStatus();
}
@Override
@@ -168,9 +152,19 @@ public class PartStorageBus
}
@Override
public boolean isValid( Object verificationToken )
public void writeToNBT( NBTTagCompound data )
{
return this.handler == verificationToken;
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" );
}
@Override
@@ -182,7 +176,102 @@ public class PartStorageBus
return super.getInventoryByName( name );
}
private byte resetCacheLogic = 0;
@Override
public void updateSetting( IConfigManager manager, Enum settingName, Enum newValue )
{
this.resetCache( true );
this.host.markForSave();
}
@Override
public void upgradesChanged()
{
super.upgradesChanged();
this.resetCache( true );
}
@Override
public void onChangeInventory( IInventory inv, int slot, InvOperation mc, ItemStack removedStack, ItemStack newStack )
{
super.onChangeInventory( inv, slot, mc, removedStack, newStack );
if ( inv == this.Config )
this.resetCache( true );
}
@Override
public boolean isValid( Object verificationToken )
{
return this.handler == verificationToken;
}
@Override
public void postChange( IBaseMonitor<IAEItemStack> monitor, Iterable<IAEItemStack> change, BaseActionSource source )
{
try
{
if ( this.proxy.isActive() )
this.proxy.getStorage().postAlterationOfStoredItems( StorageChannel.ITEMS, change, this.mySrc );
}
catch ( GridAccessException e )
{
// :(
}
}
@Override
public void onListUpdate()
{
// not used here.
}
@Override
@SideOnly( Side.CLIENT )
public void renderInventory( IPartRenderHelper rh, RenderBlocks renderer )
{
rh.setTexture( CableBusTextures.PartStorageSides.getIcon(), CableBusTextures.PartStorageSides.getIcon(), CableBusTextures.PartStorageBack.getIcon(), this.is.getIconIndex(), CableBusTextures.PartStorageSides.getIcon(), CableBusTextures.PartStorageSides.getIcon() );
rh.setBounds( 3, 3, 15, 13, 13, 16 );
rh.renderInventoryBox( renderer );
rh.setBounds( 2, 2, 14, 14, 14, 15 );
rh.renderInventoryBox( renderer );
rh.setBounds( 5, 5, 12, 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.PartStorageSides.getIcon(), CableBusTextures.PartStorageSides.getIcon(), CableBusTextures.PartStorageBack.getIcon(), this.is.getIconIndex(), CableBusTextures.PartStorageSides.getIcon(), CableBusTextures.PartStorageSides.getIcon() );
rh.setBounds( 3, 3, 15, 13, 13, 16 );
rh.renderBlock( x, y, z, renderer );
rh.setBounds( 2, 2, 14, 14, 14, 15 );
rh.renderBlock( x, y, z, renderer );
rh.setTexture( CableBusTextures.PartStorageSides.getIcon(), CableBusTextures.PartStorageSides.getIcon(), CableBusTextures.PartStorageBack.getIcon(), this.is.getIconIndex(), CableBusTextures.PartStorageSides.getIcon(), CableBusTextures.PartStorageSides.getIcon() );
rh.setBounds( 5, 5, 12, 11, 11, 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( 5, 5, 13, 11, 11, 14 );
rh.renderBlock( x, y, z, renderer );
this.renderLights( x, y, z, rh, renderer );
}
@Override
public void onNeighborChanged()
{
this.resetCache( false );
}
private void resetCache( boolean fullReset )
{
@@ -204,6 +293,53 @@ public class PartStorageBus
}
}
@Override
public void getBoxes( IPartCollisionHelper bch )
{
bch.addBox( 3, 3, 15, 13, 13, 16 );
bch.addBox( 2, 2, 14, 14, 14, 15 );
bch.addBox( 5, 5, 12, 11, 11, 14 );
}
@Override
public int cableConnectionRenderTo()
{
return 4;
}
@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_STORAGEBUS );
return true;
}
return false;
}
@Override
public TickingRequest getTickingRequest( IGridNode node )
{
return new TickingRequest( TickRates.StorageBus.min, TickRates.StorageBus.max, this.monitor == null, true );
}
@Override
public TickRateModulation tickingRequest( IGridNode node, int TicksSinceLastCall )
{
if ( this.resetCacheLogic != 0 )
this.resetCache();
if ( this.monitor != null )
return this.monitor.onTick();
return TickRateModulation.SLEEP;
}
private void resetCache()
{
boolean fullReset = this.resetCacheLogic == 2;
@@ -230,43 +366,6 @@ public class PartStorageBus
Platform.postListChanges( before, after, this, this.mySrc );
}
@Override
public void onNeighborChanged()
{
this.resetCache( false );
}
@Override
public void onChangeInventory( IInventory inv, int slot, InvOperation mc, ItemStack removedStack, ItemStack newStack )
{
super.onChangeInventory( inv, slot, mc, removedStack, newStack );
if ( inv == this.Config )
this.resetCache( true );
}
@Override
public void upgradesChanged()
{
super.upgradesChanged();
this.resetCache( true );
}
@Override
public void updateSetting( IConfigManager manager, Enum settingName, Enum newValue )
{
this.resetCache( true );
this.host.markForSave();
}
@Override
public void setPriority( int newValue )
{
this.priority = newValue;
this.host.markForSave();
this.resetCache( true );
}
public MEInventoryHandler getInternalHandler()
{
if ( this.cached )
@@ -305,13 +404,13 @@ public class PartStorageBus
if ( inv instanceof MEMonitorIInventory )
{
MEMonitorIInventory h = ( MEMonitorIInventory ) inv;
h.mode = ( StorageFilter ) this.getConfigManager().getSetting( Settings.STORAGE_FILTER );
MEMonitorIInventory h = (MEMonitorIInventory) inv;
h.mode = (StorageFilter) this.getConfigManager().getSetting( Settings.STORAGE_FILTER );
h.mySource = new MachineSource( this );
}
if ( inv instanceof MEMonitorIInventory )
this.monitor = ( MEMonitorIInventory ) inv;
this.monitor = (MEMonitorIInventory) inv;
if ( inv != null )
{
@@ -334,12 +433,12 @@ public class PartStorageBus
}
if ( this.getInstalledUpgrades( Upgrades.FUZZY ) > 0 )
this.handler.setPartitionList( new FuzzyPriorityList( priorityList, ( FuzzyMode ) this.getConfigManager().getSetting( Settings.FUZZY_MODE ) ) );
this.handler.setPartitionList( new FuzzyPriorityList( priorityList, (FuzzyMode) this.getConfigManager().getSetting( Settings.FUZZY_MODE ) ) );
else
this.handler.setPartitionList ( new PrecisePriorityList( priorityList ));
this.handler.setPartitionList( new PrecisePriorityList( priorityList ) );
if ( inv instanceof IMEMonitor )
( ( IMEMonitor ) inv ).addListener( this, this.handler );
( (IMEMonitor) inv ).addListener( this, this.handler );
}
}
}
@@ -369,13 +468,13 @@ public class PartStorageBus
IInterfaceHost achievement = null;
if ( target instanceof IInterfaceHost )
achievement = ( IInterfaceHost ) target;
achievement = (IInterfaceHost) target;
if ( target instanceof IPartHost )
{
Object part = ( ( IPartHost ) target ).getPart( side );
Object part = ( (IPartHost) target ).getPart( side );
if ( part instanceof IInterfaceHost )
achievement = ( IInterfaceHost ) part;
achievement = (IInterfaceHost) part;
}
if ( achievement != null && achievement.getActionableNode() != null )
@@ -385,100 +484,6 @@ public class PartStorageBus
}
}
@Override
@SideOnly( Side.CLIENT )
public void renderInventory( IPartRenderHelper rh, RenderBlocks renderer )
{
rh.setTexture( CableBusTextures.PartStorageSides.getIcon(), CableBusTextures.PartStorageSides.getIcon(), CableBusTextures.PartStorageBack.getIcon(),
this.is.getIconIndex(), CableBusTextures.PartStorageSides.getIcon(), CableBusTextures.PartStorageSides.getIcon() );
rh.setBounds( 3, 3, 15, 13, 13, 16 );
rh.renderInventoryBox( renderer );
rh.setBounds( 2, 2, 14, 14, 14, 15 );
rh.renderInventoryBox( renderer );
rh.setBounds( 5, 5, 12, 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.PartStorageSides.getIcon(), CableBusTextures.PartStorageSides.getIcon(), CableBusTextures.PartStorageBack.getIcon(), this.is.getIconIndex(), CableBusTextures.PartStorageSides.getIcon(), CableBusTextures.PartStorageSides.getIcon() );
rh.setBounds( 3, 3, 15, 13, 13, 16 );
rh.renderBlock( x, y, z, renderer );
rh.setBounds( 2, 2, 14, 14, 14, 15 );
rh.renderBlock( x, y, z, renderer );
rh.setTexture( CableBusTextures.PartStorageSides.getIcon(), CableBusTextures.PartStorageSides.getIcon(), CableBusTextures.PartStorageBack.getIcon(),
this.is.getIconIndex(), CableBusTextures.PartStorageSides.getIcon(), CableBusTextures.PartStorageSides.getIcon() );
rh.setBounds( 5, 5, 12, 11, 11, 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( 5, 5, 13, 11, 11, 14 );
rh.renderBlock( x, y, z, renderer );
this.renderLights( x, y, z, rh, renderer );
}
@Override
public void getBoxes( IPartCollisionHelper bch )
{
bch.addBox( 3, 3, 15, 13, 13, 16 );
bch.addBox( 2, 2, 14, 14, 14, 15 );
bch.addBox( 5, 5, 12, 11, 11, 14 );
}
@Override
public int cableConnectionRenderTo()
{
return 4;
}
@Override
public TickingRequest getTickingRequest( IGridNode node )
{
return new TickingRequest( TickRates.StorageBus.min, TickRates.StorageBus.max, this.monitor == null, true );
}
@Override
public TickRateModulation tickingRequest( IGridNode node, int TicksSinceLastCall )
{
if ( this.resetCacheLogic != 0 )
this.resetCache();
if ( this.monitor != null )
return this.monitor.onTick();
return TickRateModulation.SLEEP;
}
@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" );
}
@Override
public List<IMEInventoryHandler> getCellArray( StorageChannel channel )
{
@@ -488,7 +493,7 @@ public class PartStorageBus
if ( out != null )
return Collections.singletonList( out );
}
return Arrays.asList( new IMEInventoryHandler[] {} );
return Arrays.asList( new IMEInventoryHandler[] { } );
}
@Override
@@ -498,21 +503,16 @@ public class PartStorageBus
}
@Override
public void blinkCell( int slot )
{}
public void setPriority( int newValue )
{
this.priority = newValue;
this.host.markForSave();
this.resetCache( true );
}
@Override
public void postChange( IBaseMonitor<IAEItemStack> monitor, Iterable<IAEItemStack> change, BaseActionSource source )
public void blinkCell( int slot )
{
try
{
if ( this.proxy.isActive() )
this.proxy.getStorage().postAlterationOfStoredItems( StorageChannel.ITEMS, change, this.mySrc );
}
catch ( GridAccessException e )
{
// :(
}
}
@Override
@@ -522,12 +522,6 @@ public class PartStorageBus
return type == PipeType.ITEM && with == this.side ? ConnectOverride.CONNECT : ConnectOverride.DISCONNECT;
}
@Override
public void onListUpdate()
{
// not used here.
}
@Override
public void saveChanges( IMEInventory cellInventory )
{
+139 -142
View File
@@ -18,6 +18,7 @@
package appeng.parts.misc;
import java.util.ArrayList;
import java.util.EnumSet;
import java.util.List;
@@ -44,113 +45,41 @@ import appeng.api.parts.IPartHost;
import appeng.api.parts.IPartRenderHelper;
import appeng.api.util.AECableType;
import appeng.client.texture.CableBusTextures;
import appeng.helpers.Reflected;
import appeng.me.helpers.AENetworkProxy;
import appeng.parts.PartBasicState;
import appeng.util.Platform;
public class PartToggleBus extends PartBasicState
{
protected final int REDSTONE_FLAG = 4;
final AENetworkProxy outerProxy = new AENetworkProxy( this, "outer", null, true );
IGridConnection connection;
protected final int REDSTONE_FLAG = 4;
boolean hasRedstone = false;
@Override
public void onPlacement(EntityPlayer player, ItemStack held, ForgeDirection side)
@Reflected
public PartToggleBus( ItemStack is )
{
super.onPlacement( player, held, side );
this.outerProxy.setOwner( player );
}
super( is );
@Override
protected int populateFlags(int cf)
{
return cf | (this.getIntention() ? this.REDSTONE_FLAG : 0);
}
@Override
public void onNeighborChanged()
{
boolean oldHasRedstone = this.hasRedstone;
this.hasRedstone = this.getHost().hasRedstone( this.side );
if ( this.hasRedstone != oldHasRedstone )
{
this.updateInternalState();
this.getHost().markForUpdate();
}
}
public PartToggleBus(ItemStack is) {
this( PartToggleBus.class, is );
this.proxy.setIdlePowerUsage( 0.0 );
this.outerProxy.setIdlePowerUsage( 0.0 );
this.proxy.setFlags();
this.outerProxy.setFlags();
}
public PartToggleBus(Class cls, ItemStack is) {
super( cls, is );
@Override
public void setColors( boolean hasChan, boolean hasPower )
{
this.hasRedstone = ( this.clientFlags & this.REDSTONE_FLAG ) == this.REDSTONE_FLAG;
super.setColors( hasChan && this.hasRedstone, hasPower && this.hasRedstone );
}
@Override
public void setPartHostInfo(ForgeDirection side, IPartHost host, TileEntity tile)
protected int populateFlags( int cf )
{
super.setPartHostInfo( side, host, tile );
this.outerProxy.setValidSides( EnumSet.of( side ) );
}
@Override
public void readFromNBT(NBTTagCompound extra)
{
super.readFromNBT( extra );
this.outerProxy.readFromNBT( extra );
}
@Override
public void writeToNBT(NBTTagCompound extra)
{
super.writeToNBT( extra );
this.outerProxy.writeToNBT( extra );
}
@Override
public void addToWorld()
{
super.addToWorld();
this.outerProxy.onReady();
this.hasRedstone = this.getHost().hasRedstone( this.side );
this.updateInternalState();
}
private void updateInternalState()
{
boolean intention = this.getIntention();
if ( intention == ( this.connection == null ) )
{
if ( this.proxy.getNode() != null && this.outerProxy.getNode() != null )
{
if ( intention )
{
try
{
this.connection = AEApi.instance().createGridConnection( this.proxy.getNode(), this.outerProxy.getNode() );
}
catch (FailedConnection e)
{
// :(
}
}
else
{
this.connection.destroy();
this.connection = null;
}
}
}
return cf | ( this.getIntention() ? this.REDSTONE_FLAG : 0 );
}
protected boolean getIntention()
@@ -158,55 +87,6 @@ public class PartToggleBus extends PartBasicState
return this.getHost().hasRedstone( this.side );
}
@Override
public void removeFromWorld()
{
super.removeFromWorld();
this.outerProxy.invalidate();
}
@Override
public IGridNode getExternalFacingNode()
{
return this.outerProxy.getNode();
}
@Override
public AECableType getCableConnectionType(ForgeDirection dir)
{
return AECableType.GLASS;
}
@Override
public void setColors(boolean hasChan, boolean hasPower)
{
this.hasRedstone = (this.clientFlags & this.REDSTONE_FLAG) == this.REDSTONE_FLAG;
super.setColors( hasChan && this.hasRedstone, hasPower && this.hasRedstone );
}
@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( this.is.getIconIndex() );
rh.setBounds( 6, 6, 14, 10, 10, 16 );
rh.renderBlock( x, y, z, renderer );
rh.setBounds( 6, 6, 11, 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, 13, 10, 10, 14 );
rh.renderBlock( x, y, z, renderer );
this.renderLights( x, y, z, rh, renderer );
}
@Override
public IIcon getBreakingTexture()
{
@@ -214,14 +94,8 @@ public class PartToggleBus extends PartBasicState
}
@Override
public void getBoxes(IPartCollisionHelper bch)
{
bch.addBox( 6, 6, 11, 10, 10, 16 );
}
@Override
@SideOnly(Side.CLIENT)
public void renderInventory(IPartRenderHelper rh, RenderBlocks renderer)
@SideOnly( Side.CLIENT )
public void renderInventory( IPartRenderHelper rh, RenderBlocks renderer )
{
GL11.glTranslated( -0.2, -0.3, 0.0 );
@@ -244,12 +118,108 @@ public class PartToggleBus extends PartBasicState
rh.setTexture( null );
}
@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( this.is.getIconIndex() );
rh.setBounds( 6, 6, 14, 10, 10, 16 );
rh.renderBlock( x, y, z, renderer );
rh.setBounds( 6, 6, 11, 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, 13, 10, 10, 14 );
rh.renderBlock( x, y, z, renderer );
this.renderLights( x, y, z, rh, renderer );
}
@Override
public void onNeighborChanged()
{
boolean oldHasRedstone = this.hasRedstone;
this.hasRedstone = this.getHost().hasRedstone( this.side );
if ( this.hasRedstone != oldHasRedstone )
{
this.updateInternalState();
this.getHost().markForUpdate();
}
}
@Override
public void readFromNBT( NBTTagCompound extra )
{
super.readFromNBT( extra );
this.outerProxy.readFromNBT( extra );
}
@Override
public void writeToNBT( NBTTagCompound extra )
{
super.writeToNBT( extra );
this.outerProxy.writeToNBT( extra );
}
@Override
public void removeFromWorld()
{
super.removeFromWorld();
this.outerProxy.invalidate();
}
@Override
public void addToWorld()
{
super.addToWorld();
this.outerProxy.onReady();
this.hasRedstone = this.getHost().hasRedstone( this.side );
this.updateInternalState();
}
@Override
public void setPartHostInfo( ForgeDirection side, IPartHost host, TileEntity tile )
{
super.setPartHostInfo( side, host, tile );
this.outerProxy.setValidSides( EnumSet.of( side ) );
}
@Override
public IGridNode getExternalFacingNode()
{
return this.outerProxy.getNode();
}
@Override
public void getBoxes( IPartCollisionHelper bch )
{
bch.addBox( 6, 6, 11, 10, 10, 16 );
}
@Override
public AECableType getCableConnectionType( ForgeDirection dir )
{
return AECableType.GLASS;
}
@Override
public int cableConnectionRenderTo()
{
return 5;
}
@Override
public void onPlacement( EntityPlayer player, ItemStack held, ForgeDirection side )
{
super.onPlacement( player, held, side );
this.outerProxy.setOwner( player );
}
@Override
public void securityBreak()
{
@@ -262,4 +232,31 @@ public class PartToggleBus extends PartBasicState
this.is.stackSize = 0;
}
}
private void updateInternalState()
{
boolean intention = this.getIntention();
if ( intention == ( this.connection == null ) )
{
if ( this.proxy.getNode() != null && this.outerProxy.getNode() != null )
{
if ( intention )
{
try
{
this.connection = AEApi.instance().createGridConnection( this.proxy.getNode(), this.outerProxy.getNode() );
}
catch ( FailedConnection e )
{
// :(
}
}
else
{
this.connection.destroy();
this.connection = null;
}
}
}
}
}
@@ -40,6 +40,7 @@ import cpw.mods.fml.relauncher.SideOnly;
import appeng.api.AEApi;
import appeng.api.config.SecurityPermissions;
import appeng.api.definitions.IParts;
import appeng.api.implementations.parts.IPartCable;
import appeng.api.networking.GridFlags;
import appeng.api.networking.IGridConnection;
@@ -52,6 +53,7 @@ import appeng.api.parts.IPartHost;
import appeng.api.parts.IPartRenderHelper;
import appeng.api.util.AECableType;
import appeng.api.util.AEColor;
import appeng.api.util.AEColoredItemDefinition;
import appeng.api.util.IReadOnlyCollection;
import appeng.block.AEBaseBlock;
import appeng.client.texture.CableBusTextures;
@@ -72,9 +74,9 @@ public class PartCable extends AEBasePart implements IPartCable
EnumSet<ForgeDirection> connections = EnumSet.noneOf( ForgeDirection.class );
boolean powered = false;
public PartCable( Class c, ItemStack is )
public PartCable( ItemStack is )
{
super( c, is );
super( is );
this.proxy.setFlags( GridFlags.PREFERRED );
this.proxy.setIdlePowerUsage( 0.0 );
this.proxy.myColor = AEColor.values()[( ( ItemMultiPart ) is.getItem() ).variantOf( is.getItemDamage() )];
@@ -130,8 +132,11 @@ public class PartCable extends AEBasePart implements IPartCable
return CableBusTextures.MECable_Yellow.getIcon();
default:
}
return AEApi.instance().parts().partCableGlass.item( AEColor.Transparent ).getIconIndex(
AEApi.instance().parts().partCableGlass.stack( AEColor.Transparent, 1 ) );
final AEColoredItemDefinition glassCable = AEApi.instance().definitions().parts().cableGlass();
final ItemStack glassCableStack = glassCable.stack( AEColor.Transparent, 1 );
return glassCable.item( AEColor.Transparent ).getIconIndex( glassCableStack );
}
public IIcon getTexture( AEColor c )
@@ -177,8 +182,11 @@ public class PartCable extends AEBasePart implements IPartCable
return CableBusTextures.MECovered_Yellow.getIcon();
default:
}
return AEApi.instance().parts().partCableCovered.item( AEColor.Transparent ).getIconIndex(
AEApi.instance().parts().partCableCovered.stack( AEColor.Transparent, 1 ) );
final AEColoredItemDefinition coveredCable = AEApi.instance().definitions().parts().cableCovered();
final ItemStack coveredCableStack = coveredCable.stack( AEColor.Transparent, 1 );
return coveredCable.item( AEColor.Transparent ).getIconIndex( coveredCableStack );
}
public IIcon getSmartTexture( AEColor c )
@@ -219,8 +227,11 @@ public class PartCable extends AEBasePart implements IPartCable
return CableBusTextures.MESmart_Yellow.getIcon();
default:
}
return AEApi.instance().parts().partCableCovered.item( AEColor.Transparent ).getIconIndex(
AEApi.instance().parts().partCableSmart.stack( AEColor.Transparent, 1 ) );
final IParts parts = AEApi.instance().definitions().parts();
final ItemStack smartCableStack = parts.cableSmart().stack( AEColor.Transparent, 1 );
return parts.cableCovered().item( AEColor.Transparent ).getIconIndex( smartCableStack );
}
@Override
@@ -1009,21 +1020,23 @@ public class PartCable extends AEBasePart implements IPartCable
{
ItemStack newPart = null;
final IParts parts = AEApi.instance().definitions().parts();
if ( this.getCableConnectionType() == AECableType.GLASS )
{
newPart = AEApi.instance().parts().partCableGlass.stack( newColor, 1 );
newPart = parts.cableGlass().stack( newColor, 1 );
}
else if ( this.getCableConnectionType() == AECableType.COVERED )
{
newPart = AEApi.instance().parts().partCableCovered.stack( newColor, 1 );
newPart = parts.cableCovered().stack( newColor, 1 );
}
else if ( this.getCableConnectionType() == AECableType.SMART )
{
newPart = AEApi.instance().parts().partCableSmart.stack( newColor, 1 );
newPart = parts.cableSmart().stack( newColor, 1 );
}
else if ( this.getCableConnectionType() == AECableType.DENSE )
{
newPart = AEApi.instance().parts().partCableDense.stack( newColor, 1 );
newPart = parts.cableDense().stack( newColor, 1 );
}
boolean hasPermission = true;
@@ -18,6 +18,7 @@
package appeng.parts.networking;
import java.util.EnumSet;
import org.lwjgl.opengl.GL11;
@@ -42,33 +43,32 @@ import appeng.api.parts.IPartRenderHelper;
import appeng.api.util.AECableType;
import appeng.api.util.AEColor;
import appeng.client.texture.OffsetIcon;
import appeng.helpers.Reflected;
import appeng.util.Platform;
public class PartCableCovered extends PartCable
{
@Reflected
public PartCableCovered( ItemStack is )
{
super( is );
}
@MENetworkEventSubscribe
public void channelUpdated(MENetworkChannelsChanged c)
public void channelUpdated( MENetworkChannelsChanged c )
{
this.getHost().markForUpdate();
}
@MENetworkEventSubscribe
public void powerRender(MENetworkPowerStatusChange c)
public void powerRender( MENetworkPowerStatusChange c )
{
this.getHost().markForUpdate();
}
public PartCableCovered(Class c, ItemStack is) {
super( c, is );
}
public PartCableCovered(ItemStack is) {
this( PartCableCovered.class, is );
}
@Override
public IIcon getTexture(AEColor c)
public IIcon getTexture( AEColor c )
{
return this.getCoveredTexture( c );
}
@@ -80,7 +80,7 @@ public class PartCableCovered extends PartCable
}
@Override
public void getBoxes(IPartCollisionHelper bch)
public void getBoxes( IPartCollisionHelper bch )
{
bch.addBox( 5.0, 5.0, 5.0, 11.0, 11.0, 11.0 );
@@ -93,36 +93,36 @@ public class PartCableCovered extends PartCable
this.connections.clear();
}
for (ForgeDirection of : this.connections)
for ( ForgeDirection of : this.connections )
{
switch (of)
switch ( of )
{
case DOWN:
bch.addBox( 5.0, 0.0, 5.0, 11.0, 5.0, 11.0 );
break;
case EAST:
bch.addBox( 11.0, 5.0, 5.0, 16.0, 11.0, 11.0 );
break;
case NORTH:
bch.addBox( 5.0, 5.0, 0.0, 11.0, 11.0, 5.0 );
break;
case SOUTH:
bch.addBox( 5.0, 5.0, 11.0, 11.0, 11.0, 16.0 );
break;
case UP:
bch.addBox( 5.0, 11.0, 5.0, 11.0, 16.0, 11.0 );
break;
case WEST:
bch.addBox( 0.0, 5.0, 5.0, 5.0, 11.0, 11.0 );
break;
default:
case DOWN:
bch.addBox( 5.0, 0.0, 5.0, 11.0, 5.0, 11.0 );
break;
case EAST:
bch.addBox( 11.0, 5.0, 5.0, 16.0, 11.0, 11.0 );
break;
case NORTH:
bch.addBox( 5.0, 5.0, 0.0, 11.0, 11.0, 5.0 );
break;
case SOUTH:
bch.addBox( 5.0, 5.0, 11.0, 11.0, 11.0, 16.0 );
break;
case UP:
bch.addBox( 5.0, 11.0, 5.0, 11.0, 16.0, 11.0 );
break;
case WEST:
bch.addBox( 0.0, 5.0, 5.0, 5.0, 11.0, 11.0 );
break;
default:
}
}
}
@Override
@SideOnly(Side.CLIENT)
public void renderInventory(IPartRenderHelper rh, RenderBlocks renderer)
@SideOnly( Side.CLIENT )
public void renderInventory( IPartRenderHelper rh, RenderBlocks renderer )
{
GL11.glTranslated( -0.0, -0.0, 0.3 );
@@ -132,7 +132,7 @@ public class PartCableCovered extends PartCable
OffsetIcon main = new OffsetIcon( this.getTexture( this.getCableColor() ), offU, offV );
for (ForgeDirection side : EnumSet.of( ForgeDirection.UP, ForgeDirection.DOWN ))
for ( ForgeDirection side : EnumSet.of( ForgeDirection.UP, ForgeDirection.DOWN ) )
{
rh.renderInventoryFace( main, side, renderer );
}
@@ -141,14 +141,14 @@ public class PartCableCovered extends PartCable
offV = 0;
main = new OffsetIcon( this.getTexture( this.getCableColor() ), offU, offV );
for (ForgeDirection side : EnumSet.of( ForgeDirection.EAST, ForgeDirection.WEST ))
for ( ForgeDirection side : EnumSet.of( ForgeDirection.EAST, ForgeDirection.WEST ) )
{
rh.renderInventoryFace( main, side, renderer );
}
main = new OffsetIcon( this.getTexture( this.getCableColor() ), 0, 0 );
for (ForgeDirection side : EnumSet.of( ForgeDirection.SOUTH, ForgeDirection.NORTH ))
for ( ForgeDirection side : EnumSet.of( ForgeDirection.SOUTH, ForgeDirection.NORTH ) )
{
rh.renderInventoryFace( main, side, renderer );
}
@@ -157,8 +157,8 @@ public class PartCableCovered extends PartCable
}
@Override
@SideOnly(Side.CLIENT)
public void renderStatic(int x, int y, int z, IPartRenderHelper rh, RenderBlocks renderer)
@SideOnly( Side.CLIENT )
public void renderStatic( int x, int y, int z, IPartRenderHelper rh, RenderBlocks renderer )
{
this.renderCache = rh.useSimplifiedRendering( x, y, z, this, this.renderCache );
rh.setTexture( this.getTexture( this.getCableColor() ) );
@@ -167,7 +167,7 @@ public class PartCableCovered extends PartCable
boolean hasBuses = false;
IPartHost ph = this.getHost();
for (ForgeDirection of : EnumSet.complementOf( this.connections ))
for ( ForgeDirection of : EnumSet.complementOf( this.connections ) )
{
IPart bp = ph.getPart( of );
if ( bp instanceof IGridHost )
@@ -181,28 +181,28 @@ public class PartCableCovered extends PartCable
int len = bp.cableConnectionRenderTo();
if ( len < 8 )
{
switch (of)
switch ( of )
{
case DOWN:
rh.setBounds( 6, len, 6, 10, 5, 10 );
break;
case EAST:
rh.setBounds( 11, 6, 6, 16 - len, 10, 10 );
break;
case NORTH:
rh.setBounds( 6, 6, len, 10, 10, 5 );
break;
case SOUTH:
rh.setBounds( 6, 6, 11, 10, 10, 16 - len );
break;
case UP:
rh.setBounds( 6, 11, 6, 10, 16 - len, 10 );
break;
case WEST:
rh.setBounds( len, 6, 6, 5, 10, 10 );
break;
default:
continue;
case DOWN:
rh.setBounds( 6, len, 6, 10, 5, 10 );
break;
case EAST:
rh.setBounds( 11, 6, 6, 16 - len, 10, 10 );
break;
case NORTH:
rh.setBounds( 6, 6, len, 10, 10, 5 );
break;
case SOUTH:
rh.setBounds( 6, 6, 11, 10, 10, 16 - len );
break;
case UP:
rh.setBounds( 6, 11, 6, 10, 16 - len, 10 );
break;
case WEST:
rh.setBounds( len, 6, 6, 5, 10, 10 );
break;
default:
continue;
}
rh.renderBlock( x, y, z, renderer );
}
@@ -211,7 +211,7 @@ public class PartCableCovered extends PartCable
if ( sides.size() != 2 || !this.nonLinear( sides ) || hasBuses )
{
for (ForgeDirection of : this.connections)
for ( ForgeDirection of : this.connections )
{
this.renderCoveredConnection( x, y, z, rh, renderer, this.channelsOnSide[of.ordinal()], of );
}
@@ -224,29 +224,29 @@ public class PartCableCovered extends PartCable
{
IIcon def = this.getTexture( this.getCableColor() );
IIcon off = new OffsetIcon( def, 0, -12 );
for (ForgeDirection of : this.connections)
for ( ForgeDirection of : this.connections )
{
switch (of)
switch ( of )
{
case DOWN:
case UP:
rh.setTexture( def, def, off, off, off, off );
renderer.setRenderBounds( 5 / 16.0, 0, 5 / 16.0, 11 / 16.0, 16 / 16.0, 11 / 16.0 );
break;
case EAST:
case WEST:
rh.setTexture( off, off, off, off, def, def );
renderer.uvRotateEast = renderer.uvRotateWest = 1;
renderer.uvRotateBottom = renderer.uvRotateTop = 1;
renderer.setRenderBounds( 0, 5 / 16.0, 5 / 16.0, 16 / 16.0, 11 / 16.0, 11 / 16.0 );
break;
case NORTH:
case SOUTH:
rh.setTexture( off, off, def, def, off, off );
renderer.uvRotateNorth = renderer.uvRotateSouth = 1;
renderer.setRenderBounds( 5 / 16.0, 5 / 16.0, 0, 11 / 16.0, 11 / 16.0, 16 / 16.0 );
break;
default:
case DOWN:
case UP:
rh.setTexture( def, def, off, off, off, off );
renderer.setRenderBounds( 5 / 16.0, 0, 5 / 16.0, 11 / 16.0, 16 / 16.0, 11 / 16.0 );
break;
case EAST:
case WEST:
rh.setTexture( off, off, off, off, def, def );
renderer.uvRotateEast = renderer.uvRotateWest = 1;
renderer.uvRotateBottom = renderer.uvRotateTop = 1;
renderer.setRenderBounds( 0, 5 / 16.0, 5 / 16.0, 16 / 16.0, 11 / 16.0, 11 / 16.0 );
break;
case NORTH:
case SOUTH:
rh.setTexture( off, off, def, def, off, off );
renderer.uvRotateNorth = renderer.uvRotateSouth = 1;
renderer.setRenderBounds( 5 / 16.0, 5 / 16.0, 0, 11 / 16.0, 11 / 16.0, 16 / 16.0 );
break;
default:
}
}
@@ -256,5 +256,4 @@ public class PartCableCovered extends PartCable
renderer.uvRotateBottom = renderer.uvRotateEast = renderer.uvRotateNorth = renderer.uvRotateSouth = renderer.uvRotateTop = renderer.uvRotateWest = 0;
rh.setTexture( null );
}
}
@@ -18,17 +18,17 @@
package appeng.parts.networking;
import net.minecraft.item.ItemStack;
import appeng.helpers.Reflected;
public class PartCableGlass extends PartCable
{
public PartCableGlass(Class c, ItemStack is) {
super( c, is );
@Reflected
public PartCableGlass( ItemStack is )
{
super( is );
}
public PartCableGlass(ItemStack is) {
this( PartCableGlass.class, is );
}
}
@@ -18,6 +18,7 @@
package appeng.parts.networking;
import java.util.EnumSet;
import org.lwjgl.opengl.GL11;
@@ -46,31 +47,30 @@ import appeng.block.AEBaseBlock;
import appeng.client.texture.FlippableIcon;
import appeng.client.texture.OffsetIcon;
import appeng.client.texture.TaughtIcon;
import appeng.helpers.Reflected;
import appeng.util.Platform;
public class PartCableSmart extends PartCable
{
@Reflected
public PartCableSmart( ItemStack is )
{
super( is );
}
@MENetworkEventSubscribe
public void channelUpdated(MENetworkChannelsChanged c)
public void channelUpdated( MENetworkChannelsChanged c )
{
this.getHost().markForUpdate();
}
@MENetworkEventSubscribe
public void powerRender(MENetworkPowerStatusChange c)
public void powerRender( MENetworkPowerStatusChange c )
{
this.getHost().markForUpdate();
}
public PartCableSmart(Class c, ItemStack is) {
super( c, is );
}
public PartCableSmart(ItemStack is) {
this( PartCableSmart.class, is );
}
@Override
public AECableType getCableConnectionType()
{
@@ -78,14 +78,14 @@ public class PartCableSmart extends PartCable
}
@Override
public IIcon getTexture(AEColor c)
public IIcon getTexture( AEColor c )
{
return this.getSmartTexture( c );
}
@Override
@SideOnly(Side.CLIENT)
public void renderInventory(IPartRenderHelper rh, RenderBlocks renderer)
@SideOnly( Side.CLIENT )
public void renderInventory( IPartRenderHelper rh, RenderBlocks renderer )
{
GL11.glTranslated( -0.0, -0.0, 0.3 );
@@ -96,7 +96,7 @@ public class PartCableSmart extends PartCable
OffsetIcon ch1 = new OffsetIcon( this.getChannelTex( 4, false ).getIcon(), offU, offV );
OffsetIcon ch2 = new OffsetIcon( this.getChannelTex( 4, true ).getIcon(), offU, offV );
for (ForgeDirection side : EnumSet.of( ForgeDirection.UP, ForgeDirection.DOWN ))
for ( ForgeDirection side : EnumSet.of( ForgeDirection.UP, ForgeDirection.DOWN ) )
{
rh.setBounds( 5.0f, 5.0f, 2.0f, 11.0f, 11.0f, 14.0f );
rh.renderInventoryFace( main, side, renderer );
@@ -110,7 +110,7 @@ public class PartCableSmart extends PartCable
ch1 = new OffsetIcon( this.getChannelTex( 4, false ).getIcon(), offU, offV );
ch2 = new OffsetIcon( this.getChannelTex( 4, true ).getIcon(), offU, offV );
for (ForgeDirection side : EnumSet.of( ForgeDirection.EAST, ForgeDirection.WEST ))
for ( ForgeDirection side : EnumSet.of( ForgeDirection.EAST, ForgeDirection.WEST ) )
{
rh.setBounds( 5.0f, 5.0f, 2.0f, 11.0f, 11.0f, 14.0f );
rh.renderInventoryFace( main, side, renderer );
@@ -122,7 +122,7 @@ public class PartCableSmart extends PartCable
ch1 = new OffsetIcon( this.getChannelTex( 4, false ).getIcon(), 0, 0 );
ch2 = new OffsetIcon( this.getChannelTex( 4, true ).getIcon(), 0, 0 );
for (ForgeDirection side : EnumSet.of( ForgeDirection.SOUTH, ForgeDirection.NORTH ))
for ( ForgeDirection side : EnumSet.of( ForgeDirection.SOUTH, ForgeDirection.NORTH ) )
{
rh.setBounds( 5.0f, 5.0f, 2.0f, 11.0f, 11.0f, 14.0f );
rh.renderInventoryFace( main, side, renderer );
@@ -134,7 +134,7 @@ public class PartCableSmart extends PartCable
}
@Override
public void getBoxes(IPartCollisionHelper bch)
public void getBoxes( IPartCollisionHelper bch )
{
bch.addBox( 5.0, 5.0, 5.0, 11.0, 11.0, 11.0 );
@@ -147,36 +147,36 @@ public class PartCableSmart extends PartCable
this.connections.clear();
}
for (ForgeDirection of : this.connections)
for ( ForgeDirection of : this.connections )
{
switch (of)
switch ( of )
{
case DOWN:
bch.addBox( 5.0, 0.0, 5.0, 11.0, 5.0, 11.0 );
break;
case EAST:
bch.addBox( 11.0, 5.0, 5.0, 16.0, 11.0, 11.0 );
break;
case NORTH:
bch.addBox( 5.0, 5.0, 0.0, 11.0, 11.0, 5.0 );
break;
case SOUTH:
bch.addBox( 5.0, 5.0, 11.0, 11.0, 11.0, 16.0 );
break;
case UP:
bch.addBox( 5.0, 11.0, 5.0, 11.0, 16.0, 11.0 );
break;
case WEST:
bch.addBox( 0.0, 5.0, 5.0, 5.0, 11.0, 11.0 );
break;
default:
case DOWN:
bch.addBox( 5.0, 0.0, 5.0, 11.0, 5.0, 11.0 );
break;
case EAST:
bch.addBox( 11.0, 5.0, 5.0, 16.0, 11.0, 11.0 );
break;
case NORTH:
bch.addBox( 5.0, 5.0, 0.0, 11.0, 11.0, 5.0 );
break;
case SOUTH:
bch.addBox( 5.0, 5.0, 11.0, 11.0, 11.0, 16.0 );
break;
case UP:
bch.addBox( 5.0, 11.0, 5.0, 11.0, 16.0, 11.0 );
break;
case WEST:
bch.addBox( 0.0, 5.0, 5.0, 5.0, 11.0, 11.0 );
break;
default:
}
}
}
@Override
@SideOnly(Side.CLIENT)
public void renderStatic(int x, int y, int z, IPartRenderHelper rh, RenderBlocks renderer)
@SideOnly( Side.CLIENT )
public void renderStatic( int x, int y, int z, IPartRenderHelper rh, RenderBlocks renderer )
{
this.renderCache = rh.useSimplifiedRendering( x, y, z, this, this.renderCache );
rh.setTexture( this.getTexture( this.getCableColor() ) );
@@ -185,7 +185,7 @@ public class PartCableSmart extends PartCable
boolean hasBuses = false;
IPartHost ph = this.getHost();
for (ForgeDirection of : EnumSet.complementOf( this.connections ))
for ( ForgeDirection of : EnumSet.complementOf( this.connections ) )
{
IPart bp = ph.getPart( of );
if ( bp instanceof IGridHost )
@@ -199,28 +199,28 @@ public class PartCableSmart extends PartCable
int len = bp.cableConnectionRenderTo();
if ( len < 8 )
{
switch (of)
switch ( of )
{
case DOWN:
rh.setBounds( 6, len, 6, 10, 5, 10 );
break;
case EAST:
rh.setBounds( 11, 6, 6, 16 - len, 10, 10 );
break;
case NORTH:
rh.setBounds( 6, 6, len, 10, 10, 5 );
break;
case SOUTH:
rh.setBounds( 6, 6, 11, 10, 10, 16 - len );
break;
case UP:
rh.setBounds( 6, 11, 6, 10, 16 - len, 10 );
break;
case WEST:
rh.setBounds( len, 6, 6, 5, 10, 10 );
break;
default:
continue;
case DOWN:
rh.setBounds( 6, len, 6, 10, 5, 10 );
break;
case EAST:
rh.setBounds( 11, 6, 6, 16 - len, 10, 10 );
break;
case NORTH:
rh.setBounds( 6, 6, len, 10, 10, 5 );
break;
case SOUTH:
rh.setBounds( 6, 6, 11, 10, 10, 16 - len );
break;
case UP:
rh.setBounds( 6, 11, 6, 10, 16 - len, 10 );
break;
case WEST:
rh.setBounds( len, 6, 6, 5, 10, 10 );
break;
default:
continue;
}
rh.renderBlock( x, y, z, renderer );
@@ -253,7 +253,7 @@ public class PartCableSmart extends PartCable
if ( sides.size() != 2 || !this.nonLinear( sides ) || hasBuses )
{
for (ForgeDirection of : this.connections)
for ( ForgeDirection of : this.connections )
{
this.renderSmartConnection( x, y, z, rh, renderer, this.channelsOnSide[of.ordinal()], of );
}
@@ -266,7 +266,7 @@ public class PartCableSmart extends PartCable
{
ForgeDirection selectedSide = ForgeDirection.UNKNOWN;
for (ForgeDirection of : this.connections)
for ( ForgeDirection of : this.connections )
{
selectedSide = of;
break;
@@ -282,88 +282,88 @@ public class PartCableSmart extends PartCable
IIcon secondTaughtIcon = new TaughtIcon( this.getChannelTex( channels, true ).getIcon(), -0.2f );
IIcon secondOffsetIcon = new OffsetIcon( secondTaughtIcon, 0, -12 );
switch (selectedSide)
switch ( selectedSide )
{
case DOWN:
case UP:
renderer.setRenderBounds( 5 / 16.0, 0, 5 / 16.0, 11 / 16.0, 16 / 16.0, 11 / 16.0 );
rh.setTexture( def, def, off, off, off, off );
rh.renderBlockCurrentBounds( x, y, z, renderer );
case DOWN:
case UP:
renderer.setRenderBounds( 5 / 16.0, 0, 5 / 16.0, 11 / 16.0, 16 / 16.0, 11 / 16.0 );
rh.setTexture( def, def, off, off, off, off );
rh.renderBlockCurrentBounds( x, y, z, renderer );
renderer.uvRotateTop = 0;
renderer.uvRotateBottom = 0;
renderer.uvRotateSouth = 3;
renderer.uvRotateEast = 3;
renderer.uvRotateTop = 0;
renderer.uvRotateBottom = 0;
renderer.uvRotateSouth = 3;
renderer.uvRotateEast = 3;
Tessellator.instance.setBrightness( 15 << 20 | 15 << 4 );
Tessellator.instance.setBrightness( 15 << 20 | 15 << 4 );
Tessellator.instance.setColorOpaque_I( this.getCableColor().blackVariant );
rh.setTexture( firstTaughtIcon, firstTaughtIcon, firstOffsetIcon, firstOffsetIcon, firstOffsetIcon, firstOffsetIcon );
this.renderAllFaces( (AEBaseBlock) rh.getBlock(), x, y, z, rh, renderer );
Tessellator.instance.setColorOpaque_I( this.getCableColor().blackVariant );
rh.setTexture( firstTaughtIcon, firstTaughtIcon, firstOffsetIcon, firstOffsetIcon, firstOffsetIcon, firstOffsetIcon );
this.renderAllFaces( (AEBaseBlock) rh.getBlock(), x, y, z, rh, renderer );
Tessellator.instance.setColorOpaque_I( this.getCableColor().whiteVariant );
rh.setTexture( secondTaughtIcon, secondTaughtIcon, secondOffsetIcon, secondOffsetIcon, secondOffsetIcon, secondOffsetIcon );
this.renderAllFaces( (AEBaseBlock) rh.getBlock(), x, y, z, rh, renderer );
break;
case EAST:
case WEST:
rh.setTexture( off, off, off, off, def, def );
renderer.uvRotateEast = 2;
renderer.uvRotateWest = 1;
renderer.uvRotateBottom = 2;
renderer.uvRotateTop = 1;
renderer.uvRotateSouth = 0;
renderer.uvRotateNorth = 0;
Tessellator.instance.setColorOpaque_I( this.getCableColor().whiteVariant );
rh.setTexture( secondTaughtIcon, secondTaughtIcon, secondOffsetIcon, secondOffsetIcon, secondOffsetIcon, secondOffsetIcon );
this.renderAllFaces( (AEBaseBlock) rh.getBlock(), x, y, z, rh, renderer );
break;
case EAST:
case WEST:
rh.setTexture( off, off, off, off, def, def );
renderer.uvRotateEast = 2;
renderer.uvRotateWest = 1;
renderer.uvRotateBottom = 2;
renderer.uvRotateTop = 1;
renderer.uvRotateSouth = 0;
renderer.uvRotateNorth = 0;
AEBaseBlock blk = (AEBaseBlock) rh.getBlock();
FlippableIcon ico = blk.getRendererInstance().getTexture( ForgeDirection.EAST );
ico.setFlip( false, true );
AEBaseBlock blk = (AEBaseBlock) rh.getBlock();
FlippableIcon ico = blk.getRendererInstance().getTexture( ForgeDirection.EAST );
ico.setFlip( false, true );
renderer.setRenderBounds( 0, 5 / 16.0, 5 / 16.0, 16 / 16.0, 11 / 16.0, 11 / 16.0 );
rh.renderBlockCurrentBounds( x, y, z, renderer );
renderer.setRenderBounds( 0, 5 / 16.0, 5 / 16.0, 16 / 16.0, 11 / 16.0, 11 / 16.0 );
rh.renderBlockCurrentBounds( x, y, z, renderer );
Tessellator.instance.setBrightness( 15 << 20 | 15 << 4 );
Tessellator.instance.setBrightness( 15 << 20 | 15 << 4 );
FlippableIcon fpA = new FlippableIcon( firstTaughtIcon );
FlippableIcon fpB = new FlippableIcon( secondTaughtIcon );
FlippableIcon fpA = new FlippableIcon( firstTaughtIcon );
FlippableIcon fpB = new FlippableIcon( secondTaughtIcon );
fpA = new FlippableIcon( firstTaughtIcon );
fpB = new FlippableIcon( secondTaughtIcon );
fpA = new FlippableIcon( firstTaughtIcon );
fpB = new FlippableIcon( secondTaughtIcon );
fpA.setFlip( true, false );
fpB.setFlip( true, false );
fpA.setFlip( true, false );
fpB.setFlip( true, false );
Tessellator.instance.setColorOpaque_I( this.getCableColor().blackVariant );
rh.setTexture( firstOffsetIcon, firstOffsetIcon, firstOffsetIcon, firstOffsetIcon, firstTaughtIcon, fpA );
this.renderAllFaces( (AEBaseBlock) rh.getBlock(), x, y, z, rh, renderer );
Tessellator.instance.setColorOpaque_I( this.getCableColor().blackVariant );
rh.setTexture( firstOffsetIcon, firstOffsetIcon, firstOffsetIcon, firstOffsetIcon, firstTaughtIcon, fpA );
this.renderAllFaces( (AEBaseBlock) rh.getBlock(), x, y, z, rh, renderer );
Tessellator.instance.setColorOpaque_I( this.getCableColor().whiteVariant );
rh.setTexture( secondOffsetIcon, secondOffsetIcon, secondOffsetIcon, secondOffsetIcon, secondTaughtIcon, fpB );
this.renderAllFaces( (AEBaseBlock) rh.getBlock(), x, y, z, rh, renderer );
break;
case NORTH:
case SOUTH:
rh.setTexture( off, off, def, def, off, off );
renderer.uvRotateTop = 3;
renderer.uvRotateBottom = 3;
renderer.uvRotateNorth = 1;
renderer.uvRotateSouth = 2;
renderer.uvRotateWest = 1;
renderer.setRenderBounds( 5 / 16.0, 5 / 16.0, 0, 11 / 16.0, 11 / 16.0, 16 / 16.0 );
rh.renderBlockCurrentBounds( x, y, z, renderer );
Tessellator.instance.setColorOpaque_I( this.getCableColor().whiteVariant );
rh.setTexture( secondOffsetIcon, secondOffsetIcon, secondOffsetIcon, secondOffsetIcon, secondTaughtIcon, fpB );
this.renderAllFaces( (AEBaseBlock) rh.getBlock(), x, y, z, rh, renderer );
break;
case NORTH:
case SOUTH:
rh.setTexture( off, off, def, def, off, off );
renderer.uvRotateTop = 3;
renderer.uvRotateBottom = 3;
renderer.uvRotateNorth = 1;
renderer.uvRotateSouth = 2;
renderer.uvRotateWest = 1;
renderer.setRenderBounds( 5 / 16.0, 5 / 16.0, 0, 11 / 16.0, 11 / 16.0, 16 / 16.0 );
rh.renderBlockCurrentBounds( x, y, z, renderer );
Tessellator.instance.setBrightness( 15 << 20 | 15 << 4 );
Tessellator.instance.setBrightness( 15 << 20 | 15 << 4 );
Tessellator.instance.setColorOpaque_I( this.getCableColor().blackVariant );
rh.setTexture( firstOffsetIcon, firstOffsetIcon, firstTaughtIcon, firstTaughtIcon, firstOffsetIcon, firstOffsetIcon );
this.renderAllFaces( (AEBaseBlock) rh.getBlock(), x, y, z, rh, renderer );
Tessellator.instance.setColorOpaque_I( this.getCableColor().blackVariant );
rh.setTexture( firstOffsetIcon, firstOffsetIcon, firstTaughtIcon, firstTaughtIcon, firstOffsetIcon, firstOffsetIcon );
this.renderAllFaces( (AEBaseBlock) rh.getBlock(), x, y, z, rh, renderer );
Tessellator.instance.setColorOpaque_I( this.getCableColor().whiteVariant );
rh.setTexture( secondOffsetIcon, secondOffsetIcon, secondTaughtIcon, secondTaughtIcon, secondOffsetIcon, secondOffsetIcon );
this.renderAllFaces( (AEBaseBlock) rh.getBlock(), x, y, z, rh, renderer );
break;
default:
break;
Tessellator.instance.setColorOpaque_I( this.getCableColor().whiteVariant );
rh.setTexture( secondOffsetIcon, secondOffsetIcon, secondTaughtIcon, secondTaughtIcon, secondOffsetIcon, secondOffsetIcon );
this.renderAllFaces( (AEBaseBlock) rh.getBlock(), x, y, z, rh, renderer );
break;
default:
break;
}
}
@@ -18,6 +18,7 @@
package appeng.parts.networking;
import java.util.EnumSet;
import org.lwjgl.opengl.GL11;
@@ -50,10 +51,19 @@ import appeng.client.texture.CableBusTextures;
import appeng.client.texture.FlippableIcon;
import appeng.client.texture.OffsetIcon;
import appeng.client.texture.TaughtIcon;
import appeng.helpers.Reflected;
import appeng.util.Platform;
public class PartDenseCable extends PartCable
{
@Reflected
public PartDenseCable( ItemStack is )
{
super( is );
this.proxy.setFlags( GridFlags.DENSE_CAPACITY, GridFlags.PREFERRED );
}
@Override
public BusSupport supportsBuses()
@@ -61,25 +71,15 @@ public class PartDenseCable extends PartCable
return BusSupport.DENSE_CABLE;
}
@MENetworkEventSubscribe
public void channelUpdated(MENetworkChannelsChanged c)
@Override
public IIcon getTexture( AEColor c )
{
this.getHost().markForUpdate();
}
if ( c == AEColor.Transparent )
{
return AEApi.instance().definitions().parts().cableSmart().stack( AEColor.Transparent, 1 ).getIconIndex();
}
@MENetworkEventSubscribe
public void powerRender(MENetworkPowerStatusChange c)
{
this.getHost().markForUpdate();
}
public PartDenseCable(Class c, ItemStack is) {
super( c, is );
this.proxy.setFlags( GridFlags.DENSE_CAPACITY, GridFlags.PREFERRED );
}
public PartDenseCable(ItemStack is) {
this( PartDenseCable.class, is );
return this.getSmartTexture( c );
}
@Override
@@ -89,64 +89,7 @@ public class PartDenseCable extends PartCable
}
@Override
public IIcon getTexture(AEColor c)
{
if ( c == AEColor.Transparent )
return AEApi.instance().parts().partCableSmart.stack( AEColor.Transparent, 1 ).getIconIndex();
return this.getSmartTexture( c );
}
@Override
@SideOnly(Side.CLIENT)
public void renderInventory(IPartRenderHelper rh, RenderBlocks renderer)
{
GL11.glTranslated( -0.0, -0.0, 0.3 );
rh.setBounds( 4.0f, 4.0f, 2.0f, 12.0f, 12.0f, 14.0f );
float offU = 0;
float offV = 9;
OffsetIcon main = new OffsetIcon( this.getTexture( this.getCableColor() ), offU, offV );
OffsetIcon ch1 = new OffsetIcon( this.getChannelTex( 4, false ).getIcon(), offU, offV );
OffsetIcon ch2 = new OffsetIcon( this.getChannelTex( 4, true ).getIcon(), offU, offV );
for (ForgeDirection side : EnumSet.of( ForgeDirection.UP, ForgeDirection.DOWN ))
{
rh.renderInventoryFace( main, side, renderer );
rh.renderInventoryFace( ch1, side, renderer );
rh.renderInventoryFace( ch2, side, renderer );
}
offU = 9;
offV = 0;
main = new OffsetIcon( this.getTexture( this.getCableColor() ), offU, offV );
ch1 = new OffsetIcon( this.getChannelTex( 4, false ).getIcon(), offU, offV );
ch2 = new OffsetIcon( this.getChannelTex( 4, true ).getIcon(), offU, offV );
for (ForgeDirection side : EnumSet.of( ForgeDirection.EAST, ForgeDirection.WEST ))
{
rh.renderInventoryFace( main, side, renderer );
rh.renderInventoryFace( ch1, side, renderer );
rh.renderInventoryFace( ch2, side, renderer );
}
main = new OffsetIcon( this.getTexture( this.getCableColor() ), 0, 0 );
ch1 = new OffsetIcon( this.getChannelTex( 4, false ).getIcon(), 0, 0 );
ch2 = new OffsetIcon( this.getChannelTex( 4, true ).getIcon(), 0, 0 );
for (ForgeDirection side : EnumSet.of( ForgeDirection.SOUTH, ForgeDirection.NORTH ))
{
rh.renderInventoryFace( main, side, renderer );
rh.renderInventoryFace( ch1, side, renderer );
rh.renderInventoryFace( ch2, side, renderer );
}
rh.setTexture( null );
}
@Override
public void getBoxes(IPartCollisionHelper bch)
public void getBoxes( IPartCollisionHelper bch )
{
boolean noLadder = !bch.isBBCollision();
double min = noLadder ? 3.0 : 4.9;
@@ -163,85 +106,249 @@ public class PartDenseCable extends PartCable
this.connections.clear();
}
for (ForgeDirection of : this.connections)
for ( ForgeDirection of : this.connections )
{
if ( this.isDense( of ) )
{
switch (of)
switch ( of )
{
case DOWN:
bch.addBox( min, 0.0, min, max, min, max );
break;
case EAST:
bch.addBox( max, min, min, 16.0, max, max );
break;
case NORTH:
bch.addBox( min, min, 0.0, max, max, min );
break;
case SOUTH:
bch.addBox( min, min, max, max, max, 16.0 );
break;
case UP:
bch.addBox( min, max, min, max, 16.0, max );
break;
case WEST:
bch.addBox( 0.0, min, min, min, max, max );
break;
default:
case DOWN:
bch.addBox( min, 0.0, min, max, min, max );
break;
case EAST:
bch.addBox( max, min, min, 16.0, max, max );
break;
case NORTH:
bch.addBox( min, min, 0.0, max, max, min );
break;
case SOUTH:
bch.addBox( min, min, max, max, max, 16.0 );
break;
case UP:
bch.addBox( min, max, min, max, 16.0, max );
break;
case WEST:
bch.addBox( 0.0, min, min, min, max, max );
break;
default:
}
}
else
{
switch (of)
switch ( of )
{
case DOWN:
bch.addBox( 5.0, 0.0, 5.0, 11.0, 5.0, 11.0 );
break;
case EAST:
bch.addBox( 11.0, 5.0, 5.0, 16.0, 11.0, 11.0 );
break;
case NORTH:
bch.addBox( 5.0, 5.0, 0.0, 11.0, 11.0, 5.0 );
break;
case SOUTH:
bch.addBox( 5.0, 5.0, 11.0, 11.0, 11.0, 16.0 );
break;
case UP:
bch.addBox( 5.0, 11.0, 5.0, 11.0, 16.0, 11.0 );
break;
case WEST:
bch.addBox( 0.0, 5.0, 5.0, 5.0, 11.0, 11.0 );
break;
default:
case DOWN:
bch.addBox( 5.0, 0.0, 5.0, 11.0, 5.0, 11.0 );
break;
case EAST:
bch.addBox( 11.0, 5.0, 5.0, 16.0, 11.0, 11.0 );
break;
case NORTH:
bch.addBox( 5.0, 5.0, 0.0, 11.0, 11.0, 5.0 );
break;
case SOUTH:
bch.addBox( 5.0, 5.0, 11.0, 11.0, 11.0, 16.0 );
break;
case UP:
bch.addBox( 5.0, 11.0, 5.0, 11.0, 16.0, 11.0 );
break;
case WEST:
bch.addBox( 0.0, 5.0, 5.0, 5.0, 11.0, 11.0 );
break;
default:
}
}
}
}
private boolean isDense(ForgeDirection of)
@Override
@SideOnly( Side.CLIENT )
public void renderInventory( IPartRenderHelper rh, RenderBlocks renderer )
{
TileEntity te = this.tile.getWorldObj().getTileEntity( this.tile.xCoord + of.offsetX, this.tile.yCoord + of.offsetY, this.tile.zCoord + of.offsetZ );
if ( te instanceof IGridHost )
GL11.glTranslated( -0.0, -0.0, 0.3 );
rh.setBounds( 4.0f, 4.0f, 2.0f, 12.0f, 12.0f, 14.0f );
float offU = 0;
float offV = 9;
OffsetIcon main = new OffsetIcon( this.getTexture( this.getCableColor() ), offU, offV );
OffsetIcon ch1 = new OffsetIcon( this.getChannelTex( 4, false ).getIcon(), offU, offV );
OffsetIcon ch2 = new OffsetIcon( this.getChannelTex( 4, true ).getIcon(), offU, offV );
for ( ForgeDirection side : EnumSet.of( ForgeDirection.UP, ForgeDirection.DOWN ) )
{
AECableType t = ((IGridHost) te).getCableConnectionType( of.getOpposite() );
return t == AECableType.DENSE;
rh.renderInventoryFace( main, side, renderer );
rh.renderInventoryFace( ch1, side, renderer );
rh.renderInventoryFace( ch2, side, renderer );
}
return false;
offU = 9;
offV = 0;
main = new OffsetIcon( this.getTexture( this.getCableColor() ), offU, offV );
ch1 = new OffsetIcon( this.getChannelTex( 4, false ).getIcon(), offU, offV );
ch2 = new OffsetIcon( this.getChannelTex( 4, true ).getIcon(), offU, offV );
for ( ForgeDirection side : EnumSet.of( ForgeDirection.EAST, ForgeDirection.WEST ) )
{
rh.renderInventoryFace( main, side, renderer );
rh.renderInventoryFace( ch1, side, renderer );
rh.renderInventoryFace( ch2, side, renderer );
}
main = new OffsetIcon( this.getTexture( this.getCableColor() ), 0, 0 );
ch1 = new OffsetIcon( this.getChannelTex( 4, false ).getIcon(), 0, 0 );
ch2 = new OffsetIcon( this.getChannelTex( 4, true ).getIcon(), 0, 0 );
for ( ForgeDirection side : EnumSet.of( ForgeDirection.SOUTH, ForgeDirection.NORTH ) )
{
rh.renderInventoryFace( main, side, renderer );
rh.renderInventoryFace( ch1, side, renderer );
rh.renderInventoryFace( ch2, side, renderer );
}
rh.setTexture( null );
}
private boolean isSmart(ForgeDirection of)
@Override
@SideOnly( Side.CLIENT )
public void renderStatic( int x, int y, int z, IPartRenderHelper rh, RenderBlocks renderer )
{
TileEntity te = this.tile.getWorldObj().getTileEntity( this.tile.xCoord + of.offsetX, this.tile.yCoord + of.offsetY, this.tile.zCoord + of.offsetZ );
if ( te instanceof IGridHost )
this.renderCache = rh.useSimplifiedRendering( x, y, z, this, this.renderCache );
rh.setTexture( this.getTexture( this.getCableColor() ) );
EnumSet<ForgeDirection> sides = this.connections.clone();
boolean hasBuses = false;
for ( ForgeDirection of : this.connections )
{
AECableType t = ((IGridHost) te).getCableConnectionType( of.getOpposite() );
return t == AECableType.SMART;
if ( !this.isDense( of ) )
hasBuses = true;
}
return false;
if ( sides.size() != 2 || !this.nonLinear( sides ) || hasBuses )
{
for ( ForgeDirection of : this.connections )
{
if ( this.isDense( of ) )
this.renderDenseConnection( x, y, z, rh, renderer, this.channelsOnSide[of.ordinal()], of );
else if ( this.isSmart( of ) )
this.renderSmartConnection( x, y, z, rh, renderer, this.channelsOnSide[of.ordinal()], of );
else
this.renderCoveredConnection( x, y, z, rh, renderer, this.channelsOnSide[of.ordinal()], of );
}
rh.setTexture( this.getDenseTexture( this.getCableColor() ) );
rh.setBounds( 3, 3, 3, 13, 13, 13 );
rh.renderBlock( x, y, z, renderer );
}
else
{
ForgeDirection selectedSide = ForgeDirection.UNKNOWN;
for ( ForgeDirection of : this.connections )
{
selectedSide = of;
break;
}
int channels = this.channelsOnSide[selectedSide.ordinal()];
IIcon def = this.getTexture( this.getCableColor() );
IIcon off = new OffsetIcon( def, 0, -12 );
IIcon firstIcon = new TaughtIcon( this.getChannelTex( channels, false ).getIcon(), -0.2f );
IIcon firstOffset = new OffsetIcon( firstIcon, 0, -12 );
IIcon secondIcon = new TaughtIcon( this.getChannelTex( channels, true ).getIcon(), -0.2f );
IIcon secondOffset = new OffsetIcon( secondIcon, 0, -12 );
switch ( selectedSide )
{
case DOWN:
case UP:
renderer.setRenderBounds( 3 / 16.0, 0, 3 / 16.0, 13 / 16.0, 16 / 16.0, 13 / 16.0 );
rh.setTexture( def, def, off, off, off, off );
rh.renderBlockCurrentBounds( x, y, z, renderer );
renderer.uvRotateTop = 0;
renderer.uvRotateBottom = 0;
renderer.uvRotateSouth = 3;
renderer.uvRotateEast = 3;
Tessellator.instance.setBrightness( 15 << 20 | 15 << 4 );
Tessellator.instance.setColorOpaque_I( this.getCableColor().blackVariant );
rh.setTexture( firstIcon, firstIcon, firstOffset, firstOffset, firstOffset, firstOffset );
this.renderAllFaces( (AEBaseBlock) rh.getBlock(), x, y, z, rh, renderer );
Tessellator.instance.setColorOpaque_I( this.getCableColor().whiteVariant );
rh.setTexture( secondIcon, secondIcon, secondOffset, secondOffset, secondOffset, secondOffset );
this.renderAllFaces( (AEBaseBlock) rh.getBlock(), x, y, z, rh, renderer );
break;
case EAST:
case WEST:
rh.setTexture( off, off, off, off, def, def );
renderer.uvRotateEast = 2;
renderer.uvRotateWest = 1;
renderer.uvRotateBottom = 2;
renderer.uvRotateTop = 1;
renderer.uvRotateSouth = 0;
renderer.uvRotateNorth = 0;
AEBaseBlock blk = (AEBaseBlock) rh.getBlock();
FlippableIcon ico = blk.getRendererInstance().getTexture( ForgeDirection.EAST );
ico.setFlip( false, true );
renderer.setRenderBounds( 0, 3 / 16.0, 3 / 16.0, 16 / 16.0, 13 / 16.0, 13 / 16.0 );
rh.renderBlockCurrentBounds( x, y, z, renderer );
Tessellator.instance.setBrightness( 15 << 20 | 15 << 4 );
FlippableIcon fpA = new FlippableIcon( firstIcon );
FlippableIcon fpB = new FlippableIcon( secondIcon );
fpA.setFlip( true, false );
fpB.setFlip( true, false );
Tessellator.instance.setColorOpaque_I( this.getCableColor().blackVariant );
rh.setTexture( firstOffset, firstOffset, firstOffset, firstOffset, firstIcon, fpA );
this.renderAllFaces( (AEBaseBlock) rh.getBlock(), x, y, z, rh, renderer );
Tessellator.instance.setColorOpaque_I( this.getCableColor().whiteVariant );
rh.setTexture( secondOffset, secondOffset, secondOffset, secondOffset, secondIcon, fpB );
this.renderAllFaces( (AEBaseBlock) rh.getBlock(), x, y, z, rh, renderer );
break;
case NORTH:
case SOUTH:
rh.setTexture( off, off, def, def, off, off );
renderer.uvRotateTop = 3;
renderer.uvRotateBottom = 3;
renderer.uvRotateNorth = 1;
renderer.uvRotateSouth = 2;
renderer.uvRotateWest = 1;
renderer.setRenderBounds( 3 / 16.0, 3 / 16.0, 0, 13 / 16.0, 13 / 16.0, 16 / 16.0 );
rh.renderBlockCurrentBounds( x, y, z, renderer );
Tessellator.instance.setBrightness( 15 << 20 | 15 << 4 );
Tessellator.instance.setColorOpaque_I( this.getCableColor().blackVariant );
rh.setTexture( firstOffset, firstOffset, firstIcon, firstIcon, firstOffset, firstOffset );
this.renderAllFaces( (AEBaseBlock) rh.getBlock(), x, y, z, rh, renderer );
Tessellator.instance.setColorOpaque_I( this.getCableColor().whiteVariant );
rh.setTexture( secondOffset, secondOffset, secondIcon, secondIcon, secondOffset, secondOffset );
this.renderAllFaces( (AEBaseBlock) rh.getBlock(), x, y, z, rh, renderer );
break;
default:
break;
}
}
renderer.uvRotateBottom = renderer.uvRotateEast = renderer.uvRotateNorth = renderer.uvRotateSouth = renderer.uvRotateTop = renderer.uvRotateWest = 0;
rh.setTexture( null );
}
@SideOnly(Side.CLIENT)
public void renderDenseConnection(int x, int y, int z, IPartRenderHelper rh, RenderBlocks renderer, int channels, ForgeDirection of)
@SideOnly( Side.CLIENT )
public void renderDenseConnection( int x, int y, int z, IPartRenderHelper rh, RenderBlocks renderer, int channels, ForgeDirection of )
{
TileEntity te = this.tile.getWorldObj().getTileEntity( x + of.offsetX, y + of.offsetY, z + of.offsetZ );
IPartHost partHost = te instanceof IPartHost ? (IPartHost) te : null;
@@ -280,34 +387,33 @@ public class PartDenseCable extends PartCable
*/
rh.setFacesToRender( EnumSet.complementOf( EnumSet.of( of, of.getOpposite() ) ) );
if ( ghh != null && partHost != null && ghh.getCableConnectionType( of ) != AECableType.GLASS && partHost.getColor() != AEColor.Transparent
&& partHost.getPart( of.getOpposite() ) == null )
if ( ghh != null && partHost != null && ghh.getCableConnectionType( of ) != AECableType.GLASS && partHost.getColor() != AEColor.Transparent && partHost.getPart( of.getOpposite() ) == null )
rh.setTexture( this.getTexture( myColor = partHost.getColor() ) );
else
rh.setTexture( this.getTexture( this.getCableColor() ) );
switch (of)
switch ( of )
{
case DOWN:
rh.setBounds( 4, 0, 4, 12, 5, 12 );
break;
case EAST:
rh.setBounds( 11, 4, 4, 16, 12, 12 );
break;
case NORTH:
rh.setBounds( 4, 4, 0, 12, 12, 5 );
break;
case SOUTH:
rh.setBounds( 4, 4, 11, 12, 12, 16 );
break;
case UP:
rh.setBounds( 4, 11, 4, 12, 16, 12 );
break;
case WEST:
rh.setBounds( 0, 4, 4, 5, 12, 12 );
break;
default:
return;
case DOWN:
rh.setBounds( 4, 0, 4, 12, 5, 12 );
break;
case EAST:
rh.setBounds( 11, 4, 4, 16, 12, 12 );
break;
case NORTH:
rh.setBounds( 4, 4, 0, 12, 12, 5 );
break;
case SOUTH:
rh.setBounds( 4, 4, 11, 12, 12, 16 );
break;
case UP:
rh.setBounds( 4, 11, 4, 12, 16, 12 );
break;
case WEST:
rh.setBounds( 0, 4, 4, 5, 12, 12 );
break;
default:
return;
}
rh.renderBlock( x, y, z, renderer );
@@ -333,183 +439,79 @@ public class PartDenseCable extends PartCable
}
}
@Override
@SideOnly(Side.CLIENT)
public void renderStatic(int x, int y, int z, IPartRenderHelper rh, RenderBlocks renderer)
private boolean isSmart( ForgeDirection of )
{
this.renderCache = rh.useSimplifiedRendering( x, y, z, this, this.renderCache );
rh.setTexture( this.getTexture( this.getCableColor() ) );
EnumSet<ForgeDirection> sides = this.connections.clone();
boolean hasBuses = false;
for (ForgeDirection of : this.connections)
TileEntity te = this.tile.getWorldObj().getTileEntity( this.tile.xCoord + of.offsetX, this.tile.yCoord + of.offsetY, this.tile.zCoord + of.offsetZ );
if ( te instanceof IGridHost )
{
if ( !this.isDense( of ) )
hasBuses = true;
AECableType t = ( (IGridHost) te ).getCableConnectionType( of.getOpposite() );
return t == AECableType.SMART;
}
if ( sides.size() != 2 || !this.nonLinear( sides ) || hasBuses )
{
for (ForgeDirection of : this.connections)
{
if ( this.isDense( of ) )
this.renderDenseConnection( x, y, z, rh, renderer, this.channelsOnSide[of.ordinal()], of );
else if ( this.isSmart( of ) )
this.renderSmartConnection( x, y, z, rh, renderer, this.channelsOnSide[of.ordinal()], of );
else
this.renderCoveredConnection( x, y, z, rh, renderer, this.channelsOnSide[of.ordinal()], of );
}
rh.setTexture( this.getDenseTexture( this.getCableColor() ) );
rh.setBounds( 3, 3, 3, 13, 13, 13 );
rh.renderBlock( x, y, z, renderer );
}
else
{
ForgeDirection selectedSide = ForgeDirection.UNKNOWN;
for (ForgeDirection of : this.connections)
{
selectedSide = of;
break;
}
int channels = this.channelsOnSide[selectedSide.ordinal()];
IIcon def = this.getTexture( this.getCableColor() );
IIcon off = new OffsetIcon( def, 0, -12 );
IIcon firstIcon = new TaughtIcon( this.getChannelTex( channels, false ).getIcon(), -0.2f );
IIcon firstOffset = new OffsetIcon( firstIcon, 0, -12 );
IIcon secondIcon = new TaughtIcon( this.getChannelTex( channels, true ).getIcon(), -0.2f );
IIcon secondOffset = new OffsetIcon( secondIcon, 0, -12 );
switch (selectedSide)
{
case DOWN:
case UP:
renderer.setRenderBounds( 3 / 16.0, 0, 3 / 16.0, 13 / 16.0, 16 / 16.0, 13 / 16.0 );
rh.setTexture( def, def, off, off, off, off );
rh.renderBlockCurrentBounds( x, y, z, renderer );
renderer.uvRotateTop = 0;
renderer.uvRotateBottom = 0;
renderer.uvRotateSouth = 3;
renderer.uvRotateEast = 3;
Tessellator.instance.setBrightness( 15 << 20 | 15 << 4 );
Tessellator.instance.setColorOpaque_I( this.getCableColor().blackVariant );
rh.setTexture( firstIcon, firstIcon, firstOffset, firstOffset, firstOffset, firstOffset );
this.renderAllFaces( (AEBaseBlock) rh.getBlock(), x, y, z, rh, renderer );
Tessellator.instance.setColorOpaque_I( this.getCableColor().whiteVariant );
rh.setTexture( secondIcon, secondIcon, secondOffset, secondOffset, secondOffset, secondOffset );
this.renderAllFaces( (AEBaseBlock) rh.getBlock(), x, y, z, rh, renderer );
break;
case EAST:
case WEST:
rh.setTexture( off, off, off, off, def, def );
renderer.uvRotateEast = 2;
renderer.uvRotateWest = 1;
renderer.uvRotateBottom = 2;
renderer.uvRotateTop = 1;
renderer.uvRotateSouth = 0;
renderer.uvRotateNorth = 0;
AEBaseBlock blk = (AEBaseBlock) rh.getBlock();
FlippableIcon ico = blk.getRendererInstance().getTexture( ForgeDirection.EAST );
ico.setFlip( false, true );
renderer.setRenderBounds( 0, 3 / 16.0, 3 / 16.0, 16 / 16.0, 13 / 16.0, 13 / 16.0 );
rh.renderBlockCurrentBounds( x, y, z, renderer );
Tessellator.instance.setBrightness( 15 << 20 | 15 << 4 );
FlippableIcon fpA = new FlippableIcon( firstIcon );
FlippableIcon fpB = new FlippableIcon( secondIcon );
fpA.setFlip( true, false );
fpB.setFlip( true, false );
Tessellator.instance.setColorOpaque_I( this.getCableColor().blackVariant );
rh.setTexture( firstOffset, firstOffset, firstOffset, firstOffset, firstIcon, fpA );
this.renderAllFaces( (AEBaseBlock) rh.getBlock(), x, y, z, rh, renderer );
Tessellator.instance.setColorOpaque_I( this.getCableColor().whiteVariant );
rh.setTexture( secondOffset, secondOffset, secondOffset, secondOffset, secondIcon, fpB );
this.renderAllFaces( (AEBaseBlock) rh.getBlock(), x, y, z, rh, renderer );
break;
case NORTH:
case SOUTH:
rh.setTexture( off, off, def, def, off, off );
renderer.uvRotateTop = 3;
renderer.uvRotateBottom = 3;
renderer.uvRotateNorth = 1;
renderer.uvRotateSouth = 2;
renderer.uvRotateWest = 1;
renderer.setRenderBounds( 3 / 16.0, 3 / 16.0, 0, 13 / 16.0, 13 / 16.0, 16 / 16.0 );
rh.renderBlockCurrentBounds( x, y, z, renderer );
Tessellator.instance.setBrightness( 15 << 20 | 15 << 4 );
Tessellator.instance.setColorOpaque_I( this.getCableColor().blackVariant );
rh.setTexture( firstOffset, firstOffset, firstIcon, firstIcon, firstOffset, firstOffset );
this.renderAllFaces( (AEBaseBlock) rh.getBlock(), x, y, z, rh, renderer );
Tessellator.instance.setColorOpaque_I( this.getCableColor().whiteVariant );
rh.setTexture( secondOffset, secondOffset, secondIcon, secondIcon, secondOffset, secondOffset );
this.renderAllFaces( (AEBaseBlock) rh.getBlock(), x, y, z, rh, renderer );
break;
default:
break;
}
}
renderer.uvRotateBottom = renderer.uvRotateEast = renderer.uvRotateNorth = renderer.uvRotateSouth = renderer.uvRotateTop = renderer.uvRotateWest = 0;
rh.setTexture( null );
return false;
}
private IIcon getDenseTexture(AEColor c)
private IIcon getDenseTexture( AEColor c )
{
switch (c)
switch ( c )
{
case Black:
return CableBusTextures.MEDense_Black.getIcon();
case Blue:
return CableBusTextures.MEDense_Blue.getIcon();
case Brown:
return CableBusTextures.MEDense_Brown.getIcon();
case Cyan:
return CableBusTextures.MEDense_Cyan.getIcon();
case Gray:
return CableBusTextures.MEDense_Gray.getIcon();
case Green:
return CableBusTextures.MEDense_Green.getIcon();
case LightBlue:
return CableBusTextures.MEDense_LightBlue.getIcon();
case LightGray:
return CableBusTextures.MEDense_LightGrey.getIcon();
case Lime:
return CableBusTextures.MEDense_Lime.getIcon();
case Magenta:
return CableBusTextures.MEDense_Magenta.getIcon();
case Orange:
return CableBusTextures.MEDense_Orange.getIcon();
case Pink:
return CableBusTextures.MEDense_Pink.getIcon();
case Purple:
return CableBusTextures.MEDense_Purple.getIcon();
case Red:
return CableBusTextures.MEDense_Red.getIcon();
case White:
return CableBusTextures.MEDense_White.getIcon();
case Yellow:
return CableBusTextures.MEDense_Yellow.getIcon();
default:
case Black:
return CableBusTextures.MEDense_Black.getIcon();
case Blue:
return CableBusTextures.MEDense_Blue.getIcon();
case Brown:
return CableBusTextures.MEDense_Brown.getIcon();
case Cyan:
return CableBusTextures.MEDense_Cyan.getIcon();
case Gray:
return CableBusTextures.MEDense_Gray.getIcon();
case Green:
return CableBusTextures.MEDense_Green.getIcon();
case LightBlue:
return CableBusTextures.MEDense_LightBlue.getIcon();
case LightGray:
return CableBusTextures.MEDense_LightGrey.getIcon();
case Lime:
return CableBusTextures.MEDense_Lime.getIcon();
case Magenta:
return CableBusTextures.MEDense_Magenta.getIcon();
case Orange:
return CableBusTextures.MEDense_Orange.getIcon();
case Pink:
return CableBusTextures.MEDense_Pink.getIcon();
case Purple:
return CableBusTextures.MEDense_Purple.getIcon();
case Red:
return CableBusTextures.MEDense_Red.getIcon();
case White:
return CableBusTextures.MEDense_White.getIcon();
case Yellow:
return CableBusTextures.MEDense_Yellow.getIcon();
default:
}
return this.is.getIconIndex();
}
private boolean isDense( ForgeDirection of )
{
TileEntity te = this.tile.getWorldObj().getTileEntity( this.tile.xCoord + of.offsetX, this.tile.yCoord + of.offsetY, this.tile.zCoord + of.offsetZ );
if ( te instanceof IGridHost )
{
AECableType t = ( (IGridHost) te ).getCableConnectionType( of.getOpposite() );
return t == AECableType.DENSE;
}
return false;
}
@MENetworkEventSubscribe
public void channelUpdated( MENetworkChannelsChanged c )
{
this.getHost().markForUpdate();
}
@MENetworkEventSubscribe
public void powerRender( MENetworkPowerStatusChange c )
{
this.getHost().markForUpdate();
}
}
@@ -53,7 +53,7 @@ public class PartQuartzFiber extends AEBasePart implements IEnergyGridProvider
final AENetworkProxy outerProxy = new AENetworkProxy( this, "outer", this.proxy.getMachineRepresentation(), true );
public PartQuartzFiber(ItemStack is) {
super( PartQuartzFiber.class, is );
super( is );
this.proxy.setIdlePowerUsage( 0 );
this.proxy.setFlags( GridFlags.CANNOT_CARRY );
this.outerProxy.setIdlePowerUsage( 0 );
@@ -31,9 +31,6 @@ import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import appeng.api.config.PowerUnits;
import appeng.api.config.TunnelType;
import appeng.core.AppEng;
import appeng.integration.IntegrationType;
import appeng.me.GridAccessException;
import appeng.me.cache.helpers.TunnelCollection;
import appeng.transformer.annotations.Integration.Interface;
@@ -45,17 +42,8 @@ import appeng.util.Platform;
public class PartP2PIC2Power extends PartP2PTunnel<PartP2PIC2Power> implements ic2.api.energy.tile.IEnergySink, ic2.api.energy.tile.IEnergySource
{
@Override
public TunnelType getTunnelType()
{
return TunnelType.IC2_POWER;
}
public PartP2PIC2Power(ItemStack is) {
super( is );
if ( !AppEng.instance.isIntegrationEnabled( IntegrationType.IC2 ) )
throw new RuntimeException( "IC2 Not installed!" );
}
// two packet buffering...
@@ -37,7 +37,6 @@ import cpw.mods.fml.relauncher.SideOnly;
import buildcraft.api.transport.IPipeConnection;
import buildcraft.api.transport.IPipeTile.PipeType;
import appeng.api.config.TunnelType;
import appeng.api.networking.IGridNode;
import appeng.api.networking.events.MENetworkBootingStatusChange;
import appeng.api.networking.events.MENetworkChannelsChanged;
@@ -64,12 +63,6 @@ import appeng.util.inv.WrapperMCISidedInventory;
public class PartP2PItems extends PartP2PTunnel<PartP2PItems> implements IPipeConnection, ISidedInventory, IGridTickable
{
@Override
public TunnelType getTunnelType()
{
return TunnelType.ITEM;
}
public PartP2PItems(ItemStack is) {
super( is );
}
@@ -32,7 +32,6 @@ import net.minecraft.world.World;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import appeng.api.config.TunnelType;
import appeng.api.networking.IGridNode;
import appeng.api.networking.events.MENetworkChannelsChanged;
import appeng.api.networking.events.MENetworkPowerStatusChange;
@@ -49,12 +48,6 @@ public class PartP2PLight extends PartP2PTunnel<PartP2PLight> implements IGridTi
super( is );
}
@Override
public TunnelType getTunnelType()
{
return TunnelType.LIGHT;
}
int lastValue = 0;
float opacity = -1;
@@ -36,7 +36,6 @@ import net.minecraftforge.fluids.IFluidHandler;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import appeng.api.config.TunnelType;
import appeng.me.GridAccessException;
public class PartP2PLiquids extends PartP2PTunnel<PartP2PLiquids> implements IFluidHandler
@@ -45,12 +44,6 @@ public class PartP2PLiquids extends PartP2PTunnel<PartP2PLiquids> implements IFl
private final static FluidTankInfo[] ACTIVE_TANK = new FluidTankInfo[] { new FluidTankInfo( null, 10000 ) };
private final static FluidTankInfo[] INACTIVE_TANK = new FluidTankInfo[] { new FluidTankInfo( null, 0 ) };
@Override
public TunnelType getTunnelType()
{
return TunnelType.FLUID;
}
public PartP2PLiquids(ItemStack is) {
super( is );
}
@@ -33,9 +33,6 @@ import cpw.mods.fml.relauncher.SideOnly;
import cofh.api.energy.IEnergyReceiver;
import appeng.api.config.PowerUnits;
import appeng.api.config.TunnelType;
import appeng.core.AppEng;
import appeng.integration.IntegrationType;
import appeng.integration.modules.helpers.NullRFHandler;
import appeng.me.GridAccessException;
import appeng.transformer.annotations.Integration.Interface;
@@ -57,17 +54,6 @@ public class PartP2PRFPower extends PartP2PTunnel<PartP2PRFPower> implements IEn
public PartP2PRFPower( ItemStack is )
{
super( is );
if ( !AppEng.instance.isIntegrationEnabled( IntegrationType.RF ) )
{
throw new RuntimeException( "RF Not installed!" );
}
}
@Override
public TunnelType getTunnelType()
{
return TunnelType.RF_POWER;
}
@Override
@@ -29,7 +29,6 @@ import net.minecraft.world.World;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import appeng.api.config.TunnelType;
import appeng.api.networking.events.MENetworkBootingStatusChange;
import appeng.api.networking.events.MENetworkChannelsChanged;
import appeng.api.networking.events.MENetworkEventSubscribe;
@@ -40,12 +39,6 @@ import appeng.util.Platform;
public class PartP2PRedstone extends PartP2PTunnel<PartP2PRedstone>
{
@Override
public TunnelType getTunnelType()
{
return TunnelType.REDSTONE;
}
public PartP2PRedstone(ItemStack is) {
super( is );
}
+210 -178
View File
@@ -18,11 +18,14 @@
package appeng.parts.p2p;
import java.util.ArrayList;
import java.util.Collection;
import net.minecraft.block.Block;
import net.minecraft.client.renderer.RenderBlocks;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.IIcon;
@@ -32,11 +35,14 @@ import net.minecraftforge.common.util.ForgeDirection;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import com.google.common.base.Optional;
import appeng.api.AEApi;
import appeng.api.config.Actionable;
import appeng.api.config.PowerMultiplier;
import appeng.api.config.PowerUnits;
import appeng.api.config.TunnelType;
import appeng.api.definitions.IParts;
import appeng.api.implementations.items.IMemoryCard;
import appeng.api.implementations.items.MemoryCardMessages;
import appeng.api.parts.IPart;
@@ -52,17 +58,158 @@ import appeng.me.cache.helpers.TunnelCollection;
import appeng.parts.PartBasicState;
import appeng.util.Platform;
public class PartP2PTunnel<T extends PartP2PTunnel> extends PartBasicState
{
public abstract class PartP2PTunnel<T extends PartP2PTunnel> extends PartBasicState
{
private final TunnelCollection type = new TunnelCollection<T>( null, this.getClass() );
public boolean output;
public long freq;
final TunnelCollection type = new TunnelCollection<T>( null, this.getClass() );
public PartP2PTunnel(ItemStack is) {
super( PartP2PTunnel.class, is );
if ( this.getClass() == PartP2PTunnel.class )
throw new RuntimeException( "Don't construct the root tunnel!" );
public PartP2PTunnel( ItemStack is )
{
super( is );
}
public TunnelCollection<T> getCollection( Collection<PartP2PTunnel> collection, Class<? extends PartP2PTunnel> c )
{
if ( this.type.matches( c ) )
{
this.type.setSource( collection );
return this.type;
}
return null;
}
public T getInput()
{
if ( this.freq == 0 )
return null;
PartP2PTunnel tunnel;
try
{
tunnel = this.proxy.getP2P().getInput( this.freq );
if ( this.getClass().isInstance( tunnel ) )
return (T) tunnel;
}
catch ( GridAccessException e )
{
// :P
}
return null;
}
public TunnelCollection<T> getOutputs() throws GridAccessException
{
if ( this.proxy.isActive() )
return (TunnelCollection<T>) this.proxy.getP2P().getOutputs( this.freq, this.getClass() );
return new TunnelCollection( new ArrayList(), this.getClass() );
}
@Override
@SideOnly( Side.CLIENT )
public void renderInventory( IPartRenderHelper rh, RenderBlocks renderer )
{
rh.setTexture( this.getTypeTexture() );
rh.setBounds( 2, 2, 14, 14, 14, 16 );
rh.renderInventoryBox( renderer );
rh.setTexture( CableBusTextures.PartTunnelSides.getIcon(), CableBusTextures.PartTunnelSides.getIcon(), CableBusTextures.BlockP2PTunnel2.getIcon(), this.is.getIconIndex(), CableBusTextures.PartTunnelSides.getIcon(), CableBusTextures.PartTunnelSides.getIcon() );
rh.setBounds( 2, 2, 14, 14, 14, 16 );
rh.renderInventoryBox( renderer );
}
/**
* @return If enabled it returns the icon of an AE quatz block, else vanilla quartz block icon
*/
protected IIcon getTypeTexture()
{
final Optional<Block> maybeBlock = AEApi.instance().definitions().blocks().quartz().maybeBlock();
if ( maybeBlock.isPresent() )
{
return maybeBlock.get().getIcon( 0, 0 );
}
else
{
return Blocks.quartz_block.getIcon( 0, 0 );
}
}
@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( this.getTypeTexture() );
rh.setBounds( 2, 2, 14, 14, 14, 16 );
rh.renderBlock( x, y, z, renderer );
rh.setTexture( CableBusTextures.PartTunnelSides.getIcon(), CableBusTextures.PartTunnelSides.getIcon(), CableBusTextures.BlockP2PTunnel2.getIcon(), this.is.getIconIndex(), CableBusTextures.PartTunnelSides.getIcon(), CableBusTextures.PartTunnelSides.getIcon() );
rh.setBounds( 2, 2, 14, 14, 14, 16 );
rh.renderBlock( x, y, z, renderer );
rh.setBounds( 3, 3, 13, 13, 13, 14 );
rh.renderBlock( x, y, z, renderer );
rh.setTexture( CableBusTextures.BlockP2PTunnel3.getIcon() );
rh.setBounds( 6, 5, 12, 10, 11, 13 );
rh.renderBlock( x, y, z, renderer );
rh.setBounds( 5, 6, 12, 11, 10, 13 );
rh.renderBlock( x, y, z, renderer );
this.renderLights( x, y, z, rh, renderer );
}
@Override
public ItemStack getItemStack( PartItemStack type )
{
if ( type == PartItemStack.World || type == PartItemStack.Network || type == PartItemStack.Wrench || type == PartItemStack.Pick )
return super.getItemStack( type );
final Optional<ItemStack> maybeMEStack = AEApi.instance().definitions().parts().p2PTunnelME().maybeStack( 1 );
if ( maybeMEStack.isPresent() )
{
return maybeMEStack.get();
}
return super.getItemStack( type );
}
@Override
public void readFromNBT( NBTTagCompound data )
{
super.readFromNBT( data );
this.output = data.getBoolean( "output" );
this.freq = data.getLong( "freq" );
}
@Override
public void writeToNBT( NBTTagCompound data )
{
super.writeToNBT( data );
data.setBoolean( "output", this.output );
data.setLong( "freq", this.freq );
}
@Override
public void getBoxes( IPartCollisionHelper bch )
{
bch.addBox( 5, 5, 12, 11, 11, 13 );
bch.addBox( 3, 3, 13, 13, 13, 14 );
bch.addBox( 2, 2, 14, 14, 14, 16 );
}
@Override
public int cableConnectionRenderTo()
{
return 1;
}
@Override
@@ -72,23 +219,7 @@ public class PartP2PTunnel<T extends PartP2PTunnel> extends PartBasicState
}
@Override
public void writeToNBT(NBTTagCompound data)
{
super.writeToNBT( data );
data.setBoolean( "output", this.output );
data.setLong( "freq", this.freq );
}
@Override
public void readFromNBT(NBTTagCompound data)
{
super.readFromNBT( data );
this.output = data.getBoolean( "output" );
this.freq = data.getLong( "freq" );
}
@Override
public boolean onPartActivate(EntityPlayer player, Vec3 pos)
public boolean onPartActivate( EntityPlayer player, Vec3 pos )
{
ItemStack is = player.inventory.getCurrentItem();
@@ -108,7 +239,7 @@ public class PartP2PTunnel<T extends PartP2PTunnel> extends PartBasicState
{
if ( newType.getItem() instanceof IPartItem )
{
IPart testPart = ((IPartItem) newType.getItem()).createPartFromItemStack( newType );
IPart testPart = ( (IPartItem) newType.getItem() ).createPartFromItemStack( newType );
if ( testPart instanceof PartP2PTunnel )
{
this.getHost().removePart( this.side, true );
@@ -125,7 +256,7 @@ public class PartP2PTunnel<T extends PartP2PTunnel> extends PartBasicState
P2PCache p2p = newTunnel.proxy.getP2P();
p2p.updateFreq( newTunnel, freq );
}
catch (GridAccessException e)
catch ( GridAccessException e )
{
// :P
}
@@ -144,43 +275,61 @@ public class PartP2PTunnel<T extends PartP2PTunnel> extends PartBasicState
{
ItemStack newType = null;
switch (tt)
final IParts parts = AEApi.instance().definitions().parts();
switch ( tt )
{
case LIGHT:
newType = AEApi.instance().parts().partP2PTunnelLight.stack( 1 );
break;
case LIGHT:
for ( ItemStack stack : parts.p2PTunnelLight().maybeStack( 1 ).asSet() )
{
newType = stack;
}
break;
case RF_POWER:
newType = AEApi.instance().parts().partP2PTunnelRF.stack( 1 );
break;
case RF_POWER:
for ( ItemStack stack : parts.p2PTunnelRF().maybeStack( 1 ).asSet() )
{
newType = stack;
}
break;
case BC_POWER:
newType = AEApi.instance().parts().partP2PTunnelMJ.stack( 1 );
break;
case FLUID:
for ( ItemStack stack : parts.p2PTunnelLiquids().maybeStack( 1 ).asSet() )
{
newType = stack;
}
break;
case FLUID:
newType = AEApi.instance().parts().partP2PTunnelLiquids.stack( 1 );
break;
case IC2_POWER:
for ( ItemStack stack : parts.p2PTunnelEU().maybeStack( 1 ).asSet() )
{
newType = stack;
}
break;
case IC2_POWER:
newType = AEApi.instance().parts().partP2PTunnelEU.stack( 1 );
break;
case ITEM:
for ( ItemStack stack : parts.p2PTunnelItems().maybeStack( 1 ).asSet() )
{
newType = stack;
}
break;
case ITEM:
newType = AEApi.instance().parts().partP2PTunnelItems.stack( 1 );
break;
case ME:
for ( ItemStack stack : parts.p2PTunnelME().maybeStack( 1 ).asSet() )
{
newType = stack;
}
break;
case ME:
newType = AEApi.instance().parts().partP2PTunnelME.stack( 1 );
break;
case REDSTONE:
newType = AEApi.instance().parts().partP2PTunnelRedstone.stack( 1 );
break;
default:
break;
case REDSTONE:
for ( ItemStack stack : parts.p2PTunnelRedstone().maybeStack( 1 ).asSet() )
{
newType = stack;
}
break;
default:
break;
}
if ( newType != null && !Platform.isSameItem( newType, this.is ) )
@@ -203,7 +352,7 @@ public class PartP2PTunnel<T extends PartP2PTunnel> extends PartBasicState
P2PCache p2p = newTunnel.proxy.getP2P();
p2p.updateFreq( newTunnel, myFreq );
}
catch (GridAccessException e)
catch ( GridAccessException e )
{
// :P
}
@@ -217,13 +366,8 @@ public class PartP2PTunnel<T extends PartP2PTunnel> extends PartBasicState
return false;
}
public TunnelType getTunnelType()
{
return null;
}
@Override
public boolean onPartShiftActivate(EntityPlayer player, Vec3 pos)
public boolean onPartShiftActivate( EntityPlayer player, Vec3 pos )
{
ItemStack is = player.inventory.getCurrentItem();
if ( is != null && is.getItem() instanceof IMemoryCard )
@@ -242,7 +386,7 @@ public class PartP2PTunnel<T extends PartP2PTunnel> extends PartBasicState
{
this.proxy.getP2P().updateFreq( this, newFreq );
}
catch (GridAccessException e)
catch ( GridAccessException e )
{
// :P
}
@@ -266,116 +410,19 @@ public class PartP2PTunnel<T extends PartP2PTunnel> extends PartBasicState
{
}
@Override
public ItemStack getItemStack(PartItemStack type)
{
if ( type == PartItemStack.World || type == PartItemStack.Network || type == PartItemStack.Wrench || type == PartItemStack.Pick )
return super.getItemStack( type );
return AEApi.instance().parts().partP2PTunnelME.stack( 1 );
}
public TunnelCollection<T> getCollection(Collection<PartP2PTunnel> collection, Class<? extends PartP2PTunnel> c)
{
if ( this.type.matches( c ) )
{
this.type.setSource( collection );
return this.type;
}
return null;
}
public T getInput()
{
if ( this.freq == 0 )
return null;
PartP2PTunnel tunnel;
try
{
tunnel = this.proxy.getP2P().getInput( this.freq );
if ( this.getClass().isInstance( tunnel ) )
return (T) tunnel;
}
catch (GridAccessException e)
{
// :P
}
return null;
}
public TunnelCollection<T> getOutputs() throws GridAccessException
{
if ( this.proxy.isActive() )
return (TunnelCollection<T>) this.proxy.getP2P().getOutputs( this.freq, this.getClass() );
return new TunnelCollection( new ArrayList(), this.getClass() );
}
public void onTunnelNetworkChange()
{
}
@Override
@SideOnly(Side.CLIENT)
public void renderInventory(IPartRenderHelper rh, RenderBlocks renderer)
{
rh.setTexture( this.getTypeTexture() );
rh.setBounds( 2, 2, 14, 14, 14, 16 );
rh.renderInventoryBox( renderer );
rh.setTexture( CableBusTextures.PartTunnelSides.getIcon(), CableBusTextures.PartTunnelSides.getIcon(), CableBusTextures.BlockP2PTunnel2.getIcon(),
this.is.getIconIndex(), CableBusTextures.PartTunnelSides.getIcon(), CableBusTextures.PartTunnelSides.getIcon() );
rh.setBounds( 2, 2, 14, 14, 14, 16 );
rh.renderInventoryBox( renderer );
}
protected IIcon getTypeTexture()
{
return AEApi.instance().blocks().blockQuartz.block().getIcon( 0, 0 );
}
@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( this.getTypeTexture() );
rh.setBounds( 2, 2, 14, 14, 14, 16 );
rh.renderBlock( x, y, z, renderer );
rh.setTexture( CableBusTextures.PartTunnelSides.getIcon(), CableBusTextures.PartTunnelSides.getIcon(), CableBusTextures.BlockP2PTunnel2.getIcon(),
this.is.getIconIndex(), CableBusTextures.PartTunnelSides.getIcon(), CableBusTextures.PartTunnelSides.getIcon() );
rh.setBounds( 2, 2, 14, 14, 14, 16 );
rh.renderBlock( x, y, z, renderer );
rh.setBounds( 3, 3, 13, 13, 13, 14 );
rh.renderBlock( x, y, z, renderer );
rh.setTexture( CableBusTextures.BlockP2PTunnel3.getIcon() );
rh.setBounds( 6, 5, 12, 10, 11, 13 );
rh.renderBlock( x, y, z, renderer );
rh.setBounds( 5, 6, 12, 11, 10, 13 );
rh.renderBlock( x, y, z, renderer );
this.renderLights( x, y, z, rh, renderer );
}
@Override
@SideOnly(Side.CLIENT)
@SideOnly( Side.CLIENT )
public IIcon getBreakingTexture()
{
return CableBusTextures.BlockP2PTunnel2.getIcon();
}
protected void QueueTunnelDrain(PowerUnits unit, double f)
protected void QueueTunnelDrain( PowerUnits unit, double f )
{
double ae_to_tax = unit.convertTo( PowerUnits.AE, f * AEConfig.TUNNEL_POWER_LOSS );
@@ -383,24 +430,9 @@ public class PartP2PTunnel<T extends PartP2PTunnel> extends PartBasicState
{
this.proxy.getEnergy().extractAEPower( ae_to_tax, Actionable.MODULATE, PowerMultiplier.ONE );
}
catch (GridAccessException e)
catch ( GridAccessException e )
{
// :P
}
}
@Override
public void getBoxes(IPartCollisionHelper bch)
{
bch.addBox( 5, 5, 12, 11, 11, 13 );
bch.addBox( 3, 3, 13, 13, 13, 14 );
bch.addBox( 2, 2, 14, 14, 14, 16 );
}
@Override
public int cableConnectionRenderTo()
{
return 1;
}
}
@@ -30,7 +30,6 @@ import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.util.ForgeDirection;
import appeng.api.AEApi;
import appeng.api.config.TunnelType;
import appeng.api.exceptions.FailedConnection;
import appeng.api.networking.GridFlags;
import appeng.api.networking.IGridNode;
@@ -51,12 +50,6 @@ import appeng.me.helpers.AENetworkProxy;
public class PartP2PTunnelME extends PartP2PTunnel<PartP2PTunnelME> implements IGridTickable
{
@Override
public TunnelType getTunnelType()
{
return TunnelType.ME;
}
final AENetworkProxy outerProxy = new AENetworkProxy( this, "outer", null, true );
public final Connections connection = new Connections( this );
@@ -33,16 +33,20 @@ import appeng.api.networking.security.PlayerSource;
import appeng.api.storage.IMEMonitor;
import appeng.api.storage.data.IAEItemStack;
import appeng.client.texture.CableBusTextures;
import appeng.helpers.Reflected;
import appeng.me.GridAccessException;
import appeng.util.InventoryAdaptor;
import appeng.util.Platform;
import appeng.util.item.AEItemStack;
public class PartConversionMonitor extends PartStorageMonitor
{
@Reflected
public PartConversionMonitor( ItemStack is )
{
super( is );
public PartConversionMonitor(ItemStack is) {
super( PartConversionMonitor.class, is );
this.frontBright = CableBusTextures.PartConversionMonitor_Bright;
this.frontColored = CableBusTextures.PartConversionMonitor_Colored;
this.frontDark = CableBusTextures.PartConversionMonitor_Dark;
@@ -50,7 +54,7 @@ public class PartConversionMonitor extends PartStorageMonitor
}
@Override
public boolean onPartShiftActivate(EntityPlayer player, Vec3 pos)
public boolean onPartShiftActivate( EntityPlayer player, Vec3 pos )
{
if ( Platform.isClient() )
return true;
@@ -67,7 +71,7 @@ public class PartConversionMonitor extends PartStorageMonitor
if ( item == null && this.getDisplayed() != null )
{
ModeB = true;
item = ((IAEItemStack) this.getDisplayed()).getItemStack();
item = ( (IAEItemStack) this.getDisplayed() ).getItemStack();
}
if ( item != null )
@@ -83,7 +87,7 @@ public class PartConversionMonitor extends PartStorageMonitor
if ( ModeB )
{
for (int x = 0; x < player.inventory.getSizeInventory(); x++)
for ( int x = 0; x < player.inventory.getSizeInventory(); x++ )
{
ItemStack targetStack = player.inventory.getStackInSlot( x );
if ( input.equals( targetStack ) )
@@ -101,7 +105,7 @@ public class PartConversionMonitor extends PartStorageMonitor
player.inventory.setInventorySlotContents( player.inventory.currentItem, failedToInsert == null ? null : failedToInsert.getItemStack() );
}
}
catch (GridAccessException e)
catch ( GridAccessException e )
{
// :P
}
@@ -110,7 +114,7 @@ public class PartConversionMonitor extends PartStorageMonitor
}
@Override
protected void extractItem(EntityPlayer player)
protected void extractItem( EntityPlayer player )
{
IAEItemStack input = (IAEItemStack) this.getDisplayed();
if ( input != null )
@@ -143,11 +147,10 @@ public class PartConversionMonitor extends PartStorageMonitor
player.openContainer.detectAndSendChanges();
}
}
catch (GridAccessException e)
catch ( GridAccessException e )
{
// :P
}
}
}
}
@@ -18,6 +18,7 @@
package appeng.parts.reporting;
import java.util.List;
import net.minecraft.entity.player.EntityPlayer;
@@ -27,44 +28,48 @@ import net.minecraft.nbt.NBTTagCompound;
import appeng.client.texture.CableBusTextures;
import appeng.core.sync.GuiBridge;
import appeng.helpers.Reflected;
import appeng.tile.inventory.AppEngInternalInventory;
import appeng.tile.inventory.InvOperation;
public class PartCraftingTerminal extends PartTerminal
{
private final AppEngInternalInventory craftingGrid = new AppEngInternalInventory( this, 9 );
final AppEngInternalInventory craftingGrid = new AppEngInternalInventory( this, 9 );
@Override
public void writeToNBT(NBTTagCompound data)
@Reflected
public PartCraftingTerminal( ItemStack is )
{
super.writeToNBT( data );
this.craftingGrid.writeToNBT( data, "craftingGrid" );
super( is );
this.frontBright = CableBusTextures.PartCraftingTerm_Bright;
this.frontColored = CableBusTextures.PartCraftingTerm_Colored;
this.frontDark = CableBusTextures.PartCraftingTerm_Dark;
// frontSolid = CableBusTextures.PartCraftingTerm_Solid;
}
@Override
public void readFromNBT(NBTTagCompound data)
public void getDrops( List<ItemStack> drops, boolean wrenched )
{
super.getDrops( drops, wrenched );
for ( ItemStack is : this.craftingGrid )
if ( is != null )
drops.add( is );
}
@Override
public void readFromNBT( NBTTagCompound data )
{
super.readFromNBT( data );
this.craftingGrid.readFromNBT( data, "craftingGrid" );
}
@Override
public void getDrops(List<ItemStack> drops, boolean wrenched)
public void writeToNBT( NBTTagCompound data )
{
super.getDrops( drops, wrenched );
for (ItemStack is : this.craftingGrid)
if ( is != null )
drops.add( is );
}
public PartCraftingTerminal(ItemStack is) {
super( PartCraftingTerminal.class, is );
this.frontBright = CableBusTextures.PartCraftingTerm_Bright;
this.frontColored = CableBusTextures.PartCraftingTerm_Colored;
this.frontDark = CableBusTextures.PartCraftingTerm_Dark;
// frontSolid = CableBusTextures.PartCraftingTerm_Solid;
super.writeToNBT( data );
this.craftingGrid.writeToNBT( data, "craftingGrid" );
}
@Override
@@ -80,23 +85,22 @@ public class PartCraftingTerminal extends PartTerminal
z = this.tile.zCoord;
}
if( GuiBridge.GUI_CRAFTING_TERMINAL.hasPermissions( this.getHost().getTile(), x, y, z, this.side, p ) )
if ( GuiBridge.GUI_CRAFTING_TERMINAL.hasPermissions( this.getHost().getTile(), x, y, z, this.side, p ) )
return GuiBridge.GUI_CRAFTING_TERMINAL;
return GuiBridge.GUI_ME;
}
@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 )
{
this.host.markForSave();
}
@Override
public IInventory getInventoryByName(String name)
public IInventory getInventoryByName( String name )
{
if ( name.equals( "crafting" ) )
return this.craftingGrid;
return super.getInventoryByName( name );
}
}
@@ -18,6 +18,7 @@
package appeng.parts.reporting;
import net.minecraft.client.renderer.RenderBlocks;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.item.ItemStack;
@@ -29,22 +30,22 @@ import cpw.mods.fml.relauncher.SideOnly;
import appeng.api.parts.IPartRenderHelper;
import appeng.client.texture.CableBusTextures;
public class PartDarkMonitor extends PartMonitor
{
public PartDarkMonitor(ItemStack is) {
super( PartDarkMonitor.class, is, false );
public PartDarkMonitor( ItemStack is )
{
super( is, false );
this.notLightSource = false;
}
@Override
@SideOnly(Side.CLIENT)
public void renderInventory(IPartRenderHelper rh, RenderBlocks renderer)
@SideOnly( Side.CLIENT )
public void renderInventory( IPartRenderHelper rh, RenderBlocks renderer )
{
rh.setBounds( 2, 2, 14, 14, 14, 16 );
rh.setTexture( CableBusTextures.PartMonitorSides.getIcon(), CableBusTextures.PartMonitorSides.getIcon(), CableBusTextures.PartMonitorBack.getIcon(),
this.is.getIconIndex(), CableBusTextures.PartMonitorSides.getIcon(), CableBusTextures.PartMonitorSides.getIcon() );
rh.setTexture( CableBusTextures.PartMonitorSides.getIcon(), CableBusTextures.PartMonitorSides.getIcon(), CableBusTextures.PartMonitorBack.getIcon(), this.is.getIconIndex(), CableBusTextures.PartMonitorSides.getIcon(), CableBusTextures.PartMonitorSides.getIcon() );
rh.renderInventoryBox( renderer );
rh.setInvColor( this.getColor().mediumVariant );
@@ -55,11 +56,10 @@ public class PartDarkMonitor extends PartMonitor
}
@Override
@SideOnly(Side.CLIENT)
public void renderStatic(int x, int y, int z, IPartRenderHelper rh, RenderBlocks renderer)
@SideOnly( Side.CLIENT )
public void renderStatic( int x, int y, int z, IPartRenderHelper rh, RenderBlocks renderer )
{
rh.setTexture( CableBusTextures.PartMonitorSides.getIcon(), CableBusTextures.PartMonitorSides.getIcon(), CableBusTextures.PartMonitorBack.getIcon(),
this.is.getIconIndex(), CableBusTextures.PartMonitorSides.getIcon(), CableBusTextures.PartMonitorSides.getIcon() );
rh.setTexture( CableBusTextures.PartMonitorSides.getIcon(), CableBusTextures.PartMonitorSides.getIcon(), CableBusTextures.PartMonitorBack.getIcon(), this.is.getIconIndex(), CableBusTextures.PartMonitorSides.getIcon(), CableBusTextures.PartMonitorSides.getIcon() );
rh.setBounds( 2, 2, 14, 14, 14, 16 );
rh.renderBlock( x, y, z, renderer );
@@ -76,5 +76,4 @@ public class PartDarkMonitor extends PartMonitor
rh.setBounds( 4, 4, 13, 12, 12, 14 );
rh.renderBlock( x, y, z, renderer );
}
}
@@ -18,6 +18,7 @@
package appeng.parts.reporting;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.util.Vec3;
@@ -26,18 +27,20 @@ import appeng.client.texture.CableBusTextures;
import appeng.core.sync.GuiBridge;
import appeng.util.Platform;
public class PartInterfaceTerminal extends PartMonitor
{
public PartInterfaceTerminal( ItemStack is )
{
super( is, true );
public PartInterfaceTerminal(ItemStack is) {
super( PartInterfaceTerminal.class, is, true );
this.frontBright = CableBusTextures.PartInterfaceTerm_Bright;
this.frontColored = CableBusTextures.PartInterfaceTerm_Colored;
this.frontDark = CableBusTextures.PartInterfaceTerm_Dark;
}
@Override
public boolean onPartActivate(EntityPlayer player, Vec3 pos)
public boolean onPartActivate( EntityPlayer player, Vec3 pos )
{
if ( !super.onPartActivate( player, pos ) )
{
@@ -221,13 +221,13 @@ public class PartMonitor extends AEBasePart implements IPartMonitor, IPowerChann
return false;
}
}
public PartMonitor(ItemStack is) {
this( PartMonitor.class, is, false );
this( is, false );
}
protected PartMonitor(Class c, ItemStack is, boolean requireChannel) {
super( c, is );
protected PartMonitor(ItemStack is, boolean requireChannel) {
super( is );
if ( requireChannel )
{
@@ -18,6 +18,7 @@
package appeng.parts.reporting;
import java.util.List;
import net.minecraft.entity.player.EntityPlayer;
@@ -30,20 +31,39 @@ import appeng.api.networking.crafting.ICraftingPatternDetails;
import appeng.api.storage.data.IAEItemStack;
import appeng.client.texture.CableBusTextures;
import appeng.core.sync.GuiBridge;
import appeng.helpers.Reflected;
import appeng.tile.inventory.AppEngInternalInventory;
import appeng.tile.inventory.InvOperation;
public class PartPatternTerminal extends PartTerminal
{
final AppEngInternalInventory crafting = new AppEngInternalInventory( this, 9 );
final AppEngInternalInventory output = new AppEngInternalInventory( this, 3 );
final AppEngInternalInventory pattern = new AppEngInternalInventory( this, 2 );
private final AppEngInternalInventory crafting = new AppEngInternalInventory( this, 9 );
private final AppEngInternalInventory output = new AppEngInternalInventory( this, 3 );
private final AppEngInternalInventory pattern = new AppEngInternalInventory( this, 2 );
private boolean craftingMode = true;
@Reflected
public PartPatternTerminal( ItemStack is )
{
super( is );
this.frontBright = CableBusTextures.PartPatternTerm_Bright;
this.frontColored = CableBusTextures.PartPatternTerm_Colored;
this.frontDark = CableBusTextures.PartPatternTerm_Dark;
}
@Override
public void writeToNBT(NBTTagCompound data)
public void getDrops( List<ItemStack> drops, boolean wrenched )
{
for ( ItemStack is : this.pattern )
if ( is != null )
drops.add( is );
}
@Override
public void writeToNBT( NBTTagCompound data )
{
super.writeToNBT( data );
data.setBoolean( "craftingMode", this.craftingMode );
@@ -53,7 +73,7 @@ public class PartPatternTerminal extends PartTerminal
}
@Override
public void readFromNBT(NBTTagCompound data)
public void readFromNBT( NBTTagCompound data )
{
super.readFromNBT( data );
this.setCraftingRecipe( data.getBoolean( "craftingMode" ) );
@@ -62,21 +82,6 @@ public class PartPatternTerminal extends PartTerminal
this.crafting.readFromNBT( data, "craftingGrid" );
}
@Override
public void getDrops(List<ItemStack> drops, boolean wrenched)
{
for (ItemStack is : this.pattern)
if ( is != null )
drops.add( is );
}
public PartPatternTerminal(ItemStack is) {
super( PartPatternTerminal.class, is );
this.frontBright = CableBusTextures.PartPatternTerm_Bright;
this.frontColored = CableBusTextures.PartPatternTerm_Colored;
this.frontDark = CableBusTextures.PartPatternTerm_Dark;
}
@Override
public GuiBridge getGui( EntityPlayer p )
{
@@ -90,28 +95,13 @@ public class PartPatternTerminal extends PartTerminal
z = this.tile.zCoord;
}
if( GuiBridge.GUI_PATTERN_TERMINAL.hasPermissions( this.getHost().getTile(), x, y, z, this.side, p ) )
if ( GuiBridge.GUI_PATTERN_TERMINAL.hasPermissions( this.getHost().getTile(), x, y, z, this.side, p ) )
return GuiBridge.GUI_PATTERN_TERMINAL;
return GuiBridge.GUI_ME;
}
@Override
public IInventory getInventoryByName(String name)
{
if ( name.equals( "crafting" ) )
return this.crafting;
if ( name.equals( "output" ) )
return this.output;
if ( name.equals( "pattern" ) )
return this.pattern;
return super.getInventoryByName( name );
}
@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.pattern && slot == 1 )
{
@@ -124,13 +114,13 @@ public class PartPatternTerminal extends PartTerminal
{
this.setCraftingRecipe( details.isCraftable() );
for (int x = 0; x < this.crafting.getSizeInventory() && x < details.getInputs().length; x++)
for ( int x = 0; x < this.crafting.getSizeInventory() && x < details.getInputs().length; x++ )
{
IAEItemStack item = details.getInputs()[x];
this.crafting.setInventorySlotContents( x, item == null ? null : item.getItemStack() );
}
for (int x = 0; x < this.output.getSizeInventory() && x < details.getOutputs().length; x++)
for ( int x = 0; x < this.output.getSizeInventory() && x < details.getOutputs().length; x++ )
{
IAEItemStack item = details.getOutputs()[x];
this.output.setInventorySlotContents( x, item == null ? null : item.getItemStack() );
@@ -146,22 +136,11 @@ public class PartPatternTerminal extends PartTerminal
this.host.markForSave();
}
public boolean isCraftingRecipe()
{
return this.craftingMode;
}
public void setCraftingRecipe(boolean craftingMode)
{
this.craftingMode = craftingMode;
this.fixCraftingRecipes();
}
private void fixCraftingRecipes()
{
if ( this.craftingMode )
{
for (int x = 0; x < this.crafting.getSizeInventory(); x++)
for ( int x = 0; x < this.crafting.getSizeInventory(); x++ )
{
ItemStack is = this.crafting.getStackInSlot( x );
if ( is != null )
@@ -169,4 +148,30 @@ public class PartPatternTerminal extends PartTerminal
}
}
}
public boolean isCraftingRecipe()
{
return this.craftingMode;
}
public void setCraftingRecipe( boolean craftingMode )
{
this.craftingMode = craftingMode;
this.fixCraftingRecipes();
}
@Override
public IInventory getInventoryByName( String name )
{
if ( name.equals( "crafting" ) )
return this.crafting;
if ( name.equals( "output" ) )
return this.output;
if ( name.equals( "pattern" ) )
return this.pattern;
return super.getInventoryByName( name );
}
}
@@ -18,6 +18,7 @@
package appeng.parts.reporting;
import net.minecraft.client.renderer.RenderBlocks;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.item.ItemStack;
@@ -29,28 +30,28 @@ import cpw.mods.fml.relauncher.SideOnly;
import appeng.api.parts.IPartRenderHelper;
import appeng.client.texture.CableBusTextures;
public class PartSemiDarkMonitor extends PartMonitor
{
public PartSemiDarkMonitor( ItemStack is )
{
super( is, false );
public PartSemiDarkMonitor(ItemStack is) {
super( PartSemiDarkMonitor.class, is,false );
this.notLightSource = false;
}
@Override
@SideOnly(Side.CLIENT)
public void renderInventory(IPartRenderHelper rh, RenderBlocks renderer)
@SideOnly( Side.CLIENT )
public void renderInventory( IPartRenderHelper rh, RenderBlocks renderer )
{
rh.setBounds( 2, 2, 14, 14, 14, 16 );
rh.setTexture( CableBusTextures.PartMonitorSides.getIcon(), CableBusTextures.PartMonitorSides.getIcon(), CableBusTextures.PartMonitorBack.getIcon(),
this.is.getIconIndex(), CableBusTextures.PartMonitorSides.getIcon(), CableBusTextures.PartMonitorSides.getIcon() );
rh.setTexture( CableBusTextures.PartMonitorSides.getIcon(), CableBusTextures.PartMonitorSides.getIcon(), CableBusTextures.PartMonitorBack.getIcon(), this.is.getIconIndex(), CableBusTextures.PartMonitorSides.getIcon(), CableBusTextures.PartMonitorSides.getIcon() );
rh.renderInventoryBox( renderer );
int light = this.getColor().whiteVariant;
int dark = this.getColor().mediumVariant;
rh.setInvColor( (((((light >> 16) & 0xff) + ((dark >> 16) & 0xff)) / 2) << 16) | (((((light >> 8) & 0xff) + ((dark >> 8) & 0xff)) / 2) << 8)
| ((((light) & 0xff) + ((dark) & 0xff)) / 2) );
rh.setInvColor( ( ( ( ( ( light >> 16 ) & 0xff ) + ( ( dark >> 16 ) & 0xff ) ) / 2 ) << 16 ) | ( ( ( ( ( light >> 8 ) & 0xff ) + ( ( dark >> 8 ) & 0xff ) ) / 2 ) << 8 ) | ( ( ( ( light ) & 0xff ) + ( ( dark ) & 0xff ) ) / 2 ) );
rh.renderInventoryFace( this.frontBright.getIcon(), ForgeDirection.SOUTH, renderer );
rh.setBounds( 4, 4, 13, 12, 12, 14 );
@@ -58,11 +59,10 @@ public class PartSemiDarkMonitor extends PartMonitor
}
@Override
@SideOnly(Side.CLIENT)
public void renderStatic(int x, int y, int z, IPartRenderHelper rh, RenderBlocks renderer)
@SideOnly( Side.CLIENT )
public void renderStatic( int x, int y, int z, IPartRenderHelper rh, RenderBlocks renderer )
{
rh.setTexture( CableBusTextures.PartMonitorSides.getIcon(), CableBusTextures.PartMonitorSides.getIcon(), CableBusTextures.PartMonitorBack.getIcon(),
this.is.getIconIndex(), CableBusTextures.PartMonitorSides.getIcon(), CableBusTextures.PartMonitorSides.getIcon() );
rh.setTexture( CableBusTextures.PartMonitorSides.getIcon(), CableBusTextures.PartMonitorSides.getIcon(), CableBusTextures.PartMonitorBack.getIcon(), this.is.getIconIndex(), CableBusTextures.PartMonitorSides.getIcon(), CableBusTextures.PartMonitorSides.getIcon() );
rh.setBounds( 2, 2, 14, 14, 14, 16 );
rh.renderBlock( x, y, z, renderer );
@@ -75,12 +75,10 @@ public class PartSemiDarkMonitor extends PartMonitor
int light = this.getColor().whiteVariant;
int dark = this.getColor().mediumVariant;
Tessellator.instance.setColorOpaque( (((light >> 16) & 0xff) + ((dark >> 16) & 0xff)) / 2, (((light >> 8) & 0xff) + ((dark >> 8) & 0xff)) / 2,
(((light) & 0xff) + ((dark) & 0xff)) / 2 );
Tessellator.instance.setColorOpaque( ( ( ( light >> 16 ) & 0xff ) + ( ( dark >> 16 ) & 0xff ) ) / 2, ( ( ( light >> 8 ) & 0xff ) + ( ( dark >> 8 ) & 0xff ) ) / 2, ( ( ( light ) & 0xff ) + ( ( dark ) & 0xff ) ) / 2 );
rh.renderFace( x, y, z, this.frontBright.getIcon(), ForgeDirection.SOUTH, renderer );
rh.setBounds( 4, 4, 13, 12, 12, 14 );
rh.renderBlock( x, y, z, renderer );
}
}
@@ -57,18 +57,36 @@ import appeng.client.ClientHelper;
import appeng.client.texture.CableBusTextures;
import appeng.core.AELog;
import appeng.core.localization.PlayerMessages;
import appeng.helpers.Reflected;
import appeng.me.GridAccessException;
import appeng.util.Platform;
import appeng.util.item.AEItemStack;
public class PartStorageMonitor extends PartMonitor implements IPartStorageMonitor, IStackWatcherHost
{
IAEItemStack configuredItem;
boolean isLocked;
IStackWatcher myWatcher;
@SideOnly( Side.CLIENT )
private boolean updateList;
@SideOnly( Side.CLIENT )
private Integer dspList;
@Reflected
public PartStorageMonitor( ItemStack is )
{
super( is, true );
this.frontBright = CableBusTextures.PartStorageMonitor_Bright;
this.frontColored = CableBusTextures.PartStorageMonitor_Colored;
this.frontDark = CableBusTextures.PartStorageMonitor_Dark;
// frontSolid = CableBusTextures.PartStorageMonitor_Solid;
}
@Override
public void writeToNBT(NBTTagCompound data)
public void writeToNBT( NBTTagCompound data )
{
super.writeToNBT( data );
@@ -82,7 +100,7 @@ public class PartStorageMonitor extends PartMonitor implements IPartStorageMonit
}
@Override
public void readFromNBT(NBTTagCompound data)
public void readFromNBT( NBTTagCompound data )
{
super.readFromNBT( data );
@@ -93,7 +111,39 @@ public class PartStorageMonitor extends PartMonitor implements IPartStorageMonit
}
@Override
public void writeToStream(ByteBuf data) throws IOException
public boolean onPartActivate( EntityPlayer player, Vec3 pos )
{
if ( Platform.isClient() )
return true;
if ( !this.proxy.isActive() )
return false;
if ( !Platform.hasPermissions( this.getLocation(), player ) )
return false;
TileEntity te = this.tile;
ItemStack eq = player.getCurrentEquippedItem();
if ( Platform.isWrench( player, eq, te.xCoord, te.yCoord, te.zCoord ) )
{
this.isLocked = !this.isLocked;
player.addChatMessage( ( this.isLocked ? PlayerMessages.isNowLocked : PlayerMessages.isNowUnlocked ).get() );
this.getHost().markForUpdate();
}
else if ( !this.isLocked )
{
this.configuredItem = AEItemStack.create( eq );
this.configureWatchers();
this.getHost().markForUpdate();
}
else
this.extractItem( player );
return true;
}
@Override
public void writeToStream( ByteBuf data ) throws IOException
{
super.writeToStream( data );
@@ -105,7 +155,7 @@ public class PartStorageMonitor extends PartMonitor implements IPartStorageMonit
}
@Override
public boolean readFromStream(ByteBuf data) throws IOException
public boolean readFromStream( ByteBuf data ) throws IOException
{
boolean stuff = super.readFromStream( data );
@@ -122,69 +172,47 @@ public class PartStorageMonitor extends PartMonitor implements IPartStorageMonit
return stuff;
}
@Override
public boolean onPartActivate(EntityPlayer player, Vec3 pos)
// update the system...
public void configureWatchers()
{
if ( Platform.isClient() )
return true;
if ( this.myWatcher != null )
this.myWatcher.clear();
if ( !this.proxy.isActive() )
return false;
if ( !Platform.hasPermissions( this.getLocation(), player ) )
return false;
TileEntity te = this.tile;
ItemStack eq = player.getCurrentEquippedItem();
if ( Platform.isWrench( player, eq, te.xCoord, te.yCoord, te.zCoord ) )
try
{
this.isLocked = !this.isLocked;
player.addChatMessage( (this.isLocked ? PlayerMessages.isNowLocked : PlayerMessages.isNowUnlocked).get() );
this.getHost().markForUpdate();
if ( this.configuredItem != null )
{
if ( this.myWatcher != null )
this.myWatcher.add( this.configuredItem );
this.updateReportingValue( this.proxy.getStorage().getItemInventory() );
}
}
else if ( !this.isLocked )
catch ( GridAccessException e )
{
this.configuredItem = AEItemStack.create( eq );
this.configureWatchers();
this.getHost().markForUpdate();
// >.>
}
else
this.extractItem( player );
return true;
}
protected void extractItem(EntityPlayer player)
protected void extractItem( EntityPlayer player )
{
}
protected PartStorageMonitor(Class myClass, ItemStack is) {
super( myClass, is, true );
}
public PartStorageMonitor(ItemStack is) {
super( PartStorageMonitor.class, is, true );
this.frontBright = CableBusTextures.PartStorageMonitor_Bright;
this.frontColored = CableBusTextures.PartStorageMonitor_Colored;
this.frontDark = CableBusTextures.PartStorageMonitor_Dark;
// frontSolid = CableBusTextures.PartStorageMonitor_Solid;
}
@Override
public boolean requireDynamicRender()
private void updateReportingValue( IMEMonitor<IAEItemStack> itemInventory )
{
return true;
if ( this.configuredItem != null )
{
IAEItemStack result = itemInventory.getStorageList().findPrecise( this.configuredItem );
if ( result == null )
this.configuredItem.setStackSize( 0 );
else
this.configuredItem.setStackSize( result.getStackSize() );
}
}
@SideOnly(Side.CLIENT)
private boolean updateList;
@SideOnly(Side.CLIENT)
private Integer dspList;
@Override
@SideOnly(Side.CLIENT)
@SideOnly( Side.CLIENT )
protected void finalize() throws Throwable
{
super.finalize();
@@ -193,8 +221,8 @@ public class PartStorageMonitor extends PartMonitor implements IPartStorageMonit
}
@Override
@SideOnly(Side.CLIENT)
public void renderDynamic(double x, double y, double z, IPartRenderHelper rh, RenderBlocks renderer)
@SideOnly( Side.CLIENT )
public void renderDynamic( double x, double y, double z, IPartRenderHelper rh, RenderBlocks renderer )
{
if ( this.dspList == null )
this.dspList = GLAllocation.generateDisplayLists( 1 );
@@ -203,7 +231,7 @@ public class PartStorageMonitor extends PartMonitor implements IPartStorageMonit
if ( Platform.isDrawing( tess ) )
return;
if ( (this.clientFlags & (this.POWERED_FLAG | this.CHANNEL_FLAG)) != (this.POWERED_FLAG | this.CHANNEL_FLAG) )
if ( ( this.clientFlags & ( this.POWERED_FLAG | this.CHANNEL_FLAG ) ) != ( this.POWERED_FLAG | this.CHANNEL_FLAG ) )
return;
IAEItemStack ais = (IAEItemStack) this.getDisplayed();
@@ -226,7 +254,19 @@ public class PartStorageMonitor extends PartMonitor implements IPartStorageMonit
}
}
private void tesrRenderScreen(Tessellator tess, IAEItemStack ais)
@Override
public boolean requireDynamicRender()
{
return true;
}
@Override
public IAEStack getDisplayed()
{
return this.configuredItem;
}
private void tesrRenderScreen( Tessellator tess, IAEItemStack ais )
{
GL11.glPushAttrib( GL11.GL_ALL_ATTRIB_BITS );
ForgeDirection d = this.side;
@@ -288,9 +328,8 @@ public class PartStorageMonitor extends PartMonitor implements IPartStorageMonit
tess.setColorOpaque_F( 1.0f, 1.0f, 1.0f );
ClientHelper.proxy.doRenderItem( sis, this.tile.getWorldObj() );
}
catch (Exception e)
catch ( Exception e )
{
AELog.error( e );
}
@@ -320,63 +359,21 @@ public class PartStorageMonitor extends PartMonitor implements IPartStorageMonit
GL11.glPopAttrib();
}
@Override
public IAEStack getDisplayed()
{
return this.configuredItem;
}
@Override
public boolean isLocked()
{
return this.isLocked;
}
IStackWatcher myWatcher;
@Override
public void updateWatcher(IStackWatcher newWatcher)
public void updateWatcher( IStackWatcher newWatcher )
{
this.myWatcher = newWatcher;
this.configureWatchers();
}
// update the system...
public void configureWatchers()
{
if ( this.myWatcher != null )
this.myWatcher.clear();
try
{
if ( this.configuredItem != null )
{
if ( this.myWatcher != null )
this.myWatcher.add( this.configuredItem );
this.updateReportingValue( this.proxy.getStorage().getItemInventory() );
}
}
catch (GridAccessException e)
{
// >.>
}
}
private void updateReportingValue(IMEMonitor<IAEItemStack> itemInventory)
{
if ( this.configuredItem != null )
{
IAEItemStack result = itemInventory.getStorageList().findPrecise( this.configuredItem );
if ( result == null )
this.configuredItem.setStackSize( 0 );
else
this.configuredItem.setStackSize( result.getStackSize() );
}
}
@Override
public void onStackChange(IItemList o, IAEStack fullStack, IAEStack diffStack, BaseActionSource src, StorageChannel chan)
public void onStackChange( IItemList o, IAEStack fullStack, IAEStack diffStack, BaseActionSource src, StorageChannel chan )
{
if ( this.configuredItem != null )
{
@@ -390,9 +387,8 @@ public class PartStorageMonitor extends PartMonitor implements IPartStorageMonit
}
@Override
public boolean showNetworkInfo(MovingObjectPosition where)
public boolean showNetworkInfo( MovingObjectPosition where )
{
return false;
}
}
@@ -18,6 +18,7 @@
package appeng.parts.reporting;
import java.util.List;
import net.minecraft.entity.player.EntityPlayer;
@@ -44,48 +45,17 @@ import appeng.util.ConfigManager;
import appeng.util.IConfigManagerHost;
import appeng.util.Platform;
public class PartTerminal extends PartMonitor implements ITerminalHost, IConfigManagerHost, IViewCellStorage, IAEAppEngInventory
{
final IConfigManager cm = new ConfigManager( this );
final AppEngInternalInventory viewCell = new AppEngInternalInventory( this, 5 );
public PartTerminal(Class clz, ItemStack is) {
super( clz, is, true );
this.cm.registerSetting( Settings.SORT_BY, SortOrder.NAME );
this.cm.registerSetting( Settings.VIEW_MODE, ViewItems.ALL );
this.cm.registerSetting( Settings.SORT_DIRECTION, SortDir.ASCENDING );
}
@Override
public void getDrops(List<ItemStack> drops, boolean wrenched)
public PartTerminal( ItemStack is )
{
super.getDrops( drops, wrenched );
super( is, true );
for (ItemStack is : this.viewCell)
if ( is != null )
drops.add( is );
}
@Override
public void readFromNBT(NBTTagCompound data)
{
super.readFromNBT( data );
this.cm.readFromNBT( data );
this.viewCell.readFromNBT( data, "viewCell" );
}
@Override
public void writeToNBT(NBTTagCompound data)
{
super.writeToNBT( data );
this.cm.writeToNBT( data );
this.viewCell.writeToNBT( data, "viewCell" );
}
public PartTerminal(ItemStack is) {
super( PartTerminal.class, is, true );
this.frontBright = CableBusTextures.PartTerminal_Bright;
this.frontColored = CableBusTextures.PartTerminal_Colored;
this.frontDark = CableBusTextures.PartTerminal_Dark;
@@ -96,13 +66,40 @@ public class PartTerminal extends PartMonitor implements ITerminalHost, IConfigM
this.cm.registerSetting( Settings.SORT_DIRECTION, SortDir.ASCENDING );
}
public GuiBridge getGui( EntityPlayer player )
@Override
public void getDrops( List<ItemStack> drops, boolean wrenched )
{
return GuiBridge.GUI_ME;
super.getDrops( drops, wrenched );
for ( ItemStack is : this.viewCell )
if ( is != null )
drops.add( is );
}
@Override
public boolean onPartActivate(EntityPlayer player, Vec3 pos)
public IConfigManager getConfigManager()
{
return this.cm;
}
@Override
public void writeToNBT( NBTTagCompound data )
{
super.writeToNBT( data );
this.cm.writeToNBT( data );
this.viewCell.writeToNBT( data, "viewCell" );
}
@Override
public void readFromNBT( NBTTagCompound data )
{
super.readFromNBT( data );
this.cm.readFromNBT( data );
this.viewCell.readFromNBT( data, "viewCell" );
}
@Override
public boolean onPartActivate( EntityPlayer player, Vec3 pos )
{
if ( !super.onPartActivate( player, pos ) )
{
@@ -119,18 +116,9 @@ public class PartTerminal extends PartMonitor implements ITerminalHost, IConfigM
return false;
}
@Override
public IMEMonitor getFluidInventory()
public GuiBridge getGui( EntityPlayer player )
{
try
{
return this.proxy.getStorage().getFluidInventory();
}
catch (GridAccessException e)
{
// err nope?
}
return null;
return GuiBridge.GUI_ME;
}
@Override
@@ -140,7 +128,7 @@ public class PartTerminal extends PartMonitor implements ITerminalHost, IConfigM
{
return this.proxy.getStorage().getItemInventory();
}
catch (GridAccessException e)
catch ( GridAccessException e )
{
// err nope?
}
@@ -148,13 +136,21 @@ public class PartTerminal extends PartMonitor implements ITerminalHost, IConfigM
}
@Override
public IConfigManager getConfigManager()
public IMEMonitor getFluidInventory()
{
return this.cm;
try
{
return this.proxy.getStorage().getFluidInventory();
}
catch ( GridAccessException e )
{
// err nope?
}
return null;
}
@Override
public void updateSetting(IConfigManager manager, Enum settingName, Enum newValue)
public void updateSetting( IConfigManager manager, Enum settingName, Enum newValue )
{
}
@@ -166,7 +162,7 @@ public class PartTerminal extends PartMonitor implements ITerminalHost, IConfigM
}
@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 )
{
this.host.markForSave();
}