Relocate Source to proper directory.

This commit is contained in:
AlgorithmX2
2014-09-23 19:26:27 -05:00
parent fe927ce65d
commit 386d18a059
785 changed files with 35585 additions and 35580 deletions
+806
View File
@@ -0,0 +1,806 @@
package appeng.block;
import java.util.ArrayList;
import java.util.EnumSet;
import java.util.List;
import appeng.client.texture.FlippableIcon;
import net.minecraft.block.Block;
import net.minecraft.block.BlockContainer;
import net.minecraft.block.material.Material;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.client.resources.IResource;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.Container;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.IIcon;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.Vec3;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
import appeng.api.implementations.items.IMemoryCard;
import appeng.api.implementations.items.MemoryCardMessages;
import appeng.api.implementations.tiles.IColorableTile;
import appeng.api.util.AEColor;
import appeng.api.util.IOrientable;
import appeng.api.util.IOrientableBlock;
import appeng.block.networking.BlockCableBus;
import appeng.client.render.BaseBlockRender;
import appeng.client.render.BlockRenderInfo;
import appeng.client.render.WorldRender;
import appeng.client.texture.MissingIcon;
import appeng.core.features.AEFeature;
import appeng.core.features.AEFeatureHandler;
import appeng.core.features.IAEFeature;
import appeng.core.features.ItemStackSrc;
import appeng.helpers.AEGlassMaterial;
import appeng.helpers.ICustomCollision;
import appeng.tile.AEBaseTile;
import appeng.tile.networking.TileCableBus;
import appeng.tile.storage.TileSkyChest;
import appeng.util.LookDirection;
import appeng.util.Platform;
import appeng.util.SettingsFrom;
import cpw.mods.fml.common.registry.GameRegistry;
import cpw.mods.fml.relauncher.ReflectionHelper;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class AEBaseBlock extends BlockContainer implements IAEFeature
{
private String FeatureFullname;
private String FeatureSubname;
private AEFeatureHandler feature;
private Class<? extends TileEntity> tileEntityType = null;
protected boolean isOpaque = true;
protected boolean isFullSize = true;
protected boolean hasSubtypes = false;
protected boolean isInventory = false;
@SideOnly(Side.CLIENT)
public IIcon renderIcon;
@SideOnly(Side.CLIENT)
BlockRenderInfo renderInfo;
@Override
public String toString()
{
return FeatureFullname;
}
@SideOnly(Side.CLIENT)
protected Class<? extends BaseBlockRender> getRenderer()
{
return BaseBlockRender.class;
}
@Override
@SideOnly(Side.CLIENT)
public int getRenderType()
{
return WorldRender.instance.getRenderId();
}
@SideOnly(Side.CLIENT)
private FlippableIcon optionalIcon(IIconRegister ir, String Name, IIcon substitute)
{
// if the input is an flippable IIcon find the original.
while (substitute instanceof FlippableIcon)
substitute = ((FlippableIcon) substitute).getOriginal();
if ( substitute != null )
{
try
{
ResourceLocation resLoc = new ResourceLocation( Name );
resLoc = new ResourceLocation( resLoc.getResourceDomain(), String.format( "%s/%s%s", new Object[] { "textures/blocks",
resLoc.getResourcePath(), ".png" } ) );
IResource res = Minecraft.getMinecraft().getResourceManager().getResource( resLoc );
if ( res != null )
return new FlippableIcon( ir.registerIcon( Name ) );
}
catch (Throwable e)
{
return new FlippableIcon( substitute );
}
}
return new FlippableIcon( ir.registerIcon( Name ) );
}
@Override
@SideOnly(Side.CLIENT)
public void registerBlockIcons(IIconRegister iconRegistry)
{
BlockRenderInfo info = getRendererInstance();
FlippableIcon topIcon;
FlippableIcon bottomIcon;
FlippableIcon sideIcon;
FlippableIcon eastIcon;
FlippableIcon westIcon;
FlippableIcon southIcon;
FlippableIcon northIcon;
this.blockIcon = topIcon = optionalIcon( iconRegistry, this.getTextureName(), null );
bottomIcon = optionalIcon( iconRegistry, this.getTextureName() + "Bottom", topIcon );
sideIcon = optionalIcon( iconRegistry, this.getTextureName() + "Side", topIcon );
eastIcon = optionalIcon( iconRegistry, this.getTextureName() + "East", sideIcon );
westIcon = optionalIcon( iconRegistry, this.getTextureName() + "West", sideIcon );
southIcon = optionalIcon( iconRegistry, this.getTextureName() + "Front", sideIcon );
northIcon = optionalIcon( iconRegistry, this.getTextureName() + "Back", sideIcon );
info.updateIcons( bottomIcon, topIcon, northIcon, southIcon, eastIcon, westIcon );
}
public void registerNoIcons()
{
BlockRenderInfo info = getRendererInstance();
FlippableIcon i = new FlippableIcon( new MissingIcon( this ) );
info.updateIcons( i, i, i, i, i, i );
}
@Override
@SideOnly(Side.CLIENT)
public IIcon getIcon(int direction, int metadata)
{
if ( renderIcon != null )
return renderIcon;
return getRendererInstance().getTexture( ForgeDirection.getOrientation( direction ) );
}
public IIcon unmappedGetIcon(IBlockAccess w, int x, int y, int z, int s)
{
return super.getIcon( w, x, y, z, s );
}
@Override
public IIcon getIcon(IBlockAccess w, int x, int y, int z, int s)
{
return getIcon( mapRotation( w, x, y, z, s ), w.getBlockMetadata( x, y, z ) );
}
protected void setTileEntity(Class<? extends TileEntity> c)
{
AEBaseTile.registerTileItem( c, new ItemStackSrc( this, 0 ) );
GameRegistry.registerTileEntity( tileEntityType = c, FeatureFullname );
isInventory = IInventory.class.isAssignableFrom( c );
setTileProvider( hasBlockTileEntity() );
}
protected void setFeature(EnumSet<AEFeature> f)
{
feature = new AEFeatureHandler( f, this, FeatureSubname );
}
protected AEBaseBlock(Class<?> c, Material mat) {
this( c, mat, null );
setLightOpacity( 255 );
setLightLevel( 0 );
setHardness( 2.2F );
setTileProvider( false );
setHarvestLevel( "pickaxe", 0 );
}
// update Block value.
private void setTileProvider(boolean b)
{
ReflectionHelper.setPrivateValue( Block.class, this, b, "isTileProvider" );
}
protected AEBaseBlock(Class<?> c, Material mat, String subname) {
super( mat );
if ( mat == AEGlassMaterial.instance )
setStepSound( Block.soundTypeGlass );
else if ( mat == Material.glass )
setStepSound( Block.soundTypeGlass );
else if ( mat == Material.rock )
setStepSound( Block.soundTypeStone );
else
setStepSound( Block.soundTypeMetal );
FeatureFullname = AEFeatureHandler.getName( c, subname );
FeatureSubname = subname;
}
@Override
final public AEFeatureHandler feature()
{
return feature;
}
public boolean isOpaque()
{
return isOpaque;
}
@Override
final public boolean isOpaqueCube()
{
return isOpaque;
}
@Override
public boolean renderAsNormalBlock()
{
return isFullSize && isOpaque;
}
@Override
final public boolean isNormalCube(IBlockAccess world, int x, int y, int z)
{
return isFullSize;
}
public boolean hasBlockTileEntity()
{
return tileEntityType != null;
}
public Class<? extends TileEntity> getTileEntityClass()
{
return tileEntityType;
}
@SideOnly(Side.CLIENT)
public void setRenderStateByMeta(int itemDamage)
{
}
@SideOnly(Side.CLIENT)
public BlockRenderInfo getRendererInstance()
{
if ( renderInfo != null )
return renderInfo;
try
{
return renderInfo = new BlockRenderInfo( getRenderer().newInstance() );
}
catch (Throwable t)
{
throw new RuntimeException( t );
}
}
@Override
final public TileEntity createNewTileEntity(World var1, int var2)
{
if ( hasBlockTileEntity() )
{
try
{
return tileEntityType.newInstance();
}
catch (Throwable e)
{
throw new RuntimeException( e );
}
}
return null;
}
public <T extends TileEntity> T getTileEntity(IBlockAccess w, int x, int y, int z)
{
if ( !hasBlockTileEntity() )
return null;
TileEntity te = w.getTileEntity( x, y, z );
if ( tileEntityType.isInstance( te ) )
return (T) te;
return null;
}
protected boolean hasCustomRotation()
{
return false;
}
protected void customRotateBlock(IOrientable rotatable, ForgeDirection axis)
{
}
@Override
final public boolean rotateBlock(World w, int x, int y, int z, ForgeDirection axis)
{
IOrientable rotatable = null;
if ( hasBlockTileEntity() )
{
rotatable = (AEBaseTile) getTileEntity( w, x, y, z );
}
else if ( this instanceof IOrientableBlock )
{
rotatable = ((IOrientableBlock) this).getOrientable( w, x, y, z );
}
if ( rotatable != null && rotatable.canBeRotated() )
{
if ( hasCustomRotation() )
{
customRotateBlock( rotatable, axis );
return true;
}
else
{
ForgeDirection forward = rotatable.getForward();
ForgeDirection up = rotatable.getUp();
for (int rs = 0; rs < 4; rs++)
{
forward = Platform.rotateAround( forward, axis );
up = Platform.rotateAround( up, axis );
if ( this.isValidOrientation( w, x, y, z, forward, up ) )
{
rotatable.setOrientation( forward, up );
return true;
}
}
}
}
return super.rotateBlock( w, x, y, z, axis );
}
public ForgeDirection mapRotation(IOrientable ori, ForgeDirection dir)
{
// case DOWN: return bottomIcon;
// case UP: return blockIcon;
// case NORTH: return northIcon;
// case SOUTH: return southIcon;
// case WEST: return sideIcon;
// case EAST: return sideIcon;
ForgeDirection forward = ori.getForward();
ForgeDirection up = ori.getUp();
ForgeDirection west = ForgeDirection.UNKNOWN;
if ( forward == null || up == null )
return dir;
int west_x = forward.offsetY * up.offsetZ - forward.offsetZ * up.offsetY;
int west_y = forward.offsetZ * up.offsetX - forward.offsetX * up.offsetZ;
int west_z = forward.offsetX * up.offsetY - forward.offsetY * up.offsetX;
for (ForgeDirection dx : ForgeDirection.VALID_DIRECTIONS)
if ( dx.offsetX == west_x && dx.offsetY == west_y && dx.offsetZ == west_z )
west = dx;
if ( dir.equals( forward ) )
return ForgeDirection.SOUTH;
if ( dir.equals( forward.getOpposite() ) )
return ForgeDirection.NORTH;
if ( dir.equals( up ) )
return ForgeDirection.UP;
if ( dir.equals( up.getOpposite() ) )
return ForgeDirection.DOWN;
if ( dir.equals( west ) )
return ForgeDirection.WEST;
if ( dir.equals( west.getOpposite() ) )
return ForgeDirection.EAST;
return ForgeDirection.UNKNOWN;
}
int mapRotation(IBlockAccess w, int x, int y, int z, int s)
{
IOrientable ori = null;
if ( hasBlockTileEntity() )
{
ori = (AEBaseTile) getTileEntity( w, x, y, z );
}
else if ( this instanceof IOrientableBlock )
{
ori = ((IOrientableBlock) this).getOrientable( w, x, y, z );
}
if ( ori != null && ori.canBeRotated() )
{
return mapRotation( ori, ForgeDirection.getOrientation( s ) ).ordinal();
}
return s;
}
@Override
final public ForgeDirection[] getValidRotations(World w, int x, int y, int z)
{
if ( hasBlockTileEntity() )
{
AEBaseTile obj = getTileEntity( w, x, y, z );
if ( obj != null && obj.canBeRotated() )
{
return ForgeDirection.VALID_DIRECTIONS;
}
}
return new ForgeDirection[0];
}
@Override
public void breakBlock(World w, int x, int y, int z, Block a, int b)
{
AEBaseTile te = getTileEntity( w, x, y, z );
if ( te != null )
{
ArrayList<ItemStack> drops = new ArrayList<ItemStack>();
if ( te.dropItems() )
te.getDrops( w, x, y, z, drops );
else
te.getNoDrops( w, x, y, z, drops );
// Cry ;_; ...
Platform.spawnDrops( w, x, y, z, drops );
}
super.breakBlock( w, x, y, z, a, b );
if ( te != null )
w.setTileEntity( x, y, z, null );
}
@Override
public MovingObjectPosition collisionRayTrace(World w, int x, int y, int z, Vec3 a, Vec3 b)
{
ICustomCollision collisionHandler = null;
if ( this instanceof ICustomCollision )
collisionHandler = (ICustomCollision) this;
else
{
AEBaseTile te = getTileEntity( w, x, y, z );
if ( te instanceof ICustomCollision )
collisionHandler = (ICustomCollision) te;
}
if ( collisionHandler != null )
{
Iterable<AxisAlignedBB> bbs = collisionHandler.getSelectedBoundingBoxesFromPool( w, x, y, z, null, true );
MovingObjectPosition br = null;
double lastDist = 0;
for (AxisAlignedBB bb : bbs)
{
setBlockBounds( (float) bb.minX, (float) bb.minY, (float) bb.minZ, (float) bb.maxX, (float) bb.maxY, (float) bb.maxZ );
MovingObjectPosition r = super.collisionRayTrace( w, x, y, z, a, b );
setBlockBounds( 0, 0, 0, 1, 1, 1 );
if ( r != null )
{
double xLen = (a.xCoord - r.hitVec.xCoord);
double yLen = (a.yCoord - r.hitVec.yCoord);
double zLen = (a.zCoord - r.hitVec.zCoord);
double thisDist = xLen * xLen + yLen * yLen + zLen * zLen;
if ( br == null || lastDist > thisDist )
{
lastDist = thisDist;
br = r;
}
}
}
if ( br != null )
{
return br;
}
return null;
}
setBlockBounds( 0, 0, 0, 1, 1, 1 );
return super.collisionRayTrace( w, x, y, z, a, b );
}
@Override
@SideOnly(Side.CLIENT)
final public AxisAlignedBB getSelectedBoundingBoxFromPool(World w, int x, int y, int z)
{
ICustomCollision collisionHandler = null;
AxisAlignedBB b = null;
if ( this instanceof ICustomCollision )
collisionHandler = (ICustomCollision) this;
else
{
AEBaseTile te = getTileEntity( w, x, y, z );
if ( te instanceof ICustomCollision )
collisionHandler = (ICustomCollision) te;
}
if ( collisionHandler != null )
{
if ( Platform.isClient() )
{
EntityPlayer player = Minecraft.getMinecraft().thePlayer;
LookDirection ld = Platform.getPlayerRay( player, Platform.getEyeOffset( player ) );
Iterable<AxisAlignedBB> bbs = collisionHandler.getSelectedBoundingBoxesFromPool( w, x, y, z, Minecraft.getMinecraft().thePlayer, true );
AxisAlignedBB br = null;
double lastDist = 0;
for (AxisAlignedBB bb : bbs)
{
setBlockBounds( (float) bb.minX, (float) bb.minY, (float) bb.minZ, (float) bb.maxX, (float) bb.maxY, (float) bb.maxZ );
MovingObjectPosition r = super.collisionRayTrace( w, x, y, z, ld.a, ld.b );
setBlockBounds( 0, 0, 0, 1, 1, 1 );
if ( r != null )
{
double xLen = (ld.a.xCoord - r.hitVec.xCoord);
double yLen = (ld.a.yCoord - r.hitVec.yCoord);
double zLen = (ld.a.zCoord - r.hitVec.zCoord);
double thisDist = xLen * xLen + yLen * yLen + zLen * zLen;
if ( br == null || lastDist > thisDist )
{
lastDist = thisDist;
br = bb;
}
}
}
if ( br != null )
{
br.setBounds( br.minX + x, br.minY + y, br.minZ + z, br.maxX + x, br.maxY + y, br.maxZ + z );
return br;
}
}
for (AxisAlignedBB bx : collisionHandler.getSelectedBoundingBoxesFromPool( w, x, y, z, null, false ))
{
if ( b == null )
b = bx;
else
{
double minX = Math.min( b.minX, bx.minX );
double minY = Math.min( b.minY, bx.minY );
double minZ = Math.min( b.minZ, bx.minZ );
double maxX = Math.max( b.maxX, bx.maxX );
double maxY = Math.max( b.maxY, bx.maxY );
double maxZ = Math.max( b.maxZ, bx.maxZ );
b.setBounds( minX, minY, minZ, maxX, maxY, maxZ );
}
}
b.setBounds( b.minX + x, b.minY + y, b.minZ + z, b.maxX + x, b.maxY + y, b.maxZ + z );
}
else
b = super.getSelectedBoundingBoxFromPool( w, x, y, z );
return b;
}
@Override
// NOTE: WAS FINAL, changed for Immibis
public void addCollisionBoxesToList(World w, int x, int y, int z, AxisAlignedBB bb, List out, Entity e)
{
ICustomCollision collisionHandler = null;
if ( this instanceof ICustomCollision )
collisionHandler = (ICustomCollision) this;
else
{
AEBaseTile te = getTileEntity( w, x, y, z );
if ( te instanceof ICustomCollision )
collisionHandler = (ICustomCollision) te;
}
if ( collisionHandler != null && bb != null )
{
List<AxisAlignedBB> tmp = new ArrayList<AxisAlignedBB>();
collisionHandler.addCollidingBlockToList( w, x, y, z, bb, tmp, e );
for (AxisAlignedBB b : tmp)
{
b.minX += x;
b.minY += y;
b.minZ += z;
b.maxX += x;
b.maxY += y;
b.maxZ += z;
if ( bb.intersectsWith( b ) )
out.add( b );
}
}
else
super.addCollisionBoxesToList( w, x, y, z, bb, out, e );
}
@Override
public void onBlockDestroyedByPlayer(World par1World, int par2, int par3, int par4, int par5)
{
super.onBlockDestroyedByPlayer( par1World, par2, par3, par4, par5 );
}
public boolean onActivated(World w, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ)
{
return false;
}
@Override
final public boolean onBlockActivated(World w, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ)
{
if ( player != null )
{
ItemStack is = player.inventory.getCurrentItem();
if ( is != null )
{
if ( Platform.isWrench( player, is, x, y, z ) && player.isSneaking() )
{
Block id = w.getBlock( x, y, z );
if ( id != null )
{
AEBaseTile tile = getTileEntity( w, x, y, z );
ItemStack[] drops = Platform.getBlockDrops( w, x, y, z );
if ( tile == null )
return false;
if ( tile instanceof TileCableBus || tile instanceof TileSkyChest )
return false;
ItemStack op = new ItemStack( this );
for (ItemStack ol : drops)
{
if ( Platform.isSameItemType( ol, op ) )
{
NBTTagCompound tag = tile.downloadSettings( SettingsFrom.DISMANTLE_ITEM );
if ( tag != null )
ol.setTagCompound( tag );
}
}
if ( id.removedByPlayer( w, player, x, y, z, false ) )
{
List<ItemStack> l = new ArrayList<ItemStack>();
for (ItemStack iss : drops)
l.add( iss );
Platform.spawnDrops( w, x, y, z, l );
w.setBlockToAir( x, y, z );
}
}
return false;
}
if ( is.getItem() instanceof IMemoryCard && !(this instanceof BlockCableBus) )
{
IMemoryCard memc = (IMemoryCard) is.getItem();
if ( player.isSneaking() )
{
AEBaseTile t = getTileEntity( w, x, y, z );
if ( t != null )
{
String name = getUnlocalizedName();
NBTTagCompound data = t.downloadSettings( SettingsFrom.MEMORY_CARD );
if ( data != null )
{
memc.setMemoryCardContents( is, name, data );
memc.notifyUser( player, MemoryCardMessages.SETTINGS_SAVED );
return true;
}
}
}
else
{
String name = memc.getSettingsName( is );
NBTTagCompound data = memc.getData( is );
if ( getUnlocalizedName().equals( name ) )
{
AEBaseTile t = getTileEntity( w, x, y, z );
t.uploadSettings( SettingsFrom.MEMORY_CARD, data );
memc.notifyUser( player, MemoryCardMessages.SETTINGS_LOADED );
}
else
memc.notifyUser( player, MemoryCardMessages.INVALID_MACHINE );
return false;
}
}
}
}
return onActivated( w, x, y, z, player, side, hitX, hitY, hitZ );
}
public boolean isValidOrientation(World w, int x, int y, int z, ForgeDirection forward, ForgeDirection up)
{
return true;
}
public String getUnlocalizedName(ItemStack is)
{
return getUnlocalizedName();
}
public void addInformation(ItemStack is, EntityPlayer player, List<?> lines, boolean advancedItemTooltips)
{
}
public Class<AEBaseItemBlock> getItemBlockClass()
{
return AEBaseItemBlock.class;
}
@Override
public void postInit()
{
// override!
}
public boolean hasSubtypes()
{
return hasSubtypes;
}
public boolean hasComparatorInputOverride()
{
return isInventory;
}
public int getComparatorInputOverride(World w, int x, int y, int z, int s)
{
TileEntity te = getTileEntity( w, x, y, z );
if ( te instanceof IInventory )
return Container.calcRedstoneFromInventory( (IInventory) te );
return 0;
}
@Override
public boolean recolourBlock(World world, int x, int y, int z, ForgeDirection side, int colour)
{
TileEntity te = getTileEntity( world, x, y, z );
if ( te instanceof IColorableTile )
{
IColorableTile ct = (IColorableTile) te;
AEColor c = ct.getColor();
AEColor newColor = AEColor.values()[colour];
if ( c != newColor )
{
ct.recolourBlock( side, newColor, null );
return true;
}
return false;
}
return super.recolourBlock( world, x, y, z, side, colour );
}
@Override
public void onBlockPlacedBy(World w, int x, int y, int z, EntityLivingBase player, ItemStack is)
{
if ( is.hasDisplayName() )
{
TileEntity te = getTileEntity( w, x, y, z );
if ( te instanceof AEBaseTile )
((AEBaseTile) w.getTileEntity( x, y, z )).setName( is.getDisplayName() );
}
}
}
@@ -0,0 +1,173 @@
package appeng.block;
import java.util.List;
import net.minecraft.block.Block;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemBlock;
import net.minecraft.item.ItemStack;
import net.minecraft.util.MathHelper;
import net.minecraft.world.World;
import net.minecraftforge.client.MinecraftForgeClient;
import net.minecraftforge.common.util.ForgeDirection;
import appeng.api.util.IOrientable;
import appeng.api.util.IOrientableBlock;
import appeng.block.misc.BlockLightDetector;
import appeng.block.misc.BlockSkyCompass;
import appeng.block.networking.BlockWireless;
import appeng.client.render.ItemRenderer;
import appeng.me.helpers.IGridProxyable;
import appeng.tile.AEBaseTile;
import appeng.util.Platform;
public class AEBaseItemBlock extends ItemBlock
{
final AEBaseBlock blockType;
public AEBaseItemBlock(Block id) {
super( id );
blockType = (AEBaseBlock) id;
hasSubtypes = blockType.hasSubtypes;
if ( Platform.isClient() )
MinecraftForgeClient.registerItemRenderer( this, ItemRenderer.instance );
}
@Override
public int getMetadata(int dmg)
{
if ( hasSubtypes )
return dmg;
return 0;
}
@Override
public String getUnlocalizedName(ItemStack is)
{
return blockType.getUnlocalizedName( is );
}
@Override
public void addInformation(ItemStack is, EntityPlayer player, List lines, boolean advancedItemTooltips)
{
blockType.addInformation( is, player, lines, advancedItemTooltips );
}
@Override
public boolean placeBlockAt(ItemStack stack, EntityPlayer player, World w, int x, int y, int z, int side, float hitX, float hitY, float hitZ, int metadata)
{
ForgeDirection up = ForgeDirection.UNKNOWN;
ForgeDirection forward = ForgeDirection.UNKNOWN;
IOrientable ori = null;
if ( blockType.hasBlockTileEntity() )
{
if ( blockType instanceof BlockLightDetector )
{
up = ForgeDirection.getOrientation( side );
if ( up == ForgeDirection.UP || up == ForgeDirection.DOWN )
forward = ForgeDirection.SOUTH;
else
forward = ForgeDirection.UP;
}
else if ( blockType instanceof BlockWireless || blockType instanceof BlockSkyCompass )
{
forward = ForgeDirection.getOrientation( side );
if ( forward == ForgeDirection.UP || forward == ForgeDirection.DOWN )
up = ForgeDirection.SOUTH;
else
up = ForgeDirection.UP;
}
else
{
up = ForgeDirection.UP;
byte rotation = (byte) (MathHelper.floor_double( (double) ((player.rotationYaw * 4F) / 360F) + 2.5D ) & 3);
switch (rotation)
{
default:
case 0:
forward = ForgeDirection.SOUTH;
break;
case 1:
forward = ForgeDirection.WEST;
break;
case 2:
forward = ForgeDirection.NORTH;
break;
case 3:
forward = ForgeDirection.EAST;
break;
}
if ( player.rotationPitch > 65 )
{
up = forward.getOpposite();
forward = ForgeDirection.UP;
}
else if ( player.rotationPitch < -65 )
{
up = forward.getOpposite();
forward = ForgeDirection.DOWN;
}
}
}
if ( blockType instanceof IOrientableBlock )
{
ori = ((IOrientableBlock) blockType).getOrientable( w, x, y, z );
up = ForgeDirection.getOrientation( side );
forward = ForgeDirection.SOUTH;
if ( up.offsetY == 0 )
forward = ForgeDirection.UP;
ori.setOrientation( forward, up );
}
if ( !blockType.isValidOrientation( w, x, y, z, forward, up ) )
return false;
if ( super.placeBlockAt( stack, player, w, x, y, z, side, hitX, hitY, hitZ, metadata ) )
{
if ( blockType.hasBlockTileEntity() && !(blockType instanceof BlockLightDetector) )
{
AEBaseTile tile = blockType.getTileEntity( w, x, y, z );
ori = tile;
if ( tile == null )
return true;
if ( ori.canBeRotated() && !blockType.hasCustomRotation() )
{
if ( ori.getForward() == null || ori.getUp() == null || // null
tile.getForward() == ForgeDirection.UNKNOWN || ori.getUp() == ForgeDirection.UNKNOWN )
ori.setOrientation( forward, up );
}
if ( tile instanceof IGridProxyable )
{
((IGridProxyable) tile).getProxy().setOwner( player );
}
tile.onPlacement( stack, player, side );
}
else if ( blockType instanceof IOrientableBlock )
{
ori.setOrientation( forward, up );
}
return true;
}
return false;
}
@Override
public boolean isBookEnchantable(ItemStack itemstack1, ItemStack itemstack2)
{
return false;
}
}
@@ -0,0 +1,118 @@
package appeng.block;
import java.text.MessageFormat;
import java.util.List;
import net.minecraft.block.Block;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import appeng.api.AEApi;
import appeng.api.config.AccessRestriction;
import appeng.api.config.PowerUnits;
import appeng.api.implementations.items.IAEItemPowerStorage;
import appeng.core.localization.GuiText;
import appeng.util.Platform;
public class AEBaseItemBlockChargeable extends AEBaseItemBlock implements IAEItemPowerStorage
{
public AEBaseItemBlockChargeable(Block id) {
super( id );
}
@Override
public void addInformation(ItemStack is, EntityPlayer player, List lines, boolean advancedItemTooltips)
{
NBTTagCompound tag = is.getTagCompound();
double internalCurrentPower = 0;
double internalMaxPower = getMax( is );
if ( tag != null )
{
internalCurrentPower = tag.getDouble( "internalCurrentPower" );
}
double percent = internalCurrentPower / internalMaxPower;
lines.add( GuiText.StoredEnergy.getLocal() + ":" + MessageFormat.format( " {0,number,#} ", internalCurrentPower )
+ Platform.gui_localize( PowerUnits.AE.unlocalizedName ) + " - " + MessageFormat.format( " {0,number,#.##%} ", percent ) );
}
private double getMax(ItemStack is)
{
Block blk = Block.getBlockFromItem( this );
if ( blk == AEApi.instance().blocks().blockEnergyCell.block() )
return 200000;
else
return 8 * 200000;
}
private double getInternal(ItemStack is)
{
NBTTagCompound nbt = Platform.openNbtData( is );
return nbt.getDouble( "internalCurrentPower" );
}
private void setInternal(ItemStack is, double amt)
{
NBTTagCompound nbt = Platform.openNbtData( is );
nbt.setDouble( "internalCurrentPower", amt );
}
@Override
public double injectAEPower(ItemStack is, double amt)
{
double internalCurrentPower = getInternal( is );
double internalMaxPower = getMax( is );
internalCurrentPower += amt;
if ( internalCurrentPower > internalMaxPower )
{
amt = internalCurrentPower - internalMaxPower;
internalCurrentPower = internalMaxPower;
setInternal( is, internalCurrentPower );
return amt;
}
setInternal( is, internalCurrentPower );
return 0;
}
@Override
public double extractAEPower(ItemStack is, double amt)
{
double internalCurrentPower = getInternal( is );
if ( internalCurrentPower > amt )
{
internalCurrentPower -= amt;
setInternal( is, internalCurrentPower );
return amt;
}
amt = internalCurrentPower;
setInternal( is, 0 );
return amt;
}
@Override
public double getAEMaxPower(ItemStack is)
{
double internalMaxPower = getMax( is );
return internalMaxPower;
}
@Override
public double getAECurrentPower(ItemStack is)
{
double internalCurrentPower = getInternal( is );
return internalCurrentPower;
}
@Override
public AccessRestriction getPowerFlow(ItemStack is)
{
return AccessRestriction.WRITE;
}
}
@@ -0,0 +1,26 @@
package appeng.block;
import net.minecraft.block.material.Material;
import net.minecraft.util.IIcon;
import net.minecraft.world.IBlockAccess;
public class AEDecorativeBlock extends AEBaseBlock
{
protected AEDecorativeBlock(Class<?> c, Material mat) {
super( c, mat );
}
@Override
public IIcon getIcon(IBlockAccess w, int x, int y, int z, int s)
{
return super.unmappedGetIcon( w, x, y, z, s );
}
@Override
public int getRenderType()
{
return 0;
}
}
@@ -0,0 +1,52 @@
package appeng.block.crafting;
import java.util.List;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.IIcon;
import net.minecraftforge.common.util.ForgeDirection;
import appeng.api.AEApi;
import appeng.client.render.BaseBlockRender;
import appeng.client.render.blocks.RenderBlockCraftingCPUMonitor;
import appeng.client.texture.ExtraBlockTextures;
import appeng.tile.crafting.TileCraftingMonitorTile;
public class BlockCraftingMonitor extends BlockCraftingUnit
{
public BlockCraftingMonitor() {
super( BlockCraftingMonitor.class );
setTileEntity( TileCraftingMonitorTile.class );
}
@Override
protected Class<? extends BaseBlockRender> getRenderer()
{
return RenderBlockCraftingCPUMonitor.class;
}
@Override
public IIcon getIcon(int direction, int metadata)
{
if ( direction != ForgeDirection.SOUTH.ordinal() )
return AEApi.instance().blocks().blockCraftingUnit.block().getIcon( direction, metadata );
switch (metadata)
{
default:
case 0:
return super.getIcon( 0, 0 );
case 0 | FLAG_FORMED:
return ExtraBlockTextures.BlockCraftingMonitorFit_Light.getIcon();
}
}
@Override
public void getSubBlocks(Item i, CreativeTabs c, List l)
{
l.add( new ItemStack( this, 1, 0 ) );
}
}
@@ -0,0 +1,77 @@
package appeng.block.crafting;
import java.util.List;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.IIcon;
import appeng.client.texture.ExtraBlockTextures;
import appeng.tile.crafting.TileCraftingStorageTile;
public class BlockCraftingStorage extends BlockCraftingUnit
{
public BlockCraftingStorage() {
super( BlockCraftingStorage.class );
setTileEntity( TileCraftingStorageTile.class );
}
@Override
public Class getItemBlockClass()
{
return ItemCraftingStorage.class;
}
@Override
public String getUnlocalizedName(ItemStack is)
{
if ( is.getItemDamage() == 1 )
return "tile.appliedenergistics2.BlockCraftingStorage4k";
if ( is.getItemDamage() == 2 )
return "tile.appliedenergistics2.BlockCraftingStorage16k";
if ( is.getItemDamage() == 3 )
return "tile.appliedenergistics2.BlockCraftingStorage64k";
return getItemUnlocalizedName( is );
}
@Override
public IIcon getIcon(int direction, int metadata)
{
switch (metadata & (~4))
{
default:
case 0:
return super.getIcon( 0, 0 );
case 1:
return ExtraBlockTextures.BlockCraftingStorage4k.getIcon();
case 2:
return ExtraBlockTextures.BlockCraftingStorage16k.getIcon();
case 3:
return ExtraBlockTextures.BlockCraftingStorage64k.getIcon();
case 0 | FLAG_FORMED:
return ExtraBlockTextures.BlockCraftingStorage1kFit.getIcon();
case 1 | FLAG_FORMED:
return ExtraBlockTextures.BlockCraftingStorage4kFit.getIcon();
case 2 | FLAG_FORMED:
return ExtraBlockTextures.BlockCraftingStorage16kFit.getIcon();
case 3 | FLAG_FORMED:
return ExtraBlockTextures.BlockCraftingStorage64kFit.getIcon();
}
}
@Override
public void getSubBlocks(Item i, CreativeTabs c, List l)
{
l.add( new ItemStack( this, 1, 0 ) );
l.add( new ItemStack( this, 1, 1 ) );
l.add( new ItemStack( this, 1, 2 ) );
l.add( new ItemStack( this, 1, 3 ) );
}
}
@@ -0,0 +1,139 @@
package appeng.block.crafting;
import java.util.EnumSet;
import java.util.List;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.IIcon;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
import appeng.block.AEBaseBlock;
import appeng.client.render.BaseBlockRender;
import appeng.client.render.blocks.RenderBlockCraftingCPU;
import appeng.client.texture.ExtraBlockTextures;
import appeng.core.features.AEFeature;
import appeng.core.sync.GuiBridge;
import appeng.tile.crafting.TileCraftingTile;
import appeng.util.Platform;
public class BlockCraftingUnit extends AEBaseBlock
{
public static final int FLAG_FORMED = 8;
public static final int FLAG_POWERED = 4;
public BlockCraftingUnit(Class<? extends BlockCraftingUnit> childClass) {
super( childClass, Material.iron );
hasSubtypes = true;
setFeature( EnumSet.of( AEFeature.CraftingCPU ) );
}
public BlockCraftingUnit() {
this( BlockCraftingUnit.class );
setTileEntity( TileCraftingTile.class );
}
@Override
public boolean onActivated(World w, int x, int y, int z, EntityPlayer p, int side, float hitX, float hitY, float hitZ)
{
TileCraftingTile tg = getTileEntity( w, x, y, z );
if ( tg != null && !p.isSneaking() && tg.isFormed() && tg.isActive() )
{
if ( Platform.isClient() )
return true;
Platform.openGUI( p, tg, ForgeDirection.getOrientation( side ), GuiBridge.GUI_CRAFTING_CPU );
return true;
}
return false;
}
@Override
public int getDamageValue(World w, int x, int y, int z)
{
int meta = w.getBlockMetadata( x, y, z );
return damageDropped( meta );
}
@Override
public int damageDropped(int meta)
{
return meta & 3;
}
@Override
public String getUnlocalizedName(ItemStack is)
{
if ( is.getItemDamage() == 1 )
return "tile.appliedenergistics2.BlockCraftingAccelerator";
return getItemUnlocalizedName( is );
}
protected String getItemUnlocalizedName(ItemStack is)
{
return super.getUnlocalizedName( is );
}
@Override
public void setRenderStateByMeta(int itemDamage)
{
IIcon front = getIcon( ForgeDirection.SOUTH.ordinal(), itemDamage );
IIcon other = getIcon( ForgeDirection.NORTH.ordinal(), itemDamage );
getRendererInstance().setTemporaryRenderIcons( other, other, front, other, other, other );
}
@Override
public IIcon getIcon(int direction, int metadata)
{
switch (metadata)
{
default:
case 0:
return super.getIcon( 0, 0 );
case 1:
return ExtraBlockTextures.BlockCraftingAccelerator.getIcon();
case 0 | FLAG_FORMED:
return ExtraBlockTextures.BlockCraftingUnitFit.getIcon();
case 1 | FLAG_FORMED:
return ExtraBlockTextures.BlockCraftingAcceleratorFit.getIcon();
}
}
@Override
protected Class<? extends BaseBlockRender> getRenderer()
{
return RenderBlockCraftingCPU.class;
}
@Override
public void breakBlock(World w, int x, int y, int z, Block a, int b)
{
TileCraftingTile cp = getTileEntity( w, x, y, z );
if ( cp != null )
cp.breakCluster();
super.breakBlock( w, x, y, z, a, b );
}
@Override
public void onNeighborBlockChange(World w, int x, int y, int z, Block junk)
{
TileCraftingTile cp = getTileEntity( w, x, y, z );
if ( cp != null )
cp.updateMultiBlock();
}
@Override
public void getSubBlocks(Item i, CreativeTabs c, List l)
{
l.add( new ItemStack( this, 1, 0 ) );
l.add( new ItemStack( this, 1, 1 ) );
}
}
@@ -0,0 +1,63 @@
package appeng.block.crafting;
import java.util.EnumSet;
import net.minecraft.block.material.Material;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
import appeng.block.AEBaseBlock;
import appeng.client.render.BaseBlockRender;
import appeng.client.render.blocks.RenderBlockAssembler;
import appeng.core.features.AEFeature;
import appeng.core.sync.GuiBridge;
import appeng.tile.crafting.TileMolecularAssembler;
import appeng.util.Platform;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class BlockMolecularAssembler extends AEBaseBlock
{
public BlockMolecularAssembler() {
super( BlockMolecularAssembler.class, Material.iron );
setFeature( EnumSet.of( AEFeature.MolecularAssembler ) );
setTileEntity( TileMolecularAssembler.class );
isOpaque = false;
lightOpacity = 1;
}
public static boolean booleanAlphaPass = false;
@Override
public boolean canRenderInPass(int pass)
{
booleanAlphaPass = pass == 1;
return pass == 0 || pass == 1;
}
@Override
public int getRenderBlockPass()
{
return 1;
}
@Override
@SideOnly(Side.CLIENT)
public Class<? extends BaseBlockRender> getRenderer()
{
return RenderBlockAssembler.class;
}
@Override
public boolean onActivated(World w, int x, int y, int z, EntityPlayer p, int side, float hitX, float hitY, float hitZ)
{
TileMolecularAssembler tg = getTileEntity( w, x, y, z );
if ( tg != null && !p.isSneaking() )
{
Platform.openGUI( p, tg, ForgeDirection.getOrientation( side ), GuiBridge.GUI_MAC );
return true;
}
return false;
}
}
@@ -0,0 +1,29 @@
package appeng.block.crafting;
import net.minecraft.block.Block;
import net.minecraft.item.ItemStack;
import appeng.api.AEApi;
import appeng.block.AEBaseItemBlock;
import appeng.core.AEConfig;
import appeng.core.features.AEFeature;
public class ItemCraftingStorage extends AEBaseItemBlock
{
public ItemCraftingStorage(Block id) {
super( id );
}
@Override
public boolean hasContainerItem()
{
return AEConfig.instance.isFeatureEnabled( AEFeature.enableDisassemblyCrafting );
}
@Override
public ItemStack getContainerItem(ItemStack itemStack)
{
return AEApi.instance().blocks().blockCraftingUnit.stack( 1 );
}
}
@@ -0,0 +1,124 @@
package appeng.block.grindstone;
import java.util.EnumSet;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import net.minecraftforge.common.util.FakePlayer;
import net.minecraftforge.common.util.ForgeDirection;
import appeng.api.implementations.tiles.ICrankable;
import appeng.block.AEBaseBlock;
import appeng.client.render.BaseBlockRender;
import appeng.client.render.blocks.RenderBlockCrank;
import appeng.core.features.AEFeature;
import appeng.core.stats.Stats;
import appeng.tile.AEBaseTile;
import appeng.tile.grindstone.TileCrank;
public class BlockCrank extends AEBaseBlock
{
public BlockCrank() {
super( BlockCrank.class, Material.wood );
setFeature( EnumSet.of( AEFeature.GrindStone ) );
setTileEntity( TileCrank.class );
setLightOpacity( 0 );
isFullSize = isOpaque = false;
}
@Override
public boolean onActivated(World w, int x, int y, int z, EntityPlayer p, int side, float hitX, float hitY, float hitZ)
{
if ( p instanceof FakePlayer || p == null )
return true;
AEBaseTile tile = getTileEntity( w, x, y, z );
if ( tile instanceof TileCrank )
{
if ( ((TileCrank) tile).power() )
{
Stats.TurnedCranks.addToPlayer( p, 1 );
}
}
return true;
}
@Override
public Class<? extends BaseBlockRender> getRenderer()
{
return RenderBlockCrank.class;
}
private boolean isCrankable(World w, int x, int y, int z, ForgeDirection offset)
{
TileEntity te = w.getTileEntity( x + offset.offsetX, y + offset.offsetY, z + offset.offsetZ );
if ( te instanceof ICrankable )
{
return ((ICrankable) te).canCrankAttach( offset.getOpposite() );
}
return false;
}
private ForgeDirection findCrankable(World w, int x, int y, int z)
{
for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS)
if ( isCrankable( w, x, y, z, dir ) )
return dir;
return ForgeDirection.UNKNOWN;
}
@Override
public boolean canPlaceBlockAt(World w, int x, int y, int z)
{
return findCrankable( w, x, y, z ) != ForgeDirection.UNKNOWN;
}
@Override
public boolean isValidOrientation(World w, int x, int y, int z, ForgeDirection forward, ForgeDirection up)
{
TileEntity te = w.getTileEntity( x, y, z );
return !(te instanceof TileCrank) || isCrankable( w, x, y, z, up.getOpposite() );
}
private void dropCrank(World w, int x, int y, int z)
{
w.func_147480_a( x, y, z, true ); // w.destroyBlock( x, y, z, true );
w.markBlockForUpdate( x, y, z );
}
@Override
public void onBlockPlacedBy(World w, int x, int y, int z, EntityLivingBase p, ItemStack is)
{
AEBaseTile tile = getTileEntity( w, x, y, z );
if ( tile != null )
{
ForgeDirection mnt = findCrankable( w, x, y, z );
ForgeDirection forward = ForgeDirection.UP;
if ( mnt == ForgeDirection.UP || mnt == ForgeDirection.DOWN )
forward = ForgeDirection.SOUTH;
tile.setOrientation( forward, mnt.getOpposite() );
}
else
dropCrank( w, x, y, z );
}
@Override
public void onNeighborBlockChange(World w, int x, int y, int z, Block id)
{
AEBaseTile tile = getTileEntity( w, x, y, z );
if ( tile != null )
{
if ( !isCrankable( w, x, y, z, tile.getUp().getOpposite() ) )
dropCrank( w, x, y, z );
}
else
dropCrank( w, x, y, z );
}
}
@@ -0,0 +1,37 @@
package appeng.block.grindstone;
import java.util.EnumSet;
import net.minecraft.block.material.Material;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
import appeng.block.AEBaseBlock;
import appeng.core.features.AEFeature;
import appeng.core.sync.GuiBridge;
import appeng.tile.grindstone.TileGrinder;
import appeng.util.Platform;
public class BlockGrinder extends AEBaseBlock
{
public BlockGrinder() {
super( BlockGrinder.class, Material.rock );
setFeature( EnumSet.of( AEFeature.GrindStone ) );
setTileEntity( TileGrinder.class );
setHardness( 3.2F );
}
@Override
public boolean onActivated(World w, int x, int y, int z, EntityPlayer p, int side, float hitX, float hitY, float hitZ)
{
TileGrinder tg = getTileEntity( w, x, y, z );
if ( tg != null && !p.isSneaking() )
{
Platform.openGUI( p, tg, ForgeDirection.getOrientation( side ), GuiBridge.GUI_GRINDER );
return true;
}
return false;
}
}
@@ -0,0 +1,40 @@
package appeng.block.misc;
import java.util.EnumSet;
import net.minecraft.block.material.Material;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
import appeng.block.AEBaseBlock;
import appeng.core.features.AEFeature;
import appeng.core.sync.GuiBridge;
import appeng.tile.misc.TileCellWorkbench;
import appeng.util.Platform;
public class BlockCellWorkbench extends AEBaseBlock
{
public BlockCellWorkbench() {
super( BlockCellWorkbench.class, Material.iron );
setFeature( EnumSet.of( AEFeature.StorageCells ) );
setTileEntity( TileCellWorkbench.class );
}
@Override
public boolean onActivated(World w, int x, int y, int z, EntityPlayer p, int side, float hitX, float hitY, float hitZ)
{
if ( p.isSneaking() )
return false;
TileCellWorkbench tg = getTileEntity( w, x, y, z );
if ( tg != null )
{
if ( Platform.isServer() )
Platform.openGUI( p, tg, ForgeDirection.getOrientation( side ), GuiBridge.GUI_CELLWORKBENCH );
return true;
}
return false;
}
}
@@ -0,0 +1,161 @@
package appeng.block.misc;
import java.util.Arrays;
import java.util.EnumSet;
import java.util.List;
import java.util.Random;
import net.minecraft.block.material.Material;
import net.minecraft.client.Minecraft;
import net.minecraft.client.particle.EntityFX;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
import appeng.api.AEApi;
import appeng.block.AEBaseBlock;
import appeng.client.render.BaseBlockRender;
import appeng.client.render.blocks.RenderBlockCharger;
import appeng.client.render.effects.LightningFX;
import appeng.core.AEConfig;
import appeng.core.CommonHelper;
import appeng.core.features.AEFeature;
import appeng.helpers.ICustomCollision;
import appeng.tile.AEBaseTile;
import appeng.tile.misc.TileCharger;
import appeng.util.Platform;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class BlockCharger extends AEBaseBlock implements ICustomCollision
{
public BlockCharger() {
super( BlockCharger.class, Material.iron );
setFeature( EnumSet.of( AEFeature.Core ) );
setTileEntity( TileCharger.class );
setLightOpacity( 2 );
isFullSize = isOpaque = false;
}
@Override
public boolean onActivated(World w, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ)
{
if ( player.isSneaking() )
return false;
if ( Platform.isServer() )
{
TileCharger tc = getTileEntity( w, x, y, z );
if ( tc != null )
{
tc.activate( player );
}
}
return true;
}
@Override
protected Class<? extends BaseBlockRender> getRenderer()
{
return RenderBlockCharger.class;
}
@Override
@SideOnly(Side.CLIENT)
public void randomDisplayTick(World w, int x, int y, int z, Random r)
{
if ( !AEConfig.instance.enableEffects )
return;
if ( r.nextFloat() < 0.98 )
return;
AEBaseTile tile = getTileEntity( w, x, y, z );
if ( tile instanceof TileCharger )
{
TileCharger tc = (TileCharger) tile;
if ( AEApi.instance().materials().materialCertusQuartzCrystalCharged.sameAsStack( tc.getStackInSlot( 0 ) ) )
{
double xOff = 0.0;
double yOff = 0.0;
double zOff = 0.0;
for (int bolts = 0; bolts < 3; bolts++)
{
if ( CommonHelper.proxy.shouldAddParticles( r ) )
{
LightningFX fx = new LightningFX( w, xOff + 0.5 + x, yOff + 0.5 + y, zOff + 0.5 + z, 0.0D, 0.0D, 0.0D );
Minecraft.getMinecraft().effectRenderer.addEffect( (EntityFX) fx );
}
}
}
}
}
@Override
public Iterable<AxisAlignedBB> getSelectedBoundingBoxesFromPool(World w, int x, int y, int z, Entity e, boolean isVisual)
{
TileCharger tile = getTileEntity( w, x, y, z );
if ( tile != null )
{
double twoPixels = 2.0 / 16.0;
ForgeDirection up = tile.getUp();
ForgeDirection forward = tile.getForward();
AxisAlignedBB bb = AxisAlignedBB.getBoundingBox( twoPixels, twoPixels, twoPixels, 1.0 - twoPixels, 1.0 - twoPixels, 1.0 - twoPixels );
if ( up.offsetX != 0 )
{
bb.minX = 0;
bb.maxX = 1;
}
if ( up.offsetY != 0 )
{
bb.minY = 0;
bb.maxY = 1;
}
if ( up.offsetZ != 0 )
{
bb.minZ = 0;
bb.maxZ = 1;
}
switch (forward)
{
case DOWN:
bb.maxY = 1;
break;
case UP:
bb.minY = 0;
break;
case NORTH:
bb.maxZ = 1;
break;
case SOUTH:
bb.minZ = 0;
break;
case EAST:
bb.minX = 0;
break;
case WEST:
bb.maxX = 1;
break;
default:
break;
}
return Arrays.asList( new AxisAlignedBB[] { bb } );
}
return Arrays.asList( new AxisAlignedBB[] { AxisAlignedBB.getBoundingBox( 0.0, 0, 0.0, 1.0, 1.0, 1.0 ) } );
}
@Override
public void addCollidingBlockToList(World w, int x, int y, int z, AxisAlignedBB bb, List out, Entity e)
{
out.add( AxisAlignedBB.getBoundingBox( 0.0, 0.0, 0.0, 1.0, 1.0, 1.0 ) );
}
}
@@ -0,0 +1,43 @@
package appeng.block.misc;
import java.util.EnumSet;
import net.minecraft.block.material.Material;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
import appeng.block.AEBaseBlock;
import appeng.core.features.AEFeature;
import appeng.core.sync.GuiBridge;
import appeng.tile.misc.TileCondenser;
import appeng.util.Platform;
public class BlockCondenser extends AEBaseBlock
{
public BlockCondenser() {
super( BlockCondenser.class, Material.iron );
setFeature( EnumSet.of( AEFeature.Core ) );
setTileEntity( TileCondenser.class );
}
@Override
public boolean onActivated(World w, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ)
{
if ( player.isSneaking() )
return false;
if ( Platform.isServer() )
{
TileCondenser tc = getTileEntity( w, x, y, z );
if ( tc != null && !player.isSneaking() )
{
Platform.openGUI( player, tc, ForgeDirection.getOrientation(side), GuiBridge.GUI_CONDENSER );
return true;
}
}
return true;
}
}
@@ -0,0 +1,50 @@
package appeng.block.misc;
import java.util.EnumSet;
import net.minecraft.block.material.Material;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
import appeng.block.AEBaseBlock;
import appeng.client.render.BaseBlockRender;
import appeng.client.render.blocks.RenderBlockInscriber;
import appeng.core.features.AEFeature;
import appeng.core.sync.GuiBridge;
import appeng.tile.misc.TileInscriber;
import appeng.util.Platform;
public class BlockInscriber extends AEBaseBlock
{
public BlockInscriber() {
super( BlockInscriber.class, Material.iron );
setFeature( EnumSet.of( AEFeature.Inscriber ) );
setTileEntity( TileInscriber.class );
setLightOpacity( 2 );
isFullSize = isOpaque = false;
}
@Override
protected Class<? extends BaseBlockRender> getRenderer()
{
return RenderBlockInscriber.class;
}
@Override
public boolean onActivated(World w, int x, int y, int z, EntityPlayer p, int side, float hitX, float hitY, float hitZ)
{
if ( p.isSneaking() )
return false;
TileInscriber tg = getTileEntity( w, x, y, z );
if ( tg != null )
{
if ( Platform.isServer() )
Platform.openGUI( p, tg, ForgeDirection.getOrientation( side ), GuiBridge.GUI_INSCRIBER );
return true;
}
return false;
}
}
@@ -0,0 +1,63 @@
package appeng.block.misc;
import java.util.EnumSet;
import net.minecraft.block.material.Material;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
import appeng.api.util.IOrientable;
import appeng.block.AEBaseBlock;
import appeng.client.render.BaseBlockRender;
import appeng.client.render.blocks.RenderBlockInterface;
import appeng.core.features.AEFeature;
import appeng.core.sync.GuiBridge;
import appeng.tile.misc.TileInterface;
import appeng.util.Platform;
public class BlockInterface extends AEBaseBlock
{
public BlockInterface() {
super( BlockInterface.class, Material.iron );
setFeature( EnumSet.of( AEFeature.Core ) );
setTileEntity( TileInterface.class );
}
@Override
protected Class<? extends BaseBlockRender> getRenderer()
{
return RenderBlockInterface.class;
}
@Override
protected boolean hasCustomRotation()
{
return true;
}
@Override
protected void customRotateBlock(IOrientable rotatable, ForgeDirection axis)
{
if ( rotatable instanceof TileInterface )
{
((TileInterface) rotatable).setSide( axis );
}
}
@Override
public boolean onActivated(World w, int x, int y, int z, EntityPlayer p, int side, float hitX, float hitY, float hitZ)
{
if ( p.isSneaking() )
return false;
TileInterface tg = getTileEntity( w, x, y, z );
if ( tg != null )
{
if ( Platform.isServer() )
Platform.openGUI( p, tg, ForgeDirection.getOrientation( side ), GuiBridge.GUI_INTERFACE );
return true;
}
return false;
}
}
@@ -0,0 +1,48 @@
package appeng.block.misc;
import java.util.EnumSet;
import java.util.Random;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import appeng.core.features.AEFeature;
import appeng.tile.misc.TileLightDetector;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class BlockLightDetector extends BlockQuartzTorch
{
public BlockLightDetector() {
super( BlockLightDetector.class );
setFeature( EnumSet.of( AEFeature.LightDetector ) );
setTileEntity( TileLightDetector.class );
}
@Override
public void onNeighborChange(IBlockAccess world, int x, int y, int z, int tileX, int tileY, int tileZ)
{
super.onNeighborChange( world, x, y, z, tileX, tileY, tileZ );
TileLightDetector tld = getTileEntity( world, x, y, z );
if ( tld != null )
tld.updateLight();
}
@Override
public int isProvidingWeakPower(IBlockAccess w, int x, int y, int z, int side)
{
if ( w instanceof World && ((TileLightDetector) getTileEntity( w, x, y, z )).isReady() )
return (int) ((World) w).getBlockLightValue( x, y, z ) - 6;
return 0;
}
@Override
@SideOnly(Side.CLIENT)
public void randomDisplayTick(World w, int x, int y, int z, Random r)
{
// cancel out lightning
}
}
@@ -0,0 +1,109 @@
package appeng.block.misc;
import java.util.EnumSet;
import java.util.List;
import java.util.Random;
import net.minecraft.block.Block;
import net.minecraft.block.material.MapColor;
import net.minecraft.block.material.MaterialLiquid;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.Item;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import appeng.block.AEBaseBlock;
import appeng.client.render.BaseBlockRender;
import appeng.client.render.blocks.RenderBlockPaint;
import appeng.core.features.AEFeature;
import appeng.tile.misc.TilePaint;
import appeng.util.Platform;
public class BlockPaint extends AEBaseBlock
{
public BlockPaint() {
super( BlockPaint.class, new MaterialLiquid( MapColor.airColor ) );
setFeature( EnumSet.of( AEFeature.PaintBalls ) );
setTileEntity( TilePaint.class );
setLightOpacity( 0 );
isFullSize = false;
isOpaque = false;
}
@Override
protected Class<? extends BaseBlockRender> getRenderer()
{
return RenderBlockPaint.class;
}
@Override
public int getLightValue(IBlockAccess w, int x, int y, int z)
{
TilePaint tp = getTileEntity( w, x, y, z );
if ( tp != null )
{
return tp.getLightLevel();
}
return 0;
}
@Override
public void getSubBlocks(Item p_149666_1_, CreativeTabs p_149666_2_, List p_149666_3_)
{
// nothing..
}
@Override
public void fillWithRain(World w, int x, int y, int z)
{
if ( Platform.isServer() )
w.setBlock( x, y, z, Platform.air, 0, 3 );
}
@Override
public void onNeighborBlockChange(World w, int x, int y, int z, Block junk)
{
TilePaint tp = getTileEntity( w, x, y, z );
if ( tp != null )
tp.onNeighborBlockChange();
}
public AxisAlignedBB getCollisionBoundingBoxFromPool(World p_149668_1_, int p_149668_2_, int p_149668_3_, int p_149668_4_)
{
return null;
}
public boolean canCollideCheck(int p_149678_1_, boolean p_149678_2_)
{
return false;
}
public void dropBlockAsItemWithChance(World p_149690_1_, int p_149690_2_, int p_149690_3_, int p_149690_4_, int p_149690_5_, float p_149690_6_,
int p_149690_7_)
{
}
@Override
public Item getItemDropped(int p_149650_1_, Random p_149650_2_, int p_149650_3_)
{
return null;
}
@Override
public boolean isAir(IBlockAccess world, int x, int y, int z)
{
return true;
}
@Override
public boolean isReplaceable(IBlockAccess world, int x, int y, int z)
{
return true;
}
}
@@ -0,0 +1,125 @@
package appeng.block.misc;
import java.util.EnumSet;
import java.util.Random;
import net.minecraft.block.material.Material;
import net.minecraft.client.Minecraft;
import net.minecraft.client.particle.EntityFX;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
import appeng.api.util.IOrientable;
import appeng.api.util.IOrientableBlock;
import appeng.block.AEBaseBlock;
import appeng.client.render.BaseBlockRender;
import appeng.client.render.blocks.RenderBlockQuartzAccelerator;
import appeng.client.render.effects.LightningFX;
import appeng.core.AEConfig;
import appeng.core.CommonHelper;
import appeng.core.features.AEFeature;
import appeng.helpers.MetaRotation;
import appeng.tile.misc.TileQuartzGrowthAccelerator;
import appeng.util.Platform;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class BlockQuartzGrowthAccelerator extends AEBaseBlock implements IOrientableBlock
{
public BlockQuartzGrowthAccelerator() {
super( BlockQuartzGrowthAccelerator.class, Material.rock );
setFeature( EnumSet.of( AEFeature.Core ) );
setTileEntity( TileQuartzGrowthAccelerator.class );
}
@Override
protected Class<? extends BaseBlockRender> getRenderer()
{
return RenderBlockQuartzAccelerator.class;
}
@Override
public IOrientable getOrientable(final IBlockAccess w, final int x, final int y, final int z)
{
return new MetaRotation( w, x, y, z );
}
@Override
@SideOnly(Side.CLIENT)
public void randomDisplayTick(World w, int x, int y, int z, Random r)
{
if ( !AEConfig.instance.enableEffects )
return;
TileQuartzGrowthAccelerator tqga = getTileEntity( w, x, y, z );
if ( tqga != null && tqga.hasPower && CommonHelper.proxy.shouldAddParticles( r ) )
{
double d0 = (double) (r.nextFloat() - 0.5F);
double d1 = (double) (r.nextFloat() - 0.5F);
ForgeDirection up = tqga.getUp();
ForgeDirection forward = tqga.getForward();
ForgeDirection west = Platform.crossProduct( forward, up );
double rx = 0.5 + x;
double ry = 0.5 + y;
double rz = 0.5 + z;
double dx = 0;
double dz = 0;
rx += up.offsetX * d0;
ry += up.offsetY * d0;
rz += up.offsetZ * d0;
switch (r.nextInt( 4 ))
{
case 0:
dx = 0.6;
dz = d1;
if ( !w.getBlock( x + west.offsetX, y + west.offsetY, z + west.offsetZ ).isAir( w, x + west.offsetX, y + west.offsetY, z + west.offsetZ ) )
return;
break;
case 1:
dx = d1;
dz += 0.6;
if ( !w.getBlock( x + forward.offsetX, y + forward.offsetY, z + forward.offsetZ ).isAir( w, x + forward.offsetX, y + forward.offsetY,
z + forward.offsetZ ) )
return;
break;
case 2:
dx = d1;
dz = -0.6;
if ( !w.getBlock( x - forward.offsetX, y - forward.offsetY, z - forward.offsetZ ).isAir( w, x - forward.offsetX, y - forward.offsetY,
z - forward.offsetZ ) )
return;
break;
case 3:
dx = -0.6;
dz = d1;
if ( !w.getBlock( x - west.offsetX, y - west.offsetY, z - west.offsetZ ).isAir( w, x - west.offsetX, y - west.offsetY, z - west.offsetZ ) )
return;
break;
}
rx += dx * west.offsetX;
ry += dx * west.offsetY;
rz += dx * west.offsetZ;
rx += dz * forward.offsetX;
ry += dz * forward.offsetY;
rz += dz * forward.offsetZ;
LightningFX fx = new LightningFX( w, rx, ry, rz, 0.0D, 0.0D, 0.0D );
Minecraft.getMinecraft().effectRenderer.addEffect( (EntityFX) fx );
}
}
@Override
public boolean usesMetadata()
{
return true;
}
}
@@ -0,0 +1,143 @@
package appeng.block.misc;
import java.util.Arrays;
import java.util.EnumSet;
import java.util.List;
import java.util.Random;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.client.Minecraft;
import net.minecraft.client.particle.EntityFX;
import net.minecraft.entity.Entity;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
import appeng.api.util.IOrientable;
import appeng.api.util.IOrientableBlock;
import appeng.block.AEBaseBlock;
import appeng.client.render.BaseBlockRender;
import appeng.client.render.blocks.RenderQuartzTorch;
import appeng.client.render.effects.LightningFX;
import appeng.core.AEConfig;
import appeng.core.CommonHelper;
import appeng.core.features.AEFeature;
import appeng.helpers.ICustomCollision;
import appeng.helpers.MetaRotation;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class BlockQuartzTorch extends AEBaseBlock implements IOrientableBlock, ICustomCollision
{
protected BlockQuartzTorch(Class which) {
super( which, Material.circuits );
setLightOpacity( 0 );
isFullSize = isOpaque = false;
}
public BlockQuartzTorch() {
this( BlockQuartzTorch.class );
setFeature( EnumSet.of( AEFeature.DecorativeLights ) );
setLightLevel( 0.9375F );
}
@Override
protected Class<? extends BaseBlockRender> getRenderer()
{
return RenderQuartzTorch.class;
}
@Override
public IOrientable getOrientable(final IBlockAccess w, final int x, final int y, final int z)
{
return new MetaRotation( w, x, y, z );
}
private void dropTorch(World w, int x, int y, int z)
{
w.func_147480_a( x, y, z, true );
// w.destroyBlock( x, y, z, true );
w.markBlockForUpdate( x, y, z );
}
@Override
public boolean canPlaceBlockAt(World w, int x, int y, int z)
{
for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS)
if ( canPlaceAt( w, x, y, z, dir ) )
return true;
return false;
}
private boolean canPlaceAt(World w, int x, int y, int z, ForgeDirection dir)
{
return w.isSideSolid( x + dir.offsetX, y + dir.offsetY, z + dir.offsetZ, dir.getOpposite(), false );
}
@Override
public boolean isValidOrientation(World w, int x, int y, int z, ForgeDirection forward, ForgeDirection up)
{
return canPlaceAt( w, x, y, z, up.getOpposite() );
}
@Override
public void onNeighborBlockChange(World w, int x, int y, int z, Block id)
{
ForgeDirection up = getOrientable( w, x, y, z ).getUp();
if ( !canPlaceAt( w, x, y, z, up.getOpposite() ) )
dropTorch( w, x, y, z );
}
@Override
public Iterable<AxisAlignedBB> getSelectedBoundingBoxesFromPool(World w, int x, int y, int z, Entity e, boolean isVisual)
{
ForgeDirection up = getOrientable( w, x, y, z ).getUp();
double xOff = -0.3 * up.offsetX;
double yOff = -0.3 * up.offsetY;
double zOff = -0.3 * up.offsetZ;
return Arrays.asList( new AxisAlignedBB[] { AxisAlignedBB.getBoundingBox( xOff + 0.3, yOff + 0.3, zOff + 0.3, xOff + 0.7, yOff + 0.7, zOff + 0.7 ) } );
}
@Override
public void addCollidingBlockToList(World w, int x, int y, int z, AxisAlignedBB bb, List out, Entity e)
{/*
* double xOff = -0.15 * getUp().offsetX; double yOff = -0.15 * getUp().offsetY; double zOff = -0.15 *
* getUp().offsetZ; out.add( AxisAlignedBB.getBoundingBox( xOff + (double) x + 0.15, yOff + (double) y + 0.15, zOff
* + (double) z + 0.15,// ahh xOff + (double) x + 0.85, yOff + (double) y + 0.85, zOff + (double) z + 0.85 ) );
*/
}
@Override
@SideOnly(Side.CLIENT)
public void randomDisplayTick(World w, int x, int y, int z, Random r)
{
if ( !AEConfig.instance.enableEffects )
return;
if ( r.nextFloat() < 0.98 )
return;
ForgeDirection up = getOrientable( w, x, y, z ).getUp();
double xOff = -0.3 * up.offsetX;
double yOff = -0.3 * up.offsetY;
double zOff = -0.3 * up.offsetZ;
for (int bolts = 0; bolts < 3; bolts++)
{
if ( CommonHelper.proxy.shouldAddParticles( r ) )
{
LightningFX fx = new LightningFX( w, xOff + 0.5 + x, yOff + 0.5 + y, zOff + 0.5 + z, 0.0D, 0.0D, 0.0D );
Minecraft.getMinecraft().effectRenderer.addEffect( (EntityFX) fx );
}
}
}
@Override
public boolean usesMetadata()
{
return true;
}
}
@@ -0,0 +1,51 @@
package appeng.block.misc;
import java.util.EnumSet;
import net.minecraft.block.material.Material;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
import appeng.block.AEBaseBlock;
import appeng.client.render.BaseBlockRender;
import appeng.client.render.blocks.RendererSecurity;
import appeng.core.features.AEFeature;
import appeng.core.sync.GuiBridge;
import appeng.tile.misc.TileSecurity;
import appeng.util.Platform;
public class BlockSecurity extends AEBaseBlock
{
public BlockSecurity() {
super( BlockSecurity.class, Material.iron );
setFeature( EnumSet.of( AEFeature.Security ) );
setTileEntity( TileSecurity.class );
}
@Override
protected Class<? extends BaseBlockRender> getRenderer()
{
return RendererSecurity.class;
}
@Override
public boolean onActivated(World w, int x, int y, int z, EntityPlayer p, int side, float hitX, float hitY, float hitZ)
{
if ( p.isSneaking() )
return false;
TileSecurity tg = getTileEntity( w, x, y, z );
if ( tg != null )
{
if ( Platform.isClient() )
return true;
Platform.openGUI( p, tg, ForgeDirection.getOrientation( side ), GuiBridge.GUI_SECURITY );
return true;
}
return false;
}
}
@@ -0,0 +1,161 @@
package appeng.block.misc;
import java.util.Arrays;
import java.util.EnumSet;
import java.util.List;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.entity.Entity;
import net.minecraft.init.Blocks;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.IIcon;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
import appeng.block.AEBaseBlock;
import appeng.client.render.BaseBlockRender;
import appeng.client.render.blocks.RenderBlockSkyCompass;
import appeng.core.features.AEFeature;
import appeng.helpers.ICustomCollision;
import appeng.tile.misc.TileSkyCompass;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class BlockSkyCompass extends AEBaseBlock implements ICustomCollision
{
public BlockSkyCompass() {
super( BlockSkyCompass.class, Material.iron );
setFeature( EnumSet.of( AEFeature.MeteoriteCompass ) );
setTileEntity( TileSkyCompass.class );
isOpaque = isFullSize = false;
lightOpacity = 0;
}
@Override
@SideOnly(Side.CLIENT)
public IIcon getIcon(int direction, int metadata)
{
return Blocks.iron_block.getIcon( direction, metadata );
}
@Override
protected Class<? extends BaseBlockRender> getRenderer()
{
return RenderBlockSkyCompass.class;
}
private void dropTorch(World w, int x, int y, int z)
{
w.func_147480_a( x, y, z, true );
// w.destroyBlock( x, y, z, true );
w.markBlockForUpdate( x, y, z );
}
@Override
public boolean canPlaceBlockAt(World w, int x, int y, int z)
{
for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS)
if ( canPlaceAt( w, x, y, z, dir ) )
return true;
return false;
}
private boolean canPlaceAt(World w, int x, int y, int z, ForgeDirection dir)
{
return w.isSideSolid( x + dir.offsetX, y + dir.offsetY, z + dir.offsetZ, dir.getOpposite(), false );
}
@Override
public boolean isValidOrientation(World w, int x, int y, int z, ForgeDirection forward, ForgeDirection up)
{
TileSkyCompass sc = getTileEntity( w, x, y, z );
if ( sc != null )
return false;
return canPlaceAt( w, x, y, z, forward.getOpposite() );
}
@Override
public void onNeighborBlockChange(World w, int x, int y, int z, Block id)
{
TileSkyCompass sc = getTileEntity( w, x, y, z );
ForgeDirection up = sc.getForward();
if ( !canPlaceAt( w, x, y, z, up.getOpposite() ) )
dropTorch( w, x, y, z );
}
@Override
public Iterable<AxisAlignedBB> getSelectedBoundingBoxesFromPool(World w, int x, int y, int z, Entity e, boolean isVisual)
{
TileSkyCompass tile = getTileEntity( w, x, y, z );
if ( tile != null )
{
ForgeDirection forward = tile.getForward();
double minX = 0;
double minY = 0;
double minZ = 0;
double maxX = 1;
double maxY = 1;
double maxZ = 1;
switch (forward)
{
case DOWN:
minZ = minX = 5.0 / 16.0;
maxZ = maxX = 11.0 / 16.0;
maxY = 1.0;
minY = 14.0 / 16.0;
break;
case EAST:
minZ = minY = 5.0 / 16.0;
maxZ = maxY = 11.0 / 16.0;
maxX = 2.0 / 16.0;
minX = 0.0;
break;
case NORTH:
minY = minX = 5.0 / 16.0;
maxY = maxX = 11.0 / 16.0;
maxZ = 1.0;
minZ = 14.0 / 16.0;
break;
case SOUTH:
minY = minX = 5.0 / 16.0;
maxY = maxX = 11.0 / 16.0;
maxZ = 2.0 / 16.0;
minZ = 0.0;
break;
case UP:
minZ = minX = 5.0 / 16.0;
maxZ = maxX = 11.0 / 16.0;
maxY = 2.0 / 16.0;
minY = 0.0;
break;
case WEST:
minZ = minY = 5.0 / 16.0;
maxZ = maxY = 11.0 / 16.0;
maxX = 1.0;
minX = 14.0 / 16.0;
break;
default:
break;
}
return Arrays.asList( new AxisAlignedBB[] { AxisAlignedBB.getBoundingBox( minX, minY, minZ, maxX, maxY, maxZ ) } );
}
return Arrays.asList( new AxisAlignedBB[] { AxisAlignedBB.getBoundingBox( 0.0, 0, 0.0, 1.0, 1.0, 1.0 ) } );
}
@Override
public void addCollidingBlockToList(World w, int x, int y, int z, AxisAlignedBB bb, List out, Entity e)
{
}
@Override
public void registerBlockIcons(IIconRegister iconRegistry)
{
// :P
}
}
@@ -0,0 +1,165 @@
package appeng.block.misc;
import java.util.Arrays;
import java.util.EnumSet;
import java.util.List;
import net.minecraft.block.Block;
import net.minecraft.block.BlockDispenser;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.projectile.EntityArrow;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.item.Item;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.IIcon;
import net.minecraft.world.Explosion;
import net.minecraft.world.World;
import appeng.block.AEBaseBlock;
import appeng.client.render.BaseBlockRender;
import appeng.client.render.blocks.RenderTinyTNT;
import appeng.client.texture.FullIcon;
import appeng.core.AppEng;
import appeng.core.features.AEFeature;
import appeng.entity.EntityIds;
import appeng.entity.EntityTinyTNTPrimed;
import appeng.helpers.ICustomCollision;
import appeng.hooks.DispenserBehaviorTinyTNT;
import cpw.mods.fml.common.registry.EntityRegistry;
public class BlockTinyTNT extends AEBaseBlock implements ICustomCollision
{
public BlockTinyTNT() {
super( BlockTinyTNT.class, Material.tnt );
setFeature( EnumSet.of( AEFeature.TinyTNT ) );
setLightOpacity( 3 );
setBlockBounds( 0.25f, 0.0f, 0.25f, 0.75f, 0.5f, 0.75f );
isFullSize = isOpaque = false;
EntityRegistry.registerModEntity( EntityTinyTNTPrimed.class, "EntityTinyTNTPrimed", EntityIds.TINY_TNT, AppEng.instance, 16, 4, true );
}
@Override
public void postInit()
{
super.postInit();
BlockDispenser.dispenseBehaviorRegistry.putObject( Item.getItemFromBlock( this ), new DispenserBehaviorTinyTNT() );
}
@Override
protected Class<? extends BaseBlockRender> getRenderer()
{
return RenderTinyTNT.class;
}
@Override
public void registerBlockIcons(IIconRegister iconRegistry)
{
// no images required.
}
@Override
public IIcon getIcon(int direction, int metadata)
{
return new FullIcon( Blocks.tnt.getIcon( direction, metadata ) );
}
@Override
public void onEntityCollidedWithBlock(World w, int x, int y, int z, Entity entity)
{
if ( entity instanceof EntityArrow && !w.isRemote )
{
EntityArrow entityarrow = (EntityArrow) entity;
if ( entityarrow.isBurning() )
{
this.startFuse( w, x, y, z, entityarrow.shootingEntity instanceof EntityLivingBase ? (EntityLivingBase) entityarrow.shootingEntity : null );
w.setBlockToAir( x, y, z );
}
}
}
@Override
public void onBlockAdded(World w, int x, int y, int z)
{
super.onBlockAdded( w, x, y, z );
if ( w.isBlockIndirectlyGettingPowered( x, y, z ) )
{
this.startFuse( w, x, y, z, null );
w.setBlockToAir( x, y, z );
}
}
@Override
public void onNeighborBlockChange(World w, int x, int y, int z, Block id)
{
if ( w.isBlockIndirectlyGettingPowered( x, y, z ) )
{
this.startFuse( w, x, y, z, null );
w.setBlockToAir( x, y, z );
}
}
@Override
public boolean onActivated(World w, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ)
{
if ( player.getCurrentEquippedItem() != null && player.getCurrentEquippedItem().getItem() == Items.flint_and_steel )
{
this.startFuse( w, x, y, z, player );
w.setBlockToAir( x, y, z );
player.getCurrentEquippedItem().damageItem( 1, player );
return true;
}
else
{
return super.onActivated( w, x, y, z, player, side, hitX, hitY, hitZ );
}
}
@Override
public void onBlockDestroyedByExplosion(World w, int x, int y, int z, Explosion exp)
{
if ( !w.isRemote )
{
EntityTinyTNTPrimed entitytntprimed = new EntityTinyTNTPrimed( w, x + 0.5F, y + 0.5F, z + 0.5F, exp.getExplosivePlacedBy() );
entitytntprimed.fuse = w.rand.nextInt( entitytntprimed.fuse / 4 ) + entitytntprimed.fuse / 8;
w.spawnEntityInWorld( entitytntprimed );
}
}
public void startFuse(World w, int x, int y, int z, EntityLivingBase ignitor)
{
if ( !w.isRemote )
{
EntityTinyTNTPrimed entitytntprimed = new EntityTinyTNTPrimed( w, x + 0.5F, y + 0.5F, z + 0.5F, ignitor );
w.spawnEntityInWorld( entitytntprimed );
w.playSoundAtEntity( entitytntprimed, "game.tnt.primed", 1.0F, 1.0F );
}
}
@Override
public boolean canDropFromExplosion(Explosion exp)
{
return false;
}
@Override
public Iterable<AxisAlignedBB> getSelectedBoundingBoxesFromPool(World w, int x, int y, int z, Entity e, boolean isVisual)
{
return Arrays.asList( new AxisAlignedBB[] { AxisAlignedBB.getBoundingBox( 0.25, 0, 0.25, 0.75, 0.5, 0.75 ) } );
}
@Override
public void addCollidingBlockToList(World w, int x, int y, int z, AxisAlignedBB bb, List out, Entity e)
{
out.add( AxisAlignedBB.getBoundingBox( 0.25, 0, 0.25, 0.75, 0.5, 0.75 ) );
}
}
@@ -0,0 +1,108 @@
package appeng.block.misc;
import java.util.EnumSet;
import java.util.Random;
import net.minecraft.block.material.Material;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.util.IIcon;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
import appeng.block.AEBaseBlock;
import appeng.client.texture.ExtraBlockTextures;
import appeng.core.AEConfig;
import appeng.core.features.AEFeature;
import appeng.core.sync.GuiBridge;
import appeng.tile.AEBaseTile;
import appeng.tile.misc.TileVibrationChamber;
import appeng.util.Platform;
public class BlockVibrationChamber extends AEBaseBlock
{
public BlockVibrationChamber() {
super( BlockVibrationChamber.class, Material.iron );
setFeature( EnumSet.of( AEFeature.PowerGen ) );
setTileEntity( TileVibrationChamber.class );
setHardness( 4.2F );
}
@Override
public boolean onActivated(World w, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ)
{
if ( player.isSneaking() )
return false;
if ( Platform.isServer() )
{
TileVibrationChamber tc = getTileEntity( w, x, y, z );
if ( tc != null && !player.isSneaking() )
{
Platform.openGUI( player, tc, ForgeDirection.getOrientation( side ), GuiBridge.GUI_VIBRATIONCHAMBER );
return true;
}
}
return true;
}
@Override
public IIcon getIcon(IBlockAccess w, int x, int y, int z, int s)
{
IIcon ico = super.getIcon( w, x, y, z, s );
TileVibrationChamber tvc = getTileEntity( w, x, y, z );
if ( tvc != null && tvc.isOn && ico == getRendererInstance().getTexture( ForgeDirection.SOUTH ) )
{
return ExtraBlockTextures.BlockVibrationChamberFrontOn.getIcon();
}
return ico;
}
@Override
public void randomDisplayTick(World w, int x, int y, int z, Random r)
{
if ( !AEConfig.instance.enableEffects )
return;
AEBaseTile tile = getTileEntity( w, x, y, z );
if ( tile instanceof TileVibrationChamber )
{
TileVibrationChamber tc = (TileVibrationChamber) tile;
if ( tc.isOn )
{
float f1 = (float) x + 0.5F;
float f2 = (float) y + 0.5F;
float f3 = (float) z + 0.5F;
ForgeDirection forward = tc.getForward();
ForgeDirection up = tc.getUp();
int west_x = forward.offsetY * up.offsetZ - forward.offsetZ * up.offsetY;
int west_y = forward.offsetZ * up.offsetX - forward.offsetX * up.offsetZ;
int west_z = forward.offsetX * up.offsetY - forward.offsetY * up.offsetX;
f1 += forward.offsetX * 0.6;
f2 += forward.offsetY * 0.6;
f3 += forward.offsetZ * 0.6;
float ox = r.nextFloat();
float oy = r.nextFloat() * 0.2f;
f1 += up.offsetX * (-0.3 + oy);
f2 += up.offsetY * (-0.3 + oy);
f3 += up.offsetZ * (-0.3 + oy);
f1 += west_x * (0.3 * ox - 0.15);
f2 += west_y * (0.3 * ox - 0.15);
f3 += west_z * (0.3 * ox - 0.15);
w.spawnParticle( "smoke", (double) f1, (double) f2, (double) f3, 0.0D, 0.0D, 0.0D );
w.spawnParticle( "flame", (double) f1, (double) f2, (double) f3, 0.0D, 0.0D, 0.0D );
}
}
}
}
@@ -0,0 +1,450 @@
package appeng.block.networking;
import java.util.EnumSet;
import java.util.List;
import java.util.Random;
import net.minecraft.block.Block;
import net.minecraft.client.particle.EffectRenderer;
import net.minecraft.client.particle.EntityDiggingFX;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.IIcon;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.util.Vec3;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
import powercrystals.minefactoryreloaded.api.rednet.connectivity.IRedNetConnection;
import powercrystals.minefactoryreloaded.api.rednet.connectivity.RedNetConnectionType;
import appeng.api.parts.IPart;
import appeng.api.parts.IPartHost;
import appeng.api.parts.PartItemStack;
import appeng.api.parts.SelectedPart;
import appeng.api.util.AEColor;
import appeng.block.AEBaseBlock;
import appeng.client.render.BaseBlockRender;
import appeng.client.render.BusRenderHelper;
import appeng.client.render.blocks.RendererCableBus;
import appeng.client.texture.ExtraBlockTextures;
import appeng.core.AEConfig;
import appeng.core.Api;
import appeng.core.AppEng;
import appeng.core.CommonHelper;
import appeng.core.features.AEFeature;
import appeng.helpers.AEGlassMaterial;
import appeng.integration.IntegrationType;
import appeng.integration.abstraction.IFMP;
import appeng.parts.ICableBusContainer;
import appeng.parts.NullCableBusContainer;
import appeng.tile.AEBaseTile;
import appeng.tile.networking.TileCableBus;
import appeng.tile.networking.TileCableBusTESR;
import appeng.transformer.annotations.integration.Interface;
import appeng.transformer.annotations.integration.Method;
import appeng.util.Platform;
import cpw.mods.fml.common.registry.GameRegistry;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
@Interface(iface = "powercrystals.minefactoryreloaded.api.rednet.connectivity.IRedNetConnection", iname = "MFR")
public class BlockCableBus extends AEBaseBlock implements IRedNetConnection
{
static private ICableBusContainer nullCB = new NullCableBusContainer();
static public Class<? extends TileEntity> noTesrTile;
static public Class<? extends TileEntity> tesrTile;
public <T extends TileEntity> T getTileEntity(IBlockAccess w, int x, int y, int z)
{
TileEntity te = w.getTileEntity( x, y, z );
if ( noTesrTile.isInstance( te ) )
return (T) te;
if ( tesrTile != null && tesrTile.isInstance( te ) )
return (T) te;
return null;
}
public BlockCableBus() {
super( BlockCableBus.class, AEGlassMaterial.instance );
setFeature( EnumSet.of( AEFeature.Core ) );
setLightOpacity( 0 );
isFullSize = isOpaque = false;
}
@Override
public int getRenderBlockPass()
{
if ( AEConfig.instance.isFeatureEnabled( AEFeature.AlphaPass ) )
return 1;
return 0;
}
@SideOnly(Side.CLIENT)
public boolean addHitEffects(World world, MovingObjectPosition target, EffectRenderer effectRenderer)
{
Object pobj = cb( world, target.blockX, target.blockY, target.blockZ );
if ( pobj instanceof IPartHost )
{
IPartHost host = (IPartHost) pobj;
for (ForgeDirection side : ForgeDirection.values())
{
IPart p = host.getPart( side );
IIcon ico = getIcon( p );
if ( ico == null )
continue;
byte b0 = (byte) (Platform.getRandomInt() % 2 == 0 ? 1 : 0);
for (int i1 = 0; i1 < b0; ++i1)
{
for (int j1 = 0; j1 < b0; ++j1)
{
for (int k1 = 0; k1 < b0; ++k1)
{
double d0 = (double) target.blockX + ((double) i1 + 0.5D) / (double) b0;
double d1 = (double) target.blockY + ((double) j1 + 0.5D) / (double) b0;
double d2 = (double) target.blockZ + ((double) k1 + 0.5D) / (double) b0;
double dd0 = target.hitVec.xCoord;
double dd1 = target.hitVec.yCoord;
double dd2 = target.hitVec.zCoord;
EntityDiggingFX fx = (new EntityDiggingFX( world, dd0, dd1, dd2, d0 - (double) target.blockX - 0.5D, d1 - (double) target.blockY
- 0.5D, d2 - (double) target.blockZ - 0.5D, this, 0 )).applyColourMultiplier( target.blockX, target.blockY, target.blockZ );
fx.setParticleIcon( ico );
effectRenderer.addEffect( fx );
}
}
}
}
}
return true;
}
@SideOnly(Side.CLIENT)
public boolean addDestroyEffects(World world, int x, int y, int z, int meta, EffectRenderer effectRenderer)
{
Object pobj = cb( world, x, y, z );
if ( pobj instanceof IPartHost )
{
IPartHost host = (IPartHost) pobj;
for (ForgeDirection side : ForgeDirection.values())
{
IPart p = host.getPart( side );
IIcon ico = getIcon( p );
if ( ico == null )
continue;
byte b0 = 3;
for (int i1 = 0; i1 < b0; ++i1)
{
for (int j1 = 0; j1 < b0; ++j1)
{
for (int k1 = 0; k1 < b0; ++k1)
{
double d0 = (double) x + ((double) i1 + 0.5D) / (double) b0;
double d1 = (double) y + ((double) j1 + 0.5D) / (double) b0;
double d2 = (double) z + ((double) k1 + 0.5D) / (double) b0;
EntityDiggingFX fx = (new EntityDiggingFX( world, d0, d1, d2, d0 - (double) x - 0.5D, d1 - (double) y - 0.5D, d2 - (double) z
- 0.5D, this, meta )).applyColourMultiplier( x, y, z );
fx.setParticleIcon( ico );
effectRenderer.addEffect( fx );
}
}
}
}
}
return true;
}
private IIcon getIcon(IPart p)
{
if ( p == null )
return null;
try
{
IIcon ico = p.getBreakingTexture();
if ( ico != null )
return ico;
}
catch (Throwable t)
{
// nothing.
}
ItemStack is = p.getItemStack( PartItemStack.Network );
if ( is == null || is.getItem() == null )
return null;
return is.getItem().getIcon( is, 0 );
}
@Override
public boolean canRenderInPass(int pass)
{
BusRenderHelper.instance.setPass( pass );
if ( AEConfig.instance.isFeatureEnabled( AEFeature.AlphaPass ) )
return true;
return pass == 0;
}
@Override
public boolean isLadder(IBlockAccess world, int x, int y, int z, EntityLivingBase entity)
{
return cb( world, x, y, z ).isLadder( entity );
}
@Override
public boolean recolourBlock(World world, int x, int y, int z, ForgeDirection side, int colour)
{
return recolourBlock( world, x, y, z, side, colour, null );
}
public boolean recolourBlock(World world, int x, int y, int z, ForgeDirection side, int colour, EntityPlayer who)
{
try
{
return cb( world, x, y, z ).recolourBlock( side, AEColor.values()[colour], who );
}
catch (Throwable t)
{
}
return false;
}
@Override
public void randomDisplayTick(World world, int x, int y, int z, Random r)
{
cb( world, x, y, z ).randomDisplayTick( world, x, y, z, r );
}
@Override
public int getLightValue(IBlockAccess world, int x, int y, int z)
{
Block block = world.getBlock( x, y, z );
if ( block != null && block != this )
{
return block.getLightValue( world, x, y, z );
}
if ( block == null )
return 0;
return cb( world, x, y, z ).getLightValue();
}
@Override
public ItemStack getPickBlock(MovingObjectPosition target, World world, int x, int y, int z)
{
Vec3 v3 = target.hitVec.addVector( -x, -y, -z );
SelectedPart sp = cb( world, x, y, z ).selectPart( v3 );
if ( sp.part != null )
return sp.part.getItemStack( PartItemStack.Pick );
else if ( sp.facade != null )
return sp.facade.getItemStack();
return null;
}
@Override
public boolean isReplaceable(IBlockAccess world, int x, int y, int z)
{
return cb( world, x, y, z ).isEmpty();
}
@SuppressWarnings("deprecation")
@Override
public boolean removedByPlayer(World world, EntityPlayer player, int x, int y, int z)
{
if ( player.capabilities.isCreativeMode )
{
AEBaseTile tile = getTileEntity( world, x, y, z );
if ( tile != null )
tile.disableDrops();
// maybe ray trace?
}
return super.removedByPlayer( world, player, x, y, z );
}
@Override
public IIcon getIcon(IBlockAccess w, int x, int y, int z, int s)
{
return getIcon( s, 0 );
}
@Override
public IIcon getIcon(int direction, int metadata)
{
IIcon i = super.getIcon( direction, metadata );
if ( i != null )
return i;
return ExtraBlockTextures.BlockQuartzGlassB.getIcon();
}
@Override
protected Class<? extends BaseBlockRender> getRenderer()
{
return RendererCableBus.class;
}
@Override
public void registerBlockIcons(IIconRegister iconRegistry)
{
}
@Override
public boolean canProvidePower()
{
return true;
}
@Override
public boolean isSideSolid(IBlockAccess w, int x, int y, int z, ForgeDirection side)
{
return cb( w, x, y, z ).isSolidOnSide( side );
}
@Override
public void onNeighborBlockChange(World w, int x, int y, int z, Block meh)
{
cb( w, x, y, z ).onNeighborChanged();
}
@Override
public void onNeighborChange(IBlockAccess w, int x, int y, int z, int tileX, int tileY, int tileZ)
{
if ( Platform.isServer() )
cb( w, x, y, z ).onNeighborChanged();
}
@Override
public Item getItemDropped(int i, Random r, int k)
{
return null;
}
@Override
public boolean onActivated(World w, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ)
{
return cb( w, x, y, z ).activate( player, Vec3.createVectorHelper( hitX, hitY, hitZ ) );
}
@Override
public void onEntityCollidedWithBlock(World w, int x, int y, int z, Entity e)
{
cb( w, x, y, z ).onEntityCollision( e );
}
@Override
public boolean canConnectRedstone(IBlockAccess w, int x, int y, int z, int side)
{
switch (side)
{
case -1:
case 4:
return cb( w, x, y, z ).canConnectRedstone( EnumSet.of( ForgeDirection.UP, ForgeDirection.DOWN ) );
case 0:
return cb( w, x, y, z ).canConnectRedstone( EnumSet.of( ForgeDirection.NORTH ) );
case 1:
return cb( w, x, y, z ).canConnectRedstone( EnumSet.of( ForgeDirection.EAST ) );
case 2:
return cb( w, x, y, z ).canConnectRedstone( EnumSet.of( ForgeDirection.SOUTH ) );
case 3:
return cb( w, x, y, z ).canConnectRedstone( EnumSet.of( ForgeDirection.WEST ) );
}
return false;
}
@Override
public int isProvidingWeakPower(IBlockAccess w, int x, int y, int z, int side)
{
return cb( w, x, y, z ).isProvidingWeakPower( ForgeDirection.getOrientation( side ).getOpposite() );
}
@Override
public int isProvidingStrongPower(IBlockAccess w, int x, int y, int z, int side)
{
return cb( w, x, y, z ).isProvidingStrongPower( ForgeDirection.getOrientation( side ).getOpposite() );
}
@Override
public void getSubBlocks(Item par1, CreativeTabs par2CreativeTabs, List par3List)
{
}
public void setupTile()
{
setTileEntity( noTesrTile = Api.instance.partHelper.getCombinedInstance( TileCableBus.class.getName() ) );
if ( Platform.isClient() )
{
tesrTile = Api.instance.partHelper.getCombinedInstance( TileCableBusTESR.class.getName() );
GameRegistry.registerTileEntity( tesrTile, "ClientOnly_TESR_CableBus" );
CommonHelper.proxy.bindTileEntitySpecialRenderer( tesrTile, this );
}
}
private ICableBusContainer cb(IBlockAccess w, int x, int y, int z)
{
TileEntity te = w.getTileEntity( x, y, z );
ICableBusContainer out = null;
if ( te instanceof TileCableBus )
out = ((TileCableBus) te).cb;
else if ( AppEng.instance.isIntegrationEnabled( IntegrationType.FMP ) )
out = ((IFMP) AppEng.instance.getIntegration( IntegrationType.FMP )).getCableContainer( te );
return out == null ? nullCB : out;
}
/**
* Immibis MB Support.
*/
boolean ImmibisMicroblocks_TransformableBlockMarker = true;
@Override
@Method(iname = "MFR")
public RedNetConnectionType getConnectionType(World world, int x, int y, int z, ForgeDirection side)
{
return cb( world, x, y, z ).canConnectRedstone( EnumSet.allOf( ForgeDirection.class ) ) ? RedNetConnectionType.CableSingle : RedNetConnectionType.None;
}
int myColorMultiplier = 0xffffff;
public void setRenderColor(int color)
{
myColorMultiplier = color;
}
@Override
public int colorMultiplier(IBlockAccess p_149720_1_, int p_149720_2_, int p_149720_3_, int p_149720_4_)
{
return myColorMultiplier;
}
}
@@ -0,0 +1,38 @@
package appeng.block.networking;
import java.util.EnumSet;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.world.World;
import appeng.block.AEBaseBlock;
import appeng.client.render.BaseBlockRender;
import appeng.client.render.blocks.RenderBlockController;
import appeng.core.features.AEFeature;
import appeng.tile.networking.TileController;
public class BlockController extends AEBaseBlock
{
public BlockController() {
super( BlockController.class, Material.iron );
setFeature( EnumSet.of( AEFeature.Channels ) );
setTileEntity( TileController.class );
setHardness( 6 );
}
@Override
public void onNeighborBlockChange(World w, int x, int y, int z, Block id_junk)
{
TileController tc = getTileEntity( w, x, y, z );
if ( tc != null )
tc.onNeighborChange( false );
}
@Override
protected Class<? extends BaseBlockRender> getRenderer()
{
return RenderBlockController.class;
}
}
@@ -0,0 +1,19 @@
package appeng.block.networking;
import java.util.EnumSet;
import appeng.block.AEBaseBlock;
import appeng.core.features.AEFeature;
import appeng.helpers.AEGlassMaterial;
import appeng.tile.networking.TileCreativeEnergyCell;
public class BlockCreativeEnergyCell extends AEBaseBlock
{
public BlockCreativeEnergyCell() {
super( BlockCreativeEnergyCell.class, AEGlassMaterial.instance );
setFeature( EnumSet.of( AEFeature.Creative ) );
setTileEntity( TileCreativeEnergyCell.class );
}
}
@@ -0,0 +1,51 @@
package appeng.block.networking;
import java.util.EnumSet;
import net.minecraft.util.IIcon;
import appeng.client.texture.ExtraBlockTextures;
import appeng.core.features.AEFeature;
import appeng.tile.networking.TileDenseEnergyCell;
public class BlockDenseEnergyCell extends BlockEnergyCell
{
@Override
public double getMaxPower()
{
return 200000.0 * 8.0;
}
public BlockDenseEnergyCell() {
super( BlockDenseEnergyCell.class );
setFeature( EnumSet.of( AEFeature.DenseEnergyCells ) );
setTileEntity( TileDenseEnergyCell.class );
}
@Override
public IIcon getIcon(int direction, int metadata)
{
switch (metadata)
{
case 0:
return ExtraBlockTextures.MEDenseEnergyCell0.getIcon();
case 1:
return ExtraBlockTextures.MEDenseEnergyCell1.getIcon();
case 2:
return ExtraBlockTextures.MEDenseEnergyCell2.getIcon();
case 3:
return ExtraBlockTextures.MEDenseEnergyCell3.getIcon();
case 4:
return ExtraBlockTextures.MEDenseEnergyCell4.getIcon();
case 5:
return ExtraBlockTextures.MEDenseEnergyCell5.getIcon();
case 6:
return ExtraBlockTextures.MEDenseEnergyCell6.getIcon();
case 7:
return ExtraBlockTextures.MEDenseEnergyCell7.getIcon();
}
return super.getIcon( direction, metadata );
}
}
@@ -0,0 +1,19 @@
package appeng.block.networking;
import java.util.EnumSet;
import net.minecraft.block.material.Material;
import appeng.block.AEBaseBlock;
import appeng.core.features.AEFeature;
import appeng.tile.networking.TileEnergyAcceptor;
public class BlockEnergyAcceptor extends AEBaseBlock
{
public BlockEnergyAcceptor() {
super( BlockEnergyAcceptor.class, Material.iron );
setFeature( EnumSet.of( AEFeature.Core ) );
setTileEntity( TileEnergyAcceptor.class );
}
}
@@ -0,0 +1,89 @@
package appeng.block.networking;
import java.util.EnumSet;
import java.util.List;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.IIcon;
import appeng.block.AEBaseBlock;
import appeng.block.AEBaseItemBlockChargeable;
import appeng.client.render.BaseBlockRender;
import appeng.client.render.blocks.RenderBlockEnergyCube;
import appeng.client.texture.ExtraBlockTextures;
import appeng.core.features.AEFeature;
import appeng.helpers.AEGlassMaterial;
import appeng.tile.networking.TileEnergyCell;
import appeng.util.Platform;
public class BlockEnergyCell extends AEBaseBlock
{
public double getMaxPower()
{
return 200000.0;
}
public BlockEnergyCell(Class c) {
super( c, AEGlassMaterial.instance );
}
public BlockEnergyCell() {
this( BlockEnergyCell.class );
setFeature( EnumSet.of( AEFeature.Core ) );
setTileEntity( TileEnergyCell.class );
}
@Override
public void getSubBlocks(Item id, CreativeTabs tab, List list)
{
super.getSubBlocks( id, tab, list );
ItemStack charged = new ItemStack( this, 1 );
NBTTagCompound tag = Platform.openNbtData( charged );
tag.setDouble( "internalCurrentPower", getMaxPower() );
tag.setDouble( "internalMaxPower", getMaxPower() );
list.add( charged );
}
@Override
protected Class<? extends BaseBlockRender> getRenderer()
{
return RenderBlockEnergyCube.class;
}
@Override
public IIcon getIcon(int direction, int metadata)
{
switch (metadata)
{
case 0:
return ExtraBlockTextures.MEEnergyCell0.getIcon();
case 1:
return ExtraBlockTextures.MEEnergyCell1.getIcon();
case 2:
return ExtraBlockTextures.MEEnergyCell2.getIcon();
case 3:
return ExtraBlockTextures.MEEnergyCell3.getIcon();
case 4:
return ExtraBlockTextures.MEEnergyCell4.getIcon();
case 5:
return ExtraBlockTextures.MEEnergyCell5.getIcon();
case 6:
return ExtraBlockTextures.MEEnergyCell6.getIcon();
case 7:
return ExtraBlockTextures.MEEnergyCell7.getIcon();
}
return super.getIcon( direction, metadata );
}
@Override
public Class getItemBlockClass()
{
return AEBaseItemBlockChargeable.class;
}
}
@@ -0,0 +1,188 @@
package appeng.block.networking;
import java.util.Arrays;
import java.util.EnumSet;
import java.util.List;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.IIcon;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
import appeng.block.AEBaseBlock;
import appeng.client.render.BaseBlockRender;
import appeng.client.render.blocks.RenderBlockWireless;
import appeng.core.features.AEFeature;
import appeng.core.sync.GuiBridge;
import appeng.helpers.AEGlassMaterial;
import appeng.helpers.ICustomCollision;
import appeng.tile.networking.TileWireless;
import appeng.util.Platform;
public class BlockWireless extends AEBaseBlock implements ICustomCollision
{
public BlockWireless() {
super( BlockWireless.class, AEGlassMaterial.instance );
setFeature( EnumSet.of( AEFeature.Core, AEFeature.WirelessAccessTerminal ) );
setTileEntity( TileWireless.class );
setLightOpacity( 0 );
isFullSize = false;
isOpaque = false;
}
@Override
protected Class<? extends BaseBlockRender> getRenderer()
{
return RenderBlockWireless.class;
}
@Override
public IIcon getIcon(int direction, int metadata)
{
return super.getIcon( direction, metadata );
}
@Override
public Iterable<AxisAlignedBB> getSelectedBoundingBoxesFromPool(World w, int x, int y, int z, Entity e, boolean isVisual)
{
TileWireless tile = getTileEntity( w, x, y, z );
if ( tile != null )
{
ForgeDirection forward = tile.getForward();
double minX = 0;
double minY = 0;
double minZ = 0;
double maxX = 1;
double maxY = 1;
double maxZ = 1;
switch (forward)
{
case DOWN:
minZ = minX = 3.0 / 16.0;
maxZ = maxX = 13.0 / 16.0;
maxY = 1.0;
minY = 5.0 / 16.0;
break;
case EAST:
minZ = minY = 3.0 / 16.0;
maxZ = maxY = 13.0 / 16.0;
maxX = 11.0 / 16.0;
minX = 0.0;
break;
case NORTH:
minY = minX = 3.0 / 16.0;
maxY = maxX = 13.0 / 16.0;
maxZ = 1.0;
minZ = 5.0 / 16.0;
break;
case SOUTH:
minY = minX = 3.0 / 16.0;
maxY = maxX = 13.0 / 16.0;
maxZ = 11.0 / 16.0;
minZ = 0.0;
break;
case UP:
minZ = minX = 3.0 / 16.0;
maxZ = maxX = 13.0 / 16.0;
maxY = 11.0 / 16.0;
minY = 0.0;
break;
case WEST:
minZ = minY = 3.0 / 16.0;
maxZ = maxY = 13.0 / 16.0;
maxX = 1.0;
minX = 5.0 / 16.0;
break;
default:
break;
}
return Arrays.asList( new AxisAlignedBB[] { AxisAlignedBB.getBoundingBox( minX, minY, minZ, maxX, maxY, maxZ ) } );
}
return Arrays.asList( new AxisAlignedBB[] { AxisAlignedBB.getBoundingBox( 0.0, 0, 0.0, 1.0, 1.0, 1.0 ) } );
}
@Override
public void addCollidingBlockToList(World w, int x, int y, int z, AxisAlignedBB bb, List out, Entity e)
{
TileWireless tile = getTileEntity( w, x, y, z );
if ( tile != null )
{
ForgeDirection forward = tile.getForward();
double minX = 0;
double minY = 0;
double minZ = 0;
double maxX = 1;
double maxY = 1;
double maxZ = 1;
switch (forward)
{
case DOWN:
minZ = minX = 3.0 / 16.0;
maxZ = maxX = 13.0 / 16.0;
maxY = 1.0;
minY = 5.0 / 16.0;
break;
case EAST:
minZ = minY = 3.0 / 16.0;
maxZ = maxY = 13.0 / 16.0;
maxX = 11.0 / 16.0;
minX = 0.0;
break;
case NORTH:
minY = minX = 3.0 / 16.0;
maxY = maxX = 13.0 / 16.0;
maxZ = 1.0;
minZ = 5.0 / 16.0;
break;
case SOUTH:
minY = minX = 3.0 / 16.0;
maxY = maxX = 13.0 / 16.0;
maxZ = 11.0 / 16.0;
minZ = 0.0;
break;
case UP:
minZ = minX = 3.0 / 16.0;
maxZ = maxX = 13.0 / 16.0;
maxY = 11.0 / 16.0;
minY = 0.0;
break;
case WEST:
minZ = minY = 3.0 / 16.0;
maxZ = maxY = 13.0 / 16.0;
maxX = 1.0;
minX = 5.0 / 16.0;
break;
default:
break;
}
out.add( AxisAlignedBB.getBoundingBox( minX, minY, minZ, maxX, maxY, maxZ ) );
}
else
out.add( AxisAlignedBB.getBoundingBox( 0.0, 0.0, 0.0, 1.0, 1.0, 1.0 ) );
}
@Override
public boolean onActivated(World w, int x, int y, int z, EntityPlayer p, int side, float hitX, float hitY, float hitZ)
{
if ( p.isSneaking() )
return false;
TileWireless tg = getTileEntity( w, x, y, z );
if ( tg != null )
{
if ( Platform.isServer() )
Platform.openGUI( p, tg, ForgeDirection.getOrientation( side ), GuiBridge.GUI_WIRELESS );
return true;
}
return false;
}
}
@@ -0,0 +1,110 @@
package appeng.block.qnb;
import java.util.Arrays;
import java.util.EnumSet;
import java.util.List;
import java.util.Random;
import net.minecraft.block.Block;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
import appeng.block.AEBaseBlock;
import appeng.client.EffectType;
import appeng.client.render.BaseBlockRender;
import appeng.client.render.blocks.RenderQNB;
import appeng.core.CommonHelper;
import appeng.core.features.AEFeature;
import appeng.core.sync.GuiBridge;
import appeng.helpers.AEGlassMaterial;
import appeng.helpers.ICustomCollision;
import appeng.tile.qnb.TileQuantumBridge;
import appeng.util.Platform;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class BlockQuantumLinkChamber extends AEBaseBlock implements ICustomCollision
{
public BlockQuantumLinkChamber() {
super( BlockQuantumLinkChamber.class, AEGlassMaterial.instance );
setFeature( EnumSet.of( AEFeature.QuantumNetworkBridge ) );
setTileEntity( TileQuantumBridge.class );
float shave = 2.0f / 16.0f;
setBlockBounds( shave, shave, shave, 1.0f - shave, 1.0f - shave, 1.0f - shave );
setLightOpacity( 0 );
isFullSize = isOpaque = false;
}
@Override
@SideOnly(Side.CLIENT)
public void randomDisplayTick(World w, int bx, int by, int bz, Random r)
{
TileQuantumBridge bridge = getTileEntity( w, bx, by, bz );
if ( bridge != null )
{
if ( bridge.hasQES() )
{
if ( CommonHelper.proxy.shouldAddParticles( r ) )
CommonHelper.proxy.spawnEffect( EffectType.Energy, w, bx + 0.5, by + 0.5, bz + 0.5, null );
}
}
}
@Override
public void onNeighborBlockChange(World w, int x, int y, int z, Block pointlessnumber)
{
TileQuantumBridge bridge = getTileEntity( w, x, y, z );
if ( bridge != null )
bridge.neighborUpdate();
}
@Override
public void breakBlock(World w, int x, int y, int z, Block a, int b)
{
TileQuantumBridge bridge = getTileEntity( w, x, y, z );
if ( bridge != null )
bridge.breakCluster();
super.breakBlock( w, x, y, z, a, b );
}
@Override
protected Class<? extends BaseBlockRender> getRenderer()
{
return RenderQNB.class;
}
@Override
public boolean onActivated(World w, int x, int y, int z, EntityPlayer p, int side, float hitX, float hitY, float hitZ)
{
if ( p.isSneaking() )
return false;
TileQuantumBridge tg = getTileEntity( w, x, y, z );
if ( tg != null )
{
if ( Platform.isServer() )
Platform.openGUI( p, tg, ForgeDirection.getOrientation( side ), GuiBridge.GUI_QNB );
return true;
}
return false;
}
@Override
public Iterable<AxisAlignedBB> getSelectedBoundingBoxesFromPool(World w, int x, int y, int z, Entity e, boolean isVisual)
{
double OnePx = 2.0 / 16.0;
return Arrays.asList( new AxisAlignedBB[] { AxisAlignedBB.getBoundingBox( OnePx, OnePx, OnePx, 1.0 - OnePx, 1.0 - OnePx, 1.0 - OnePx ) } );
}
@Override
public void addCollidingBlockToList(World w, int x, int y, int z, AxisAlignedBB bb, List out, Entity e)
{
double OnePx = 2.0 / 16.0;
out.add( AxisAlignedBB.getBoundingBox( OnePx, OnePx, OnePx, 1.0 - OnePx, 1.0 - OnePx, 1.0 - OnePx ) );
}
}
@@ -0,0 +1,88 @@
package appeng.block.qnb;
import java.util.Arrays;
import java.util.EnumSet;
import java.util.List;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.entity.Entity;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.world.World;
import appeng.block.AEBaseBlock;
import appeng.client.render.BaseBlockRender;
import appeng.client.render.blocks.RenderQNB;
import appeng.core.features.AEFeature;
import appeng.helpers.ICustomCollision;
import appeng.tile.qnb.TileQuantumBridge;
public class BlockQuantumRing extends AEBaseBlock implements ICustomCollision
{
public BlockQuantumRing() {
super( BlockQuantumRing.class, Material.iron );
setFeature( EnumSet.of( AEFeature.QuantumNetworkBridge ) );
setTileEntity( TileQuantumBridge.class );
float shave = 2.0f / 16.0f;
setBlockBounds( shave, shave, shave, 1.0f - shave, 1.0f - shave, 1.0f - shave );
setLightOpacity( 1 );
isFullSize = isOpaque = false;
}
@Override
public void onNeighborBlockChange(World w, int x, int y, int z, Block pointlessnumber)
{
TileQuantumBridge bridge = getTileEntity( w, x, y, z );
if ( bridge != null )
bridge.neighborUpdate();
}
@Override
public void breakBlock(World w, int x, int y, int z, Block a, int b)
{
TileQuantumBridge bridge = getTileEntity( w, x, y, z );
if ( bridge != null )
bridge.breakCluster();
super.breakBlock( w, x, y, z, a, b );
}
@Override
protected Class<? extends BaseBlockRender> getRenderer()
{
return RenderQNB.class;
}
@Override
public Iterable<AxisAlignedBB> getSelectedBoundingBoxesFromPool(World w, int x, int y, int z, Entity e, boolean isVisual)
{
double OnePx = 2.0 / 16.0;
TileQuantumBridge bridge = getTileEntity( w, x, y, z );
if ( bridge != null && bridge.isCorner() )
{
OnePx = 4.0 / 16.0;
}
else if ( bridge != null && bridge.isFormed() )
{
OnePx = 1.0 / 16.0;
}
return Arrays.asList( new AxisAlignedBB[] { AxisAlignedBB.getBoundingBox( OnePx, OnePx, OnePx, 1.0 - OnePx, 1.0 - OnePx, 1.0 - OnePx ) } );
}
@Override
public void addCollidingBlockToList(World w, int x, int y, int z, AxisAlignedBB bb, List out, Entity e)
{
double OnePx = 2.0 / 16.0;
TileQuantumBridge bridge = getTileEntity( w, x, y, z );
if ( bridge != null && bridge.isCorner() )
{
OnePx = 4.0 / 16.0;
}
else if ( bridge != null && bridge.isFormed() )
{
OnePx = 1.0 / 16.0;
}
out.add( AxisAlignedBB.getBoundingBox( OnePx, OnePx, OnePx, 1.0 - OnePx, 1.0 - OnePx, 1.0 - OnePx ) );
}
}
@@ -0,0 +1,17 @@
package appeng.block.solids;
import java.util.EnumSet;
import net.minecraft.block.material.Material;
import appeng.block.AEDecorativeBlock;
import appeng.core.features.AEFeature;
public class BlockFluix extends AEDecorativeBlock
{
public BlockFluix() {
super( BlockFluix.class, Material.rock );
setFeature( EnumSet.of( AEFeature.DecorativeQuartzBlocks ) );
}
}
@@ -0,0 +1,17 @@
package appeng.block.solids;
import java.util.EnumSet;
import net.minecraft.block.material.Material;
import appeng.block.AEDecorativeBlock;
import appeng.core.features.AEFeature;
public class BlockQuartz extends AEDecorativeBlock
{
public BlockQuartz() {
super( BlockQuartz.class, Material.rock );
setFeature( EnumSet.of( AEFeature.DecorativeQuartzBlocks ) );
}
}
@@ -0,0 +1,17 @@
package appeng.block.solids;
import java.util.EnumSet;
import net.minecraft.block.material.Material;
import appeng.block.AEDecorativeBlock;
import appeng.core.features.AEFeature;
public class BlockQuartzChiseled extends AEDecorativeBlock
{
public BlockQuartzChiseled() {
super( BlockQuartzChiseled.class, Material.rock );
setFeature( EnumSet.of( AEFeature.DecorativeQuartzBlocks ) );
}
}
@@ -0,0 +1,48 @@
package appeng.block.solids;
import java.util.EnumSet;
import net.minecraft.block.material.Material;
import net.minecraft.world.IBlockAccess;
import appeng.block.AEBaseBlock;
import appeng.client.render.BaseBlockRender;
import appeng.client.render.blocks.RenderQuartzGlass;
import appeng.core.features.AEFeature;
import appeng.helpers.AEGlassMaterial;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class BlockQuartzGlass extends AEBaseBlock
{
public BlockQuartzGlass() {
this( BlockQuartzGlass.class );
}
@Override
@SideOnly(Side.CLIENT)
public Class<? extends BaseBlockRender> getRenderer()
{
return RenderQuartzGlass.class;
}
@Override
public boolean shouldSideBeRendered(IBlockAccess w, int x, int y, int z, int side)
{
Material mat = w.getBlock( x, y, z ).getMaterial();
if ( mat == Material.glass || mat == AEGlassMaterial.instance )
{
if ( w.getBlock( x, y, z ).getRenderType() == this.getRenderType() )
return false;
}
return super.shouldSideBeRendered( w, x, y, z, side );
}
public BlockQuartzGlass(Class c) {
super( c, Material.glass );
setFeature( EnumSet.of( AEFeature.DecorativeQuartzBlocks ) );
setLightOpacity( 0 );
isOpaque = false;
}
}
@@ -0,0 +1,45 @@
package appeng.block.solids;
import java.util.EnumSet;
import java.util.Random;
import net.minecraft.client.Minecraft;
import net.minecraft.client.particle.EntityFX;
import net.minecraft.world.World;
import appeng.client.render.effects.VibrantFX;
import appeng.core.AEConfig;
import appeng.core.CommonHelper;
import appeng.core.features.AEFeature;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class BlockQuartzLamp extends BlockQuartzGlass
{
public BlockQuartzLamp() {
super( BlockQuartzLamp.class );
setFeature( EnumSet.of( AEFeature.DecorativeQuartzBlocks, AEFeature.DecorativeLights ) );
setLightLevel( 1.0f );
setBlockTextureName( "BlockQuartzGlass" );
}
@Override
@SideOnly(Side.CLIENT)
public void randomDisplayTick(World w, int x, int y, int z, Random r)
{
if ( !AEConfig.instance.enableEffects )
return;
if ( CommonHelper.proxy.shouldAddParticles( r ) )
{
double d0 = (double) (r.nextFloat() - 0.5F) * 0.96D;
double d1 = (double) (r.nextFloat() - 0.5F) * 0.96D;
double d2 = (double) (r.nextFloat() - 0.5F) * 0.96D;
VibrantFX fx = new VibrantFX( w, 0.5 + x + d0, 0.5 + y + d1, 0.5 + z + d2, 0.0D, 0.0D, 0.0D );
Minecraft.getMinecraft().effectRenderer.addEffect( (EntityFX) fx );
}
}
}
@@ -0,0 +1,33 @@
package appeng.block.solids;
import java.util.EnumSet;
import net.minecraft.block.material.Material;
import net.minecraft.world.IBlockAccess;
import appeng.api.util.IOrientable;
import appeng.api.util.IOrientableBlock;
import appeng.block.AEBaseBlock;
import appeng.core.features.AEFeature;
import appeng.helpers.MetaRotation;
public class BlockQuartzPillar extends AEBaseBlock implements IOrientableBlock
{
public BlockQuartzPillar() {
super( BlockQuartzPillar.class, Material.rock );
setFeature( EnumSet.of( AEFeature.DecorativeQuartzBlocks ) );
}
@Override
public IOrientable getOrientable(final IBlockAccess w, final int x, final int y, final int z)
{
return new MetaRotation( w, x, y, z );
}
@Override
public boolean usesMetadata()
{
return true;
}
}
@@ -0,0 +1,190 @@
package appeng.block.solids;
import java.util.EnumSet;
import java.util.List;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.IIcon;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.entity.player.PlayerEvent;
import rblocks.api.RotatableBlockEnable;
import appeng.api.util.IOrientable;
import appeng.api.util.IOrientableBlock;
import appeng.block.AEBaseBlock;
import appeng.core.AppEng;
import appeng.core.WorldSettings;
import appeng.core.features.AEFeature;
import appeng.helpers.LocationRotation;
import appeng.helpers.NullRotation;
import appeng.integration.IntegrationType;
import appeng.integration.abstraction.IRB;
import appeng.util.Platform;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
@RotatableBlockEnable
public class BlockSkyStone extends AEBaseBlock implements IOrientableBlock
{
@SideOnly(Side.CLIENT)
IIcon Block;
@SideOnly(Side.CLIENT)
IIcon Brick;
@SideOnly(Side.CLIENT)
IIcon SmallBrick;
@SubscribeEvent
public void breakFaster(PlayerEvent.BreakSpeed Ev)
{
if ( Ev.block == this && Ev.entityPlayer != null )
{
ItemStack is = Ev.entityPlayer.inventory.getCurrentItem();
int level = -1;
if ( is != null )
level = is.getItem().getHarvestLevel( is, "pickaxe" );
if ( Ev.metadata > 0 || level >= 3 || Ev.originalSpeed > 7.0 )
Ev.newSpeed /= 0.1;
}
}
public BlockSkyStone() {
super( BlockSkyStone.class, Material.rock );
setFeature( EnumSet.of( AEFeature.Core ) );
setHardness( 50 );
hasSubtypes = true;
blockResistance = 150.0f;
setHarvestLevel( "pickaxe", 3, 0 );
MinecraftForge.EVENT_BUS.register( this );
}
@Override
public int damageDropped(int meta)
{
return meta;
}
@Override
public String getUnlocalizedName(ItemStack is)
{
if ( is.getItemDamage() == 1 )
return getUnlocalizedName() + ".Block";
if ( is.getItemDamage() == 2 )
return getUnlocalizedName() + ".Brick";
if ( is.getItemDamage() == 3 )
return getUnlocalizedName() + ".SmallBrick";
return getUnlocalizedName();
}
@Override
public IOrientable getOrientable(final IBlockAccess w, final int x, final int y, final int z)
{
if ( AppEng.instance.isIntegrationEnabled( IntegrationType.RB ) )
{
TileEntity te = w.getTileEntity( x, y, z );
if ( te != null )
{
IOrientable out = ((IRB) AppEng.instance.getIntegration( IntegrationType.RB )).getOrientable( te );
if ( out != null )
return out;
}
}
if ( w.getBlockMetadata( x, y, z ) == 0 )
return new LocationRotation( w, x, y, z );
return new NullRotation();
}
@Override
@SideOnly(Side.CLIENT)
public void registerBlockIcons(IIconRegister ir)
{
super.registerBlockIcons( ir );
Block = ir.registerIcon( getTextureName() + ".Block" );
Brick = ir.registerIcon( getTextureName() + ".Brick" );
SmallBrick = ir.registerIcon( getTextureName() + ".SmallBrick" );
}
@Override
@SideOnly(Side.CLIENT)
public IIcon getIcon(int direction, int metadata)
{
if ( metadata == 1 )
return Block;
if ( metadata == 2 )
return Brick;
if ( metadata == 3 )
return SmallBrick;
return super.getIcon( direction, metadata );
}
@Override
public void setRenderStateByMeta(int metadata)
{
getRendererInstance().setTemporaryRenderIcon( getIcon( 0, metadata ) );
}
@Override
public ItemStack getPickBlock(MovingObjectPosition target, World world, int x, int y, int z)
{
ItemStack is = super.getPickBlock( target, world, x, y, z );
is.setItemDamage( world.getBlockMetadata( x, y, z ) );
return is;
}
@Override
@SideOnly(Side.CLIENT)
public void getSubBlocks(Item i, CreativeTabs ct, List l)
{
super.getSubBlocks( i, ct, l );
l.add( new ItemStack( i, 1, 1 ) );
l.add( new ItemStack( i, 1, 2 ) );
l.add( new ItemStack( i, 1, 3 ) );
}
@Override
public void onBlockAdded(World w, int x, int y, int z)
{
super.onBlockAdded( w, x, y, z );
if ( Platform.isServer() )
WorldSettings.getInstance().getCompass().updateArea( w, x, y, z );
}
@Override
public void breakBlock(World w, int x, int y, int z, Block b, int WTF)
{
super.breakBlock( w, x, y, z, b, WTF );
if ( Platform.isServer() )
WorldSettings.getInstance().getCompass().updateArea( w, x, y, z );
}
// use AE2's renderer, no rotatable blocks.
int getRealRenderType()
{
return getRenderType();
}
@Override
public boolean usesMetadata()
{
return false;
}
}
@@ -0,0 +1,128 @@
package appeng.block.solids;
import java.util.EnumSet;
import java.util.Random;
import net.minecraft.block.material.Material;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.MathHelper;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.oredict.OreDictionary;
import appeng.api.AEApi;
import appeng.block.AEBaseBlock;
import appeng.client.render.BaseBlockRender;
import appeng.client.render.blocks.RenderQuartzOre;
import appeng.core.features.AEFeature;
public class OreQuartz extends AEBaseBlock
{
public int boostBrightnessLow;
public int boostBrightnessHigh;
public boolean enhanceBrightness;
public OreQuartz(Class self) {
super( self, Material.rock );
setFeature( EnumSet.of( AEFeature.Core ) );
setHardness( 3.0F );
setResistance( 5.0F );
boostBrightnessLow = 0;
boostBrightnessHigh = 1;
enhanceBrightness = false;
}
@Override
public void postInit()
{
OreDictionary.registerOre( "oreCertusQuartz", new ItemStack( this ) );
}
@Override
protected Class<? extends BaseBlockRender> getRenderer()
{
return RenderQuartzOre.class;
}
@Override
public int getMixedBrightnessForBlock(IBlockAccess par1iBlockAccess, int par2, int par3, int par4)
{
int j1 = super.getMixedBrightnessForBlock( par1iBlockAccess, par2, par3, par4 );
if ( enhanceBrightness )
{
j1 = Math.max( j1 >> 20, j1 >> 4 );
if ( j1 > 4 )
j1 += boostBrightnessHigh;
else
j1 += boostBrightnessLow;
if ( j1 > 15 )
j1 = 15;
return j1 << 20 | j1 << 4;
}
return j1;
}
public OreQuartz() {
this( OreQuartz.class );
}
ItemStack getItemDropped()
{
return AEApi.instance().materials().materialCertusQuartzCrystal.stack( 1 );
}
@Override
public Item getItemDropped(int id, Random rand, int meta)
{
return getItemDropped().getItem();
}
@Override
public int damageDropped(int id)
{
return getItemDropped().getItemDamage();
}
@Override
public int quantityDropped(Random rand)
{
return 1 + rand.nextInt( 2 );
}
@Override
public int quantityDroppedWithBonus(int fortune, Random rand)
{
if ( fortune > 0 && Item.getItemFromBlock( this ) != getItemDropped( 0, rand, fortune ) )
{
int j = rand.nextInt( fortune + 2 ) - 1;
if ( j < 0 )
{
j = 0;
}
return this.quantityDropped( rand ) * (j + 1);
}
else
{
return this.quantityDropped( rand );
}
}
@Override
public void dropBlockAsItemWithChance(World w, int x, int y, int z, int blockid, float something, int meta)
{
super.dropBlockAsItemWithChance( w, x, y, z, blockid, something, meta );
if ( getItemDropped( blockid, w.rand, meta ) != Item.getItemFromBlock( this ) )
{
int xp = MathHelper.getRandomIntegerInRange( w.rand, 2, 5 );
this.dropXpOnBlockBreak( w, x, y, z, xp );
}
}
}
@@ -0,0 +1,74 @@
package appeng.block.solids;
import java.util.Random;
import net.minecraft.client.Minecraft;
import net.minecraft.client.particle.EntityFX;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
import appeng.api.AEApi;
import appeng.client.render.effects.ChargedOreFX;
import appeng.core.AEConfig;
import appeng.core.CommonHelper;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class OreQuartzCharged extends OreQuartz
{
public OreQuartzCharged() {
super( OreQuartzCharged.class );
boostBrightnessLow = 2;
boostBrightnessHigh = 5;
}
@Override
ItemStack getItemDropped()
{
return AEApi.instance().materials().materialCertusQuartzCrystalCharged.stack( 1 );
}
@Override
@SideOnly(Side.CLIENT)
public void randomDisplayTick(World w, int x, int y, int z, Random r)
{
if ( !AEConfig.instance.enableEffects )
return;
double xOff = (double) (r.nextFloat());
double yOff = (double) (r.nextFloat());
double zOff = (double) (r.nextFloat());
switch (r.nextInt( 6 ))
{
case 0:
xOff = -0.01;
break;
case 1:
yOff = -0.01;
break;
case 2:
xOff = -0.01;
break;
case 3:
zOff = -0.01;
break;
case 4:
xOff = 1.01;
break;
case 5:
yOff = 1.01;
break;
case 6:
zOff = 1.01;
break;
}
if ( CommonHelper.proxy.shouldAddParticles( r ) )
{
ChargedOreFX fx = new ChargedOreFX( w, x + xOff, y + yOff, z + zOff, 0.0f, 0.0f, 0.0f );
Minecraft.getMinecraft().effectRenderer.addEffect( (EntityFX) fx );
}
}
}
@@ -0,0 +1,70 @@
package appeng.block.spatial;
import java.util.Arrays;
import java.util.EnumSet;
import java.util.List;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.Entity;
import net.minecraft.item.Item;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import appeng.block.AEBaseBlock;
import appeng.client.render.BaseBlockRender;
import appeng.client.render.blocks.RenderNull;
import appeng.core.features.AEFeature;
import appeng.helpers.ICustomCollision;
public class BlockMatrixFrame extends AEBaseBlock implements ICustomCollision
{
public BlockMatrixFrame() {
super( BlockMatrixFrame.class, Material.anvil);
setFeature( EnumSet.of( AEFeature.SpatialIO ) );
setResistance( 6000000.0F );
setBlockUnbreakable();
setLightOpacity( 0 );
isOpaque = false;
}
@Override
protected Class<? extends BaseBlockRender> getRenderer()
{
return RenderNull.class;
}
@Override
public void getSubBlocks(Item id, CreativeTabs tab, List list)
{
}
@Override
public void registerBlockIcons(IIconRegister iconRegistry)
{
}
@Override
public boolean canEntityDestroy(IBlockAccess world, int x, int y, int z, Entity entity)
{
return false;
}
@Override
public Iterable<AxisAlignedBB> getSelectedBoundingBoxesFromPool(World w, int x, int y, int z, Entity e, boolean isVisual)
{
return Arrays.asList( new AxisAlignedBB[] {} );// AxisAlignedBB.getBoundingBox( 0.25, 0, 0.25, 0.75, 0.5, 0.75 )
// } );
}
@Override
public void addCollidingBlockToList(World w, int x, int y, int z, AxisAlignedBB bb, List out, Entity e)
{
out.add( AxisAlignedBB.getBoundingBox( 0.0, 0.0, 0.0, 1.0, 1.0, 1.0 ) );
}
}
@@ -0,0 +1,49 @@
package appeng.block.spatial;
import java.util.EnumSet;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
import appeng.block.AEBaseBlock;
import appeng.core.features.AEFeature;
import appeng.core.sync.GuiBridge;
import appeng.tile.spatial.TileSpatialIOPort;
import appeng.util.Platform;
public class BlockSpatialIOPort extends AEBaseBlock
{
public BlockSpatialIOPort() {
super( BlockSpatialIOPort.class, Material.iron );
setFeature( EnumSet.of( AEFeature.SpatialIO ) );
setTileEntity( TileSpatialIOPort.class );
}
@Override
public final void onNeighborBlockChange(World w, int x, int y, int z, Block junk)
{
TileSpatialIOPort te = getTileEntity( w, x, y, z );
if ( te != null )
te.updateRedstoneState();
}
@Override
public boolean onActivated(World w, int x, int y, int z, EntityPlayer p, int side, float hitX, float hitY, float hitZ)
{
if ( p.isSneaking() )
return false;
TileSpatialIOPort tg = getTileEntity( w, x, y, z );
if ( tg != null )
{
if ( Platform.isServer() )
Platform.openGUI( p, tg, ForgeDirection.getOrientation( side ), GuiBridge.GUI_SPATIALIOPORT );
return true;
}
return false;
}
}
@@ -0,0 +1,47 @@
package appeng.block.spatial;
import java.util.EnumSet;
import net.minecraft.block.Block;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import appeng.block.AEBaseBlock;
import appeng.client.render.BaseBlockRender;
import appeng.client.render.blocks.RenderSpatialPylon;
import appeng.core.features.AEFeature;
import appeng.helpers.AEGlassMaterial;
import appeng.tile.spatial.TileSpatialPylon;
public class BlockSpatialPylon extends AEBaseBlock
{
public BlockSpatialPylon() {
super( BlockSpatialPylon.class, AEGlassMaterial.instance );
setFeature( EnumSet.of( AEFeature.SpatialIO ) );
setTileEntity( TileSpatialPylon.class );
}
@Override
public void onNeighborBlockChange(World w, int x, int y, int z, Block junk)
{
TileSpatialPylon tsp = getTileEntity( w, x, y, z );
if ( tsp != null )
tsp.onNeighborBlockChange();
}
@Override
public int getLightValue(IBlockAccess w, int x, int y, int z)
{
TileSpatialPylon tsp = getTileEntity( w, x, y, z );
if ( tsp != null )
return tsp.getLightValue();
return super.getLightValue( w, x, y, z );
}
@Override
protected Class<? extends BaseBlockRender> getRenderer()
{
return RenderSpatialPylon.class;
}
}
@@ -0,0 +1,67 @@
package appeng.block.storage;
import java.util.EnumSet;
import net.minecraft.block.material.Material;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
import appeng.api.AEApi;
import appeng.api.storage.ICellHandler;
import appeng.block.AEBaseBlock;
import appeng.client.render.BaseBlockRender;
import appeng.client.render.blocks.RenderMEChest;
import appeng.core.features.AEFeature;
import appeng.core.localization.PlayerMessages;
import appeng.core.sync.GuiBridge;
import appeng.tile.storage.TileChest;
import appeng.util.Platform;
public class BlockChest extends AEBaseBlock
{
public BlockChest() {
super( BlockChest.class, Material.iron );
setFeature( EnumSet.of( AEFeature.StorageCells, AEFeature.MEChest ) );
setTileEntity( TileChest.class );
}
@Override
protected Class<? extends BaseBlockRender> getRenderer()
{
return RenderMEChest.class;
}
@Override
public boolean onActivated(World w, int x, int y, int z, EntityPlayer p, int side, float hitX, float hitY, float hitZ)
{
TileChest tg = getTileEntity( w, x, y, z );
if ( tg != null && !p.isSneaking() )
{
if ( Platform.isClient() )
return true;
if ( side != tg.getUp().ordinal() )
{
Platform.openGUI( p, tg, ForgeDirection.getOrientation( side ), GuiBridge.GUI_CHEST );
}
else
{
ItemStack cell = tg.getStackInSlot( 1 );
if ( cell != null )
{
ICellHandler ch = AEApi.instance().registries().cell().getHandler( cell );
tg.openGui( p, ch, cell, side );
}
else
p.addChatMessage( PlayerMessages.ChestCannotReadStorageCell.get() );
}
return true;
}
return false;
}
}
@@ -0,0 +1,48 @@
package appeng.block.storage;
import java.util.EnumSet;
import net.minecraft.block.material.Material;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
import appeng.block.AEBaseBlock;
import appeng.client.render.BaseBlockRender;
import appeng.client.render.blocks.RenderDrive;
import appeng.core.features.AEFeature;
import appeng.core.sync.GuiBridge;
import appeng.tile.storage.TileDrive;
import appeng.util.Platform;
public class BlockDrive extends AEBaseBlock
{
public BlockDrive() {
super( BlockDrive.class, Material.iron );
setFeature( EnumSet.of( AEFeature.StorageCells, AEFeature.MEDrive ) );
setTileEntity( TileDrive.class );
}
@Override
protected Class<? extends BaseBlockRender> getRenderer()
{
return RenderDrive.class;
}
@Override
public boolean onActivated(World w, int x, int y, int z, EntityPlayer p, int side, float hitX, float hitY, float hitZ)
{
if ( p.isSneaking() )
return false;
TileDrive tg = getTileEntity( w, x, y, z );
if ( tg != null )
{
if ( Platform.isServer() )
Platform.openGUI( p, tg, ForgeDirection.getOrientation( side ), GuiBridge.GUI_DRIVE );
return true;
}
return false;
}
}
@@ -0,0 +1,48 @@
package appeng.block.storage;
import java.util.EnumSet;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
import appeng.block.AEBaseBlock;
import appeng.core.features.AEFeature;
import appeng.core.sync.GuiBridge;
import appeng.tile.storage.TileIOPort;
import appeng.util.Platform;
public class BlockIOPort extends AEBaseBlock
{
public BlockIOPort() {
super( BlockIOPort.class, Material.iron );
setFeature( EnumSet.of( AEFeature.StorageCells, AEFeature.IOPort ) );
setTileEntity( TileIOPort.class );
}
@Override
public final void onNeighborBlockChange(World w, int x, int y, int z, Block junk)
{
TileIOPort te = getTileEntity( w, x, y, z );
if ( te != null )
te.updateRedstoneState();
}
@Override
public boolean onActivated(World w, int x, int y, int z, EntityPlayer p, int side, float hitX, float hitY, float hitZ)
{
if ( p.isSneaking() )
return false;
TileIOPort tg = getTileEntity( w, x, y, z );
if ( tg != null )
{
if ( Platform.isServer() )
Platform.openGUI( p, tg, ForgeDirection.getOrientation( side ), GuiBridge.GUI_IOPORT );
return true;
}
return false;
}
}
@@ -0,0 +1,128 @@
package appeng.block.storage;
import java.util.Arrays;
import java.util.EnumSet;
import java.util.List;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.IIcon;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
import appeng.api.AEApi;
import appeng.block.AEBaseBlock;
import appeng.client.render.BaseBlockRender;
import appeng.client.render.blocks.RenderBlockSkyChest;
import appeng.core.features.AEFeature;
import appeng.core.sync.GuiBridge;
import appeng.helpers.ICustomCollision;
import appeng.tile.storage.TileSkyChest;
import appeng.util.Platform;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class BlockSkyChest extends AEBaseBlock implements ICustomCollision
{
public BlockSkyChest() {
super( BlockSkyChest.class, Material.rock );
setFeature( EnumSet.of( AEFeature.Core, AEFeature.SkyStoneChests ) );
setTileEntity( TileSkyChest.class );
isOpaque = isFullSize = false;
lightOpacity = 0;
hasSubtypes = true;
setHardness( 50 );
blockResistance = 150.0f;
}
@Override
public String getUnlocalizedName(ItemStack is)
{
if ( is.getItemDamage() == 1 )
return getUnlocalizedName() + ".Block";
return getUnlocalizedName();
}
@Override
public int damageDropped(int metadata) {
return metadata;
}
@Override
@SideOnly(Side.CLIENT)
public IIcon getIcon(int direction, int metadata)
{
if ( metadata == 1 )
return AEApi.instance().blocks().blockSkyStone.block().getIcon( direction, 1 );
return AEApi.instance().blocks().blockSkyStone.block().getIcon( direction, metadata );
}
@Override
public ItemStack getPickBlock(MovingObjectPosition target, World world, int x, int y, int z)
{
ItemStack is = super.getPickBlock( target, world, x, y, z );
is.setItemDamage( world.getBlockMetadata( x, y, z ) );
return is;
}
@Override
@SideOnly(Side.CLIENT)
public void getSubBlocks(Item i, CreativeTabs ct, List l)
{
super.getSubBlocks( i, ct, l );
l.add( new ItemStack( i, 1, 1 ) );
}
@Override
public boolean onActivated(World w, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ)
{
if ( Platform.isServer() )
Platform.openGUI( player, getTileEntity( w, x, y, z ), ForgeDirection.getOrientation( side ), GuiBridge.GUI_SKYCHEST );
return true;
}
@Override
protected Class<? extends BaseBlockRender> getRenderer()
{
return RenderBlockSkyChest.class;
}
@Override
public Iterable<AxisAlignedBB> getSelectedBoundingBoxesFromPool(World w, int x, int y, int z, Entity e, boolean isVisual)
{
TileSkyChest sk = getTileEntity( w, x, y, z );
double sc = 0.06;
ForgeDirection o = ForgeDirection.UNKNOWN;
if ( sk != null )
o = sk.getUp();
double X = o.offsetX == 0 ? 0.06 : 0.0;
double Y = o.offsetY == 0 ? 0.06 : 0.0;
double Z = o.offsetZ == 0 ? 0.06 : 0.0;
return Arrays.asList( new AxisAlignedBB[] { AxisAlignedBB.getBoundingBox( Math.max( 0.0, X - o.offsetX * sc ), Math.max( 0.0, Y - o.offsetY * sc ),
Math.max( 0.0, Z - o.offsetZ * sc ), Math.min( 1.0, (1.0 - X) - o.offsetX * sc ), Math.min( 1.0, (1.0 - Y) - o.offsetY * sc ),
Math.min( 1.0, (1.0 - Z) - o.offsetZ * sc ) ) } );
}
@Override
public void addCollidingBlockToList(World w, int x, int y, int z, AxisAlignedBB bb, List out, Entity e)
{
out.add( AxisAlignedBB.getBoundingBox( 0.05, 0.05, 0.05, 0.95, 0.95, 0.95 ) );
}
@Override
public void registerBlockIcons(IIconRegister iconRegistry)
{
}
}
@@ -0,0 +1,407 @@
package appeng.client;
import static net.minecraftforge.client.IItemRenderer.ItemRenderType.ENTITY;
import static net.minecraftforge.client.IItemRenderer.ItemRendererHelper.BLOCK_3D;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
import net.minecraft.block.Block;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.FontRenderer;
import net.minecraft.client.particle.EntityFX;
import net.minecraft.client.renderer.RenderBlocks;
import net.minecraft.client.renderer.entity.RenderItem;
import net.minecraft.client.renderer.entity.RenderManager;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Items;
import net.minecraft.item.ItemBlock;
import net.minecraft.item.ItemStack;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.util.Vec3;
import net.minecraft.world.World;
import net.minecraftforge.client.ForgeHooksClient;
import net.minecraftforge.client.IItemRenderer;
import net.minecraftforge.client.MinecraftForgeClient;
import net.minecraftforge.client.event.MouseEvent;
import net.minecraftforge.client.event.RenderLivingEvent;
import net.minecraftforge.client.event.TextureStitchEvent;
import net.minecraftforge.common.MinecraftForge;
import org.lwjgl.opengl.GL11;
import appeng.api.parts.CableRenderMode;
import appeng.api.util.AEColor;
import appeng.block.AEBaseBlock;
import appeng.client.render.BaseBlockRender;
import appeng.client.render.TESRWrapper;
import appeng.client.render.WorldRender;
import appeng.client.render.effects.AssemblerFX;
import appeng.client.render.effects.CraftingFx;
import appeng.client.render.effects.EnergyFx;
import appeng.client.render.effects.LightningArcFX;
import appeng.client.render.effects.LightningFX;
import appeng.client.render.effects.VibrantFX;
import appeng.client.texture.CableBusTextures;
import appeng.client.texture.ExtraBlockTextures;
import appeng.client.texture.ExtraItemTextures;
import appeng.core.AEConfig;
import appeng.core.AELog;
import appeng.core.CommonHelper;
import appeng.core.sync.network.NetworkHandler;
import appeng.core.sync.packets.PacketAssemblerAnimation;
import appeng.core.sync.packets.PacketValueConfig;
import appeng.entity.EntityFloatingItem;
import appeng.entity.EntityTinyTNTPrimed;
import appeng.entity.RenderFloatingItem;
import appeng.entity.RenderTinyTNTPrimed;
import appeng.helpers.IMouseWheelItem;
import appeng.hooks.TickHandler;
import appeng.hooks.TickHandler.PlayerColor;
import appeng.server.ServerHelper;
import appeng.transformer.MissingCoreMod;
import appeng.util.Platform;
import cpw.mods.fml.client.registry.ClientRegistry;
import cpw.mods.fml.client.registry.RenderingRegistry;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
public class ClientHelper extends ServerHelper
{
private static RenderItem itemRenderer = new RenderItem();
private static RenderBlocks blockRenderer = new RenderBlocks();
@Override
public CableRenderMode getRenderMode()
{
if ( Platform.isServer() )
return super.getRenderMode();
Minecraft mc = Minecraft.getMinecraft();
EntityPlayer player = mc.thePlayer;
return renderModeForPlayer( player );
}
@Override
public void triggerUpdates()
{
Minecraft mc = Minecraft.getMinecraft();
if ( mc == null || mc.thePlayer == null || mc.theWorld == null )
return;
EntityPlayer player = mc.thePlayer;
if ( player == null )
return;
int x = (int) player.posX;
int y = (int) player.posY;
int z = (int) player.posZ;
int range = 16 * 16;
mc.theWorld.markBlockRangeForRenderUpdate( x - range, y - range, z - range, x + range, y + range, z + range );
}
@SubscribeEvent
public void postPlayerRender(RenderLivingEvent.Pre p)
{
PlayerColor player = TickHandler.instance.getPlayerColors().get( p.entity.getEntityId() );
if ( player != null )
{
AEColor col = player.myColor;
float r = (float) (0xff & (col.mediumVariant >> 16));
float g = (float) (0xff & (col.mediumVariant >> 8));
float b = (float) (0xff & (col.mediumVariant));
GL11.glColor3f( r / 255.0f, g / 255.0f, b / 255.0f );
}
}
@Override
public void doRenderItem(ItemStack itemstack, World w)
{
if ( itemstack != null )
{
EntityItem entityitem = new EntityItem( w, 0.0D, 0.0D, 0.0D, itemstack );
entityitem.getEntityItem().stackSize = 1;
// set all this stuff and then do shit? meh?
entityitem.hoverStart = 0;
entityitem.age = 0;
entityitem.rotationYaw = 0;
GL11.glPushMatrix();
GL11.glTranslatef( 0, -0.04F, 0 );
GL11.glColor4f( 1.0F, 1.0F, 1.0F, 1.0F );
// GL11.glDisable( GL11.GL_CULL_FACE );
if ( itemstack.isItemEnchanted() || itemstack.getItem().requiresMultipleRenderPasses() )
{
GL11.glTranslatef( 0.0f, -0.05f, -0.25f );
GL11.glScalef( 1.0f / 1.5f, 1.0f / 1.5f, 1.0f / 1.5f );
// GL11.glTranslated( -8.0, -12.2, -10.6 );
GL11.glScalef( 1.0f, -1.0f, 0.005f );
// GL11.glScalef( 1.0f , -1.0f, 1.0f );
Block block = Block.getBlockFromItem( itemstack.getItem() );
if ( (itemstack.getItemSpriteNumber() == 0 && block != null && RenderBlocks.renderItemIn3d( block.getRenderType() )) )
{
GL11.glRotatef( 25.0f, 1.0f, 0.0f, 0.0f );
GL11.glRotatef( 15.0f, 0.0f, 1.0f, 0.0f );
GL11.glRotatef( 30.0f, 0.0f, 1.0f, 0.0f );
}
IItemRenderer customRenderer = MinecraftForgeClient.getItemRenderer( itemstack, ENTITY );
if ( customRenderer != null && !(itemstack.getItem() instanceof ItemBlock) )
{
if ( customRenderer.shouldUseRenderHelper( ENTITY, itemstack, BLOCK_3D ) )
{
GL11.glTranslatef( 0, -0.04F, 0 );
GL11.glScalef( 0.7f, 0.7f, 0.7f );
GL11.glRotatef( 35, 1, 0, 0 );
GL11.glRotatef( 45, 0, 1, 0 );
GL11.glRotatef( -90, 0, 1, 0 );
}
}
else if ( itemstack.getItem() instanceof ItemBlock )
{
GL11.glTranslatef( 0, -0.04F, 0 );
GL11.glScalef( 1.1f, 1.1f, 1.1f );
GL11.glRotatef( -90, 0, 1, 0 );
}
else
{
GL11.glTranslatef( 0, -0.14F, 0 );
GL11.glScalef( 0.8f, 0.8f, 0.8f );
}
RenderItem.renderInFrame = true;
RenderManager.instance.renderEntityWithPosYaw( entityitem, 0.0D, 0.0D, 0.0D, 0.0F, 0.0F );
RenderItem.renderInFrame = false;
}
else
{
GL11.glScalef( 1.0f / 42.0f, 1.0f / 42.0f, 1.0f / 42.0f );
GL11.glTranslated( -8.0, -10.2, -10.4 );
GL11.glScalef( 1.0f, 1.0f, 0.005f );
RenderItem.renderInFrame = false;
FontRenderer fr = Minecraft.getMinecraft().fontRenderer;
if ( !ForgeHooksClient.renderInventoryItem( blockRenderer, Minecraft.getMinecraft().renderEngine, itemstack, true, 0, (float) 0, (float) 0 ) )
{
itemRenderer.renderItemIntoGUI( fr, Minecraft.getMinecraft().renderEngine, itemstack, 0, 0, false );
}
}
GL11.glPopMatrix();
}
}
@Override
public void init()
{
MinecraftForge.EVENT_BUS.register( this );
}
@Override
public void postinit()
{
RenderingRegistry.registerBlockHandler( WorldRender.instance );
RenderManager.instance.entityRenderMap.put( EntityTinyTNTPrimed.class, new RenderTinyTNTPrimed() );
RenderManager.instance.entityRenderMap.put( EntityFloatingItem.class, new RenderFloatingItem() );
}
@SubscribeEvent
public void wheelEvent(MouseEvent me)
{
if ( me.isCanceled() || me.dwheel == 0 )
return;
Minecraft mc = Minecraft.getMinecraft();
EntityPlayer player = mc.thePlayer;
ItemStack is = player.getHeldItem();
if ( is != null && is.getItem() instanceof IMouseWheelItem && player.isSneaking() )
{
try
{
NetworkHandler.instance.sendToServer( new PacketValueConfig( "Item", me.dwheel > 0 ? "WheelUp" : "WheelDown" ) );
me.setCanceled( true );
}
catch (IOException e)
{
AELog.error( e );
}
}
}
@SubscribeEvent
public void updateTextureSheet(TextureStitchEvent.Pre ev)
{
if ( ev.map.getTextureType() == 1 )
{
for (ExtraItemTextures et : ExtraItemTextures.values())
et.registerIcon( ev.map );
}
if ( ev.map.getTextureType() == 0 )
{
for (ExtraBlockTextures et : ExtraBlockTextures.values())
et.registerIcon( ev.map );
for (CableBusTextures cb : CableBusTextures.values())
cb.registerIcon( ev.map );
}
}
@Override
public World getWorld()
{
if ( Platform.isClient() )
return Minecraft.getMinecraft().theWorld;
else
return super.getWorld();
}
@Override
public void bindTileEntitySpecialRenderer(Class tile, AEBaseBlock blk)
{
BaseBlockRender bbr = blk.getRendererInstance().rendererInstance;
if ( bbr.hasTESR && tile != null )
ClientRegistry.bindTileEntitySpecialRenderer( tile, new TESRWrapper( bbr ) );
}
@Override
public List<EntityPlayer> getPlayers()
{
if ( Platform.isClient() )
{
List<EntityPlayer> o = new ArrayList();
o.add( Minecraft.getMinecraft().thePlayer );
return o;
}
else
return super.getPlayers();
}
@Override
public void spawnEffect(EffectType effect, World worldObj, double posX, double posY, double posZ, Object o)
{
if ( AEConfig.instance.enableEffects )
{
switch (effect)
{
case Assembler:
spawnAssembler( worldObj, posX, posY, posZ, o );
return;
case Vibrant:
spawnVibrant( worldObj, posX, posY, posZ );
return;
case Crafting:
spawnCrafting( worldObj, posX, posY, posZ );
return;
case Energy:
spawnEnergy( worldObj, posX, posY, posZ );
return;
case Lightning:
spawnLightning( worldObj, posX, posY, posZ );
return;
case LightningArc:
spawnLightningArc( worldObj, posX, posY, posZ, (Vec3) o );
return;
}
}
}
private void spawnAssembler(World worldObj, double posX, double posY, double posZ, Object o)
{
PacketAssemblerAnimation paa = (PacketAssemblerAnimation) o;
AssemblerFX fx = new AssemblerFX( Minecraft.getMinecraft().theWorld, posX, posY, posZ, 0.0D, 0.0D, 0.0D, paa.rate, paa.is );
Minecraft.getMinecraft().effectRenderer.addEffect( (EntityFX) fx );
}
private void spawnVibrant(World w, double x, double y, double z)
{
if ( CommonHelper.proxy.shouldAddParticles( Platform.getRandom() ) )
{
double d0 = (double) (Platform.getRandomFloat() - 0.5F) * 0.26D;
double d1 = (double) (Platform.getRandomFloat() - 0.5F) * 0.26D;
double d2 = (double) (Platform.getRandomFloat() - 0.5F) * 0.26D;
VibrantFX fx = new VibrantFX( w, x + d0, y + d1, z + d2, 0.0D, 0.0D, 0.0D );
Minecraft.getMinecraft().effectRenderer.addEffect( (EntityFX) fx );
}
}
private void spawnLightningArc(World worldObj, double posX, double posY, double posZ, Vec3 second)
{
LightningFX fx = new LightningArcFX( worldObj, posX, posY, posZ, second.xCoord, second.yCoord, second.zCoord, 0.0f, 0.0f, 0.0f );
Minecraft.getMinecraft().effectRenderer.addEffect( (EntityFX) fx );
}
private void spawnLightning(World worldObj, double posX, double posY, double posZ)
{
LightningFX fx = new LightningFX( worldObj, posX, posY + 0.3f, posZ, 0.0f, 0.0f, 0.0f );
Minecraft.getMinecraft().effectRenderer.addEffect( (EntityFX) fx );
}
private void spawnEnergy(World w, double posX, double posY, double posZ)
{
float x = (float) (((Platform.getRandomInt() % 100) * 0.01) - 0.5) * 0.7f;
float y = (float) (((Platform.getRandomInt() % 100) * 0.01) - 0.5) * 0.7f;
float z = (float) (((Platform.getRandomInt() % 100) * 0.01) - 0.5) * 0.7f;
EnergyFx fx = new EnergyFx( w, posX + x, posY + y, posZ + z, Items.diamond );
fx.motionX = -x * 0.1;
fx.motionY = -y * 0.1;
fx.motionZ = -z * 0.1;
Minecraft.getMinecraft().effectRenderer.addEffect( (EntityFX) fx );
}
private void spawnCrafting(World w, double posX, double posY, double posZ)
{
float x = (float) (((Platform.getRandomInt() % 100) * 0.01) - 0.5) * 0.7f;
float y = (float) (((Platform.getRandomInt() % 100) * 0.01) - 0.5) * 0.7f;
float z = (float) (((Platform.getRandomInt() % 100) * 0.01) - 0.5) * 0.7f;
CraftingFx fx = new CraftingFx( w, posX + x, posY + y, posZ + z, Items.diamond );
fx.motionX = -x * 0.2;
fx.motionY = -y * 0.2;
fx.motionZ = -z * 0.2;
Minecraft.getMinecraft().effectRenderer.addEffect( (EntityFX) fx );
}
@Override
public boolean shouldAddParticles(Random r)
{
int setting = Minecraft.getMinecraft().gameSettings.particleSetting;
if ( setting == 2 )
return false;
if ( setting == 0 )
return true;
return r.nextInt( 2 * (setting + 1) ) == 0;
}
@Override
public MovingObjectPosition getMOP()
{
return Minecraft.getMinecraft().objectMouseOver;
}
@Override
public void missingCoreMod()
{
throw new MissingCoreMod();
}
}
@@ -0,0 +1,6 @@
package appeng.client;
public enum EffectType
{
Energy, Lightning, Vibrant, Crafting, Assembler, LightningArc
}
@@ -0,0 +1,952 @@
package appeng.client.gui;
import java.io.IOException;
import java.text.DecimalFormat;
import java.text.ParseException;
import java.util.Collection;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.Set;
import java.util.concurrent.TimeUnit;
import appeng.container.slot.*;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.client.renderer.RenderHelper;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.client.renderer.entity.RenderItem;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.Container;
import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ResourceLocation;
import org.lwjgl.input.Keyboard;
import org.lwjgl.input.Mouse;
import org.lwjgl.opengl.GL11;
import org.lwjgl.opengl.GL12;
import appeng.api.storage.data.IAEItemStack;
import appeng.client.gui.widgets.GuiScrollbar;
import appeng.client.gui.widgets.ITooltip;
import appeng.client.me.InternalSlotME;
import appeng.client.me.SlotDisconnected;
import appeng.client.me.SlotME;
import appeng.client.render.AppEngRenderItem;
import appeng.container.AEBaseContainer;
import appeng.container.slot.AppEngSlot.hasCalculatedValidness;
import appeng.container.slot.SlotInaccessible;
import appeng.core.AELog;
import appeng.core.AppEng;
import appeng.core.sync.network.NetworkHandler;
import appeng.core.sync.packets.PacketInventoryAction;
import appeng.core.sync.packets.PacketSwapSlots;
import appeng.helpers.InventoryAction;
import appeng.integration.IntegrationType;
import appeng.integration.abstraction.INEI;
import appeng.util.Platform;
import com.google.common.base.Stopwatch;
import cpw.mods.fml.common.ObfuscationReflectionHelper;
public abstract class AEBaseGui extends GuiContainer
{
protected List<InternalSlotME> meSlots = new LinkedList<InternalSlotME>();
protected GuiScrollbar myScrollBar = null;
static public boolean switchingGuis;
private boolean subGui;
public AEBaseGui(Container container)
{
super( container );
subGui = switchingGuis;
switchingGuis = false;
}
protected int getQty(GuiButton btn)
{
try
{
DecimalFormat df = new DecimalFormat( "+#;-#" );
return df.parse( btn.displayString ).intValue();
}
catch (ParseException e)
{
return 0;
}
}
public boolean isSubGui()
{
return subGui;
}
@Override
public void initGui()
{
super.initGui();
Iterator<Slot> i = inventorySlots.inventorySlots.iterator();
while (i.hasNext())
if ( i.next() instanceof SlotME )
i.remove();
for (InternalSlotME me : meSlots)
inventorySlots.inventorySlots.add( new SlotME( me ) );
}
@Override
public void handleMouseInput()
{
super.handleMouseInput();
int i = Mouse.getEventDWheel();
if ( i != 0 && isShiftKeyDown() )
{
int x = Mouse.getEventX() * this.width / this.mc.displayWidth;
int y = this.height - Mouse.getEventY() * this.height / this.mc.displayHeight - 1;
mouseWheelEvent( x, y, i / Math.abs( i ) );
}
else if ( i != 0 && myScrollBar != null )
myScrollBar.wheel( i );
}
protected void mouseWheelEvent(int x, int y, int wheel)
{
Slot slot = getSlot( x, y );
if ( slot instanceof SlotME )
{
IAEItemStack item = ((SlotME) slot).getAEStack();
if ( item != null )
{
try
{
((AEBaseContainer) inventorySlots).setTargetStack( item );
InventoryAction direction = wheel > 0 ? InventoryAction.ROLLDOWN : InventoryAction.ROLLUP;
int times = Math.abs( wheel );
for (int h = 0; h < times; h++)
{
PacketInventoryAction p = new PacketInventoryAction( direction, inventorySlots.inventorySlots.size(), 0 );
NetworkHandler.instance.sendToServer( p );
}
}
catch (IOException e)
{
AELog.error( e );
}
}
}
}
@Override
public void onGuiClosed()
{
super.onGuiClosed();
subGui = true; // in case the gui is reopened later ( i'm looking at you NEI )
}
@Override
protected void mouseClicked(int xCoord, int yCoord, int btn)
{
drag_click.clear();
if ( btn == 1 )
{
for (Object o : this.buttonList)
{
GuiButton guibutton = (GuiButton) o;
if ( guibutton.mousePressed( this.mc, xCoord, yCoord ) )
{
super.mouseClicked( xCoord, yCoord, 0 );
return;
}
}
}
super.mouseClicked( xCoord, yCoord, btn );
}
boolean disableShiftClick = false;
Stopwatch dbl_clickTimer = Stopwatch.createStarted();
ItemStack dbl_whichItem;
Slot bl_clicked;
// dragy
Set<Slot> drag_click = new HashSet();
@Override
protected void handleMouseClick(Slot slot, int slotIdx, int ctrlDown, int key)
{
EntityPlayer player = Minecraft.getMinecraft().thePlayer;
if ( slot instanceof SlotFake )
{
InventoryAction action = null;
action = ctrlDown == 1 ? InventoryAction.SPLIT_OR_PLACESINGLE : InventoryAction.PICKUP_OR_SETDOWN;
if ( drag_click.size() > 1 )
return;
if ( action != null )
{
try
{
PacketInventoryAction p = new PacketInventoryAction( action, slotIdx, 0 );
NetworkHandler.instance.sendToServer( p );
}
catch (IOException e)
{
AELog.error( e );
}
}
return;
}
if ( slot instanceof SlotPatternTerm )
{
if ( key == 6 )
return; // prevent weird double clicks..
try
{
NetworkHandler.instance.sendToServer( ((SlotPatternTerm) slot).getRequest( key == 1 ) );
}
catch (IOException e)
{
AELog.error( e );
}
}
else if ( slot instanceof SlotCraftingTerm )
{
if ( key == 6 )
return; // prevent weird double clicks..
InventoryAction action = null;
if ( key == 1 )
action = InventoryAction.CRAFT_SHIFT;
else
action = ctrlDown == 1 ? InventoryAction.CRAFT_STACK : InventoryAction.CRAFT_ITEM;
if ( action != null )
{
try
{
PacketInventoryAction p = new PacketInventoryAction( action, slotIdx, 0 );
NetworkHandler.instance.sendToServer( p );
}
catch (IOException e)
{
AELog.error( e );
}
}
return;
}
if ( Keyboard.isKeyDown( Keyboard.KEY_SPACE ) )
{
if ( enableSpaceClicking() )
{
IAEItemStack stack = null;
if ( slot instanceof SlotME )
stack = ((SlotME) slot).getAEStack();
try
{
int slotNum = inventorySlots.inventorySlots.size();
if ( !(slot instanceof SlotME) && slot != null )
slotNum = slot.slotNumber;
((AEBaseContainer) inventorySlots).setTargetStack( stack );
PacketInventoryAction p = new PacketInventoryAction( InventoryAction.MOVE_REGION, slotNum, 0 );
NetworkHandler.instance.sendToServer( p );
}
catch (IOException e)
{
AELog.error( e );
}
return;
}
}
if ( slot instanceof SlotDisconnected )
{
InventoryAction action = null;
switch (key)
{
case 0: // pickup / set-down.
action = ctrlDown == 1 ? InventoryAction.SPLIT_OR_PLACESINGLE : InventoryAction.PICKUP_OR_SETDOWN;
break;
case 1:
action = ctrlDown == 1 ? InventoryAction.PICKUP_SINGLE : InventoryAction.SHIFT_CLICK;
break;
case 3: // creative dupe:
if ( player.capabilities.isCreativeMode )
{
action = InventoryAction.CREATIVE_DUPLICATE;
}
break;
default:
case 4: // drop item:
case 6:
}
if ( action != null )
{
try
{
PacketInventoryAction p = new PacketInventoryAction( action, slot.getSlotIndex(), ((SlotDisconnected) slot).mySlot.id );
NetworkHandler.instance.sendToServer( p );
}
catch (IOException e)
{
AELog.error( e );
}
}
return;
}
if ( slot instanceof SlotME )
{
InventoryAction action = null;
IAEItemStack stack = null;
switch (key)
{
case 0: // pickup / set-down.
action = ctrlDown == 1 ? InventoryAction.SPLIT_OR_PLACESINGLE : InventoryAction.PICKUP_OR_SETDOWN;
stack = ((SlotME) slot).getAEStack();
if ( stack != null && action == InventoryAction.PICKUP_OR_SETDOWN && stack.getStackSize() == 0 && player.inventory.getItemStack() == null )
action = InventoryAction.AUTOCRAFT;
break;
case 1:
action = ctrlDown == 1 ? InventoryAction.PICKUP_SINGLE : InventoryAction.SHIFT_CLICK;
stack = ((SlotME) slot).getAEStack();
break;
case 3: // creative dupe:
stack = ((SlotME) slot).getAEStack();
if ( stack != null && stack.isCraftable() )
action = InventoryAction.AUTOCRAFT;
else if ( player.capabilities.isCreativeMode )
{
IAEItemStack slotItem = ((SlotME) slot).getAEStack();
if ( slotItem != null )
{
action = InventoryAction.CREATIVE_DUPLICATE;
}
}
break;
default:
case 4: // drop item:
case 6:
}
if ( action != null )
{
try
{
((AEBaseContainer) inventorySlots).setTargetStack( stack );
PacketInventoryAction p = new PacketInventoryAction( action, inventorySlots.inventorySlots.size(), 0 );
NetworkHandler.instance.sendToServer( p );
}
catch (IOException e)
{
AELog.error( e );
}
}
return;
}
if ( disableShiftClick == false && isShiftKeyDown() )
{
disableShiftClick = true;
if ( dbl_whichItem == null || bl_clicked != slot || dbl_clickTimer.elapsed( TimeUnit.MILLISECONDS ) > 150 )
{
// some simple double click logic.
bl_clicked = slot;
dbl_clickTimer = Stopwatch.createStarted();
if ( slot != null )
dbl_whichItem = slot.getHasStack() ? slot.getStack().copy() : null;
else
dbl_whichItem = null;
}
else if ( dbl_whichItem != null )
{
// a replica of the weird broken vanilla feature.
Iterator iterator = this.inventorySlots.inventorySlots.iterator();
while (iterator.hasNext())
{
Slot targetSlot = (Slot) iterator.next();
if ( targetSlot != null && targetSlot.canTakeStack( this.mc.thePlayer ) && targetSlot.getHasStack()
&& targetSlot.inventory == slot.inventory && Container.func_94527_a( targetSlot, dbl_whichItem, true ) )
{
this.handleMouseClick( targetSlot, targetSlot.slotNumber, ctrlDown, 1 );
}
}
}
disableShiftClick = false;
}
super.handleMouseClick( slot, slotIdx, ctrlDown, key );
}
protected void mouseClickMove(int x, int y, int c, long d)
{
Slot slot = this.getSlot( x, y );
ItemStack itemstack = this.mc.thePlayer.inventory.getItemStack();
if ( slot instanceof SlotFake && itemstack != null )
{
drag_click.add( slot );
if ( drag_click.size() > 1 )
{
try
{
for (Slot dr : drag_click)
{
PacketInventoryAction p = new PacketInventoryAction( c == 0 ? InventoryAction.PICKUP_OR_SETDOWN : InventoryAction.PLACE_SINGLE,
dr.slotNumber, 0 );
NetworkHandler.instance.sendToServer( p );
}
}
catch (IOException e)
{
AELog.error( e );
}
}
}
else
super.mouseClickMove( x, y, c, d );
}
protected boolean enableSpaceClicking()
{
return true;
}
@Override
protected boolean checkHotbarKeys(int p_146983_1_)
{
Slot theSlot;
try
{
theSlot = ObfuscationReflectionHelper.getPrivateValue( GuiContainer.class, this, "theSlot", "field_147006_u", "f" );
}
catch (Throwable t)
{
return false;
}
if ( this.mc.thePlayer.inventory.getItemStack() == null && theSlot != null )
{
for (int j = 0; j < 9; ++j)
{
if ( p_146983_1_ == this.mc.gameSettings.keyBindsHotbar[j].getKeyCode() )
{
for (Slot s : (List<Slot>) inventorySlots.inventorySlots)
{
if ( s.getSlotIndex() == j && s.inventory == ((AEBaseContainer) inventorySlots).getPlayerInv() )
{
if ( !s.canTakeStack( ((AEBaseContainer) inventorySlots).getPlayerInv().player ) )
{
return false;
}
}
}
if ( theSlot.getSlotStackLimit() == 64 )
{
this.handleMouseClick( theSlot, theSlot.slotNumber, j, 2 );
return true;
}
else
{
try
{
for (Slot s : (List<Slot>) inventorySlots.inventorySlots)
{
if ( s.getSlotIndex() == j && s.inventory == ((AEBaseContainer) inventorySlots).getPlayerInv() )
{
NetworkHandler.instance.sendToServer( new PacketSwapSlots( s.slotNumber, theSlot.slotNumber ) );
return true;
}
}
}
catch (IOException e)
{
AELog.error( e );
}
}
}
}
}
return false;
}
@Override
public void drawScreen(int mouse_x, int mouse_y, float btn)
{
super.drawScreen( mouse_x, mouse_y, btn );
boolean hasClicked = Mouse.isButtonDown( 0 );
if ( hasClicked && myScrollBar != null )
myScrollBar.click( this, mouse_x - guiLeft, mouse_y - guiTop );
for (Object c : buttonList)
{
if ( c instanceof ITooltip )
{
ITooltip tooltip = (ITooltip) c;
int x = tooltip.xPos(); // ((GuiImgButton) c).xPosition;
int y = tooltip.yPos(); // ((GuiImgButton) c).yPosition;
if ( x < mouse_x && x + tooltip.getWidth() > mouse_x && tooltip.isVisible() )
{
if ( y < mouse_y && y + tooltip.getHeight() > mouse_y )
{
if ( y < 15 )
y = 15;
String msg = tooltip.getMsg();
if ( msg != null )
drawTooltip( x + 11, y + 4, 0, msg );
}
}
}
}
}
public void drawTooltip(int par2, int par3, int forceWidth, String Msg)
{
GL11.glPushAttrib( GL11.GL_ALL_ATTRIB_BITS );
GL11.glDisable( GL12.GL_RESCALE_NORMAL );
RenderHelper.disableStandardItemLighting();
GL11.glDisable( GL11.GL_LIGHTING );
GL11.glDisable( GL11.GL_DEPTH_TEST );
String[] var4 = Msg.split( "\n" );
if ( var4.length > 0 )
{
int var5 = 0;
int var6;
int var7;
for (var6 = 0; var6 < var4.length; ++var6)
{
var7 = fontRendererObj.getStringWidth( (String) var4[var6] );
if ( var7 > var5 )
{
var5 = var7;
}
}
var6 = par2 + 12;
var7 = par3 - 12;
int var9 = 8;
if ( var4.length > 1 )
{
var9 += 2 + (var4.length - 1) * 10;
}
if ( this.guiTop + var7 + var9 + 6 > this.height )
{
var7 = this.height - var9 - this.guiTop - 6;
}
if ( forceWidth > 0 )
var5 = forceWidth;
this.zLevel = 300.0F;
itemRender.zLevel = 300.0F;
int var10 = -267386864;
this.drawGradientRect( var6 - 3, var7 - 4, var6 + var5 + 3, var7 - 3, var10, var10 );
this.drawGradientRect( var6 - 3, var7 + var9 + 3, var6 + var5 + 3, var7 + var9 + 4, var10, var10 );
this.drawGradientRect( var6 - 3, var7 - 3, var6 + var5 + 3, var7 + var9 + 3, var10, var10 );
this.drawGradientRect( var6 - 4, var7 - 3, var6 - 3, var7 + var9 + 3, var10, var10 );
this.drawGradientRect( var6 + var5 + 3, var7 - 3, var6 + var5 + 4, var7 + var9 + 3, var10, var10 );
int var11 = 1347420415;
int var12 = (var11 & 16711422) >> 1 | var11 & -16777216;
this.drawGradientRect( var6 - 3, var7 - 3 + 1, var6 - 3 + 1, var7 + var9 + 3 - 1, var11, var12 );
this.drawGradientRect( var6 + var5 + 2, var7 - 3 + 1, var6 + var5 + 3, var7 + var9 + 3 - 1, var11, var12 );
this.drawGradientRect( var6 - 3, var7 - 3, var6 + var5 + 3, var7 - 3 + 1, var11, var11 );
this.drawGradientRect( var6 - 3, var7 + var9 + 2, var6 + var5 + 3, var7 + var9 + 3, var12, var12 );
for (int var13 = 0; var13 < var4.length; ++var13)
{
String var14 = (String) var4[var13];
if ( var13 == 0 )
{
var14 = "\u00a7" + Integer.toHexString( 15 ) + var14;
}
else
{
var14 = "\u00a77" + var14;
}
this.fontRendererObj.drawStringWithShadow( var14, var6, var7, -1 );
if ( var13 == 0 )
{
var7 += 2;
}
var7 += 10;
}
this.zLevel = 0.0F;
itemRender.zLevel = 0.0F;
}
GL11.glPopAttrib();
}
public abstract void drawBG(int offsetX, int offsetY, int mouseX, int mouseY);
public abstract void drawFG(int offsetX, int offsetY, int mouseX, int mouseY);
public void bindTexture(String base, String file)
{
ResourceLocation loc = new ResourceLocation( base, "textures/" + file );
this.mc.getTextureManager().bindTexture( loc );
}
public void bindTexture(String file)
{
ResourceLocation loc = new ResourceLocation( "appliedenergistics2", "textures/" + file );
this.mc.getTextureManager().bindTexture( loc );
}
protected void drawItem(int x, int y, ItemStack is)
{
this.zLevel = 100.0F;
itemRender.zLevel = 100.0F;
GL11.glPushAttrib( GL11.GL_ALL_ATTRIB_BITS );
GL11.glEnable( GL11.GL_LIGHTING );
GL11.glEnable( GL12.GL_RESCALE_NORMAL );
GL11.glEnable( GL11.GL_DEPTH_TEST );
RenderHelper.enableGUIStandardItemLighting();
itemRender.renderItemAndEffectIntoGUI( this.fontRendererObj, this.mc.renderEngine, is, x, y );
GL11.glPopAttrib();
itemRender.zLevel = 0.0F;
this.zLevel = 0.0F;
}
@Override
final protected void drawGuiContainerBackgroundLayer(float f, int x, int y)
{
int ox = guiLeft; // (width - xSize) / 2;
int oy = guiTop; // (height - ySize) / 2;
GL11.glColor4f( 1.0F, 1.0F, 1.0F, 1.0F );
drawBG( ox, oy, x, y );
for (Object o : inventorySlots.inventorySlots)
{
if ( o instanceof OptionalSlotFake )
{
OptionalSlotFake fs = (OptionalSlotFake) o;
if ( fs.renderDisabled() )
{
if ( fs.isEnabled() )
{
this.drawTexturedModalRect( ox + fs.xDisplayPosition - 1, oy + fs.yDisplayPosition - 1, fs.srcX - 1, fs.srcY - 1, 18, 18 );
}
else
{
GL11.glPushAttrib( GL11.GL_ALL_ATTRIB_BITS );
GL11.glColor4f( 1.0F, 1.0F, 1.0F, 0.4F );
GL11.glEnable( GL11.GL_BLEND );
this.drawTexturedModalRect( ox + fs.xDisplayPosition - 1, oy + fs.yDisplayPosition - 1, fs.srcX - 1, fs.srcY - 1, 18, 18 );
GL11.glColor4f( 1.0F, 1.0F, 1.0F, 1.0F );
GL11.glPopAttrib();
}
}
}
}
}
@Override
final protected void drawGuiContainerForegroundLayer(int x, int y)
{
int ox = guiLeft; // (width - xSize) / 2;
int oy = guiTop; // (height - ySize) / 2;
GL11.glColor4f( 1.0F, 1.0F, 1.0F, 1.0F );
if ( myScrollBar != null )
myScrollBar.draw( this );
drawFG( ox, oy, x, y );
}
protected String getGuiDisplayName(String in)
{
return hasCustomInventoryName() ? getInventoryName() : in;
}
private String getInventoryName()
{
return ((AEBaseContainer) inventorySlots).customName;
}
private boolean hasCustomInventoryName()
{
if ( inventorySlots instanceof AEBaseContainer )
return ((AEBaseContainer) inventorySlots).customName != null;
return false;
}
protected Slot getSlot(int mousex, int mousey)
{
for (int j1 = 0; j1 < this.inventorySlots.inventorySlots.size(); ++j1)
{
Slot slot = (Slot) this.inventorySlots.inventorySlots.get( j1 );
// isPointInRegion
if ( func_146978_c( slot.xDisplayPosition, slot.yDisplayPosition, 16, 16, mousex, mousey ) )
{
return slot;
}
}
return null;
}
protected static String join(Collection<?> s, String delimiter)
{
StringBuilder builder = new StringBuilder();
Iterator iter = s.iterator();
while (iter.hasNext())
{
builder.append( iter.next() );
if ( !iter.hasNext() )
{
break;
}
builder.append( delimiter );
}
return builder.toString();
}
boolean useNEI = false;
private RenderItem setItemRender(RenderItem aeri2)
{
if ( AppEng.instance.isIntegrationEnabled( IntegrationType.NEI ) )
{
return ((INEI) AppEng.instance.getIntegration( IntegrationType.NEI )).setItemRender( aeri2 );
}
else
{
RenderItem ri = itemRender;
itemRender = aeri2;
return ri;
}
}
private void safeDrawSlot(Slot s)
{
try
{
// drawSlotInventory
// super.func_146977_a( s );r
GuiContainer.class.getDeclaredMethod( "func_146977_a_original", Slot.class ).invoke( this, s );
}
catch (Exception err)
{
Tessellator tessellator = Tessellator.instance;
if ( Platform.isDrawing( tessellator ) )
tessellator.draw();
}
}
AppEngRenderItem aeri = new AppEngRenderItem();
protected boolean isPowered()
{
return true;
}
public void a(Slot s)
{
drawSlot( s );
}
public void func_146977_a(Slot s)
{
drawSlot( s );
}
public void drawSlot(Slot s)
{
if ( s instanceof SlotME )
{
RenderItem pIR = setItemRender( aeri );
try
{
this.zLevel = 100.0F;
itemRender.zLevel = 100.0F;
if ( !isPowered() )
{
GL11.glDisable( GL11.GL_LIGHTING );
super.drawRect( s.xDisplayPosition, s.yDisplayPosition, 16 + s.xDisplayPosition, 16 + s.yDisplayPosition, 0x66111111 );
GL11.glEnable( GL11.GL_LIGHTING );
}
this.zLevel = 0.0F;
itemRender.zLevel = 0.0F;
if ( s instanceof SlotME )
aeri.aestack = ((SlotME) s).getAEStack();
else
aeri.aestack = null;
safeDrawSlot( s );
}
catch (Exception err)
{
AELog.warning( "[AppEng] AE prevented crash while drawing slot: " + err.toString() );
if ( Platform.isDrawing( Tessellator.instance ) )
Tessellator.instance.draw();
}
setItemRender( pIR );
return;
}
else
{
try
{
ItemStack is = s.getStack();
if ( s instanceof AppEngSlot && (((AppEngSlot) s).renderIconWithItem() || is == null) && (((AppEngSlot) s).shouldDisplay()) )
{
AppEngSlot aes = (AppEngSlot) s;
if ( aes.getIcon() >= 0 )
{
bindTexture( "guis/states.png" );
GL11.glPushAttrib( GL11.GL_ALL_ATTRIB_BITS );
Tessellator tessellator = Tessellator.instance;
try
{
int uv_y = (int) Math.floor( aes.getIcon() / 16 );
int uv_x = aes.getIcon() - uv_y * 16;
GL11.glEnable( GL11.GL_BLEND );
GL11.glDisable( GL11.GL_LIGHTING );
GL11.glEnable( GL11.GL_TEXTURE_2D );
GL11.glBlendFunc( GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA );
GL11.glColor4f( 1.0f, 1.0f, 1.0f, 1.0f );
float par1 = aes.xDisplayPosition;
float par2 = aes.yDisplayPosition;
float par3 = uv_x * 16;
float par4 = uv_y * 16;
float par5 = 16;
float par6 = 16;
float f = 0.00390625F;
float f1 = 0.00390625F;
tessellator.startDrawingQuads();
tessellator.setColorRGBA_F( 1.0f, 1.0f, 1.0f, aes.getOpacityOfIcon() );
tessellator.addVertexWithUV( (double) (par1 + 0), (double) (par2 + par6), (double) this.zLevel, (double) ((float) (par3 + 0) * f),
(double) ((float) (par4 + par6) * f1) );
tessellator.addVertexWithUV( (double) (par1 + par5), (double) (par2 + par6), (double) this.zLevel,
(double) ((float) (par3 + par5) * f), (double) ((float) (par4 + par6) * f1) );
tessellator.addVertexWithUV( (double) (par1 + par5), (double) (par2 + 0), (double) this.zLevel,
(double) ((float) (par3 + par5) * f), (double) ((float) (par4 + 0) * f1) );
tessellator.addVertexWithUV( (double) (par1 + 0), (double) (par2 + 0), (double) this.zLevel, (double) ((float) (par3 + 0) * f),
(double) ((float) (par4 + 0) * f1) );
tessellator.setColorRGBA_F( 1.0f, 1.0f, 1.0f, 1.0f );
tessellator.draw();
}
catch (Exception err)
{
if ( Platform.isDrawing( tessellator ) )
tessellator.draw();
}
GL11.glPopAttrib();
}
}
if ( is != null && s instanceof AppEngSlot )
{
if ( ((AppEngSlot) s).isValid == hasCalculatedValidness.NotAvailable )
{
boolean isValid = s.isItemValid( is ) || s instanceof SlotOutput || s instanceof AppEngCraftingSlot || s instanceof SlotDisabled
|| s instanceof SlotInaccessible || s instanceof SlotFake || s instanceof SlotRestrictedInput || s instanceof SlotDisconnected;
if ( isValid && s instanceof SlotRestrictedInput )
{
try
{
isValid = ((SlotRestrictedInput) s).isValid( is, this.mc.theWorld );
}
catch (Exception err)
{
AELog.error( err );
}
}
((AppEngSlot) s).isValid = isValid ? hasCalculatedValidness.Valid : hasCalculatedValidness.Invalid;
}
if ( ((AppEngSlot) s).isValid == hasCalculatedValidness.Invalid )
{
this.zLevel = 100.0F;
itemRender.zLevel = 100.0F;
GL11.glDisable( GL11.GL_LIGHTING );
super.drawRect( s.xDisplayPosition, s.yDisplayPosition, 16 + s.xDisplayPosition, 16 + s.yDisplayPosition, 0x66ff6666 );
GL11.glEnable( GL11.GL_LIGHTING );
this.zLevel = 0.0F;
itemRender.zLevel = 0.0F;
}
}
if ( s instanceof AppEngSlot )
{
((AppEngSlot) s).isDisplay = true;
safeDrawSlot( s );
}
else
safeDrawSlot( s );
return;
}
catch (Exception err)
{
AELog.warning( "[AppEng] AE prevented crash while drawing slot: " + err.toString() );
}
}
// do the usual for non-ME Slots.
safeDrawSlot( s );
}
}
@@ -0,0 +1,103 @@
package appeng.client.gui;
import java.text.NumberFormat;
import java.util.List;
import java.util.Locale;
import net.minecraft.inventory.Container;
import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack;
import appeng.api.storage.data.IAEItemStack;
import appeng.client.me.SlotME;
import appeng.core.AEConfig;
public abstract class AEBaseMEGui extends AEBaseGui
{
public AEBaseMEGui(Container container) {
super( container );
}
public List<String> handleItemTooltip(ItemStack stack, int mousex, int mousey, List<String> currenttip)
{
if ( stack != null )
{
Slot s = getSlot( mousex, mousey );
if ( s instanceof SlotME )
{
int BigNumber = AEConfig.instance.useTerminalUseLargeFont() ? 999 : 9999;
IAEItemStack myStack = null;
try
{
SlotME theSlotField = (SlotME) s;
myStack = theSlotField.getAEStack();
}
catch (Throwable ignore)
{
}
if ( myStack != null )
{
if ( myStack.getStackSize() > BigNumber || (myStack.getStackSize() > 1 && stack.isItemDamaged()) )
currenttip.add( "\u00a77Items Stored: " + NumberFormat.getNumberInstance( Locale.US ).format( myStack.getStackSize() ) );
if ( myStack.getCountRequestable() > 0 )
currenttip.add( "\u00a77Items Requestable: " + NumberFormat.getNumberInstance( Locale.US ).format( myStack.getCountRequestable() ) );
}
else if ( stack.stackSize > BigNumber || (stack.stackSize > 1 && stack.isItemDamaged()) )
{
currenttip.add( "\u00a77Items Stored: " + NumberFormat.getNumberInstance( Locale.US ).format( stack.stackSize ) );
}
}
}
return currenttip;
}
// Vanilla version...
// protected void drawItemStackTooltip(ItemStack stack, int x, int y)
@Override
protected void renderToolTip(ItemStack stack, int x, int y)
{
Slot s = getSlot( x, y );
if ( s instanceof SlotME && stack != null )
{
int BigNumber = AEConfig.instance.useTerminalUseLargeFont() ? 999 : 9999;
IAEItemStack myStack = null;
try
{
SlotME theSlotField = (SlotME) s;
myStack = theSlotField.getAEStack();
}
catch (Throwable ignore)
{
}
if ( myStack != null )
{
List currenttip = stack.getTooltip( this.mc.thePlayer, this.mc.gameSettings.advancedItemTooltips );
if ( myStack.getStackSize() > BigNumber || (myStack.getStackSize() > 1 && stack.isItemDamaged()) )
currenttip.add( "Items Stored: " + NumberFormat.getNumberInstance( Locale.US ).format( myStack.getStackSize() ) );
if ( myStack.getCountRequestable() > 0 )
currenttip.add( "Items Requestable: " + NumberFormat.getNumberInstance( Locale.US ).format( myStack.getCountRequestable() ) );
drawTooltip( x, y, 0, join( currenttip, "\n" ) );
}
else if ( stack != null && stack.stackSize > BigNumber )
{
List var4 = stack.getTooltip( this.mc.thePlayer, this.mc.gameSettings.advancedItemTooltips );
var4.add( "Items Stored: " + NumberFormat.getNumberInstance( Locale.US ).format( stack.stackSize ) );
drawTooltip( x, y, 0, join( var4, "\n" ) );
return;
}
}
super.renderToolTip( stack, x, y );
// super.drawItemStackTooltip( stack, x, y );
}
}
@@ -0,0 +1,23 @@
package appeng.client.gui;
import net.minecraft.inventory.Container;
public class GuiNull extends AEBaseGui
{
public GuiNull(Container container) {
super( container );
}
@Override
public void drawBG(int offsetX, int offsetY, int mouseX, int mouseY)
{
}
@Override
public void drawFG(int offsetX, int offsetY, int mouseX, int mouseY)
{
}
}
@@ -0,0 +1,45 @@
package appeng.client.gui.config;
import java.util.ArrayList;
import java.util.List;
import net.minecraft.client.gui.GuiScreen;
import net.minecraftforge.common.config.ConfigCategory;
import net.minecraftforge.common.config.ConfigElement;
import appeng.core.AEConfig;
import appeng.core.AppEng;
import cpw.mods.fml.client.config.GuiConfig;
import cpw.mods.fml.client.config.IConfigElement;
public class AEConfigGui extends GuiConfig
{
private static List<IConfigElement> getConfigElements()
{
List<IConfigElement> list = new ArrayList<IConfigElement>();
for (String cat : AEConfig.instance.getCategoryNames())
{
if ( cat.equals( "versionchecker" ) )
continue;
if ( cat.equals( "settings" ) )
continue;
ConfigCategory cc = AEConfig.instance.getCategory( cat );
if ( cc.isChild() )
continue;
ConfigElement ce = new ConfigElement( cc );
list.add( ce );
}
return list;
}
public AEConfigGui(GuiScreen parent) {
super( parent, getConfigElements(), AppEng.modid, false, false, GuiConfig.getAbridgedConfigPath( AEConfig.instance.getFilePath() ) );
}
}
@@ -0,0 +1,36 @@
package appeng.client.gui.config;
import java.util.Set;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiScreen;
import cpw.mods.fml.client.IModGuiFactory;
public class AEConfigGuiFactory implements IModGuiFactory
{
@Override
public void initialize(Minecraft minecraftInstance)
{
}
@Override
public Class<? extends GuiScreen> mainConfigGuiClass()
{
return AEConfigGui.class;
}
@Override
public Set<RuntimeOptionCategoryElement> runtimeGuiCategories()
{
return null;
}
@Override
public RuntimeOptionGuiHandler getHandlerFor(RuntimeOptionCategoryElement element)
{
return null;
}
}
@@ -0,0 +1,178 @@
package appeng.client.gui.implementations;
import java.io.IOException;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import org.lwjgl.input.Mouse;
import appeng.api.config.ActionItems;
import appeng.api.config.CopyMode;
import appeng.api.config.FuzzyMode;
import appeng.api.config.Settings;
import appeng.api.config.Upgrades;
import appeng.api.implementations.items.IUpgradeModule;
import appeng.client.gui.widgets.GuiImgButton;
import appeng.client.gui.widgets.GuiToggleButton;
import appeng.container.implementations.ContainerCellWorkbench;
import appeng.core.localization.GuiText;
import appeng.core.sync.network.NetworkHandler;
import appeng.core.sync.packets.PacketValueConfig;
import appeng.tile.misc.TileCellWorkbench;
import appeng.util.Platform;
public class GuiCellWorkbench extends GuiUpgradeable
{
ContainerCellWorkbench ccwb;
TileCellWorkbench tcw;
GuiImgButton clear;
GuiImgButton partition;
GuiToggleButton copyMode;
public GuiCellWorkbench(InventoryPlayer inventoryPlayer, TileCellWorkbench te) {
super( new ContainerCellWorkbench( inventoryPlayer, te ) );
ccwb = (ContainerCellWorkbench) inventorySlots;
ySize = 251;
tcw = te;
}
@Override
protected boolean drawUpgrades()
{
return ccwb.availableUpgrades() > 0;
}
@Override
public void initGui()
{
super.initGui();
}
@Override
public void drawBG(int offsetX, int offsetY, int mouseX, int mouseY)
{
handleButtonVisibility();
bindTexture( getBackground() );
this.drawTexturedModalRect( offsetX, offsetY, 0, 0, 211 - 34, ySize );
if ( drawUpgrades() )
{
if ( ccwb.availableUpgrades() <= 8 )
{
this.drawTexturedModalRect( offsetX + 177, offsetY, 177, 0, 35, 7 + ccwb.availableUpgrades() * 18 );
this.drawTexturedModalRect( offsetX + 177, offsetY + (7 + (ccwb.availableUpgrades()) * 18), 177, 151, 35, 7 );
}
else if ( ccwb.availableUpgrades() <= 16 )
{
this.drawTexturedModalRect( offsetX + 177, offsetY, 177, 0, 35, 7 + 8 * 18 );
this.drawTexturedModalRect( offsetX + 177, offsetY + (7 + (8) * 18), 177, 151, 35, 7 );
int dx = ccwb.availableUpgrades() - 8;
this.drawTexturedModalRect( offsetX + 177 + 27, offsetY, 186, 0, 35 - 8, 7 + dx * 18 );
if ( dx == 8 )
this.drawTexturedModalRect( offsetX + 177 + 27, offsetY + (7 + (dx) * 18), 186, 151, 35 - 8, 7 );
else
this.drawTexturedModalRect( offsetX + 177 + 27 + 4, offsetY + (7 + (dx) * 18), 186 + 4, 151, 35 - 8, 7 );
}
else
{
this.drawTexturedModalRect( offsetX + 177, offsetY, 177, 0, 35, 7 + 8 * 18 );
this.drawTexturedModalRect( offsetX + 177, offsetY + (7 + (8) * 18), 177, 151, 35, 7 );
this.drawTexturedModalRect( offsetX + 177 + 27, offsetY, 186, 0, 35 - 8, 7 + 8 * 18 );
this.drawTexturedModalRect( offsetX + 177 + 27, offsetY + (7 + (8) * 18), 186, 151, 35 - 8, 7 );
int dx = ccwb.availableUpgrades() - 16;
this.drawTexturedModalRect( offsetX + 177 + 27 + 18, offsetY, 186, 0, 35 - 8, 7 + dx * 18 );
if ( dx == 8 )
this.drawTexturedModalRect( offsetX + 177 + 27 + 18, offsetY + (7 + (dx) * 18), 186, 151, 35 - 8, 7 );
else
this.drawTexturedModalRect( offsetX + 177 + 27 + 18 + 4, offsetY + (7 + (dx) * 18), 186 + 4, 151, 35 - 8, 7 );
}
}
if ( hasToolbox() )
this.drawTexturedModalRect( offsetX + 178, offsetY + ySize - 90, 178, 161, 68, 68 );
}
@Override
protected void actionPerformed(GuiButton btn)
{
try
{
if ( btn == copyMode )
{
NetworkHandler.instance.sendToServer( new PacketValueConfig( "CellWorkbench.Action", "CopyMode" ) );
}
else if ( btn == partition )
{
NetworkHandler.instance.sendToServer( new PacketValueConfig( "CellWorkbench.Action", "Partition" ) );
}
else if ( btn == clear )
{
NetworkHandler.instance.sendToServer( new PacketValueConfig( "CellWorkbench.Action", "Clear" ) );
}
else if ( btn == fuzzyMode )
{
boolean backwards = Mouse.isButtonDown( 1 );
FuzzyMode fz = (FuzzyMode) fuzzyMode.getCurrentValue();
fz = Platform.rotateEnum( fz, backwards, Settings.FUZZY_MODE.getPossibleValues() );
NetworkHandler.instance.sendToServer( new PacketValueConfig( "CellWorkbench.Fuzzy", fz.name() ) );
}
else
super.actionPerformed( btn );
}
catch (IOException err)
{
}
}
@Override
protected void addButtons()
{
clear = new GuiImgButton( this.guiLeft - 18, guiTop + 8, Settings.ACTIONS, ActionItems.CLOSE );
partition = new GuiImgButton( this.guiLeft - 18, guiTop + 28, Settings.ACTIONS, ActionItems.WRENCH );
copyMode = new GuiToggleButton( this.guiLeft - 18, guiTop + 48, 11 * 16 + 5, 12 * 16 + 5, GuiText.CopyMode.getLocal(), GuiText.CopyModeDesc.getLocal() );
fuzzyMode = new GuiImgButton( this.guiLeft - 18, guiTop + 68, Settings.FUZZY_MODE, FuzzyMode.IGNORE_ALL );
buttonList.add( fuzzyMode );
buttonList.add( partition );
buttonList.add( clear );
buttonList.add( copyMode );
}
protected void handleButtonVisibility()
{
copyMode.setState( ccwb.copyMode == CopyMode.CLEAR_ON_REMOVE );
boolean hasFuzzy = false;
IInventory inv = ccwb.getCellUpgradeInventory();
for (int x = 0; x < inv.getSizeInventory(); x++)
{
ItemStack is = inv.getStackInSlot( x );
if ( is != null && is.getItem() instanceof IUpgradeModule )
{
if ( ((IUpgradeModule) is.getItem()).getType( is ) == Upgrades.FUZZY )
hasFuzzy = true;
}
}
fuzzyMode.setVisibility( hasFuzzy );
}
protected String getBackground()
{
return "guis/cellworkbench.png";
}
protected GuiText getName()
{
return GuiText.CellWorkbench;
}
}
@@ -0,0 +1,67 @@
package appeng.client.gui.implementations;
import java.io.IOException;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.entity.player.InventoryPlayer;
import appeng.client.gui.AEBaseGui;
import appeng.client.gui.widgets.GuiTabButton;
import appeng.container.implementations.ContainerChest;
import appeng.core.AELog;
import appeng.core.localization.GuiText;
import appeng.core.sync.GuiBridge;
import appeng.core.sync.network.NetworkHandler;
import appeng.core.sync.packets.PacketSwitchGuis;
import appeng.tile.storage.TileChest;
public class GuiChest extends AEBaseGui
{
GuiTabButton priority;
@Override
protected void actionPerformed(GuiButton par1GuiButton)
{
super.actionPerformed( par1GuiButton );
if ( par1GuiButton == priority )
{
try
{
NetworkHandler.instance.sendToServer( new PacketSwitchGuis( GuiBridge.GUI_PRIORITY ) );
}
catch (IOException e)
{
AELog.error( e );
}
}
}
@Override
public void initGui()
{
super.initGui();
buttonList.add( priority = new GuiTabButton( this.guiLeft + 154, this.guiTop, 2 + 4 * 16, GuiText.Priority.getLocal(), itemRender ) );
}
public GuiChest(InventoryPlayer inventoryPlayer, TileChest te) {
super( new ContainerChest( inventoryPlayer, te ) );
this.ySize = 166;
}
@Override
public void drawBG(int offsetX, int offsetY, int mouseX, int mouseY)
{
bindTexture( "guis/chest.png" );
this.drawTexturedModalRect( offsetX, offsetY, 0, 0, xSize, ySize );
}
@Override
public void drawFG(int offsetX, int offsetY, int mouseX, int mouseY)
{
fontRendererObj.drawString( getGuiDisplayName( GuiText.Chest.getLocal() ), 8, 6, 4210752 );
fontRendererObj.drawString( GuiText.inventory.getLocal(), 8, ySize - 96 + 3, 4210752 );
}
}
@@ -0,0 +1,90 @@
package appeng.client.gui.implementations;
import java.io.IOException;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.entity.player.InventoryPlayer;
import org.lwjgl.input.Mouse;
import appeng.api.config.Settings;
import appeng.client.gui.AEBaseGui;
import appeng.client.gui.widgets.GuiImgButton;
import appeng.client.gui.widgets.GuiProgressBar;
import appeng.client.gui.widgets.GuiProgressBar.Direction;
import appeng.container.implementations.ContainerCondenser;
import appeng.core.AELog;
import appeng.core.localization.GuiText;
import appeng.core.sync.network.NetworkHandler;
import appeng.core.sync.packets.PacketConfigButton;
import appeng.tile.misc.TileCondenser;
public class GuiCondenser extends AEBaseGui
{
ContainerCondenser cvc;
GuiProgressBar pb;
GuiImgButton mode;
public GuiCondenser(InventoryPlayer inventoryPlayer, TileCondenser te) {
super( new ContainerCondenser( inventoryPlayer, te ) );
cvc = (ContainerCondenser) inventorySlots;
this.ySize = 197;
}
@Override
protected void actionPerformed(GuiButton btn)
{
super.actionPerformed( btn );
boolean backwards = Mouse.isButtonDown( 1 );
if ( mode == btn )
{
try
{
NetworkHandler.instance.sendToServer( new PacketConfigButton( Settings.CONDENSER_OUTPUT, backwards ) );
}
catch (IOException e)
{
AELog.error( e );
}
}
}
@Override
public void initGui()
{
super.initGui();
pb = new GuiProgressBar( "guis/condenser.png", 120 + guiLeft, 25 + guiTop, 178, 25, 6, 18, Direction.VERTICAL );
pb.TitleName = GuiText.StoredEnergy.getLocal();
mode = new GuiImgButton( 128 + guiLeft, 52 + guiTop, Settings.CONDENSER_OUTPUT, cvc.output );
this.buttonList.add( pb );
this.buttonList.add( mode );
}
@Override
public void drawBG(int offsetX, int offsetY, int mouseX, int mouseY)
{
bindTexture( "guis/condenser.png" );
this.drawTexturedModalRect( offsetX, offsetY, 0, 0, xSize, ySize );
}
@Override
public void drawFG(int offsetX, int offsetY, int mouseX, int mouseY)
{
fontRendererObj.drawString( getGuiDisplayName( GuiText.Condenser.getLocal() ), 8, 6, 4210752 );
fontRendererObj.drawString( GuiText.inventory.getLocal(), 8, ySize - 96 + 3, 4210752 );
mode.set( cvc.output );
mode.FillVar = "" + cvc.output.requiredPower;
pb.max = (int) cvc.requiredEnergy;
pb.current = (int) cvc.storedPower;
}
}
@@ -0,0 +1,257 @@
package appeng.client.gui.implementations;
import java.io.IOException;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.item.ItemStack;
import appeng.api.AEApi;
import appeng.api.storage.ITerminalHost;
import appeng.client.gui.AEBaseGui;
import appeng.client.gui.widgets.GuiNumberBox;
import appeng.client.gui.widgets.GuiTabButton;
import appeng.container.AEBaseContainer;
import appeng.container.implementations.ContainerCraftAmount;
import appeng.core.AEConfig;
import appeng.core.AELog;
import appeng.core.localization.GuiText;
import appeng.core.sync.GuiBridge;
import appeng.core.sync.network.NetworkHandler;
import appeng.core.sync.packets.PacketCraftRequest;
import appeng.core.sync.packets.PacketSwitchGuis;
import appeng.helpers.WirelessTerminalGuiObject;
import appeng.parts.reporting.PartCraftingTerminal;
import appeng.parts.reporting.PartPatternTerminal;
import appeng.parts.reporting.PartTerminal;
public class GuiCraftAmount extends AEBaseGui
{
GuiNumberBox amountToCraft;
GuiTabButton originalGuiBtn;
GuiButton next;
GuiButton plus1, plus10, plus100, plus1000;
GuiButton minus1, minus10, minus100, minus1000;
GuiBridge OriginalGui;
public GuiCraftAmount(InventoryPlayer inventoryPlayer, ITerminalHost te) {
super( new ContainerCraftAmount( inventoryPlayer, te ) );
}
@Override
public void initGui()
{
super.initGui();
int a = AEConfig.instance.craftItemsByStackAmounts( 0 );
int b = AEConfig.instance.craftItemsByStackAmounts( 1 );
int c = AEConfig.instance.craftItemsByStackAmounts( 2 );
int d = AEConfig.instance.craftItemsByStackAmounts( 3 );
buttonList.add( plus1 = new GuiButton( 0, this.guiLeft + 20, this.guiTop + 26, 22, 20, "+" + a ) );
buttonList.add( plus10 = new GuiButton( 0, this.guiLeft + 48, this.guiTop + 26, 28, 20, "+" + b ) );
buttonList.add( plus100 = new GuiButton( 0, this.guiLeft + 82, this.guiTop + 26, 32, 20, "+" + c ) );
buttonList.add( plus1000 = new GuiButton( 0, this.guiLeft + 120, this.guiTop + 26, 38, 20, "+" + d ) );
buttonList.add( minus1 = new GuiButton( 0, this.guiLeft + 20, this.guiTop + 75, 22, 20, "-" + a ) );
buttonList.add( minus10 = new GuiButton( 0, this.guiLeft + 48, this.guiTop + 75, 28, 20, "-" + b ) );
buttonList.add( minus100 = new GuiButton( 0, this.guiLeft + 82, this.guiTop + 75, 32, 20, "-" + c ) );
buttonList.add( minus1000 = new GuiButton( 0, this.guiLeft + 120, this.guiTop + 75, 38, 20, "-" + d ) );
buttonList.add( next = new GuiButton( 0, this.guiLeft + 128, this.guiTop + 51, 38, 20, GuiText.Next.getLocal() ) );
ItemStack myIcon = null;
Object target = ((AEBaseContainer) inventorySlots).getTarget();
if ( target instanceof WirelessTerminalGuiObject )
{
myIcon = AEApi.instance().items().itemWirelessTerminal.stack( 1 );
OriginalGui = GuiBridge.GUI_WIRELESS_TERM;
}
if ( target instanceof PartTerminal )
{
myIcon = AEApi.instance().parts().partTerminal.stack( 1 );
OriginalGui = GuiBridge.GUI_ME;
}
if ( target instanceof PartCraftingTerminal )
{
myIcon = AEApi.instance().parts().partCraftingTerminal.stack( 1 );
OriginalGui = GuiBridge.GUI_CRAFTING_TERMINAL;
}
if ( target instanceof PartPatternTerminal )
{
myIcon = AEApi.instance().parts().partPatternTerminal.stack( 1 );
OriginalGui = GuiBridge.GUI_PATTERN_TERMINAL;
}
if ( OriginalGui != null )
buttonList.add( originalGuiBtn = new GuiTabButton( this.guiLeft + 154, this.guiTop, myIcon, myIcon.getDisplayName(), itemRender ) );
amountToCraft = new GuiNumberBox( fontRendererObj, this.guiLeft + 62, this.guiTop + 57, 59, fontRendererObj.FONT_HEIGHT, Integer.class );
amountToCraft.setEnableBackgroundDrawing( false );
amountToCraft.setMaxStringLength( 16 );
amountToCraft.setTextColor( 0xFFFFFF );
amountToCraft.setVisible( true );
amountToCraft.setFocused( true );
amountToCraft.setText( "1" );
}
@Override
protected void actionPerformed(GuiButton btn)
{
super.actionPerformed( btn );
try
{
if ( btn == originalGuiBtn )
{
NetworkHandler.instance.sendToServer( new PacketSwitchGuis( OriginalGui ) );
}
if ( btn == next )
{
NetworkHandler.instance.sendToServer( new PacketCraftRequest( Integer.parseInt( this.amountToCraft.getText() ), isShiftKeyDown() ) );
}
}
catch (NumberFormatException e)
{
// nope..
amountToCraft.setText( "1" );
}
catch (IOException e)
{
AELog.error( e );
}
boolean isPlus = btn == plus1 || btn == plus10 || btn == plus100 || btn == plus1000;
boolean isMinus = btn == minus1 || btn == minus10 || btn == minus100 || btn == minus1000;
if ( isPlus || isMinus )
addQty( getQty( btn ) );
}
private void addQty(int i)
{
try
{
String Out = amountToCraft.getText();
boolean Fixed = false;
while (Out.startsWith( "0" ) && Out.length() > 1)
{
Out = Out.substring( 1 );
Fixed = true;
}
if ( Fixed )
amountToCraft.setText( Out );
if ( Out.length() == 0 )
Out = "0";
long result = Integer.parseInt( Out );
if ( result == 1 && i > 1 )
result = 0;
result += i;
if ( result < 1 )
result = 1;
Out = Long.toString( result );
Integer.parseInt( Out );
amountToCraft.setText( Out );
}
catch (NumberFormatException e)
{
// :P
}
}
@Override
protected void keyTyped(char character, int key)
{
if ( !this.checkHotbarKeys( key ) )
{
if ( key == 28 )
{
actionPerformed( next );
}
if ( (key == 211 || key == 205 || key == 203 || key == 14 || character == '-' || Character.isDigit( character ))
&& amountToCraft.textboxKeyTyped( character, key ) )
{
try
{
String Out = amountToCraft.getText();
boolean Fixed = false;
while (Out.startsWith( "0" ) && Out.length() > 1)
{
Out = Out.substring( 1 );
Fixed = true;
}
if ( Fixed )
amountToCraft.setText( Out );
if ( Out.length() == 0 )
Out = "0";
long result = Long.parseLong( Out );
if ( result < 0 )
{
amountToCraft.setText( "1" );
}
}
catch (NumberFormatException e)
{
// :P
}
}
else
{
super.keyTyped( character, key );
}
}
}
@Override
public void drawBG(int offsetX, int offsetY, int mouseX, int mouseY)
{
next.displayString = isShiftKeyDown() ? GuiText.Start.getLocal() : GuiText.Next.getLocal();
bindTexture( "guis/craftAmt.png" );
this.drawTexturedModalRect( offsetX, offsetY, 0, 0, xSize, ySize );
try
{
Long.parseLong( amountToCraft.getText() );
next.enabled = amountToCraft.getText().length() > 0;
}
catch (NumberFormatException e)
{
next.enabled = false;
}
amountToCraft.drawTextBox();
}
protected String getBackground()
{
return "guis/craftAmt.png";
}
@Override
public void drawFG(int offsetX, int offsetY, int mouseX, int mouseY)
{
fontRendererObj.drawString( GuiText.SelectAmount.getLocal(), 8, 6, 4210752 );
}
}
@@ -0,0 +1,519 @@
package appeng.client.gui.implementations;
import java.io.IOException;
import java.text.NumberFormat;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.item.ItemStack;
import org.lwjgl.input.Mouse;
import org.lwjgl.opengl.GL11;
import appeng.api.AEApi;
import appeng.api.storage.ITerminalHost;
import appeng.api.storage.data.IAEItemStack;
import appeng.api.storage.data.IItemList;
import appeng.client.gui.AEBaseGui;
import appeng.client.gui.widgets.GuiScrollbar;
import appeng.container.implementations.ContainerCraftConfirm;
import appeng.core.AELog;
import appeng.core.localization.GuiText;
import appeng.core.sync.GuiBridge;
import appeng.core.sync.network.NetworkHandler;
import appeng.core.sync.packets.PacketSwitchGuis;
import appeng.core.sync.packets.PacketValueConfig;
import appeng.helpers.WirelessTerminalGuiObject;
import appeng.parts.reporting.PartCraftingTerminal;
import appeng.parts.reporting.PartPatternTerminal;
import appeng.parts.reporting.PartTerminal;
import appeng.util.Platform;
import com.google.common.base.Joiner;
public class GuiCraftConfirm extends AEBaseGui
{
ContainerCraftConfirm ccc;
int rows = 5;
IItemList<IAEItemStack> storage = AEApi.instance().storage().createItemList();
IItemList<IAEItemStack> pending = AEApi.instance().storage().createItemList();
IItemList<IAEItemStack> missing = AEApi.instance().storage().createItemList();
List<IAEItemStack> visual = new ArrayList();
GuiBridge OriginalGui;
boolean isAutoStart()
{
return ((ContainerCraftConfirm) inventorySlots).autoStart;
}
boolean isSimulation()
{
return ((ContainerCraftConfirm) inventorySlots).simulation;
}
public GuiCraftConfirm(InventoryPlayer inventoryPlayer, ITerminalHost te) {
super( new ContainerCraftConfirm( inventoryPlayer, te ) );
xSize = 238;
ySize = 206;
myScrollBar = new GuiScrollbar();
ccc = (ContainerCraftConfirm) this.inventorySlots;
if ( te instanceof WirelessTerminalGuiObject )
OriginalGui = GuiBridge.GUI_WIRELESS_TERM;
if ( te instanceof PartTerminal )
OriginalGui = GuiBridge.GUI_ME;
if ( te instanceof PartCraftingTerminal )
OriginalGui = GuiBridge.GUI_CRAFTING_TERMINAL;
if ( te instanceof PartPatternTerminal )
OriginalGui = GuiBridge.GUI_PATTERN_TERMINAL;
}
GuiButton cancel;
GuiButton start;
GuiButton selectcpu;
@Override
public void initGui()
{
super.initGui();
start = new GuiButton( 0, this.guiLeft + 162, this.guiTop + ySize - 25, 50, 20, GuiText.Start.getLocal() );
start.enabled = false;
buttonList.add( start );
selectcpu = new GuiButton( 0, this.guiLeft + (219 - 180) / 2, this.guiTop + ySize - 68, 180, 20, GuiText.CraftingCPU.getLocal() + ": "
+ GuiText.Automatic );
selectcpu.enabled = false;
buttonList.add( selectcpu );
if ( OriginalGui != null )
cancel = new GuiButton( 0, this.guiLeft + 6, this.guiTop + ySize - 25, 50, 20, GuiText.Cancel.getLocal() );
buttonList.add( cancel );
}
private void updateCPUButtonText()
{
String btnTextText = GuiText.CraftingCPU.getLocal() + ": " + GuiText.Automatic.getLocal();
if ( ccc.selectedCpu >= 0 )// && ccc.selectedCpu < ccc.cpus.size() )
{
if ( ccc.myName.length() > 0 )
{
String name = ccc.myName.substring( 0, Math.min( 20, ccc.myName.length() ) );
btnTextText = GuiText.CraftingCPU.getLocal() + ": " + name;
}
else
btnTextText = GuiText.CraftingCPU.getLocal() + ": #" + ccc.selectedCpu;
}
if ( ccc.noCPU )
btnTextText = GuiText.NoCraftingCPUs.getLocal();
selectcpu.displayString = btnTextText;
}
@Override
protected void actionPerformed(GuiButton btn)
{
super.actionPerformed( btn );
boolean backwards = Mouse.isButtonDown( 1 );
if ( btn == selectcpu )
{
try
{
NetworkHandler.instance.sendToServer( new PacketValueConfig( "Terminal.Cpu", backwards ? "Prev" : "Next" ) );
}
catch (IOException e)
{
AELog.error( e );
}
}
if ( btn == cancel )
{
try
{
NetworkHandler.instance.sendToServer( new PacketSwitchGuis( OriginalGui ) );
}
catch (IOException e)
{
AELog.error( e );
}
}
if ( btn == start )
{
try
{
NetworkHandler.instance.sendToServer( new PacketValueConfig( "Terminal.Start", "Start" ) );
}
catch (Throwable e)
{
AELog.error( e );
}
}
}
private long getTotal(IAEItemStack is)
{
IAEItemStack a = storage.findPrecise( is );
IAEItemStack c = pending.findPrecise( is );
IAEItemStack m = missing.findPrecise( is );
long total = 0;
if ( a != null )
total += a.getStackSize();
if ( c != null )
total += c.getStackSize();
if ( m != null )
total += m.getStackSize();
return total;
}
public void postUpdate(List<IAEItemStack> list, byte ref)
{
switch (ref)
{
case 0:
for (IAEItemStack l : list)
handleInput( storage, l );
break;
case 1:
for (IAEItemStack l : list)
handleInput( pending, l );
break;
case 2:
for (IAEItemStack l : list)
handleInput( missing, l );
break;
}
for (IAEItemStack l : list)
{
long amt = getTotal( l );
if ( amt <= 0 )
deleteVisualStack( l );
else
{
IAEItemStack is = findVisualStack( l );
is.setStackSize( amt );
}
}
setScrollBar();
}
private void handleInput(IItemList<IAEItemStack> s, IAEItemStack l)
{
IAEItemStack a = s.findPrecise( l );
if ( l.getStackSize() <= 0 )
{
if ( a != null )
a.reset();
}
else
{
if ( a == null )
{
s.add( l.copy() );
a = s.findPrecise( l );
}
if ( a != null )
a.setStackSize( l.getStackSize() );
}
}
private IAEItemStack findVisualStack(IAEItemStack l)
{
Iterator<IAEItemStack> i = visual.iterator();
while (i.hasNext())
{
IAEItemStack o = i.next();
if ( o.equals( l ) )
return o;
}
IAEItemStack stack = l.copy();
visual.add( stack );
return stack;
}
private void deleteVisualStack(IAEItemStack l)
{
Iterator<IAEItemStack> i = visual.iterator();
while (i.hasNext())
{
IAEItemStack o = i.next();
if ( o.equals( l ) )
{
i.remove();
return;
}
}
}
private void setScrollBar()
{
int size = visual.size();
myScrollBar.setTop( 19 ).setLeft( 218 ).setHeight( 114 );
myScrollBar.setRange( 0, (size + 2) / 3 - rows, 1 );
}
@Override
protected void keyTyped(char character, int key)
{
if ( !this.checkHotbarKeys( key ) )
{
if ( key == 28 )
{
actionPerformed( start );
}
super.keyTyped( character, key );
}
}
@Override
public void drawBG(int offsetX, int offsetY, int mouseX, int mouseY)
{
setScrollBar();
bindTexture( "guis/craftingreport.png" );
this.drawTexturedModalRect( offsetX, offsetY, 0, 0, xSize, ySize );
}
int tooltip = -1;
@Override
public void drawScreen(int mouse_x, int mouse_y, float btn)
{
updateCPUButtonText();
start.enabled = ccc.noCPU || isSimulation() ? false : true;
selectcpu.enabled = isSimulation() ? false : true;
int x = 0;
int y = 0;
int gx = (width - xSize) / 2;
int gy = (height - ySize) / 2;
int yoff = 23;
tooltip = -1;
for (int z = 0; z <= 4 * 5; z++)
{
int minX = gx + 9 + x * 67;
int minY = gy + 22 + y * yoff;
if ( minX < mouse_x && minX + 67 > mouse_x )
{
if ( minY < mouse_y && minY + yoff - 2 > mouse_y )
{
tooltip = z;
break;
}
}
x++;
if ( x > 2 )
{
y++;
x = 0;
}
}
super.drawScreen( mouse_x, mouse_y, btn );
}
@Override
public void drawFG(int offsetX, int offsetY, int mouseX, int mouseY)
{
long BytesUsed = ccc.bytesUsed;
String byteUsed = NumberFormat.getInstance().format( BytesUsed );
String Add = BytesUsed > 0 ? (byteUsed + " " + GuiText.BytesUsed.getLocal()) : GuiText.CalculatingWait.getLocal();
fontRendererObj.drawString( GuiText.CraftingPlan.getLocal() + " - " + Add, 8, 7, 4210752 );
String dsp = null;
if ( isSimulation() )
dsp = GuiText.Simulation.getLocal();
else
dsp = ccc.cpuBytesAvail > 0 ? (GuiText.Bytes.getLocal() + ": " + ccc.cpuBytesAvail + " : " + GuiText.CoProcessors.getLocal() + ": " + ccc.cpuCoProcessors)
: GuiText.Bytes.getLocal() + ": N/A : " + GuiText.CoProcessors.getLocal() + ": N/A";
int offset = (219 - fontRendererObj.getStringWidth( dsp )) / 2;
fontRendererObj.drawString( dsp, offset, 165, 4210752 );
int sectionLength = 67;
int x = 0;
int y = 0;
int xo = 0 + 9;
int yo = 0 + 22;
int viewStart = myScrollBar.getCurrentScroll() * 3;
int viewEnd = viewStart + 3 * rows;
String dspToolTip = "";
List<String> lineList = new LinkedList();
int toolPosX = 0;
int toolPosY = 0;
int offY = 23;
for (int z = viewStart; z < Math.min( viewEnd, visual.size() ); z++)
{
IAEItemStack refStack = visual.get( z );// repo.getReferenceItem( z );
if ( refStack != null )
{
GL11.glPushMatrix();
GL11.glScaled( 0.5, 0.5, 0.5 );
IAEItemStack stored = storage.findPrecise( refStack );
IAEItemStack pendingStack = pending.findPrecise( refStack );
IAEItemStack missingStack = missing.findPrecise( refStack );
int lines = 0;
if ( stored != null && stored.getStackSize() > 0 )
lines++;
if ( pendingStack != null && pendingStack.getStackSize() > 0 )
lines++;
if ( pendingStack != null && pendingStack.getStackSize() > 0 )
lines++;
int negY = ((lines - 1) * 5) / 2;
int downY = 0;
boolean red = false;
if ( stored != null && stored.getStackSize() > 0 )
{
String str = Long.toString( stored.getStackSize() );
if ( stored.getStackSize() >= 10000 )
str = Long.toString( stored.getStackSize() / 1000 ) + "k";
if ( stored.getStackSize() >= 10000000 )
str = Long.toString( stored.getStackSize() / 1000000 ) + "m";
str = GuiText.FromStorage.getLocal() + ": " + str;
int w = 4 + fontRendererObj.getStringWidth( str );
fontRendererObj.drawString( str, (int) ((x * (1 + sectionLength) + xo + sectionLength - 19 - ((float) w * 0.5)) * 2), (int) ((y * offY + yo
+ 6 - negY + downY) * 2), 4210752 );
if ( tooltip == z - viewStart )
lineList.add( GuiText.FromStorage.getLocal() + ": " + Long.toString( stored.getStackSize() ) );
downY += 5;
}
if ( missingStack != null && missingStack.getStackSize() > 0 )
{
String str = Long.toString( missingStack.getStackSize() );
if ( missingStack.getStackSize() >= 10000 )
str = Long.toString( missingStack.getStackSize() / 1000 ) + "k";
if ( missingStack.getStackSize() >= 10000000 )
str = Long.toString( missingStack.getStackSize() / 1000000 ) + "m";
str = GuiText.Missing.getLocal() + ": " + str;
int w = 4 + fontRendererObj.getStringWidth( str );
fontRendererObj.drawString( str, (int) ((x * (1 + sectionLength) + xo + sectionLength - 19 - ((float) w * 0.5)) * 2), (int) ((y * offY + yo
+ 6 - negY + downY) * 2), 4210752 );
if ( tooltip == z - viewStart )
lineList.add( GuiText.Missing.getLocal() + ": " + Long.toString( missingStack.getStackSize() ) );
red = true;
downY += 5;
}
if ( pendingStack != null && pendingStack.getStackSize() > 0 )
{
String str = Long.toString( pendingStack.getStackSize() );
if ( pendingStack.getStackSize() >= 10000 )
str = Long.toString( pendingStack.getStackSize() / 1000 ) + "k";
if ( pendingStack.getStackSize() >= 10000000 )
str = Long.toString( pendingStack.getStackSize() / 1000000 ) + "m";
str = GuiText.ToCraft.getLocal() + ": " + str;
int w = 4 + fontRendererObj.getStringWidth( str );
fontRendererObj.drawString( str, (int) ((x * (1 + sectionLength) + xo + sectionLength - 19 - ((float) w * 0.5)) * 2), (int) ((y * offY + yo
+ 6 - negY + downY) * 2), 4210752 );
if ( tooltip == z - viewStart )
lineList.add( GuiText.ToCraft.getLocal() + ": " + Long.toString( pendingStack.getStackSize() ) );
}
GL11.glPopMatrix();
int posX = x * (1 + sectionLength) + xo + sectionLength - 19;
int posY = y * offY + yo;
ItemStack is = refStack.copy().getItemStack();
if ( tooltip == z - viewStart )
{
dspToolTip = Platform.getItemDisplayName( is );
if ( lineList.size() > 0 )
dspToolTip = dspToolTip + "\n" + Joiner.on( "\n" ).join( lineList );
toolPosX = x * (1 + sectionLength) + xo + sectionLength - 8;
toolPosY = y * offY + yo;
}
drawItem( posX, posY, is );
if ( red )
{
int startX = x * (1 + sectionLength) + xo;
int startY = posY - 4;
drawRect( startX, startY, startX + sectionLength, startY + offY, 0x1AFF0000 );
}
x++;
if ( x > 2 )
{
y++;
x = 0;
}
}
}
if ( tooltip >= 0 && dspToolTip.length() > 0 )
{
GL11.glPushAttrib( GL11.GL_ALL_ATTRIB_BITS );
drawTooltip( toolPosX, toolPosY + 10, 0, dspToolTip );
GL11.glPopAttrib();
}
}
}
@@ -0,0 +1,415 @@
package appeng.client.gui.implementations;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.item.ItemStack;
import org.lwjgl.opengl.GL11;
import appeng.api.AEApi;
import appeng.api.config.SortDir;
import appeng.api.config.SortOrder;
import appeng.api.config.ViewItems;
import appeng.api.storage.data.IAEItemStack;
import appeng.api.storage.data.IItemList;
import appeng.client.gui.AEBaseGui;
import appeng.client.gui.widgets.GuiScrollbar;
import appeng.client.gui.widgets.ISortSource;
import appeng.container.implementations.ContainerCraftingCPU;
import appeng.core.AELog;
import appeng.core.localization.GuiText;
import appeng.core.sync.network.NetworkHandler;
import appeng.core.sync.packets.PacketValueConfig;
import appeng.util.Platform;
import com.google.common.base.Joiner;
public class GuiCraftingCPU extends AEBaseGui implements ISortSource
{
int rows = 6;
IItemList<IAEItemStack> storage = AEApi.instance().storage().createItemList();
IItemList<IAEItemStack> active = AEApi.instance().storage().createItemList();
IItemList<IAEItemStack> pending = AEApi.instance().storage().createItemList();
List<IAEItemStack> visual = new ArrayList();
public void clearItems()
{
storage = AEApi.instance().storage().createItemList();
active = AEApi.instance().storage().createItemList();
pending = AEApi.instance().storage().createItemList();
visual = new ArrayList();
}
protected GuiCraftingCPU(ContainerCraftingCPU container) {
super( container );
this.ySize = 184;
this.xSize = 238;
myScrollBar = new GuiScrollbar();
}
public GuiCraftingCPU(InventoryPlayer inventoryPlayer, Object te) {
this( new ContainerCraftingCPU( inventoryPlayer, te ) );
}
GuiButton cancel;
@Override
protected void actionPerformed(GuiButton btn)
{
super.actionPerformed( btn );
if ( cancel == btn )
{
try
{
NetworkHandler.instance.sendToServer( new PacketValueConfig( "TileCrafting.Cancel", "Cancel" ) );
}
catch (IOException e)
{
AELog.error( e );
}
}
}
@Override
public void initGui()
{
super.initGui();
setScrollBar();
cancel = new GuiButton( 0, this.guiLeft + 163, this.guiTop + ySize - 25, 50, 20, GuiText.Cancel.getLocal() );
buttonList.add( cancel );
}
private long getTotal(IAEItemStack is)
{
IAEItemStack a = storage.findPrecise( is );
IAEItemStack b = active.findPrecise( is );
IAEItemStack c = pending.findPrecise( is );
long total = 0;
if ( a != null )
total += a.getStackSize();
if ( b != null )
total += b.getStackSize();
if ( c != null )
total += c.getStackSize();
return total;
}
public void postUpdate(List<IAEItemStack> list, byte ref)
{
switch (ref)
{
case 0:
for (IAEItemStack l : list)
handleInput( storage, l );
break;
case 1:
for (IAEItemStack l : list)
handleInput( active, l );
break;
case 2:
for (IAEItemStack l : list)
handleInput( pending, l );
break;
}
for (IAEItemStack l : list)
{
long amt = getTotal( l );
if ( amt <= 0 )
deleteVisualStack( l );
else
{
IAEItemStack is = findVisualStack( l );
is.setStackSize( amt );
}
}
setScrollBar();
}
private void handleInput(IItemList<IAEItemStack> s, IAEItemStack l)
{
IAEItemStack a = s.findPrecise( l );
if ( l.getStackSize() <= 0 )
{
if ( a != null )
a.reset();
}
else
{
if ( a == null )
{
s.add( l.copy() );
a = s.findPrecise( l );
}
if ( a != null )
a.setStackSize( l.getStackSize() );
}
}
private IAEItemStack findVisualStack(IAEItemStack l)
{
Iterator<IAEItemStack> i = visual.iterator();
while (i.hasNext())
{
IAEItemStack o = i.next();
if ( o.equals( l ) )
return o;
}
IAEItemStack stack = l.copy();
visual.add( stack );
return stack;
}
private void deleteVisualStack(IAEItemStack l)
{
Iterator<IAEItemStack> i = visual.iterator();
while (i.hasNext())
{
IAEItemStack o = i.next();
if ( o.equals( l ) )
{
i.remove();
return;
}
}
}
private void setScrollBar()
{
int size = visual.size();
myScrollBar.setTop( 19 ).setLeft( 218 ).setHeight( 137 );
myScrollBar.setRange( 0, (size + 2) / 3 - rows, 1 );
}
@Override
public void drawBG(int offsetX, int offsetY, int mouseX, int mouseY)
{
bindTexture( "guis/craftingcpu.png" );
this.drawTexturedModalRect( offsetX, offsetY, 0, 0, xSize, ySize );
}
int tooltip = -1;
@Override
public void drawScreen(int mouse_x, int mouse_y, float btn)
{
cancel.enabled = !visual.isEmpty();
int x = 0;
int y = 0;
int gx = (width - xSize) / 2;
int gy = (height - ySize) / 2;
int yoff = 23;
tooltip = -1;
for (int z = 0; z <= 4 * 5; z++)
{
int minX = gx + 9 + x * 67;
int minY = gy + 22 + y * yoff;
if ( minX < mouse_x && minX + 67 > mouse_x )
{
if ( minY < mouse_y && minY + yoff - 2 > mouse_y )
{
tooltip = z;
break;
}
}
x++;
if ( x > 2 )
{
y++;
x = 0;
}
}
super.drawScreen( mouse_x, mouse_y, btn );
}
@Override
public void drawFG(int offsetX, int offsetY, int mouseX, int mouseY)
{
fontRendererObj.drawString( getGuiDisplayName( GuiText.CraftingStatus.getLocal() ), 8, 7, 4210752 );
int sectionLength = 67;
int x = 0;
int y = 0;
int xo = 0 + 9;
int yo = 0 + 22;
int viewStart = myScrollBar.getCurrentScroll() * 3;
int viewEnd = viewStart + 3 * 6;
String dspToolTip = "";
List<String> lineList = new LinkedList();
int toolPosX = 0;
int toolPosY = 0;
int offY = 23;
for (int z = viewStart; z < Math.min( viewEnd, visual.size() ); z++)
{
IAEItemStack refStack = visual.get( z );// repo.getReferenceItem( z );
if ( refStack != null )
{
GL11.glPushMatrix();
GL11.glScaled( 0.5, 0.5, 0.5 );
IAEItemStack stored = storage.findPrecise( refStack );
IAEItemStack activeStack = active.findPrecise( refStack );
IAEItemStack pendingStack = pending.findPrecise( refStack );
int lines = 0;
if ( stored != null && stored.getStackSize() > 0 )
lines++;
if ( activeStack != null && activeStack.getStackSize() > 0 )
lines++;
if ( pendingStack != null && pendingStack.getStackSize() > 0 )
lines++;
int negY = ((lines - 1) * 5) / 2;
int downY = 0;
if ( stored != null && stored.getStackSize() > 0 )
{
String str = Long.toString( stored.getStackSize() );
if ( stored.getStackSize() >= 10000 )
str = Long.toString( stored.getStackSize() / 1000 ) + "k";
if ( stored.getStackSize() >= 10000000 )
str = Long.toString( stored.getStackSize() / 1000000 ) + "m";
str = GuiText.Stored.getLocal() + ": " + str;
int w = 4 + fontRendererObj.getStringWidth( str );
fontRendererObj.drawString( str, (int) ((x * (1 + sectionLength) + xo + sectionLength - 19 - ((float) w * 0.5)) * 2), (int) ((y * offY + yo
+ 6 - negY + downY) * 2), 4210752 );
if ( tooltip == z - viewStart )
lineList.add( GuiText.Stored.getLocal() + ": " + Long.toString( stored.getStackSize() ) );
downY += 5;
}
if ( activeStack != null && activeStack.getStackSize() > 0 )
{
String str = Long.toString( activeStack.getStackSize() );
if ( activeStack.getStackSize() >= 10000 )
str = Long.toString( activeStack.getStackSize() / 1000 ) + "k";
if ( activeStack.getStackSize() >= 10000000 )
str = Long.toString( activeStack.getStackSize() / 1000000 ) + "m";
str = GuiText.Crafting.getLocal() + ": " + str;
int w = 4 + fontRendererObj.getStringWidth( str );
fontRendererObj.drawString( str, (int) ((x * (1 + sectionLength) + xo + sectionLength - 19 - ((float) w * 0.5)) * 2), (int) ((y * offY + yo
+ 6 - negY + downY) * 2), 4210752 );
if ( tooltip == z - viewStart )
lineList.add( GuiText.Crafting.getLocal() + ": " + Long.toString( activeStack.getStackSize() ) );
downY += 5;
}
if ( pendingStack != null && pendingStack.getStackSize() > 0 )
{
String str = Long.toString( pendingStack.getStackSize() );
if ( pendingStack.getStackSize() >= 10000 )
str = Long.toString( pendingStack.getStackSize() / 1000 ) + "k";
if ( pendingStack.getStackSize() >= 10000000 )
str = Long.toString( pendingStack.getStackSize() / 1000000 ) + "m";
str = GuiText.Scheduled.getLocal() + ": " + str;
int w = 4 + fontRendererObj.getStringWidth( str );
fontRendererObj.drawString( str, (int) ((x * (1 + sectionLength) + xo + sectionLength - 19 - ((float) w * 0.5)) * 2), (int) ((y * offY + yo
+ 6 - negY + downY) * 2), 4210752 );
if ( tooltip == z - viewStart )
lineList.add( GuiText.Scheduled.getLocal() + ": " + Long.toString( pendingStack.getStackSize() ) );
}
GL11.glPopMatrix();
int posX = x * (1 + sectionLength) + xo + sectionLength - 19;
int posY = y * offY + yo;
ItemStack is = refStack.copy().getItemStack();
if ( tooltip == z - viewStart )
{
dspToolTip = Platform.getItemDisplayName( is );
if ( lineList.size() > 0 )
dspToolTip = dspToolTip + "\n" + Joiner.on( "\n" ).join( lineList );
toolPosX = x * (1 + sectionLength) + xo + sectionLength - 8;
toolPosY = y * offY + yo;
}
drawItem( posX, posY, is );
x++;
if ( x > 2 )
{
y++;
x = 0;
}
}
}
if ( tooltip >= 0 && dspToolTip.length() > 0 )
{
GL11.glPushAttrib( GL11.GL_ALL_ATTRIB_BITS );
drawTooltip( toolPosX, toolPosY + 10, 0, dspToolTip );
GL11.glPopAttrib();
}
}
@Override
public Enum getSortBy()
{
return SortOrder.NAME;
}
@Override
public Enum getSortDir()
{
return SortDir.ASCENDING;
}
@Override
public Enum getSortDisplay()
{
return ViewItems.ALL;
}
}
@@ -0,0 +1,151 @@
/**
*
*/
package appeng.client.gui.implementations;
import java.io.IOException;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.item.ItemStack;
import org.lwjgl.input.Mouse;
import appeng.api.AEApi;
import appeng.api.storage.ITerminalHost;
import appeng.client.gui.widgets.GuiTabButton;
import appeng.container.implementations.ContainerCraftingStatus;
import appeng.core.AELog;
import appeng.core.localization.GuiText;
import appeng.core.sync.GuiBridge;
import appeng.core.sync.network.NetworkHandler;
import appeng.core.sync.packets.PacketSwitchGuis;
import appeng.core.sync.packets.PacketValueConfig;
import appeng.helpers.WirelessTerminalGuiObject;
import appeng.parts.reporting.PartCraftingTerminal;
import appeng.parts.reporting.PartPatternTerminal;
import appeng.parts.reporting.PartTerminal;
public class GuiCraftingStatus extends GuiCraftingCPU
{
ContainerCraftingStatus ccc;
GuiButton selectcpu;
GuiTabButton originalGuiBtn;
GuiBridge OriginalGui;
ItemStack myIcon = null;
public GuiCraftingStatus(InventoryPlayer inventoryPlayer, ITerminalHost te) {
super( new ContainerCraftingStatus( inventoryPlayer, te ) );
ccc = (ContainerCraftingStatus) inventorySlots;
Object target = ccc.getTarget();
if ( target instanceof WirelessTerminalGuiObject )
{
myIcon = AEApi.instance().items().itemWirelessTerminal.stack( 1 );
OriginalGui = GuiBridge.GUI_WIRELESS_TERM;
}
if ( target instanceof PartTerminal )
{
myIcon = AEApi.instance().parts().partTerminal.stack( 1 );
OriginalGui = GuiBridge.GUI_ME;
}
if ( target instanceof PartCraftingTerminal )
{
myIcon = AEApi.instance().parts().partCraftingTerminal.stack( 1 );
OriginalGui = GuiBridge.GUI_CRAFTING_TERMINAL;
}
if ( target instanceof PartPatternTerminal )
{
myIcon = AEApi.instance().parts().partPatternTerminal.stack( 1 );
OriginalGui = GuiBridge.GUI_PATTERN_TERMINAL;
}
}
@Override
protected void actionPerformed(GuiButton btn)
{
super.actionPerformed( btn );
boolean backwards = Mouse.isButtonDown( 1 );
if ( btn == selectcpu )
{
try
{
NetworkHandler.instance.sendToServer( new PacketValueConfig( "Terminal.Cpu", backwards ? "Prev" : "Next" ) );
}
catch (IOException e)
{
AELog.error( e );
}
}
if ( btn == originalGuiBtn )
{
try
{
NetworkHandler.instance.sendToServer( new PacketSwitchGuis( OriginalGui ) );
}
catch (IOException e)
{
AELog.error( e );
}
}
}
@Override
protected String getGuiDisplayName(String in)
{
return in; // the cup name is on the button
}
@Override
public void initGui()
{
super.initGui();
selectcpu = new GuiButton( 0, this.guiLeft + 8, this.guiTop + ySize - 25, 150, 20, GuiText.CraftingCPU.getLocal() + ": " + GuiText.NoCraftingCPUs );
// selectcpu.enabled = false;
buttonList.add( selectcpu );
if ( myIcon != null )
{
buttonList.add( originalGuiBtn = new GuiTabButton( this.guiLeft + 213, this.guiTop - 4, myIcon, myIcon.getDisplayName(), itemRender ) );
originalGuiBtn.hideEdge = 13;
}
}
private void updateCPUButtonText()
{
String btnTextText = GuiText.NoCraftingJobs.getLocal();
if ( ccc.selectedCpu >= 0 )// && ccc.selectedCpu < ccc.cpus.size() )
{
if ( ccc.myName.length() > 0 )
{
String name = ccc.myName.substring( 0, Math.min( 20, ccc.myName.length() ) );
btnTextText = GuiText.CPUs.getLocal() + ": " + name;
}
else
btnTextText = GuiText.CPUs.getLocal() + ": #" + ccc.selectedCpu;
}
if ( ccc.noCPU )
btnTextText = GuiText.NoCraftingJobs.getLocal();
selectcpu.displayString = btnTextText;
}
@Override
public void drawScreen(int mouse_x, int mouse_y, float btn)
{
updateCPUButtonText();
super.drawScreen( mouse_x, mouse_y, btn );
}
}
@@ -0,0 +1,82 @@
package appeng.client.gui.implementations;
import java.io.IOException;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.Container;
import net.minecraft.inventory.Slot;
import appeng.api.config.ActionItems;
import appeng.api.config.Settings;
import appeng.api.storage.ITerminalHost;
import appeng.client.gui.widgets.GuiImgButton;
import appeng.container.implementations.ContainerCraftingTerm;
import appeng.container.slot.SlotCraftingMatrix;
import appeng.core.AELog;
import appeng.core.localization.GuiText;
import appeng.core.sync.network.NetworkHandler;
import appeng.core.sync.packets.PacketInventoryAction;
import appeng.helpers.InventoryAction;
public class GuiCraftingTerm extends GuiMEMonitorable
{
GuiImgButton clearBtn;
@Override
public void initGui()
{
super.initGui();
buttonList.add( clearBtn = new GuiImgButton( this.guiLeft + 92, this.guiTop + this.ySize - 156, Settings.ACTIONS, ActionItems.STASH ) );
clearBtn.halfSize = true;
}
@Override
protected void actionPerformed(GuiButton btn)
{
super.actionPerformed( btn );
if ( clearBtn == btn )
{
Slot s = null;
Container c = inventorySlots;
for (Object j : c.inventorySlots)
{
if ( j instanceof SlotCraftingMatrix )
s = (Slot) j;
}
if ( s != null )
{
PacketInventoryAction p;
try
{
p = new PacketInventoryAction( InventoryAction.MOVE_REGION, s.slotNumber, 0 );
NetworkHandler.instance.sendToServer( p );
}
catch (IOException e)
{
AELog.error( e );
}
}
}
}
public GuiCraftingTerm(InventoryPlayer inventoryPlayer, ITerminalHost te) {
super( inventoryPlayer, te, new ContainerCraftingTerm( inventoryPlayer, te ) );
reservedSpace = 73;
}
protected String getBackground()
{
return "guis/crafting.png";
}
@Override
public void drawFG(int offsetX, int offsetY, int mouseX, int mouseY)
{
super.drawFG( offsetX, offsetY, mouseX, mouseY );
fontRendererObj.drawString( GuiText.CraftingTerminal.getLocal(), 8, ySize - 96 + 1 - reservedSpace, 4210752 );
}
}
@@ -0,0 +1,67 @@
package appeng.client.gui.implementations;
import java.io.IOException;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.entity.player.InventoryPlayer;
import appeng.client.gui.AEBaseGui;
import appeng.client.gui.widgets.GuiTabButton;
import appeng.container.implementations.ContainerDrive;
import appeng.core.AELog;
import appeng.core.localization.GuiText;
import appeng.core.sync.GuiBridge;
import appeng.core.sync.network.NetworkHandler;
import appeng.core.sync.packets.PacketSwitchGuis;
import appeng.tile.storage.TileDrive;
public class GuiDrive extends AEBaseGui
{
GuiTabButton priority;
@Override
protected void actionPerformed(GuiButton par1GuiButton)
{
super.actionPerformed( par1GuiButton );
if ( par1GuiButton == priority )
{
try
{
NetworkHandler.instance.sendToServer( new PacketSwitchGuis( GuiBridge.GUI_PRIORITY ) );
}
catch (IOException e)
{
AELog.error( e );
}
}
}
@Override
public void initGui()
{
super.initGui();
buttonList.add( priority = new GuiTabButton( this.guiLeft + 154, this.guiTop, 2 + 4 * 16, GuiText.Priority.getLocal(), itemRender ) );
}
public GuiDrive(InventoryPlayer inventoryPlayer, TileDrive te) {
super( new ContainerDrive( inventoryPlayer, te ) );
this.ySize = 199;
}
@Override
public void drawBG(int offsetX, int offsetY, int mouseX, int mouseY)
{
bindTexture( "guis/drive.png" );
this.drawTexturedModalRect( offsetX, offsetY, 0, 0, xSize, ySize );
}
@Override
public void drawFG(int offsetX, int offsetY, int mouseX, int mouseY)
{
fontRendererObj.drawString( getGuiDisplayName( GuiText.Drive.getLocal() ), 8, 6, 4210752 );
fontRendererObj.drawString( GuiText.inventory.getLocal(), 8, ySize - 96 + 3, 4210752 );
}
}
@@ -0,0 +1,78 @@
package appeng.client.gui.implementations;
import java.io.IOException;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.entity.player.InventoryPlayer;
import appeng.api.config.FuzzyMode;
import appeng.api.config.Settings;
import appeng.client.gui.widgets.GuiImgButton;
import appeng.client.gui.widgets.GuiTabButton;
import appeng.container.implementations.ContainerFormationPlane;
import appeng.core.AELog;
import appeng.core.localization.GuiText;
import appeng.core.sync.GuiBridge;
import appeng.core.sync.network.NetworkHandler;
import appeng.core.sync.packets.PacketSwitchGuis;
import appeng.parts.automation.PartFormationPlane;
public class GuiFormationPlane extends GuiUpgradeable
{
GuiTabButton priority;
public GuiFormationPlane(InventoryPlayer inventoryPlayer, PartFormationPlane te) {
super( new ContainerFormationPlane( inventoryPlayer, te ) );
this.ySize = 251;
}
@Override
public void drawBG(int offsetX, int offsetY, int mouseX, int mouseY)
{
super.drawBG( offsetX, offsetY, mouseX, mouseY );
}
@Override
public void drawFG(int offsetX, int offsetY, int mouseX, int mouseY)
{
fontRendererObj.drawString( getGuiDisplayName( GuiText.FormationPlane.getLocal() ), 8, 6, 4210752 );
fontRendererObj.drawString( GuiText.inventory.getLocal(), 8, ySize - 96 + 3, 4210752 );
if ( fuzzyMode != null )
fuzzyMode.set( cvb.fzMode );
}
@Override
protected void addButtons()
{
fuzzyMode = new GuiImgButton( this.guiLeft - 18, guiTop + 28, Settings.FUZZY_MODE, FuzzyMode.IGNORE_ALL );
buttonList.add( priority = new GuiTabButton( this.guiLeft + 154, this.guiTop, 2 + 4 * 16, GuiText.Priority.getLocal(), itemRender ) );
buttonList.add( fuzzyMode );
}
@Override
protected void actionPerformed(GuiButton btn)
{
super.actionPerformed( btn );
if ( btn == priority )
{
try
{
NetworkHandler.instance.sendToServer( new PacketSwitchGuis( GuiBridge.GUI_PRIORITY ) );
}
catch (IOException e)
{
AELog.error( e );
}
}
}
protected String getBackground()
{
return "guis/storagebus.png";
}
}
@@ -0,0 +1,31 @@
package appeng.client.gui.implementations;
import net.minecraft.entity.player.InventoryPlayer;
import appeng.client.gui.AEBaseGui;
import appeng.container.implementations.ContainerGrinder;
import appeng.core.localization.GuiText;
import appeng.tile.grindstone.TileGrinder;
public class GuiGrinder extends AEBaseGui
{
public GuiGrinder(InventoryPlayer inventoryPlayer, TileGrinder te) {
super( new ContainerGrinder( inventoryPlayer, te ) );
this.ySize = 176;
}
@Override
public void drawBG(int offsetX, int offsetY, int mouseX, int mouseY)
{
bindTexture( "guis/grinder.png" );
this.drawTexturedModalRect( offsetX, offsetY, 0, 0, xSize, ySize );
}
@Override
public void drawFG(int offsetX, int offsetY, int mouseX, int mouseY)
{
fontRendererObj.drawString( getGuiDisplayName( GuiText.GrindStone.getLocal() ), 8, 6, 4210752 );
fontRendererObj.drawString( GuiText.inventory.getLocal(), 8, ySize - 96 + 3, 4210752 );
}
}
@@ -0,0 +1,96 @@
package appeng.client.gui.implementations;
import java.io.IOException;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.entity.player.InventoryPlayer;
import org.lwjgl.input.Mouse;
import appeng.api.AEApi;
import appeng.api.config.FullnessMode;
import appeng.api.config.OperationMode;
import appeng.api.config.RedstoneMode;
import appeng.api.config.Settings;
import appeng.client.gui.widgets.GuiImgButton;
import appeng.container.implementations.ContainerIOPort;
import appeng.core.AELog;
import appeng.core.localization.GuiText;
import appeng.core.sync.network.NetworkHandler;
import appeng.core.sync.packets.PacketConfigButton;
import appeng.tile.storage.TileIOPort;
public class GuiIOPort extends GuiUpgradeable
{
GuiImgButton fullMode;
GuiImgButton operationMode;
public GuiIOPort(InventoryPlayer inventoryPlayer, TileIOPort te) {
super( new ContainerIOPort( inventoryPlayer, te ) );
this.ySize = 166;
}
@Override
public void drawBG(int offsetX, int offsetY, int mouseX, int mouseY)
{
super.drawBG( offsetX, offsetY, mouseX, mouseY );
this.drawItem( offsetX + 66 - 8, offsetY + 17, AEApi.instance().items().itemCell1k.stack( 1 ) );
this.drawItem( offsetX + 94 + 8, offsetY + 17, AEApi.instance().blocks().blockDrive.stack( 1 ) );
}
@Override
public void drawFG(int offsetX, int offsetY, int mouseX, int mouseY)
{
fontRendererObj.drawString( getGuiDisplayName( GuiText.IOPort.getLocal() ), 8, 6, 4210752 );
fontRendererObj.drawString( GuiText.inventory.getLocal(), 8, ySize - 96 + 3, 4210752 );
if ( redstoneMode != null )
redstoneMode.set( cvb.rsMode );
if ( operationMode != null )
operationMode.set( ((ContainerIOPort) cvb).opMode );
if ( fullMode != null )
fullMode.set( ((ContainerIOPort) cvb).fMode );
}
@Override
protected void addButtons()
{
redstoneMode = new GuiImgButton( this.guiLeft - 18, guiTop + 28, Settings.REDSTONE_CONTROLLED, RedstoneMode.IGNORE );
fullMode = new GuiImgButton( this.guiLeft - 18, guiTop + 8, Settings.FULLNESS_MODE, FullnessMode.EMPTY );
operationMode = new GuiImgButton( this.guiLeft + 80, guiTop + 17, Settings.OPERATION_MODE, OperationMode.EMPTY );
buttonList.add( operationMode );
buttonList.add( redstoneMode );
buttonList.add( fullMode );
}
@Override
protected void actionPerformed(GuiButton btn)
{
super.actionPerformed( btn );
boolean backwards = Mouse.isButtonDown( 1 );
try
{
if ( btn == fullMode )
NetworkHandler.instance.sendToServer( new PacketConfigButton( fullMode.getSetting(), backwards ) );
if ( btn == operationMode )
NetworkHandler.instance.sendToServer( new PacketConfigButton( operationMode.getSetting(), backwards ) );
}
catch (IOException e)
{
AELog.error( e );
}
}
protected String getBackground()
{
return "guis/ioport.png";
}
}
@@ -0,0 +1,52 @@
package appeng.client.gui.implementations;
import net.minecraft.entity.player.InventoryPlayer;
import appeng.client.gui.AEBaseGui;
import appeng.client.gui.widgets.GuiProgressBar;
import appeng.client.gui.widgets.GuiProgressBar.Direction;
import appeng.container.implementations.ContainerInscriber;
import appeng.core.localization.GuiText;
import appeng.tile.misc.TileInscriber;
public class GuiInscriber extends AEBaseGui
{
ContainerInscriber cvc;
GuiProgressBar pb;
public GuiInscriber(InventoryPlayer inventoryPlayer, TileInscriber te) {
super( new ContainerInscriber( inventoryPlayer, te ) );
cvc = (ContainerInscriber) inventorySlots;
this.ySize = 176;
}
@Override
public void initGui()
{
super.initGui();
pb = new GuiProgressBar( "guis/inscriber.png", 135, 39, 179, 39, 6, 18, Direction.VERTICAL );
this.buttonList.add( pb );
}
@Override
public void drawBG(int offsetX, int offsetY, int mouseX, int mouseY)
{
bindTexture( "guis/inscriber.png" );
pb.xPosition = 135 + guiLeft;
pb.yPosition = 39 + guiTop;
this.drawTexturedModalRect( offsetX, offsetY, 0, 0, xSize, ySize );
}
@Override
public void drawFG(int offsetX, int offsetY, int mouseX, int mouseY)
{
pb.max = cvc.maxProcessingTime;
pb.current = cvc.processingTime;
pb.FullMsg = (pb.current * 100 / pb.max) + "%";
fontRendererObj.drawString( getGuiDisplayName( GuiText.Inscriber.getLocal() ), 8, 6, 4210752 );
fontRendererObj.drawString( GuiText.inventory.getLocal(), 8, ySize - 96 + 3, 4210752 );
}
}
@@ -0,0 +1,106 @@
package appeng.client.gui.implementations;
import java.io.IOException;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.entity.player.InventoryPlayer;
import org.lwjgl.input.Mouse;
import appeng.api.config.Settings;
import appeng.api.config.YesNo;
import appeng.client.gui.widgets.GuiImgButton;
import appeng.client.gui.widgets.GuiTabButton;
import appeng.client.gui.widgets.GuiToggleButton;
import appeng.container.implementations.ContainerInterface;
import appeng.core.AELog;
import appeng.core.localization.GuiText;
import appeng.core.sync.GuiBridge;
import appeng.core.sync.network.NetworkHandler;
import appeng.core.sync.packets.PacketConfigButton;
import appeng.core.sync.packets.PacketSwitchGuis;
import appeng.helpers.IInterfaceHost;
public class GuiInterface extends GuiUpgradeable
{
GuiTabButton priority;
GuiImgButton BlockMode;
GuiToggleButton interfaceMode;
public GuiInterface(InventoryPlayer inventoryPlayer, IInterfaceHost te) {
super( new ContainerInterface( inventoryPlayer, te ) );
this.ySize = 211;
}
@Override
protected void actionPerformed(GuiButton btn)
{
super.actionPerformed( btn );
boolean backwards = Mouse.isButtonDown( 1 );
if ( btn == priority )
{
try
{
NetworkHandler.instance.sendToServer( new PacketSwitchGuis( GuiBridge.GUI_PRIORITY ) );
}
catch (IOException e)
{
AELog.error( e );
}
}
try
{
if ( btn == interfaceMode )
NetworkHandler.instance.sendToServer( new PacketConfigButton( Settings.INTERFACE_TERMINAL, backwards ) );
if ( btn == BlockMode )
NetworkHandler.instance.sendToServer( new PacketConfigButton( BlockMode.getSetting(), backwards ) );
}
catch (IOException e)
{
AELog.error( e );
}
}
@Override
protected void addButtons()
{
priority = new GuiTabButton( this.guiLeft + 154, this.guiTop, 2 + 4 * 16, GuiText.Priority.getLocal(), itemRender );
buttonList.add( priority );
BlockMode = new GuiImgButton( this.guiLeft - 18, guiTop + 8, Settings.BLOCK, YesNo.NO );
buttonList.add( BlockMode );
interfaceMode = new GuiToggleButton( this.guiLeft - 18, guiTop + 26, 84, 85, GuiText.InterfaceTerminal.getLocal(),
GuiText.InterfaceTerminalHint.getLocal() );
buttonList.add( interfaceMode );
}
protected String getBackground()
{
return "guis/interface.png";
}
@Override
public void drawFG(int offsetX, int offsetY, int mouseX, int mouseY)
{
if ( BlockMode != null )
BlockMode.set( ((ContainerInterface) cvb).bMode );
if ( interfaceMode != null )
interfaceMode.setState( ((ContainerInterface) cvb).iTermMode == YesNo.YES );
fontRendererObj.drawString( getGuiDisplayName( GuiText.Interface.getLocal() ), 8, 6, 4210752 );
fontRendererObj.drawString( GuiText.Config.getLocal(), 18, 6 + 11 + 7, 4210752 );
fontRendererObj.drawString( GuiText.StoredItems.getLocal(), 18, 6 + 60 + 7, 4210752 );
fontRendererObj.drawString( GuiText.Patterns.getLocal(), 8, 6 + 73 + 7, 4210752 );
fontRendererObj.drawString( GuiText.inventory.getLocal(), 8, ySize - 96 + 3, 4210752 );
}
}
@@ -0,0 +1,213 @@
package appeng.client.gui.implementations;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedList;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import org.lwjgl.opengl.GL11;
import appeng.client.gui.AEBaseGui;
import appeng.client.gui.widgets.GuiScrollbar;
import appeng.client.me.ClientDCInternalInv;
import appeng.client.me.SlotDisconnected;
import appeng.container.implementations.ContainerInterfaceTerminal;
import appeng.core.localization.GuiText;
import appeng.parts.reporting.PartMonitor;
import com.google.common.collect.HashMultimap;
public class GuiInterfaceTerminal extends AEBaseGui
{
HashMap<Long, ClientDCInternalInv> byId = new HashMap();
HashMultimap<String, ClientDCInternalInv> byName = HashMultimap.create();
ArrayList<String> names = new ArrayList();
ArrayList<Object> lines = new ArrayList();
private int getTotalRows()
{
return names.size() + byId.size();// unique names, and each inv row.
}
public GuiInterfaceTerminal(InventoryPlayer inventoryPlayer, PartMonitor te) {
super( new ContainerInterfaceTerminal( inventoryPlayer, te ) );
myScrollBar = new GuiScrollbar();
xSize = 195;
ySize = 222;
}
LinkedList<SlotDisconnected> dcSlots = new LinkedList();
@Override
public void initGui()
{
super.initGui();
myScrollBar.setLeft( 175 );
myScrollBar.setHeight( 106 );
myScrollBar.setTop( 18 );
}
@Override
public void drawBG(int offsetX, int offsetY, int mouseX, int mouseY)
{
bindTexture( "guis/interfaceterminal.png" );
this.drawTexturedModalRect( offsetX, offsetY, 0, 0, xSize, ySize );
int offset = 17;
int ex = myScrollBar.getCurrentScroll();
int linesOnPage = 6;
for (int x = 0; x < linesOnPage; x++)
{
if ( ex + x < lines.size() )
{
Object lineObj = lines.get( ex + x );
if ( lineObj instanceof ClientDCInternalInv )
{
ClientDCInternalInv inv = (ClientDCInternalInv) lineObj;
GL11.glColor4f( 1, 1, 1, 1 );
for (int z = 0; z < inv.inv.getSizeInventory(); z++)
this.drawTexturedModalRect( offsetX + z * 18 + 7, offsetY + offset, 7, 139, 18, 18 );
}
}
offset += 18;
}
}
@Override
public void drawFG(int offsetX, int offsetY, int mouseX, int mouseY)
{
fontRendererObj.drawString( getGuiDisplayName( GuiText.InterfaceTerminal.getLocal() ), 8, 6, 4210752 );
fontRendererObj.drawString( GuiText.inventory.getLocal(), 8, ySize - 96 + 3, 4210752 );
int offset = 17;
// for (String name : lines)
int ex = myScrollBar.getCurrentScroll();
int linesOnPage = 6;
Iterator<Object> o = inventorySlots.inventorySlots.iterator();
while (o.hasNext())
{
if ( o.next() instanceof SlotDisconnected )
o.remove();
}
for (int x = 0; x < linesOnPage; x++)
{
if ( ex + x < lines.size() )
{
Object lineObj = lines.get( ex + x );
if ( lineObj instanceof ClientDCInternalInv )
{
ClientDCInternalInv inv = (ClientDCInternalInv) lineObj;
for (int z = 0; z < inv.inv.getSizeInventory(); z++)
{
inventorySlots.inventorySlots.add( new SlotDisconnected( inv, z, z * 18 + 8, 1 + offset ) );
}
}
else if ( lineObj instanceof String )
{
String name = (String) lineObj;
int rows = byName.get( name ).size();
if ( rows > 1 )
name = name + " (" + rows + ")";
while (name.length() > 2 && fontRendererObj.getStringWidth( name ) > 155)
name = name.substring( 0, name.length() - 1 );
fontRendererObj.drawString( name, 10, 6 + offset, 4210752 );
}
offset += 18;
}
}
}
boolean refreshList = false;
public void postUpdate(NBTTagCompound in)
{
if ( in.getBoolean( "clear" ) )
{
byId.clear();
refreshList = true;
}
for (Object oKey : in.func_150296_c())
{
String key = (String) oKey;
if ( key.startsWith( "=" ) )
{
try
{
long id = Long.parseLong( key.substring( 1 ), Character.MAX_RADIX );
NBTTagCompound invData = in.getCompoundTag( key );
ClientDCInternalInv current = getById( id, invData.getLong( "sortBy" ), invData.getString( "un" ) );
for (int x = 0; x < current.inv.getSizeInventory(); x++)
{
String which = Integer.toString( x );
if ( invData.hasKey( which ) )
current.inv.setInventorySlotContents( x, ItemStack.loadItemStackFromNBT( invData.getCompoundTag( which ) ) );
}
}
catch (NumberFormatException ex)
{
}
}
}
if ( refreshList )
{
refreshList = false;
byName.clear();
for (ClientDCInternalInv o : byId.values())
byName.put( o.getName(), o );
names.clear();
names.addAll( byName.keySet() );
Collections.sort( names );
lines = new ArrayList( getTotalRows() );
for (String n : names)
{
lines.add( n );
ArrayList<ClientDCInternalInv> lset = new ArrayList();
lset.addAll( byName.get( n ) );
Collections.sort( lset );
for (ClientDCInternalInv i : lset)
{
lines.add( i );
}
}
myScrollBar.setRange( 0, getTotalRows() - 6, 2 );
}
}
private ClientDCInternalInv getById(long id, long sortBy, String string)
{
ClientDCInternalInv o = byId.get( id );
if ( o == null )
{
byId.put( id, o = new ClientDCInternalInv( 9, id, sortBy, string ) );
refreshList = true;
}
return o;
}
}
@@ -0,0 +1,238 @@
package appeng.client.gui.implementations;
import java.io.IOException;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.entity.player.InventoryPlayer;
import org.lwjgl.input.Mouse;
import appeng.api.config.FuzzyMode;
import appeng.api.config.LevelType;
import appeng.api.config.RedstoneMode;
import appeng.api.config.Settings;
import appeng.api.config.Upgrades;
import appeng.api.config.YesNo;
import appeng.client.gui.widgets.GuiImgButton;
import appeng.client.gui.widgets.GuiNumberBox;
import appeng.container.implementations.ContainerLevelEmitter;
import appeng.core.AEConfig;
import appeng.core.AELog;
import appeng.core.localization.GuiText;
import appeng.core.sync.network.NetworkHandler;
import appeng.core.sync.packets.PacketConfigButton;
import appeng.core.sync.packets.PacketValueConfig;
import appeng.parts.automation.PartLevelEmitter;
public class GuiLevelEmitter extends GuiUpgradeable
{
GuiNumberBox level;
GuiButton plus1, plus10, plus100, plus1000;
GuiButton minus1, minus10, minus100, minus1000;
GuiImgButton levelMode;
GuiImgButton craftingMode;
public GuiLevelEmitter(InventoryPlayer inventoryPlayer, PartLevelEmitter te) {
super( new ContainerLevelEmitter( inventoryPlayer, te ) );
}
@Override
public void initGui()
{
super.initGui();
level = new GuiNumberBox( fontRendererObj, this.guiLeft + 24, this.guiTop + 43, 79, fontRendererObj.FONT_HEIGHT, Long.class );
level.setEnableBackgroundDrawing( false );
level.setMaxStringLength( 16 );
level.setTextColor( 0xFFFFFF );
level.setVisible( true );
level.setFocused( true );
((ContainerLevelEmitter) inventorySlots).setTextField( level );
}
@Override
protected void addButtons()
{
levelMode = new GuiImgButton( this.guiLeft - 18, guiTop + 8, Settings.LEVEL_TYPE, LevelType.ITEM_LEVEL );
redstoneMode = new GuiImgButton( this.guiLeft - 18, guiTop + 28, Settings.REDSTONE_EMITTER, RedstoneMode.LOW_SIGNAL );
fuzzyMode = new GuiImgButton( this.guiLeft - 18, guiTop + 48, Settings.FUZZY_MODE, FuzzyMode.IGNORE_ALL );
craftingMode = new GuiImgButton( this.guiLeft - 18, guiTop + 48, Settings.CRAFT_VIA_REDSTONE, YesNo.NO );
int a = AEConfig.instance.levelByStackAmounts( 0 );
int b = AEConfig.instance.levelByStackAmounts( 1 );
int c = AEConfig.instance.levelByStackAmounts( 2 );
int d = AEConfig.instance.levelByStackAmounts( 3 );
buttonList.add( plus1 = new GuiButton( 0, this.guiLeft + 20, this.guiTop + 17, 22, 20, "+" + a ) );
buttonList.add( plus10 = new GuiButton( 0, this.guiLeft + 48, this.guiTop + 17, 28, 20, "+" + b ) );
buttonList.add( plus100 = new GuiButton( 0, this.guiLeft + 82, this.guiTop + 17, 32, 20, "+" + c ) );
buttonList.add( plus1000 = new GuiButton( 0, this.guiLeft + 120, this.guiTop + 17, 38, 20, "+" + d ) );
buttonList.add( minus1 = new GuiButton( 0, this.guiLeft + 20, this.guiTop + 59, 22, 20, "-" + a ) );
buttonList.add( minus10 = new GuiButton( 0, this.guiLeft + 48, this.guiTop + 59, 28, 20, "-" + b ) );
buttonList.add( minus100 = new GuiButton( 0, this.guiLeft + 82, this.guiTop + 59, 32, 20, "-" + c ) );
buttonList.add( minus1000 = new GuiButton( 0, this.guiLeft + 120, this.guiTop + 59, 38, 20, "-" + d ) );
buttonList.add( levelMode );
buttonList.add( redstoneMode );
buttonList.add( fuzzyMode );
buttonList.add( craftingMode );
}
@Override
protected void actionPerformed(GuiButton btn)
{
super.actionPerformed( btn );
boolean backwards = Mouse.isButtonDown( 1 );
try
{
if ( btn == craftingMode )
NetworkHandler.instance.sendToServer( new PacketConfigButton( craftingMode.getSetting(), backwards ) );
if ( btn == levelMode )
NetworkHandler.instance.sendToServer( new PacketConfigButton( levelMode.getSetting(), backwards ) );
}
catch (IOException e)
{
AELog.error( e );
}
boolean isPlus = btn == plus1 || btn == plus10 || btn == plus100 || btn == plus1000;
boolean isMinus = btn == minus1 || btn == minus10 || btn == minus100 || btn == minus1000;
if ( isPlus || isMinus )
addQty( getQty( btn ) );
}
private void addQty(long i)
{
try
{
String Out = level.getText();
boolean Fixed = false;
while (Out.startsWith( "0" ) && Out.length() > 1)
{
Out = Out.substring( 1 );
Fixed = true;
}
if ( Fixed )
level.setText( Out );
if ( Out.length() == 0 )
Out = "0";
long result = Long.parseLong( Out );
result += i;
if ( result < 0 )
result = 0;
level.setText( Out = Long.toString( result ) );
NetworkHandler.instance.sendToServer( new PacketValueConfig( "LevelEmitter.Value", Out ) );
}
catch (NumberFormatException e)
{
// nope..
level.setText( "0" );
}
catch (IOException e)
{
AELog.error( e );
}
}
protected void handleButtonVisibility()
{
craftingMode.setVisibility( bc.getInstalledUpgrades( Upgrades.CRAFTING ) > 0 );
fuzzyMode.setVisibility( bc.getInstalledUpgrades( Upgrades.FUZZY ) > 0 );
}
@Override
protected void keyTyped(char character, int key)
{
if ( !this.checkHotbarKeys( key ) )
{
if ( (key == 211 || key == 205 || key == 203 || key == 14 || Character.isDigit( character )) && level.textboxKeyTyped( character, key ) )
{
try
{
String Out = level.getText();
boolean Fixed = false;
while (Out.startsWith( "0" ) && Out.length() > 1)
{
Out = Out.substring( 1 );
Fixed = true;
}
if ( Fixed )
level.setText( Out );
if ( Out.length() == 0 )
Out = "0";
NetworkHandler.instance.sendToServer( new PacketValueConfig( "LevelEmitter.Value", Out ) );
}
catch (IOException e)
{
AELog.error( e );
}
}
else
{
super.keyTyped( character, key );
}
}
}
@Override
public void drawFG(int offsetX, int offsetY, int mouseX, int mouseY)
{
boolean notCraftingMode = bc.getInstalledUpgrades( Upgrades.CRAFTING ) == 0;
// configure enabled status...
level.setEnabled( notCraftingMode );
plus1.enabled = notCraftingMode;
plus10.enabled = notCraftingMode;
plus100.enabled = notCraftingMode;
plus1000.enabled = notCraftingMode;
minus1.enabled = notCraftingMode;
minus10.enabled = notCraftingMode;
minus100.enabled = notCraftingMode;
minus1000.enabled = notCraftingMode;
levelMode.enabled = notCraftingMode;
redstoneMode.enabled = notCraftingMode;
super.drawFG( offsetX, offsetY, mouseX, mouseY );
if ( craftingMode != null )
craftingMode.set( ((ContainerLevelEmitter) cvb).cmType );
if ( levelMode != null )
levelMode.set( ((ContainerLevelEmitter) cvb).lvType );
}
@Override
public void drawBG(int offsetX, int offsetY, int mouseX, int mouseY)
{
super.drawBG( offsetX, offsetY, mouseX, mouseY );
level.drawTextBox();
}
protected String getBackground()
{
return "guis/lvlemitter.png";
}
protected GuiText getName()
{
return GuiText.LevelEmitter;
}
}
@@ -0,0 +1,68 @@
package appeng.client.gui.implementations;
import net.minecraft.entity.player.InventoryPlayer;
import appeng.api.config.RedstoneMode;
import appeng.api.config.Settings;
import appeng.client.gui.widgets.GuiImgButton;
import appeng.client.gui.widgets.GuiProgressBar;
import appeng.client.gui.widgets.GuiProgressBar.Direction;
import appeng.container.implementations.ContainerMAC;
import appeng.core.localization.GuiText;
import appeng.tile.crafting.TileMolecularAssembler;
public class GuiMAC extends GuiUpgradeable
{
ContainerMAC cmac;
GuiProgressBar pb;
@Override
public void initGui()
{
super.initGui();
pb = new GuiProgressBar( "guis/mac.png", 139, 36, 148, 201, 6, 18, Direction.VERTICAL );
this.buttonList.add( pb );
}
@Override
public void drawBG(int offsetX, int offsetY, int mouseX, int mouseY)
{
pb.xPosition = 148 + guiLeft;
pb.yPosition = 48 + guiTop;
super.drawBG( offsetX, offsetY, mouseX, mouseY );
}
@Override
public void drawFG(int offsetX, int offsetY, int mouseX, int mouseY)
{
pb.max = 100;
pb.current = cmac.craftProgress;
pb.FullMsg = pb.current + "%";
super.drawFG( offsetX, offsetY, mouseX, mouseY );
}
@Override
protected void addButtons()
{
redstoneMode = new GuiImgButton( this.guiLeft - 18, guiTop + 8, Settings.REDSTONE_CONTROLLED, RedstoneMode.IGNORE );
buttonList.add( redstoneMode );
}
protected String getBackground()
{
return "guis/mac.png";
}
public GuiMAC(InventoryPlayer inventoryPlayer, TileMolecularAssembler te) {
super( new ContainerMAC( inventoryPlayer, te ) );
this.ySize = 197;
this.cmac = (ContainerMAC) this.inventorySlots;
}
protected GuiText getName()
{
return GuiText.MolecularAssembler;
}
}
@@ -0,0 +1,472 @@
package appeng.client.gui.implementations;
import java.io.IOException;
import java.util.List;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack;
import org.lwjgl.input.Mouse;
import appeng.api.config.SearchBoxMode;
import appeng.api.config.Settings;
import appeng.api.config.TerminalStyle;
import appeng.api.implementations.guiobjects.IPortableCell;
import appeng.api.implementations.tiles.IMEChest;
import appeng.api.implementations.tiles.IViewCellStorage;
import appeng.api.storage.ITerminalHost;
import appeng.api.storage.data.IAEItemStack;
import appeng.api.util.IConfigManager;
import appeng.api.util.IConfigurableObject;
import appeng.client.gui.AEBaseMEGui;
import appeng.client.gui.widgets.GuiImgButton;
import appeng.client.gui.widgets.GuiScrollbar;
import appeng.client.gui.widgets.GuiTabButton;
import appeng.client.gui.widgets.ISortSource;
import appeng.client.gui.widgets.MEGuiTextField;
import appeng.client.me.InternalSlotME;
import appeng.client.me.ItemRepo;
import appeng.container.implementations.ContainerMEMonitorable;
import appeng.container.slot.AppEngSlot;
import appeng.container.slot.SlotCraftingMatrix;
import appeng.container.slot.SlotFakeCraftingMatrix;
import appeng.core.AEConfig;
import appeng.core.AELog;
import appeng.core.AppEng;
import appeng.core.localization.GuiText;
import appeng.core.sync.GuiBridge;
import appeng.core.sync.network.NetworkHandler;
import appeng.core.sync.packets.PacketSwitchGuis;
import appeng.core.sync.packets.PacketValueConfig;
import appeng.helpers.WirelessTerminalGuiObject;
import appeng.integration.IntegrationType;
import appeng.parts.reporting.PartTerminal;
import appeng.tile.misc.TileSecurity;
import appeng.util.IConfigManagerHost;
import appeng.util.Platform;
public class GuiMEMonitorable extends AEBaseMEGui implements ISortSource, IConfigManagerHost
{
GuiTabButton craftingStatusBtn;
MEGuiTextField searchField;
private static String memoryText = "";
public static int CraftingGridOffsetX;
public static int CraftingGridOffsetY;
ItemRepo repo;
GuiText myName;
int xoffset = 9;
int perRow = 9;
int reservedSpace = 0;
int lowerTextureOffset = 0;
boolean customSortOrder = true;
int rows = 0;
int maxRows = Integer.MAX_VALUE;
int standardSize;
IConfigManager configSrc;
GuiImgButton ViewBox;
GuiImgButton SortByBox;
GuiImgButton SortDirBox;
GuiImgButton searchBoxSettings, terminalStyleBox;
boolean viewCell;
ItemStack myCurrentViewCells[] = new ItemStack[5];
ContainerMEMonitorable mecontainer;
public GuiMEMonitorable(InventoryPlayer inventoryPlayer, ITerminalHost te) {
this( inventoryPlayer, te, new ContainerMEMonitorable( inventoryPlayer, te ) );
}
public GuiMEMonitorable(InventoryPlayer inventoryPlayer, ITerminalHost te, ContainerMEMonitorable c) {
super( c );
myScrollBar = new GuiScrollbar();
repo = new ItemRepo( myScrollBar, this );
xSize = 185;
ySize = 204;
if ( te instanceof IViewCellStorage )
xSize += 33;
standardSize = xSize;
configSrc = ((IConfigurableObject) inventorySlots).getConfigManager();
(mecontainer = (ContainerMEMonitorable) inventorySlots).gui = this;
viewCell = te instanceof IViewCellStorage;
if ( te instanceof TileSecurity )
myName = GuiText.Security;
else if ( te instanceof WirelessTerminalGuiObject )
myName = GuiText.WirelessTerminal;
else if ( te instanceof IPortableCell )
myName = GuiText.PortableCell;
else if ( te instanceof IMEChest )
myName = GuiText.Chest;
else if ( te instanceof PartTerminal )
myName = GuiText.Terminal;
}
public void postUpdate(List<IAEItemStack> list)
{
for (IAEItemStack is : list)
repo.postUpdate( is );
repo.updateView();
setScrollBar();
}
private void setScrollBar()
{
myScrollBar.setTop( 18 ).setLeft( 175 ).setHeight( rows * 18 - 2 );
myScrollBar.setRange( 0, (repo.size() + perRow - 1) / perRow - rows, Math.max( 1, rows / 6 ) );
}
public void re_init()
{
this.buttonList.clear();
this.initGui();
}
@Override
public void onGuiClosed()
{
super.onGuiClosed();
memoryText = searchField.getText();
}
@Override
public void initGui()
{
maxRows = getMaxRows();
perRow = AEConfig.instance.getConfigManager().getSetting( Settings.TERMINAL_STYLE ) != TerminalStyle.FULL ? 9 : 9 + ((width - standardSize) / 18);
boolean hasNEI = AppEng.instance.isIntegrationEnabled( IntegrationType.NEI );
int NEI = hasNEI ? 0 : 0;
int top = hasNEI ? 22 : 0;
int magicNumber = 114 + 1;
int extraSpace = height - magicNumber - NEI - top - reservedSpace;
rows = (int) Math.floor( extraSpace / 18 );
if ( rows > maxRows )
{
top += (rows - maxRows) * 18 / 2;
rows = maxRows;
}
if ( hasNEI )
rows--;
if ( rows < 3 )
rows = 3;
meSlots.clear();
for (int y = 0; y < rows; y++)
{
for (int x = 0; x < perRow; x++)
{
meSlots.add( new InternalSlotME( repo, x + y * perRow, xoffset + x * 18, 18 + y * 18 ) );
}
}
if ( AEConfig.instance.getConfigManager().getSetting( Settings.TERMINAL_STYLE ) != TerminalStyle.FULL )
this.xSize = standardSize + ((perRow - 9) * 18);
else
this.xSize = standardSize;
super.initGui();
// full size : 204
// extra slots : 72
// slot 18
this.ySize = magicNumber + rows * 18 + reservedSpace;
// this.guiTop = top;
int unusedSpace = height - ySize;
guiTop = (int) Math.floor( (float) unusedSpace / (unusedSpace < 0 ? 3.8f : 2.0f) );
int offset = guiTop + 8;
if ( customSortOrder )
{
buttonList.add( SortByBox = new GuiImgButton( this.guiLeft - 18, offset, Settings.SORT_BY, configSrc.getSetting( Settings.SORT_BY ) ) );
offset += 20;
}
if ( viewCell || this instanceof GuiWirelessTerm )
{
buttonList.add( ViewBox = new GuiImgButton( this.guiLeft - 18, offset, Settings.VIEW_MODE, configSrc.getSetting( Settings.VIEW_MODE ) ) );
offset += 20;
}
buttonList.add( SortDirBox = new GuiImgButton( this.guiLeft - 18, offset, Settings.SORT_DIRECTION, configSrc.getSetting( Settings.SORT_DIRECTION ) ) );
offset += 20;
buttonList.add( searchBoxSettings = new GuiImgButton( this.guiLeft - 18, offset, Settings.SEARCH_MODE, AEConfig.instance.settings
.getSetting( Settings.SEARCH_MODE ) ) );
offset += 20;
if ( !(this instanceof GuiMEPortableCell) || this instanceof GuiWirelessTerm )
{
buttonList.add( terminalStyleBox = new GuiImgButton( this.guiLeft - 18, offset, Settings.TERMINAL_STYLE, AEConfig.instance.settings
.getSetting( Settings.TERMINAL_STYLE ) ) );
}
searchField = new MEGuiTextField( fontRendererObj, this.guiLeft + Math.max( 82, xoffset ), this.guiTop + 6, 89, fontRendererObj.FONT_HEIGHT );
searchField.setEnableBackgroundDrawing( false );
searchField.setMaxStringLength( 25 );
searchField.setTextColor( 0xFFFFFF );
searchField.setVisible( true );
if ( viewCell || this instanceof GuiWirelessTerm )
{
buttonList.add( craftingStatusBtn = new GuiTabButton( this.guiLeft + 170, this.guiTop - 4, 2 + 11 * 16, GuiText.CraftingStatus.getLocal(),
itemRender ) );
craftingStatusBtn.hideEdge = 13;
}
// Enum setting = AEConfig.instance.getSetting( "Terminal", SearchBoxMode.class, SearchBoxMode.AUTOSEARCH );
Enum setting = AEConfig.instance.settings.getSetting( Settings.SEARCH_MODE );
searchField.setFocused( SearchBoxMode.AUTOSEARCH == setting || SearchBoxMode.NEI_AUTOSEARCH == setting );
if ( isSubGui() )
{
searchField.setText( memoryText );
repo.searchString = memoryText;
repo.updateView();
setScrollBar();
}
CraftingGridOffsetX = Integer.MAX_VALUE;
CraftingGridOffsetY = Integer.MAX_VALUE;
for (Object s : inventorySlots.inventorySlots)
{
if ( s instanceof AppEngSlot )
{
if ( ((AppEngSlot) s).xDisplayPosition < 197 )
repositionSlot( (AppEngSlot) s );
}
if ( s instanceof SlotCraftingMatrix || s instanceof SlotFakeCraftingMatrix )
{
Slot g = (Slot) s;
if ( g.xDisplayPosition > 0 && g.yDisplayPosition > 0 )
{
CraftingGridOffsetX = Math.min( CraftingGridOffsetX, g.xDisplayPosition );
CraftingGridOffsetY = Math.min( CraftingGridOffsetY, g.yDisplayPosition );
}
}
}
CraftingGridOffsetX -= 25;
CraftingGridOffsetY -= 6;
}
protected void repositionSlot(AppEngSlot s)
{
s.yDisplayPosition = s.defY + ySize - 78 - 5;
}
@Override
protected void actionPerformed(GuiButton btn)
{
if ( btn == craftingStatusBtn )
{
try
{
NetworkHandler.instance.sendToServer( new PacketSwitchGuis( GuiBridge.GUI_CRAFTING_STATUS ) );
}
catch (IOException e)
{
AELog.error( e );
}
}
if ( btn instanceof GuiImgButton )
{
boolean backwards = Mouse.isButtonDown( 1 );
GuiImgButton iBtn = (GuiImgButton) btn;
if ( iBtn.getSetting() != Settings.ACTIONS )
{
Enum cv = iBtn.getCurrentValue();
Enum next = Platform.rotateEnum( cv, backwards, iBtn.getSetting().getPossibleValues() );
if ( btn == terminalStyleBox )
AEConfig.instance.settings.putSetting( iBtn.getSetting(), next );
else if ( btn == searchBoxSettings )
AEConfig.instance.settings.putSetting( iBtn.getSetting(), next );
else
{
try
{
NetworkHandler.instance.sendToServer( new PacketValueConfig( iBtn.getSetting().name(), next.name() ) );
}
catch (IOException e)
{
AELog.error( e );
}
}
iBtn.set( next );
if ( next.getClass() == SearchBoxMode.class || next.getClass() == TerminalStyle.class )
re_init();
}
}
}
@Override
protected void mouseClicked(int xCoord, int yCoord, int btn)
{
Enum setting = AEConfig.instance.settings.getSetting( Settings.SEARCH_MODE );
if ( !(SearchBoxMode.AUTOSEARCH == setting || SearchBoxMode.NEI_AUTOSEARCH == setting) )
searchField.mouseClicked( xCoord, yCoord, btn );
if ( btn == 1 && searchField.isMouseIn( xCoord, yCoord ) )
{
searchField.setText( "" );
repo.searchString = "";
repo.updateView();
setScrollBar();
}
super.mouseClicked( xCoord, yCoord, btn );
}
@Override
protected void keyTyped(char character, int key)
{
if ( !this.checkHotbarKeys( key ) )
{
if ( character == ' ' && this.searchField.getText().length() == 0 )
return;
if ( searchField.textboxKeyTyped( character, key ) )
{
repo.searchString = this.searchField.getText();
repo.updateView();
setScrollBar();
}
else
{
super.keyTyped( character, key );
}
}
}
@Override
public void updateScreen()
{
repo.setPower( mecontainer.hasPower );
super.updateScreen();
}
@Override
public void drawBG(int offsetX, int offsetY, int mouseX, int mouseY)
{
int x_width = 197;
bindTexture( getBackground() );
this.drawTexturedModalRect( offsetX, offsetY, 0, 0, x_width, 18 );
if ( viewCell || (this instanceof GuiSecurity) )
this.drawTexturedModalRect( offsetX + x_width, offsetY, x_width, 0, 46, 128 );
for (int x = 0; x < rows; x++)
this.drawTexturedModalRect( offsetX, offsetY + 18 + x * 18, 0, 18, x_width, 18 );
this.drawTexturedModalRect( offsetX, offsetY + 16 + rows * 18 + lowerTextureOffset, 0, 106 - 18 - 18, x_width, 99 + reservedSpace - lowerTextureOffset );
if ( viewCell )
{
boolean update = false;
for (int i = 0; i < 5; i++)
{
if ( myCurrentViewCells[i] != mecontainer.cellView[i].getStack() )
{
update = true;
myCurrentViewCells[i] = mecontainer.cellView[i].getStack();
}
}
if ( update )
repo.setViewCell( myCurrentViewCells );
}
if ( searchField != null )
searchField.drawTextBox();
}
protected String getBackground()
{
return "guis/terminal.png";
}
@Override
public void drawFG(int offsetX, int offsetY, int mouseX, int mouseY)
{
fontRendererObj.drawString( getGuiDisplayName( myName.getLocal() ), 8, 6, 4210752 );
fontRendererObj.drawString( GuiText.inventory.getLocal(), 8, ySize - 96 + 3, 4210752 );
}
@Override
public Enum getSortBy()
{
return configSrc.getSetting( Settings.SORT_BY );
}
@Override
public Enum getSortDir()
{
return configSrc.getSetting( Settings.SORT_DIRECTION );
}
@Override
public Enum getSortDisplay()
{
return configSrc.getSetting( Settings.VIEW_MODE );
}
@Override
public void updateSetting(IConfigManager manager, Enum settingName, Enum newValue)
{
if ( SortByBox != null )
SortByBox.set( configSrc.getSetting( Settings.SORT_BY ) );
if ( SortDirBox != null )
SortDirBox.set( configSrc.getSetting( Settings.SORT_DIRECTION ) );
if ( ViewBox != null )
ViewBox.set( configSrc.getSetting( Settings.VIEW_MODE ) );
repo.updateView();
}
protected boolean isPowered()
{
return repo.hasPower();
}
int getMaxRows()
{
return AEConfig.instance.getConfigManager().getSetting( Settings.TERMINAL_STYLE ) == TerminalStyle.SMALL ? 6 : Integer.MAX_VALUE;
}
}
@@ -0,0 +1,24 @@
package appeng.client.gui.implementations;
import net.minecraft.entity.player.InventoryPlayer;
import appeng.api.implementations.guiobjects.IPortableCell;
import appeng.container.implementations.ContainerMEPortableCell;
public class GuiMEPortableCell extends GuiMEMonitorable
{
public GuiMEPortableCell(InventoryPlayer inventoryPlayer, IPortableCell te) {
super( inventoryPlayer, te, new ContainerMEPortableCell( inventoryPlayer, null ) );
}
int defaultGetMaxRows()
{
return super.getMaxRows();
}
@Override
int getMaxRows()
{
return 3;
}
}
@@ -0,0 +1,295 @@
package appeng.client.gui.implementations;
import java.util.List;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack;
import org.lwjgl.input.Mouse;
import org.lwjgl.opengl.GL11;
import appeng.api.config.Settings;
import appeng.api.config.SortDir;
import appeng.api.config.SortOrder;
import appeng.api.config.ViewItems;
import appeng.api.implementations.guiobjects.INetworkTool;
import appeng.api.storage.data.IAEItemStack;
import appeng.client.gui.AEBaseGui;
import appeng.client.gui.widgets.GuiImgButton;
import appeng.client.gui.widgets.GuiScrollbar;
import appeng.client.gui.widgets.ISortSource;
import appeng.client.me.ItemRepo;
import appeng.client.me.SlotME;
import appeng.container.implementations.ContainerNetworkStatus;
import appeng.core.AEConfig;
import appeng.core.localization.GuiText;
import appeng.util.Platform;
public class GuiNetworkStatus extends AEBaseGui implements ISortSource
{
ItemRepo repo;
GuiImgButton units;
int rows = 4;
public GuiNetworkStatus(InventoryPlayer inventoryPlayer, INetworkTool te) {
super( new ContainerNetworkStatus( inventoryPlayer, te ) );
this.ySize = 153;
this.xSize = 195;
myScrollBar = new GuiScrollbar();
repo = new ItemRepo( myScrollBar, this );
repo.rowSize = 5;
}
@Override
protected void actionPerformed(GuiButton btn)
{
super.actionPerformed( btn );
boolean backwards = Mouse.isButtonDown( 1 );
if ( btn == units )
{
AEConfig.instance.nextPowerUnit( backwards );
units.set( AEConfig.instance.selectedPowerUnit() );
}
}
@Override
public void initGui()
{
super.initGui();
units = new GuiImgButton( this.guiLeft - 18, guiTop + 8, Settings.POWER_UNITS, AEConfig.instance.selectedPowerUnit() );
buttonList.add( units );
}
public void postUpdate(List<IAEItemStack> list)
{
repo.clear();
for (IAEItemStack is : list)
repo.postUpdate( is );
repo.updateView();
setScrollBar();
}
private void setScrollBar()
{
int size = repo.size();
myScrollBar.setTop( 39 ).setLeft( 175 ).setHeight( 78 );
myScrollBar.setRange( 0, (size + 4) / 5 - rows, 1 );
}
@Override
public void drawBG(int offsetX, int offsetY, int mouseX, int mouseY)
{
bindTexture( "guis/networkstatus.png" );
this.drawTexturedModalRect( offsetX, offsetY, 0, 0, xSize, ySize );
}
int tooltip = -1;
@Override
public void drawScreen(int mouse_x, int mouse_y, float btn)
{
int x = 0;
int y = 0;
int gx = (width - xSize) / 2;
int gy = (height - ySize) / 2;
tooltip = -1;
for (int z = 0; z <= 4 * 5; z++)
{
int minX = gx + 14 + x * 31;
int minY = gy + 41 + y * 18;
if ( minX < mouse_x && minX + 28 > mouse_x )
{
if ( minY < mouse_y && minY + 20 > mouse_y )
{
tooltip = z;
break;
}
}
x++;
if ( x > 4 )
{
y++;
x = 0;
}
}
super.drawScreen( mouse_x, mouse_y, btn );
}
@Override
public void drawFG(int offsetX, int offsetY, int mouseX, int mouseY)
{
ContainerNetworkStatus ns = (ContainerNetworkStatus) inventorySlots;
fontRendererObj.drawString( GuiText.NetworkDetails.getLocal(), 8, 6, 4210752 );
fontRendererObj.drawString( GuiText.StoredPower.getLocal() + ": " + Platform.formatPowerLong( ns.currentPower, false ), 13, 16, 4210752 );
fontRendererObj.drawString( GuiText.MaxPower.getLocal() + ": " + Platform.formatPowerLong( ns.maxPower, false ), 13, 26, 4210752 );
fontRendererObj.drawString( GuiText.PowerInputRate.getLocal() + ": " + Platform.formatPowerLong( ns.avgAddition, true ), 13, 143 - 10, 4210752 );
fontRendererObj.drawString( GuiText.PowerUsageRate.getLocal() + ": " + Platform.formatPowerLong( ns.powerUsage, true ), 13, 143 - 20, 4210752 );
int sectionLength = 30;
int x = 0;
int y = 0;
int xo = 0 + 12;
int yo = 0 + 42;
int viewStart = 0;// myScrollBar.getCurrentScroll() * 5;
int viewEnd = viewStart + 5 * 4;
String ToolTip = "";
int toolPosX = 0;
int toolPosY = 0;
for (int z = viewStart; z < Math.min( viewEnd, repo.size() ); z++)
{
IAEItemStack refStack = repo.getReferenceItem( z );
if ( refStack != null )
{
GL11.glPushMatrix();
GL11.glScaled( 0.5, 0.5, 0.5 );
String str = Long.toString( refStack.getStackSize() );
if ( refStack.getStackSize() >= 10000 )
str = Long.toString( refStack.getStackSize() / 1000 ) + "k";
int w = fontRendererObj.getStringWidth( str );
fontRendererObj.drawString( str, (int) ((x * sectionLength + xo + sectionLength - 19 - ((float) w * 0.5)) * 2), (int) ((y * 18 + yo + 6) * 2),
4210752 );
GL11.glPopMatrix();
int posX = x * sectionLength + xo + sectionLength - 18;
int posY = y * 18 + yo;
if ( tooltip == z - viewStart )
{
ToolTip = Platform.getItemDisplayName( repo.getItem( z ) );
ToolTip = ToolTip + ("\n" + GuiText.Installed.getLocal() + ": " + (refStack.getStackSize()));
if ( refStack.getCountRequestable() > 0 )
ToolTip = ToolTip + ("\n" + GuiText.EnergyDrain.getLocal() + ": " + Platform.formatPowerLong( refStack.getCountRequestable(), true ));
toolPosX = x * sectionLength + xo + sectionLength - 8;
toolPosY = y * 18 + yo;
}
drawItem( posX, posY, repo.getItem( z ) );
x++;
if ( x > 4 )
{
y++;
x = 0;
}
}
}
if ( tooltip >= 0 && ToolTip.length() > 0 )
{
GL11.glPushAttrib( GL11.GL_ALL_ATTRIB_BITS );
drawTooltip( toolPosX, toolPosY + 10, 0, ToolTip );
GL11.glPopAttrib();
}
}
// @Override - NEI
public List<String> handleItemTooltip(ItemStack stack, int mousex, int mousey, List<String> currenttip)
{
if ( stack != null )
{
Slot s = getSlot( mousex, mousey );
if ( s instanceof SlotME )
{
IAEItemStack myStack = null;
try
{
SlotME theSlotField = (SlotME) s;
myStack = theSlotField.getAEStack();
}
catch (Throwable ignore)
{
}
if ( myStack != null )
{
while (currenttip.size() > 1)
currenttip.remove( 1 );
}
}
}
return currenttip;
}
// Vanilla version...
protected void drawItemStackTooltip(ItemStack stack, int x, int y)
{
Slot s = getSlot( x, y );
if ( s instanceof SlotME && stack != null )
{
IAEItemStack myStack = null;
try
{
SlotME theSlotField = (SlotME) s;
myStack = theSlotField.getAEStack();
}
catch (Throwable ignore)
{
}
if ( myStack != null )
{
List currenttip = stack.getTooltip( this.mc.thePlayer, this.mc.gameSettings.advancedItemTooltips );
while (currenttip.size() > 1)
currenttip.remove( 1 );
currenttip.add( GuiText.Installed.getLocal() + ": " + (myStack.getStackSize()) );
currenttip.add( GuiText.EnergyDrain.getLocal() + ": " + Platform.formatPowerLong( myStack.getCountRequestable(), true ) );
drawTooltip( x, y, 0, join( currenttip, "\n" ) );
}
}
// super.drawItemStackTooltip( stack, x, y );
}
@Override
public Enum getSortBy()
{
return SortOrder.NAME;
}
@Override
public Enum getSortDir()
{
return SortDir.ASCENDING;
}
@Override
public Enum getSortDisplay()
{
return ViewItems.ALL;
}
}
@@ -0,0 +1,69 @@
package appeng.client.gui.implementations;
import java.io.IOException;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.entity.player.InventoryPlayer;
import appeng.api.implementations.guiobjects.INetworkTool;
import appeng.client.gui.AEBaseGui;
import appeng.client.gui.widgets.GuiToggleButton;
import appeng.container.implementations.ContainerNetworkTool;
import appeng.core.AELog;
import appeng.core.localization.GuiText;
import appeng.core.sync.network.NetworkHandler;
import appeng.core.sync.packets.PacketValueConfig;
public class GuiNetworkTool extends AEBaseGui
{
GuiToggleButton tFacades;
public GuiNetworkTool(InventoryPlayer inventoryPlayer, INetworkTool te) {
super( new ContainerNetworkTool( inventoryPlayer, te ) );
this.ySize = 166;
}
@Override
protected void actionPerformed(GuiButton btn)
{
super.actionPerformed( btn );
try
{
if ( btn == tFacades )
NetworkHandler.instance.sendToServer( new PacketValueConfig( "NetworkTool", "Toggle" ) );
}
catch (IOException e)
{
AELog.error( e );
}
}
@Override
public void initGui()
{
super.initGui();
tFacades = new GuiToggleButton( this.guiLeft - 18, guiTop + 8, 23, 22, GuiText.TransparentFacades.getLocal(), GuiText.TransparentFacadesHint.getLocal() );
buttonList.add( tFacades );
}
@Override
public void drawBG(int offsetX, int offsetY, int mouseX, int mouseY)
{
bindTexture( "guis/toolbox.png" );
this.drawTexturedModalRect( offsetX, offsetY, 0, 0, xSize, ySize );
}
@Override
public void drawFG(int offsetX, int offsetY, int mouseX, int mouseY)
{
if ( tFacades != null )
tFacades.setState( ((ContainerNetworkTool) inventorySlots).facadeMode );
fontRendererObj.drawString( getGuiDisplayName( GuiText.NetworkTool.getLocal() ), 8, 6, 4210752 );
fontRendererObj.drawString( GuiText.inventory.getLocal(), 8, ySize - 96 + 3, 4210752 );
}
}
@@ -0,0 +1,125 @@
package appeng.client.gui.implementations;
import java.io.IOException;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.item.ItemStack;
import appeng.api.config.ActionItems;
import appeng.api.config.Settings;
import appeng.api.storage.ITerminalHost;
import appeng.client.gui.widgets.GuiImgButton;
import appeng.client.gui.widgets.GuiTabButton;
import appeng.container.implementations.ContainerPatternTerm;
import appeng.container.slot.AppEngSlot;
import appeng.core.localization.GuiText;
import appeng.core.sync.network.NetworkHandler;
import appeng.core.sync.packets.PacketValueConfig;
public class GuiPatternTerm extends GuiMEMonitorable
{
ContainerPatternTerm container;
GuiTabButton tabCraftButton;
GuiTabButton tabProcessButton;
// GuiImgButton substitutionsBtn;
GuiImgButton encodeBtn;
GuiImgButton clearBtn;
@Override
public void initGui()
{
super.initGui();
buttonList.add( tabCraftButton = new GuiTabButton( this.guiLeft + 173, this.guiTop + this.ySize - 177, new ItemStack( Blocks.crafting_table ),
GuiText.CraftingPattern.getLocal(), itemRender ) );
buttonList.add( tabProcessButton = new GuiTabButton( this.guiLeft + 173, this.guiTop + this.ySize - 177, new ItemStack( Blocks.furnace ),
GuiText.ProcessingPattern.getLocal(), itemRender ) );
// buttonList.add( substitutionsBtn = new GuiImgButton( this.guiLeft + 84, this.guiTop + this.ySize - 163,
// Settings.ACTIONS, ActionItems.SUBSTITUTION ) );
// substitutionsBtn.halfSize = true;
buttonList.add( clearBtn = new GuiImgButton( this.guiLeft + 74, this.guiTop + this.ySize - 163, Settings.ACTIONS, ActionItems.CLOSE ) );
clearBtn.halfSize = true;
buttonList.add( encodeBtn = new GuiImgButton( this.guiLeft + 147, this.guiTop + this.ySize - 142, Settings.ACTIONS, ActionItems.ENCODE ) );
}
@Override
protected void actionPerformed(GuiButton btn)
{
super.actionPerformed( btn );
try
{
if ( tabCraftButton == btn || tabProcessButton == btn )
{
NetworkHandler.instance.sendToServer( new PacketValueConfig( "PatternTerminal.CraftMode", tabProcessButton == btn ? "1" : "0" ) );
}
if ( encodeBtn == btn )
{
NetworkHandler.instance.sendToServer( new PacketValueConfig( "PatternTerminal.Encode", "1" ) );
}
if ( clearBtn == btn )
{
NetworkHandler.instance.sendToServer( new PacketValueConfig( "PatternTerminal.Clear", "1" ) );
}
}
catch (IOException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}
// if ( substitutionsBtn == btn )
// {
// }
}
protected void repositionSlot(AppEngSlot s)
{
if ( s.isPlayerSide() )
s.yDisplayPosition = s.defY + ySize - 78 - 5;
else
s.yDisplayPosition = s.defY + ySize - 78 - 3;
}
public GuiPatternTerm(InventoryPlayer inventoryPlayer, ITerminalHost te) {
super( inventoryPlayer, te, new ContainerPatternTerm( inventoryPlayer, te ) );
container = (ContainerPatternTerm) this.inventorySlots;
reservedSpace = 81;
}
protected String getBackground()
{
if ( container.craftingMode )
return "guis/pattern.png";
return "guis/pattern2.png";
}
@Override
public void drawFG(int offsetX, int offsetY, int mouseX, int mouseY)
{
if ( !container.craftingMode )
{
tabCraftButton.visible = false;
tabProcessButton.visible = true;
}
else
{
tabCraftButton.visible = true;
tabProcessButton.visible = false;
}
super.drawFG( offsetX, offsetY, mouseX, mouseY );
fontRendererObj.drawString( GuiText.PatternTerminal.getLocal(), 8, ySize - 96 + 2 - reservedSpace, 4210752 );
}
}
@@ -0,0 +1,234 @@
package appeng.client.gui.implementations;
import java.io.IOException;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.item.ItemStack;
import appeng.api.AEApi;
import appeng.client.gui.AEBaseGui;
import appeng.client.gui.widgets.GuiNumberBox;
import appeng.client.gui.widgets.GuiTabButton;
import appeng.container.AEBaseContainer;
import appeng.container.implementations.ContainerPriority;
import appeng.core.AEConfig;
import appeng.core.AELog;
import appeng.core.localization.GuiText;
import appeng.core.sync.GuiBridge;
import appeng.core.sync.network.NetworkHandler;
import appeng.core.sync.packets.PacketSwitchGuis;
import appeng.core.sync.packets.PacketValueConfig;
import appeng.helpers.IPriorityHost;
import appeng.parts.automation.PartFormationPlane;
import appeng.parts.misc.PartInterface;
import appeng.parts.misc.PartStorageBus;
import appeng.tile.misc.TileInterface;
import appeng.tile.storage.TileChest;
import appeng.tile.storage.TileDrive;
public class GuiPriority extends AEBaseGui
{
GuiNumberBox priority;
GuiTabButton originalGuiBtn;
GuiButton plus1, plus10, plus100, plus1000;
GuiButton minus1, minus10, minus100, minus1000;
GuiBridge OriginalGui;
public GuiPriority(InventoryPlayer inventoryPlayer, IPriorityHost te) {
super( new ContainerPriority( inventoryPlayer, te ) );
}
@Override
public void initGui()
{
super.initGui();
int a = AEConfig.instance.priorityByStacksAmounts( 0 );
int b = AEConfig.instance.priorityByStacksAmounts( 1 );
int c = AEConfig.instance.priorityByStacksAmounts( 2 );
int d = AEConfig.instance.priorityByStacksAmounts( 3 );
buttonList.add( plus1 = new GuiButton( 0, this.guiLeft + 20, this.guiTop + 32, 22, 20, "+" + a ) );
buttonList.add( plus10 = new GuiButton( 0, this.guiLeft + 48, this.guiTop + 32, 28, 20, "+" + b ) );
buttonList.add( plus100 = new GuiButton( 0, this.guiLeft + 82, this.guiTop + 32, 32, 20, "+" + c ) );
buttonList.add( plus1000 = new GuiButton( 0, this.guiLeft + 120, this.guiTop + 32, 38, 20, "+" + d ) );
buttonList.add( minus1 = new GuiButton( 0, this.guiLeft + 20, this.guiTop + 69, 22, 20, "-" + a ) );
buttonList.add( minus10 = new GuiButton( 0, this.guiLeft + 48, this.guiTop + 69, 28, 20, "-" + b ) );
buttonList.add( minus100 = new GuiButton( 0, this.guiLeft + 82, this.guiTop + 69, 32, 20, "-" + c ) );
buttonList.add( minus1000 = new GuiButton( 0, this.guiLeft + 120, this.guiTop + 69, 38, 20, "-" + d ) );
ItemStack myIcon = null;
Object target = ((AEBaseContainer) inventorySlots).getTarget();
if ( target instanceof PartStorageBus )
{
myIcon = AEApi.instance().parts().partStorageBus.stack( 1 );
OriginalGui = GuiBridge.GUI_STORAGEBUS;
}
if ( target instanceof PartFormationPlane )
{
myIcon = AEApi.instance().parts().partFormationPlane.stack( 1 );
OriginalGui = GuiBridge.GUI_FPLANE;
}
if ( target instanceof TileDrive )
{
myIcon = AEApi.instance().blocks().blockDrive.stack( 1 );
OriginalGui = GuiBridge.GUI_DRIVE;
}
if ( target instanceof TileChest )
{
myIcon = AEApi.instance().blocks().blockChest.stack( 1 );
OriginalGui = GuiBridge.GUI_CHEST;
}
if ( target instanceof TileInterface )
{
myIcon = AEApi.instance().blocks().blockInterface.stack( 1 );
OriginalGui = GuiBridge.GUI_INTERFACE;
}
if ( target instanceof PartInterface )
{
myIcon = AEApi.instance().parts().partInterface.stack( 1 );
OriginalGui = GuiBridge.GUI_INTERFACE;
}
if ( OriginalGui != null )
buttonList.add( originalGuiBtn = new GuiTabButton( this.guiLeft + 154, this.guiTop, myIcon, myIcon.getDisplayName(), itemRender ) );
priority = new GuiNumberBox( fontRendererObj, this.guiLeft + 62, this.guiTop + 57, 59, fontRendererObj.FONT_HEIGHT, Long.class );
priority.setEnableBackgroundDrawing( false );
priority.setMaxStringLength( 16 );
priority.setTextColor( 0xFFFFFF );
priority.setVisible( true );
priority.setFocused( true );
((ContainerPriority) inventorySlots).setTextField( priority );
}
@Override
protected void actionPerformed(GuiButton btn)
{
super.actionPerformed( btn );
if ( btn == originalGuiBtn )
{
try
{
NetworkHandler.instance.sendToServer( new PacketSwitchGuis( OriginalGui ) );
}
catch (IOException e)
{
AELog.error( e );
}
}
boolean isPlus = btn == plus1 || btn == plus10 || btn == plus100 || btn == plus1000;
boolean isMinus = btn == minus1 || btn == minus10 || btn == minus100 || btn == minus1000;
if ( isPlus || isMinus )
addQty( getQty( btn ) );
}
private void addQty(int i)
{
try
{
String Out = priority.getText();
boolean Fixed = false;
while (Out.startsWith( "0" ) && Out.length() > 1)
{
Out = Out.substring( 1 );
Fixed = true;
}
if ( Fixed )
priority.setText( Out );
if ( Out.length() == 0 )
Out = "0";
long result = Long.parseLong( Out );
result += i;
priority.setText( Out = Long.toString( result ) );
NetworkHandler.instance.sendToServer( new PacketValueConfig( "PriorityHost.Priority", Out ) );
}
catch(NumberFormatException e )
{
// nope..
priority.setText( "0" );
}
catch (IOException e)
{
AELog.error( e );
}
}
@Override
protected void keyTyped(char character, int key)
{
if ( !this.checkHotbarKeys( key ) )
{
if ( (key == 211 || key == 205 || key == 203 || key == 14 || character == '-' || Character.isDigit( character ))
&& priority.textboxKeyTyped( character, key ) )
{
try
{
String Out = priority.getText();
boolean Fixed = false;
while (Out.startsWith( "0" ) && Out.length() > 1)
{
Out = Out.substring( 1 );
Fixed = true;
}
if ( Fixed )
priority.setText( Out );
if ( Out.length() == 0 )
Out = "0";
NetworkHandler.instance.sendToServer( new PacketValueConfig( "PriorityHost.Priority", Out ) );
}
catch (IOException e)
{
AELog.error( e );
}
}
else
{
super.keyTyped( character, key );
}
}
}
@Override
public void drawBG(int offsetX, int offsetY, int mouseX, int mouseY)
{
bindTexture( "guis/priority.png" );
this.drawTexturedModalRect( offsetX, offsetY, 0, 0, xSize, ySize );
priority.drawTextBox();
}
protected String getBackground()
{
return "guis/priority.png";
}
@Override
public void drawFG(int offsetX, int offsetY, int mouseX, int mouseY)
{
fontRendererObj.drawString( GuiText.Priority.getLocal(), 8, 6, 4210752 );
}
}
@@ -0,0 +1,31 @@
package appeng.client.gui.implementations;
import net.minecraft.entity.player.InventoryPlayer;
import appeng.client.gui.AEBaseGui;
import appeng.container.implementations.ContainerQNB;
import appeng.core.localization.GuiText;
import appeng.tile.qnb.TileQuantumBridge;
public class GuiQNB extends AEBaseGui
{
public GuiQNB(InventoryPlayer inventoryPlayer, TileQuantumBridge te) {
super( new ContainerQNB( inventoryPlayer, te ) );
this.ySize = 166;
}
@Override
public void drawBG(int offsetX, int offsetY, int mouseX, int mouseY)
{
bindTexture( "guis/chest.png" );
this.drawTexturedModalRect( offsetX, offsetY, 0, 0, xSize, ySize );
}
@Override
public void drawFG(int offsetX, int offsetY, int mouseX, int mouseY)
{
fontRendererObj.drawString( getGuiDisplayName( GuiText.QuantumLinkChamber.getLocal() ), 8, 6, 4210752 );
fontRendererObj.drawString( GuiText.inventory.getLocal(), 8, ySize - 96 + 3, 4210752 );
}
}
@@ -0,0 +1,75 @@
package appeng.client.gui.implementations;
import java.io.IOException;
import net.minecraft.client.gui.GuiTextField;
import net.minecraft.entity.player.InventoryPlayer;
import appeng.client.gui.AEBaseGui;
import appeng.container.implementations.ContainerQuartzKnife;
import appeng.core.AELog;
import appeng.core.localization.GuiText;
import appeng.core.sync.network.NetworkHandler;
import appeng.core.sync.packets.PacketValueConfig;
import appeng.items.contents.QuartzKnifeObj;
public class GuiQuartzKnife extends AEBaseGui
{
GuiTextField name;
public GuiQuartzKnife(InventoryPlayer inventoryPlayer, QuartzKnifeObj te) {
super( new ContainerQuartzKnife( inventoryPlayer, te ) );
this.ySize = 184;
}
@Override
public void initGui()
{
super.initGui();
name = new GuiTextField( fontRendererObj, this.guiLeft + 24, this.guiTop + 32, 79, fontRendererObj.FONT_HEIGHT );
name.setEnableBackgroundDrawing( false );
name.setMaxStringLength( 32 );
name.setTextColor( 0xFFFFFF );
name.setVisible( true );
name.setFocused( true );
}
@Override
public void drawBG(int offsetX, int offsetY, int mouseX, int mouseY)
{
bindTexture( "guis/quartzknife.png" );
this.drawTexturedModalRect( offsetX, offsetY, 0, 0, xSize, ySize );
name.drawTextBox();
}
@Override
protected void keyTyped(char character, int key)
{
if ( name.textboxKeyTyped( character, key ) )
{
try
{
String Out = name.getText();
((ContainerQuartzKnife) inventorySlots).setName( Out );
NetworkHandler.instance.sendToServer( new PacketValueConfig( "QuartzKnife.Name", Out ) );
}
catch (IOException e)
{
AELog.error( e );
}
}
else
{
super.keyTyped( character, key );
}
}
@Override
public void drawFG(int offsetX, int offsetY, int mouseX, int mouseY)
{
fontRendererObj.drawString( getGuiDisplayName( GuiText.QuartzCuttingKnife.getLocal() ), 8, 6, 4210752 );
fontRendererObj.drawString( GuiText.inventory.getLocal(), 8, ySize - 96 + 3, 4210752 );
}
}
@@ -0,0 +1,110 @@
package appeng.client.gui.implementations;
import java.io.IOException;
import net.minecraft.entity.player.InventoryPlayer;
import appeng.api.config.SecurityPermissions;
import appeng.api.config.SortOrder;
import appeng.api.storage.ITerminalHost;
import appeng.client.gui.widgets.GuiToggleButton;
import appeng.container.implementations.ContainerSecurity;
import appeng.core.AELog;
import appeng.core.localization.GuiText;
import appeng.core.sync.network.NetworkHandler;
import appeng.core.sync.packets.PacketValueConfig;
public class GuiSecurity extends GuiMEMonitorable
{
public GuiSecurity(InventoryPlayer inventoryPlayer, ITerminalHost te) {
super( inventoryPlayer, te, new ContainerSecurity( inventoryPlayer, te ) );
customSortOrder = false;
reservedSpace = 33;
// increase size so that the slot is over the gui.
xSize += 56;
standardSize = xSize;
}
GuiToggleButton inject, extract, craft, build, security;
@Override
public void initGui()
{
super.initGui();
int top = this.guiTop + this.ySize - 116;
buttonList.add( inject = new GuiToggleButton( this.guiLeft + 56 + 18 * 0, top, 11 * 16 + 0, 12 * 16 + 0, SecurityPermissions.INJECT
.getUnlocalizedName(), SecurityPermissions.INJECT.getUnlocalizedTip() ) );
buttonList.add( extract = new GuiToggleButton( this.guiLeft + 56 + 18 * 1, top, 11 * 16 + 1, 12 * 16 + 1, SecurityPermissions.EXTRACT
.getUnlocalizedName(), SecurityPermissions.EXTRACT.getUnlocalizedTip() ) );
buttonList.add( craft = new GuiToggleButton( this.guiLeft + 56 + 18 * 2, top, 11 * 16 + 2, 12 * 16 + 2, SecurityPermissions.CRAFT.getUnlocalizedName(),
SecurityPermissions.CRAFT.getUnlocalizedTip() ) );
buttonList.add( build = new GuiToggleButton( this.guiLeft + 56 + 18 * 3, top, 11 * 16 + 3, 12 * 16 + 3, SecurityPermissions.BUILD.getUnlocalizedName(),
SecurityPermissions.BUILD.getUnlocalizedTip() ) );
buttonList.add( security = new GuiToggleButton( this.guiLeft + 56 + 18 * 4, top, 11 * 16 + 4, 12 * 16 + 4, SecurityPermissions.SECURITY
.getUnlocalizedName(), SecurityPermissions.SECURITY.getUnlocalizedTip() ) );
}
protected void actionPerformed(net.minecraft.client.gui.GuiButton btn)
{
super.actionPerformed( btn );
SecurityPermissions toggleSetting = null;
if ( btn == inject )
toggleSetting = SecurityPermissions.INJECT;
if ( btn == extract )
toggleSetting = SecurityPermissions.EXTRACT;
if ( btn == craft )
toggleSetting = SecurityPermissions.CRAFT;
if ( btn == build )
toggleSetting = SecurityPermissions.BUILD;
if ( btn == security )
toggleSetting = SecurityPermissions.SECURITY;
if ( toggleSetting != null )
{
try
{
NetworkHandler.instance.sendToServer( new PacketValueConfig( "TileSecurity.ToggleOption", toggleSetting.name() ) );
}
catch (IOException e)
{
AELog.error( e );
}
}
};
protected String getBackground()
{
ContainerSecurity cs = (ContainerSecurity) inventorySlots;
inject.setState( (cs.security & (1 << SecurityPermissions.INJECT.ordinal())) > 0 );
extract.setState( (cs.security & (1 << SecurityPermissions.EXTRACT.ordinal())) > 0 );
craft.setState( (cs.security & (1 << SecurityPermissions.CRAFT.ordinal())) > 0 );
build.setState( (cs.security & (1 << SecurityPermissions.BUILD.ordinal())) > 0 );
security.setState( (cs.security & (1 << SecurityPermissions.SECURITY.ordinal())) > 0 );
return "guis/security.png";
}
@Override
public void drawFG(int offsetX, int offsetY, int mouseX, int mouseY)
{
super.drawFG( offsetX, offsetY, mouseX, mouseY );
fontRendererObj.drawString( GuiText.SecurityCardEditor.getLocal(), 8, ySize - 96 + 1 - reservedSpace, 4210752 );
}
@Override
public Enum getSortBy()
{
return SortOrder.NAME;
}
}
@@ -0,0 +1,39 @@
package appeng.client.gui.implementations;
import net.minecraft.entity.player.InventoryPlayer;
import appeng.client.gui.AEBaseGui;
import appeng.container.implementations.ContainerSkyChest;
import appeng.core.AppEng;
import appeng.core.localization.GuiText;
import appeng.integration.IntegrationType;
import appeng.tile.storage.TileSkyChest;
public class GuiSkyChest extends AEBaseGui
{
public GuiSkyChest(InventoryPlayer inventoryPlayer, TileSkyChest te) {
super( new ContainerSkyChest( inventoryPlayer, te ) );
this.ySize = 195;
}
@Override
public void drawBG(int offsetX, int offsetY, int mouseX, int mouseY)
{
bindTexture( "guis/skychest.png" );
this.drawTexturedModalRect( offsetX, offsetY, 0, 0, xSize, ySize );
}
@Override
public void drawFG(int offsetX, int offsetY, int mouseX, int mouseY)
{
fontRendererObj.drawString( getGuiDisplayName( GuiText.SkyChest.getLocal() ), 8, 8, 4210752 );
fontRendererObj.drawString( GuiText.inventory.getLocal(), 8, ySize - 96 + 2, 4210752 );
}
@Override
protected boolean enableSpaceClicking()
{
return !AppEng.instance.isIntegrationEnabled( IntegrationType.InvTweaks );
}
}
@@ -0,0 +1,71 @@
package appeng.client.gui.implementations;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.entity.player.InventoryPlayer;
import org.lwjgl.input.Mouse;
import appeng.api.config.Settings;
import appeng.client.gui.AEBaseGui;
import appeng.client.gui.widgets.GuiImgButton;
import appeng.container.implementations.ContainerSpatialIOPort;
import appeng.core.AEConfig;
import appeng.core.localization.GuiText;
import appeng.tile.spatial.TileSpatialIOPort;
import appeng.util.Platform;
public class GuiSpatialIOPort extends AEBaseGui
{
ContainerSpatialIOPort csiop;
GuiImgButton units;
public GuiSpatialIOPort(InventoryPlayer inventoryPlayer, TileSpatialIOPort te) {
super( new ContainerSpatialIOPort( inventoryPlayer, te ) );
this.ySize = 199;
csiop = (ContainerSpatialIOPort) inventorySlots;
}
@Override
protected void actionPerformed(GuiButton btn)
{
super.actionPerformed( btn );
boolean backwards = Mouse.isButtonDown( 1 );
if ( btn == units )
{
AEConfig.instance.nextPowerUnit( backwards );
units.set( AEConfig.instance.selectedPowerUnit() );
}
}
@Override
public void initGui()
{
super.initGui();
units = new GuiImgButton( this.guiLeft - 18, guiTop + 8, Settings.POWER_UNITS, AEConfig.instance.selectedPowerUnit() );
buttonList.add( units );
}
@Override
public void drawBG(int offsetX, int offsetY, int mouseX, int mouseY)
{
bindTexture( "guis/spatialio.png" );
this.drawTexturedModalRect( offsetX, offsetY, 0, 0, xSize, ySize );
}
@Override
public void drawFG(int offsetX, int offsetY, int mouseX, int mouseY)
{
fontRendererObj.drawString( GuiText.StoredPower.getLocal() + ": " + Platform.formatPowerLong( csiop.currentPower, false ), 13, 21, 4210752 );
fontRendererObj.drawString( GuiText.MaxPower.getLocal() + ": " + Platform.formatPowerLong( csiop.maxPower, false ), 13, 31, 4210752 );
fontRendererObj.drawString( GuiText.RequiredPower.getLocal() + ": " + Platform.formatPowerLong( csiop.reqPower, false ), 13, 78, 4210752 );
fontRendererObj.drawString( GuiText.Efficiency.getLocal() + ": " + (((float) csiop.eff) / 100) + "%", 13, 88, 4210752 );
fontRendererObj.drawString( getGuiDisplayName( GuiText.SpatialIOPort.getLocal() ), 8, 6, 4210752 );
fontRendererObj.drawString( GuiText.inventory.getLocal(), 8, ySize - 96, 4210752 );
}
}
@@ -0,0 +1,120 @@
package appeng.client.gui.implementations;
import java.io.IOException;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.entity.player.InventoryPlayer;
import org.lwjgl.input.Mouse;
import appeng.api.config.AccessRestriction;
import appeng.api.config.ActionItems;
import appeng.api.config.FuzzyMode;
import appeng.api.config.Settings;
import appeng.api.config.StorageFilter;
import appeng.client.gui.widgets.GuiImgButton;
import appeng.client.gui.widgets.GuiTabButton;
import appeng.container.implementations.ContainerStorageBus;
import appeng.core.AELog;
import appeng.core.localization.GuiText;
import appeng.core.sync.GuiBridge;
import appeng.core.sync.network.NetworkHandler;
import appeng.core.sync.packets.PacketConfigButton;
import appeng.core.sync.packets.PacketSwitchGuis;
import appeng.core.sync.packets.PacketValueConfig;
import appeng.parts.misc.PartStorageBus;
public class GuiStorageBus extends GuiUpgradeable
{
GuiImgButton rwMode;
GuiImgButton storageFilter;
GuiTabButton priority;
GuiImgButton partition;
GuiImgButton clear;
public GuiStorageBus(InventoryPlayer inventoryPlayer, PartStorageBus te) {
super( new ContainerStorageBus( inventoryPlayer, te ) );
this.ySize = 251;
}
@Override
public void drawBG(int offsetX, int offsetY, int mouseX, int mouseY)
{
super.drawBG( offsetX, offsetY, mouseX, mouseY );
}
@Override
public void drawFG(int offsetX, int offsetY, int mouseX, int mouseY)
{
fontRendererObj.drawString( getGuiDisplayName( GuiText.StorageBus.getLocal() ), 8, 6, 4210752 );
fontRendererObj.drawString( GuiText.inventory.getLocal(), 8, ySize - 96 + 3, 4210752 );
if ( fuzzyMode != null )
fuzzyMode.set( cvb.fzMode );
if ( storageFilter != null )
storageFilter.set( ((ContainerStorageBus) cvb).storageFilter );
if ( rwMode != null )
rwMode.set( ((ContainerStorageBus) cvb).rwMode );
}
@Override
protected void addButtons()
{
clear = new GuiImgButton( this.guiLeft - 18, guiTop + 8, Settings.ACTIONS, ActionItems.CLOSE );
partition = new GuiImgButton( this.guiLeft - 18, guiTop + 28, Settings.ACTIONS, ActionItems.WRENCH );
rwMode = new GuiImgButton( this.guiLeft - 18, guiTop + 48, Settings.ACCESS, AccessRestriction.READ_WRITE );
storageFilter = new GuiImgButton( this.guiLeft - 18, guiTop + 68, Settings.STORAGE_FILTER, StorageFilter.EXTRACTABLE_ONLY );
fuzzyMode = new GuiImgButton( this.guiLeft - 18, guiTop + 88, Settings.FUZZY_MODE, FuzzyMode.IGNORE_ALL );
buttonList.add( priority = new GuiTabButton( this.guiLeft + 154, this.guiTop, 2 + 4 * 16, GuiText.Priority.getLocal(), itemRender ) );
buttonList.add( storageFilter );
buttonList.add( fuzzyMode );
buttonList.add( rwMode );
buttonList.add( partition );
buttonList.add( clear );
}
@Override
protected void actionPerformed(GuiButton btn)
{
super.actionPerformed( btn );
boolean backwards = Mouse.isButtonDown( 1 );
try
{
if ( btn == partition )
NetworkHandler.instance.sendToServer( new PacketValueConfig( "StorageBus.Action", "Partition" ) );
else if ( btn == clear )
NetworkHandler.instance.sendToServer( new PacketValueConfig( "StorageBus.Action", "Clear" ) );
else if ( btn == priority )
NetworkHandler.instance.sendToServer( new PacketSwitchGuis( GuiBridge.GUI_PRIORITY ) );
else if ( btn == fuzzyMode )
NetworkHandler.instance.sendToServer( new PacketConfigButton( fuzzyMode.getSetting(), backwards ) );
else if ( btn == rwMode )
NetworkHandler.instance.sendToServer( new PacketConfigButton( rwMode.getSetting(), backwards ) );
else if ( btn == storageFilter )
NetworkHandler.instance.sendToServer( new PacketConfigButton( storageFilter.getSetting(), backwards ) );
}
catch (IOException e)
{
AELog.error( e );
}
}
protected String getBackground()
{
return "guis/storagebus.png";
}
}
@@ -0,0 +1,150 @@
package appeng.client.gui.implementations;
import java.io.IOException;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.entity.player.InventoryPlayer;
import org.lwjgl.input.Mouse;
import appeng.api.config.FuzzyMode;
import appeng.api.config.RedstoneMode;
import appeng.api.config.Settings;
import appeng.api.config.Upgrades;
import appeng.api.config.YesNo;
import appeng.api.implementations.IUpgradeableHost;
import appeng.client.gui.AEBaseGui;
import appeng.client.gui.widgets.GuiImgButton;
import appeng.container.implementations.ContainerUpgradeable;
import appeng.core.AELog;
import appeng.core.localization.GuiText;
import appeng.core.sync.network.NetworkHandler;
import appeng.core.sync.packets.PacketConfigButton;
import appeng.parts.automation.PartImportBus;
public class GuiUpgradeable extends AEBaseGui
{
ContainerUpgradeable cvb;
IUpgradeableHost bc;
GuiImgButton redstoneMode;
GuiImgButton fuzzyMode;
GuiImgButton craftMode;
public GuiUpgradeable(InventoryPlayer inventoryPlayer, IUpgradeableHost te) {
this( new ContainerUpgradeable( inventoryPlayer, te ) );
}
public GuiUpgradeable(ContainerUpgradeable te) {
super( te );
cvb = (ContainerUpgradeable) te;
bc = (IUpgradeableHost) te.getTarget();
this.xSize = hasToolbox() ? 246 : 211;
this.ySize = 184;
}
@Override
public void initGui()
{
super.initGui();
addButtons();
}
protected void addButtons()
{
redstoneMode = new GuiImgButton( this.guiLeft - 18, guiTop + 8, Settings.REDSTONE_CONTROLLED, RedstoneMode.IGNORE );
fuzzyMode = new GuiImgButton( this.guiLeft - 18, guiTop + 28, Settings.FUZZY_MODE, FuzzyMode.IGNORE_ALL );
craftMode = new GuiImgButton( this.guiLeft - 18, guiTop + 48, Settings.CRAFT_ONLY, YesNo.NO );
buttonList.add( craftMode );
buttonList.add( redstoneMode );
buttonList.add( fuzzyMode );
}
@Override
protected void actionPerformed(GuiButton btn)
{
super.actionPerformed( btn );
boolean backwards = Mouse.isButtonDown( 1 );
try
{
if ( btn == redstoneMode )
NetworkHandler.instance.sendToServer( new PacketConfigButton( redstoneMode.getSetting(), backwards ) );
if ( btn == craftMode )
NetworkHandler.instance.sendToServer( new PacketConfigButton( craftMode.getSetting(), backwards ) );
if ( btn == fuzzyMode )
NetworkHandler.instance.sendToServer( new PacketConfigButton( fuzzyMode.getSetting(), backwards ) );
}
catch (IOException e)
{
AELog.error( e );
}
}
protected boolean hasToolbox()
{
return ((ContainerUpgradeable) inventorySlots).hasToolbox();
}
@Override
public void drawBG(int offsetX, int offsetY, int mouseX, int mouseY)
{
handleButtonVisibility();
bindTexture( getBackground() );
this.drawTexturedModalRect( offsetX, offsetY, 0, 0, 211 - 34, ySize );
if ( drawUpgrades() )
this.drawTexturedModalRect( offsetX + 177, offsetY, 177, 0, 35, 14 + cvb.availableUpgrades() * 18 );
if ( hasToolbox() )
this.drawTexturedModalRect( offsetX + 178, offsetY + ySize - 90, 178, ySize - 90, 68, 68 );
}
protected boolean drawUpgrades()
{
return true;
}
protected String getBackground()
{
return "guis/bus.png";
}
protected void handleButtonVisibility()
{
if ( redstoneMode != null )
redstoneMode.setVisibility( bc.getInstalledUpgrades( Upgrades.REDSTONE ) > 0 );
if ( fuzzyMode != null )
fuzzyMode.setVisibility( bc.getInstalledUpgrades( Upgrades.FUZZY ) > 0 );
if ( craftMode != null )
craftMode.setVisibility( bc.getInstalledUpgrades( Upgrades.CRAFTING ) > 0 );
}
@Override
public void drawFG(int offsetX, int offsetY, int mouseX, int mouseY)
{
fontRendererObj.drawString( getGuiDisplayName( getName().getLocal() ), 8, 6, 4210752 );
fontRendererObj.drawString( GuiText.inventory.getLocal(), 8, ySize - 96 + 3, 4210752 );
if ( redstoneMode != null )
redstoneMode.set( cvb.rsMode );
if ( fuzzyMode != null )
fuzzyMode.set( cvb.fzMode );
if ( craftMode != null )
craftMode.set( cvb.cMode );
}
protected GuiText getName()
{
return bc instanceof PartImportBus ? GuiText.ImportBus : GuiText.ExportBus;
}
}
@@ -0,0 +1,66 @@
package appeng.client.gui.implementations;
import net.minecraft.entity.player.InventoryPlayer;
import org.lwjgl.opengl.GL11;
import appeng.client.gui.AEBaseGui;
import appeng.client.gui.widgets.GuiProgressBar;
import appeng.client.gui.widgets.GuiProgressBar.Direction;
import appeng.container.implementations.ContainerVibrationChamber;
import appeng.core.localization.GuiText;
import appeng.tile.misc.TileVibrationChamber;
public class GuiVibrationChamber extends AEBaseGui
{
ContainerVibrationChamber cvc;
GuiProgressBar pb;
public GuiVibrationChamber(InventoryPlayer inventoryPlayer, TileVibrationChamber te) {
super( new ContainerVibrationChamber( inventoryPlayer, te ) );
cvc = (ContainerVibrationChamber) inventorySlots;
this.ySize = 166;
}
@Override
public void initGui()
{
super.initGui();
pb = new GuiProgressBar( "guis/vibchamber.png", 99, 36, 176, 14, 6, 18, Direction.VERTICAL );
this.buttonList.add( pb );
}
@Override
public void drawBG(int offsetX, int offsetY, int mouseX, int mouseY)
{
bindTexture( "guis/vibchamber.png" );
pb.xPosition = 99 + guiLeft;
pb.yPosition = 36 + guiTop;
this.drawTexturedModalRect( offsetX, offsetY, 0, 0, xSize, ySize );
}
@Override
public void drawFG(int offsetX, int offsetY, int mouseX, int mouseY)
{
fontRendererObj.drawString( getGuiDisplayName( GuiText.VibrationChamber.getLocal() ), 8, 6, 4210752 );
fontRendererObj.drawString( GuiText.inventory.getLocal(), 8, ySize - 96 + 3, 4210752 );
int k = 25;
int l = -15;
pb.max = 200;
pb.current = cvc.burnProgress > 0 ? cvc.burnSpeed : 0;
pb.FullMsg = (cvc.aePerTick * pb.current / 100) + " ae/t";
if ( cvc.burnProgress > 0 )
{
int i1 = cvc.burnProgress;
bindTexture( "guis/vibchamber.png" );
GL11.glColor3f( 1, 1, 1 );
this.drawTexturedModalRect( k + 56, l + 36 + 12 - i1, 176, 12 - i1, 14, i1 + 2 );
}
}
}
@@ -0,0 +1,77 @@
package appeng.client.gui.implementations;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.entity.player.InventoryPlayer;
import org.lwjgl.input.Mouse;
import appeng.api.config.Settings;
import appeng.client.gui.AEBaseGui;
import appeng.client.gui.widgets.GuiImgButton;
import appeng.container.implementations.ContainerWireless;
import appeng.core.AEConfig;
import appeng.core.localization.GuiText;
import appeng.tile.networking.TileWireless;
import appeng.util.Platform;
public class GuiWireless extends AEBaseGui
{
GuiImgButton units;
@Override
protected void actionPerformed(GuiButton btn)
{
super.actionPerformed( btn );
boolean backwards = Mouse.isButtonDown( 1 );
if ( btn == units )
{
AEConfig.instance.nextPowerUnit( backwards );
units.set( AEConfig.instance.selectedPowerUnit() );
}
}
@Override
public void initGui()
{
super.initGui();
units = new GuiImgButton( this.guiLeft - 18, guiTop + 8, Settings.POWER_UNITS, AEConfig.instance.selectedPowerUnit() );
buttonList.add( units );
}
public GuiWireless(InventoryPlayer inventoryPlayer, TileWireless te) {
super( new ContainerWireless( inventoryPlayer, te ) );
this.ySize = 166;
}
@Override
public void drawBG(int offsetX, int offsetY, int mouseX, int mouseY)
{
bindTexture( "guis/wireless.png" );
this.drawTexturedModalRect( offsetX, offsetY, 0, 0, xSize, ySize );
}
@Override
public void drawFG(int offsetX, int offsetY, int mouseX, int mouseY)
{
fontRendererObj.drawString( getGuiDisplayName( GuiText.Wireless.getLocal() ), 8, 6, 4210752 );
fontRendererObj.drawString( GuiText.inventory.getLocal(), 8, ySize - 96 + 3, 4210752 );
ContainerWireless cw = (ContainerWireless) inventorySlots;
if ( cw.range > 0 )
{
String msga = GuiText.Range.getLocal() + ": " + ((double) cw.range / 10.0) + " m";
String msgb = GuiText.PowerUsageRate.getLocal() + ": " + Platform.formatPowerLong( cw.drain, true );
int strWidth = Math.max( fontRendererObj.getStringWidth( msga ), fontRendererObj.getStringWidth( msgb ) );
int cOffset = (this.xSize / 2) - (strWidth / 2);
fontRendererObj.drawString( msga, cOffset, 20, 4210752 );
fontRendererObj.drawString( msgb, cOffset, 20 + 12, 4210752 );
}
}
}
@@ -0,0 +1,19 @@
package appeng.client.gui.implementations;
import net.minecraft.entity.player.InventoryPlayer;
import appeng.api.implementations.guiobjects.IPortableCell;
public class GuiWirelessTerm extends GuiMEPortableCell
{
public GuiWirelessTerm(InventoryPlayer inventoryPlayer, IPortableCell te) {
super( inventoryPlayer, te );
maxRows = Integer.MAX_VALUE;
}
@Override
int getMaxRows()
{
return defaultGetMaxRows();
}
}
@@ -0,0 +1,352 @@
package appeng.client.gui.widgets;
import java.util.HashMap;
import java.util.Map;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.util.StatCollector;
import org.lwjgl.opengl.GL11;
import appeng.api.config.AccessRestriction;
import appeng.api.config.ActionItems;
import appeng.api.config.CondenserOutput;
import appeng.api.config.FullnessMode;
import appeng.api.config.FuzzyMode;
import appeng.api.config.LevelType;
import appeng.api.config.OperationMode;
import appeng.api.config.PowerUnits;
import appeng.api.config.RedstoneMode;
import appeng.api.config.RelativeDirection;
import appeng.api.config.SearchBoxMode;
import appeng.api.config.Settings;
import appeng.api.config.SortDir;
import appeng.api.config.SortOrder;
import appeng.api.config.StorageFilter;
import appeng.api.config.TerminalStyle;
import appeng.api.config.ViewItems;
import appeng.api.config.YesNo;
import appeng.client.texture.ExtraBlockTextures;
import appeng.core.localization.ButtonToolTips;
public class GuiImgButton extends GuiButton implements ITooltip
{
class EnumPair
{
Enum setting;
Enum value;
EnumPair(Enum a, Enum b) {
setting = a;
value = b;
}
@Override
public int hashCode()
{
return setting.hashCode() ^ value.hashCode();
}
@Override
public boolean equals(Object obj)
{
EnumPair d = (EnumPair) obj;
return d.setting.equals( setting ) && d.value.equals( value );
}
};
class BtnAppearance
{
public int index;
public String DisplayName;
public String DisplayValue;
};
public boolean halfSize = false;
public String FillVar;
private final Enum buttonSetting;
private Enum currentValue;
static private Map<EnumPair, BtnAppearance> Appearances;
private void registerApp(int IIcon, Settings setting, Enum val, ButtonToolTips title, Object hint)
{
BtnAppearance a = new BtnAppearance();
a.DisplayName = title.getUnlocalized();
a.DisplayValue = (String) (hint instanceof String ? hint : ((ButtonToolTips) hint).getUnlocalized());
a.index = IIcon;
Appearances.put( new EnumPair( setting, val ), a );
}
public void setVisibility(boolean vis)
{
visible = vis;
enabled = vis;
}
public GuiImgButton(int x, int y, Enum idx, Enum val) {
super( 0, 0, 16, "" );
buttonSetting = idx;
currentValue = val;
xPosition = x;
yPosition = y;
width = 16;
height = 16;
if ( Appearances == null )
{
Appearances = new HashMap();
registerApp( 16 * 7 + 0, Settings.CONDENSER_OUTPUT, CondenserOutput.TRASH, ButtonToolTips.CondenserOutput, ButtonToolTips.Trash );
registerApp( 16 * 7 + 1, Settings.CONDENSER_OUTPUT, CondenserOutput.MATTER_BALLS, ButtonToolTips.CondenserOutput, ButtonToolTips.MatterBalls );
registerApp( 16 * 7 + 2, Settings.CONDENSER_OUTPUT, CondenserOutput.SINGULARITY, ButtonToolTips.CondenserOutput, ButtonToolTips.Singularity );
registerApp( 16 * 9 + 1, Settings.ACCESS, AccessRestriction.READ, ButtonToolTips.IOMode, ButtonToolTips.Read );
registerApp( 16 * 9 + 0, Settings.ACCESS, AccessRestriction.WRITE, ButtonToolTips.IOMode, ButtonToolTips.Write );
registerApp( 16 * 9 + 2, Settings.ACCESS, AccessRestriction.READ_WRITE, ButtonToolTips.IOMode, ButtonToolTips.ReadWrite );
registerApp( 16 * 10 + 0, Settings.POWER_UNITS, PowerUnits.AE, ButtonToolTips.PowerUnits, PowerUnits.AE.unlocalizedName );
registerApp( 16 * 10 + 1, Settings.POWER_UNITS, PowerUnits.EU, ButtonToolTips.PowerUnits, PowerUnits.EU.unlocalizedName );
registerApp( 16 * 10 + 2, Settings.POWER_UNITS, PowerUnits.MJ, ButtonToolTips.PowerUnits, PowerUnits.MJ.unlocalizedName );
registerApp( 16 * 10 + 3, Settings.POWER_UNITS, PowerUnits.MK, ButtonToolTips.PowerUnits, PowerUnits.MK.unlocalizedName );
registerApp( 16 * 10 + 4, Settings.POWER_UNITS, PowerUnits.WA, ButtonToolTips.PowerUnits, PowerUnits.WA.unlocalizedName );
registerApp( 16 * 10 + 5, Settings.POWER_UNITS, PowerUnits.RF, ButtonToolTips.PowerUnits, PowerUnits.RF.unlocalizedName );
registerApp( 3, Settings.REDSTONE_CONTROLLED, RedstoneMode.IGNORE, ButtonToolTips.RedstoneMode, ButtonToolTips.AlwaysActive );
registerApp( 0, Settings.REDSTONE_CONTROLLED, RedstoneMode.LOW_SIGNAL, ButtonToolTips.RedstoneMode, ButtonToolTips.ActiveWithoutSignal );
registerApp( 1, Settings.REDSTONE_CONTROLLED, RedstoneMode.HIGH_SIGNAL, ButtonToolTips.RedstoneMode, ButtonToolTips.ActiveWithSignal );
registerApp( 2, Settings.REDSTONE_CONTROLLED, RedstoneMode.SIGNAL_PULSE, ButtonToolTips.RedstoneMode, ButtonToolTips.ActiveOnPulse );
registerApp( 0, Settings.REDSTONE_EMITTER, RedstoneMode.LOW_SIGNAL, ButtonToolTips.RedstoneMode, ButtonToolTips.EmitLevelsBelow );
registerApp( 1, Settings.REDSTONE_EMITTER, RedstoneMode.HIGH_SIGNAL, ButtonToolTips.RedstoneMode, ButtonToolTips.EmitLevelAbove );
registerApp( 51, Settings.OPERATION_MODE, OperationMode.FILL, ButtonToolTips.TransferDirection, ButtonToolTips.TransferToStorageCell );
registerApp( 50, Settings.OPERATION_MODE, OperationMode.EMPTY, ButtonToolTips.TransferDirection, ButtonToolTips.TransferToNetwork );
registerApp( 51, Settings.IO_DIRECTION, RelativeDirection.LEFT, ButtonToolTips.TransferDirection, ButtonToolTips.TransferToStorageCell );
registerApp( 50, Settings.IO_DIRECTION, RelativeDirection.RIGHT, ButtonToolTips.TransferDirection, ButtonToolTips.TransferToNetwork );
registerApp( 48, Settings.SORT_DIRECTION, SortDir.ASCENDING, ButtonToolTips.SortOrder, ButtonToolTips.ToggleSortDirection );
registerApp( 49, Settings.SORT_DIRECTION, SortDir.DESCENDING, ButtonToolTips.SortOrder, ButtonToolTips.ToggleSortDirection );
registerApp( 16 * 2 + 3, Settings.SEARCH_MODE, SearchBoxMode.AUTOSEARCH, ButtonToolTips.SearchMode, ButtonToolTips.SearchMode_Auto );
registerApp( 16 * 2 + 4, Settings.SEARCH_MODE, SearchBoxMode.MANUAL_SEARCH, ButtonToolTips.SearchMode, ButtonToolTips.SearchMode_Standard );
registerApp( 16 * 2 + 5, Settings.SEARCH_MODE, SearchBoxMode.NEI_AUTOSEARCH, ButtonToolTips.SearchMode, ButtonToolTips.SearchMode_NEIAuto );
registerApp( 16 * 2 + 6, Settings.SEARCH_MODE, SearchBoxMode.NEI_MANUAL_SEARCH, ButtonToolTips.SearchMode, ButtonToolTips.SearchMode_NEIStandard );
registerApp( 16 * 5 + 3, Settings.LEVEL_TYPE, LevelType.ENERGY_LEVEL, ButtonToolTips.LevelType, ButtonToolTips.LevelType_Energy );
registerApp( 16 * 4 + 3, Settings.LEVEL_TYPE, LevelType.ITEM_LEVEL, ButtonToolTips.LevelType, ButtonToolTips.LevelType_Item );
registerApp( 16 * 13 + 0, Settings.TERMINAL_STYLE, TerminalStyle.TALL, ButtonToolTips.TerminalStyle, ButtonToolTips.TerminalStyle_Tall );
registerApp( 16 * 13 + 1, Settings.TERMINAL_STYLE, TerminalStyle.SMALL, ButtonToolTips.TerminalStyle, ButtonToolTips.TerminalStyle_Small );
registerApp( 16 * 13 + 2, Settings.TERMINAL_STYLE, TerminalStyle.FULL, ButtonToolTips.TerminalStyle, ButtonToolTips.TerminalStyle_Full );
registerApp( 64, Settings.SORT_BY, SortOrder.NAME, ButtonToolTips.SortBy, ButtonToolTips.ItemName );
registerApp( 65, Settings.SORT_BY, SortOrder.AMOUNT, ButtonToolTips.SortBy, ButtonToolTips.NumberOfItems );
registerApp( 68, Settings.SORT_BY, SortOrder.INVTWEAKS, ButtonToolTips.SortBy, ButtonToolTips.InventoryTweaks );
registerApp( 69, Settings.SORT_BY, SortOrder.MOD, ButtonToolTips.SortBy, ButtonToolTips.Mod );
registerApp( 66, Settings.ACTIONS, ActionItems.WRENCH, ButtonToolTips.PartitionStorage, ButtonToolTips.PartitionStorageHint );
registerApp( 6, Settings.ACTIONS, ActionItems.CLOSE, ButtonToolTips.Clear, ButtonToolTips.ClearSettings );
registerApp( 6, Settings.ACTIONS, ActionItems.STASH, ButtonToolTips.Stash, ButtonToolTips.StashDesc );
registerApp( 8, Settings.ACTIONS, ActionItems.ENCODE, ButtonToolTips.Encode, ButtonToolTips.EncodeDescription );
registerApp( 4 + 3 * 16, Settings.ACTIONS, ActionItems.SUBSTITUTION, ButtonToolTips.Substitutions, ButtonToolTips.SubstitutionsDesc );
registerApp( 16, Settings.VIEW_MODE, ViewItems.STORED, ButtonToolTips.View, ButtonToolTips.StoredItems );
registerApp( 18, Settings.VIEW_MODE, ViewItems.ALL, ButtonToolTips.View, ButtonToolTips.StoredCraftable );
registerApp( 19, Settings.VIEW_MODE, ViewItems.CRAFTABLE, ButtonToolTips.View, ButtonToolTips.Craftable );
registerApp( 16 * 6 + 0, Settings.FUZZY_MODE, FuzzyMode.PERCENT_25, ButtonToolTips.FuzzyMode, ButtonToolTips.FZPercent_25 );
registerApp( 16 * 6 + 1, Settings.FUZZY_MODE, FuzzyMode.PERCENT_50, ButtonToolTips.FuzzyMode, ButtonToolTips.FZPercent_50 );
registerApp( 16 * 6 + 2, Settings.FUZZY_MODE, FuzzyMode.PERCENT_75, ButtonToolTips.FuzzyMode, ButtonToolTips.FZPercent_75 );
registerApp( 16 * 6 + 3, Settings.FUZZY_MODE, FuzzyMode.PERCENT_99, ButtonToolTips.FuzzyMode, ButtonToolTips.FZPercent_99 );
registerApp( 16 * 6 + 4, Settings.FUZZY_MODE, FuzzyMode.IGNORE_ALL, ButtonToolTips.FuzzyMode, ButtonToolTips.FZIgnoreAll );
registerApp( 80, Settings.FULLNESS_MODE, FullnessMode.EMPTY, ButtonToolTips.OperationMode, ButtonToolTips.MoveWhenEmpty );
registerApp( 81, Settings.FULLNESS_MODE, FullnessMode.HALF, ButtonToolTips.OperationMode, ButtonToolTips.MoveWhenWorkIsDone );
registerApp( 82, Settings.FULLNESS_MODE, FullnessMode.FULL, ButtonToolTips.OperationMode, ButtonToolTips.MoveWhenFull );
registerApp( 16 * 1 + 5, Settings.BLOCK, YesNo.YES, ButtonToolTips.InterfaceBlockingMode, ButtonToolTips.Blocking );
registerApp( 16 * 1 + 4, Settings.BLOCK, YesNo.NO, ButtonToolTips.InterfaceBlockingMode, ButtonToolTips.NonBlocking );
registerApp( 16 * 1 + 3, Settings.CRAFT_ONLY, YesNo.YES, ButtonToolTips.Craft, ButtonToolTips.CraftOnly );
registerApp( 16 * 1 + 2, Settings.CRAFT_ONLY, YesNo.NO, ButtonToolTips.Craft, ButtonToolTips.CraftEither );
registerApp( 16 * 11 + 2, Settings.CRAFT_VIA_REDSTONE, YesNo.YES, ButtonToolTips.EmitterMode, ButtonToolTips.CraftViaRedstone );
registerApp( 16 * 11 + 1, Settings.CRAFT_VIA_REDSTONE, YesNo.NO, ButtonToolTips.EmitterMode, ButtonToolTips.EmitWhenCrafting );
registerApp( 16 * 3 + 5, Settings.STORAGE_FILTER, StorageFilter.EXTRACTABLE_ONLY, ButtonToolTips.ReportInaccessibleItems,
ButtonToolTips.ReportInaccessibleItemsNo );
registerApp( 16 * 3 + 6, Settings.STORAGE_FILTER, StorageFilter.NONE, ButtonToolTips.ReportInaccessibleItems,
ButtonToolTips.ReportInaccessibleItemsYes );
}
}
@Override
public boolean isVisible()
{
return visible;
}
@Override
public void drawButton(Minecraft par1Minecraft, int par2, int par3)
{
if ( this.visible )
{
int iconIndex = getIconIndex();
if ( halfSize )
{
width = 8;
height = 8;
GL11.glPushMatrix();
GL11.glTranslatef( this.xPosition, this.yPosition, 0.0F );
GL11.glScalef( 0.5f, 0.5f, 0.5f );
if ( enabled )
GL11.glColor4f( 1.0f, 1.0f, 1.0f, 1.0f );
else
GL11.glColor4f( 0.5f, 0.5f, 0.5f, 1.0f );
par1Minecraft.renderEngine.bindTexture( ExtraBlockTextures.GuiTexture( "guis/states.png" ) );
this.field_146123_n = par2 >= this.xPosition && par3 >= this.yPosition && par2 < this.xPosition + this.width
&& par3 < this.yPosition + this.height;
int uv_y = (int) Math.floor( iconIndex / 16 );
int uv_x = iconIndex - uv_y * 16;
this.drawTexturedModalRect( 0, 0, 256 - 16, 256 - 16, 16, 16 );
this.drawTexturedModalRect( 0, 0, uv_x * 16, uv_y * 16, 16, 16 );
this.mouseDragged( par1Minecraft, par2, par3 );
GL11.glPopMatrix();
}
else
{
if ( enabled )
GL11.glColor4f( 1.0f, 1.0f, 1.0f, 1.0f );
else
GL11.glColor4f( 0.5f, 0.5f, 0.5f, 1.0f );
par1Minecraft.renderEngine.bindTexture( ExtraBlockTextures.GuiTexture( "guis/states.png" ) );
this.field_146123_n = par2 >= this.xPosition && par3 >= this.yPosition && par2 < this.xPosition + this.width
&& par3 < this.yPosition + this.height;
int uv_y = (int) Math.floor( iconIndex / 16 );
int uv_x = iconIndex - uv_y * 16;
this.drawTexturedModalRect( this.xPosition, this.yPosition, 256 - 16, 256 - 16, 16, 16 );
this.drawTexturedModalRect( this.xPosition, this.yPosition, uv_x * 16, uv_y * 16, 16, 16 );
this.mouseDragged( par1Minecraft, par2, par3 );
}
}
GL11.glColor4f( 1.0f, 1.0f, 1.0f, 1.0f );
}
private int getIconIndex()
{
if ( buttonSetting != null && currentValue != null )
{
BtnAppearance app = Appearances.get( new EnumPair( buttonSetting, currentValue ) );
if ( app == null )
return 256 - 1;
return app.index;
}
return 256 - 1;
}
public Settings getSetting()
{
return (Settings) buttonSetting;
}
public Enum getCurrentValue()
{
return currentValue;
}
@Override
public String getMsg()
{
String DisplayName = null;
String DisplayValue = null;
if ( buttonSetting != null && currentValue != null )
{
BtnAppearance ba = Appearances.get( new EnumPair( buttonSetting, currentValue ) );
if ( ba == null )
return "No Such Message";
DisplayName = ba.DisplayName;
DisplayValue = ba.DisplayValue;
}
if ( DisplayName != null )
{
String Name = StatCollector.translateToLocal( DisplayName );
String Value = StatCollector.translateToLocal( DisplayValue );
if ( Name == null || Name.equals( "" ) )
Name = DisplayName;
if ( Value == null || Value.equals( "" ) )
Value = DisplayValue;
if ( FillVar != null )
Value = Value.replaceFirst( "%s", FillVar );
Value = Value.replace( "\\n", "\n" );
StringBuilder sb = new StringBuilder( Value );
int i = sb.lastIndexOf( "\n" );
if ( i <= 0 )
i = 0;
while (i + 30 < sb.length() && (i = sb.lastIndexOf( " ", i + 30 )) != -1)
{
sb.replace( i, i + 1, "\n" );
}
return Name + "\n" + sb.toString();
}
return null;
}
@Override
public int xPos()
{
return xPosition;
}
@Override
public int yPos()
{
return yPosition;
}
@Override
public int getWidth()
{
return halfSize ? 8 : 16;
}
@Override
public int getHeight()
{
return halfSize ? 8 : 16;
}
public void set(Enum e)
{
if ( currentValue != e )
{
currentValue = e;
}
}
}
@@ -0,0 +1,39 @@
package appeng.client.gui.widgets;
import net.minecraft.client.gui.FontRenderer;
import net.minecraft.client.gui.GuiTextField;
public class GuiNumberBox extends GuiTextField
{
final Class type;
public GuiNumberBox(FontRenderer p_i1032_1_, int p_i1032_2_, int p_i1032_3_, int p_i1032_4_, int p_i1032_5_,Class type) {
super( p_i1032_1_, p_i1032_2_, p_i1032_3_, p_i1032_4_, p_i1032_5_ );
this.type = type;
}
@Override
public void writeText(String p_146191_1_)
{
String original = getText();
super.writeText( p_146191_1_ );
try
{
if ( type == int.class || type == Integer.class )
Integer.parseInt( getText() );
else if ( type == long.class || type == Long.class )
Long.parseLong( getText() );
else if ( type == double.class || type == Double.class )
Double.parseDouble( getText() );
}
catch(NumberFormatException e )
{
setText( original );
}
}
}
@@ -0,0 +1,102 @@
package appeng.client.gui.widgets;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.util.ResourceLocation;
import appeng.core.localization.GuiText;
public class GuiProgressBar extends GuiButton implements ITooltip
{
public enum Direction
{
HORIZONTAL, VERTICAL
};
private ResourceLocation texture;
private int fill_u;
private int fill_v;
private Direction layout;
public String FullMsg;
public String TitleName;
public int current;
public int max;
public GuiProgressBar(String string, int posX, int posY, int u, int y, int _width, int _height, Direction dir) {
super( posX, posY, _width, "" );
this.xPosition = posX;
this.yPosition = posY;
texture = new ResourceLocation( "appliedenergistics2", "textures/" + string );
width = _width;
height = _height;
fill_u = u;
fill_v = y;
current = 0;
max = 100;
layout = dir;
}
@Override
public void drawButton(Minecraft par1Minecraft, int par2, int par3)
{
if ( this.visible )
{
par1Minecraft.getTextureManager().bindTexture( texture );
if ( layout == Direction.VERTICAL )
{
int diff = height - (max > 0 ? (height * current) / max : 0);
this.drawTexturedModalRect( this.xPosition, this.yPosition + diff, fill_u, fill_v + diff, width, height - diff );
}
else
{
int diff = width - (max > 0 ? (width * current) / max : 0);
this.drawTexturedModalRect( this.xPosition, this.yPosition, fill_u + diff, fill_v, width - diff, height );
}
this.mouseDragged( par1Minecraft, par2, par3 );
}
}
@Override
public String getMsg()
{
if ( FullMsg != null )
return FullMsg;
return (TitleName != null ? TitleName : "") + "\n" + current + " " + GuiText.Of.getLocal() + " " + max;
}
@Override
public int xPos()
{
return xPosition - 2;
}
@Override
public int yPos()
{
return yPosition - 2;
}
@Override
public int getWidth()
{
return width + 4;
}
@Override
public int getHeight()
{
return height + 4;
}
@Override
public boolean isVisible()
{
return true;
}
}
@@ -0,0 +1,132 @@
package appeng.client.gui.widgets;
import org.lwjgl.opengl.GL11;
import appeng.client.gui.AEBaseGui;
public class GuiScrollbar implements IScrollSource
{
private int displayX = 0;
private int displayY = 0;
private int width = 12;
private int height = 16;
private int pageSize = 1;
private int maxScroll = 0;
private int minScroll = 0;
private int currentScroll = 0;
private void applyRange()
{
currentScroll = Math.max( Math.min( currentScroll, maxScroll ), minScroll );
}
public void draw(AEBaseGui g)
{
g.bindTexture( "minecraft", "gui/container/creative_inventory/tabs.png" );
GL11.glColor4f( 1.0f, 1.0f, 1.0f, 1.0f );
if ( getRange() == 0 )
{
g.drawTexturedModalRect( displayX, displayY, 232 + width, 0, width, 15 );
}
else
{
int offset = (currentScroll - minScroll) * (height - 15) / getRange();
g.drawTexturedModalRect( displayX, offset + displayY, 232, 0, width, 15 );
}
}
public int getRange()
{
return maxScroll - minScroll;
}
public int getLeft()
{
return displayX;
}
public int getTop()
{
return displayY;
}
public int getWidth()
{
return width;
}
public int getHeight()
{
return height;
}
public GuiScrollbar setLeft(int v)
{
displayX = v;
return this;
}
public GuiScrollbar setTop(int v)
{
displayY = v;
return this;
}
public GuiScrollbar setWidth(int v)
{
width = v;
return this;
}
public GuiScrollbar setHeight(int v)
{
height = v;
return this;
}
public void setRange(int min, int max, int pageSize)
{
minScroll = min;
maxScroll = max;
this.pageSize = pageSize;
if ( minScroll > maxScroll )
maxScroll = minScroll;
applyRange();
}
@Override
public int getCurrentScroll()
{
return currentScroll;
}
public void click(AEBaseGui aeBaseGui, int x, int y)
{
if ( getRange() == 0 )
return;
if ( x > displayX && x <= displayX + width )
{
if ( y > displayY && y <= displayY + height )
{
currentScroll = (y - displayY);
currentScroll = minScroll + ((currentScroll * 2 * getRange() / height));
currentScroll = (currentScroll + 1) >> 1;
applyRange();
}
}
}
public void wheel(int delta)
{
delta = Math.max( Math.min( -delta, 1 ), -1 );
currentScroll += delta * pageSize;
applyRange();
}
}
@@ -0,0 +1,135 @@
package appeng.client.gui.widgets;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.FontRenderer;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.renderer.RenderHelper;
import net.minecraft.client.renderer.entity.RenderItem;
import net.minecraft.item.ItemStack;
import org.lwjgl.opengl.GL11;
import org.lwjgl.opengl.GL12;
import appeng.client.texture.ExtraBlockTextures;
public class GuiTabButton extends GuiButton implements ITooltip
{
RenderItem itemRenderer;
int myIcon = -1;
public int hideEdge = 0;
ItemStack myItem;
String Msg;
public void setVisibility(boolean vis)
{
visible = vis;
enabled = vis;
}
public GuiTabButton(int x, int y, int ico, String Msg, RenderItem ir) {
super( 0, 0, 16, "" );
xPosition = x;
yPosition = y;
width = 22;
height = 22;
myIcon = ico;
this.Msg = Msg;
this.itemRenderer = ir;
}
public GuiTabButton(int x, int y, ItemStack ico, String Msg, RenderItem ir) {
super( 0, 0, 16, "" );
xPosition = x;
yPosition = y;
width = 22;
height = 22;
myItem = ico;
this.Msg = Msg;
this.itemRenderer = ir;
}
@Override
public boolean isVisible()
{
return visible;
}
@Override
public void drawButton(Minecraft par1Minecraft, int par2, int par3)
{
if ( this.visible )
{
GL11.glColor4f( 1.0f, 1.0f, 1.0f, 1.0f );
par1Minecraft.renderEngine.bindTexture( ExtraBlockTextures.GuiTexture( "guis/states.png" ) );
this.field_146123_n = par2 >= this.xPosition && par3 >= this.yPosition && par2 < this.xPosition + this.width && par3 < this.yPosition + this.height;
int uv_y = (int) Math.floor( 13 / 16 );
int uv_x = (hideEdge > 0 ? 11 : 13) - uv_y * 16;
int offsetX = hideEdge > 0 ? 1 : 0;
this.drawTexturedModalRect( this.xPosition, this.yPosition, uv_x * 16, uv_y * 16, 25, 22 );
if ( myIcon >= 0 )
{
uv_y = (int) Math.floor( myIcon / 16 );
uv_x = myIcon - uv_y * 16;
this.drawTexturedModalRect( offsetX + this.xPosition + 3, this.yPosition + 3, uv_x * 16, uv_y * 16, 16, 16 );
}
this.mouseDragged( par1Minecraft, par2, par3 );
if ( myItem != null )
{
this.zLevel = 100.0F;
itemRenderer.zLevel = 100.0F;
GL11.glEnable( GL11.GL_LIGHTING );
GL11.glEnable( GL12.GL_RESCALE_NORMAL );
RenderHelper.enableGUIStandardItemLighting();
FontRenderer fontrenderer = par1Minecraft.fontRenderer;
itemRenderer.renderItemAndEffectIntoGUI( fontrenderer, par1Minecraft.renderEngine, myItem, offsetX + this.xPosition + 3, this.yPosition + 3 );
GL11.glDisable( GL11.GL_LIGHTING );
itemRenderer.zLevel = 0.0F;
this.zLevel = 0.0F;
}
}
}
@Override
public String getMsg()
{
return Msg;
}
@Override
public int xPos()
{
return xPosition;
}
@Override
public int yPos()
{
return yPosition;
}
@Override
public int getWidth()
{
return 22;
}
@Override
public int getHeight()
{
return 22;
}
}
@@ -0,0 +1,132 @@
package appeng.client.gui.widgets;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.util.StatCollector;
import org.lwjgl.opengl.GL11;
import appeng.client.texture.ExtraBlockTextures;
public class GuiToggleButton extends GuiButton implements ITooltip
{
int iconIdxOn;
int iconIdxOff;
String Name;
String Hint;
boolean on;
public void setState(boolean isOn)
{
on = isOn;
}
public void setVisibility(boolean vis)
{
visible = vis;
enabled = vis;
}
public GuiToggleButton(int x, int y, int on, int off, String Name, String Hint) {
super( 0, 0, 16, "" );
iconIdxOn = on;
iconIdxOff = off;
this.Name = Name;
this.Hint = Hint;
xPosition = x;
yPosition = y;
width = 16;
height = 16;
}
@Override
public boolean isVisible()
{
return visible;
}
@Override
public void drawButton(Minecraft par1Minecraft, int par2, int par3)
{
if ( this.visible )
{
int iconIndex = getIconIndex();
GL11.glColor4f( 1.0f, 1.0f, 1.0f, 1.0f );
par1Minecraft.renderEngine.bindTexture( ExtraBlockTextures.GuiTexture( "guis/states.png" ) );
this.field_146123_n = par2 >= this.xPosition && par3 >= this.yPosition && par2 < this.xPosition + this.width && par3 < this.yPosition + this.height;
int uv_y = (int) Math.floor( iconIndex / 16 );
int uv_x = iconIndex - uv_y * 16;
this.drawTexturedModalRect( this.xPosition, this.yPosition, 256 - 16, 256 - 16, 16, 16 );
this.drawTexturedModalRect( this.xPosition, this.yPosition, uv_x * 16, uv_y * 16, 16, 16 );
this.mouseDragged( par1Minecraft, par2, par3 );
}
}
private int getIconIndex()
{
return on ? iconIdxOn : iconIdxOff;
}
@Override
public String getMsg()
{
String DisplayName = Name;
String DisplayValue = Hint;
if ( DisplayName != null )
{
String Name = StatCollector.translateToLocal( DisplayName );
String Value = StatCollector.translateToLocal( DisplayValue );
if ( Name == null || Name.equals( "" ) )
Name = DisplayName;
if ( Value == null || Value.equals( "" ) )
Value = DisplayValue;
Value = Value.replace( "\\n", "\n" );
StringBuilder sb = new StringBuilder( Value );
int i = sb.lastIndexOf( "\n" );
if ( i <= 0 )
i = 0;
while (i + 30 < sb.length() && (i = sb.lastIndexOf( " ", i + 30 )) != -1)
{
sb.replace( i, i + 1, "\n" );
}
return Name + "\n" + sb.toString();
}
return null;
}
@Override
public int xPos()
{
return xPosition;
}
@Override
public int yPos()
{
return yPosition;
}
@Override
public int getWidth()
{
return 16;
}
@Override
public int getHeight()
{
return 16;
}
}
@@ -0,0 +1,8 @@
package appeng.client.gui.widgets;
public interface IScrollSource
{
int getCurrentScroll();
}
@@ -0,0 +1,24 @@
package appeng.client.gui.widgets;
import appeng.api.config.SortDir;
import appeng.api.config.ViewItems;
public interface ISortSource
{
/**
* @return Sor
*/
Enum getSortBy();
/**
* @return {@link SortDir}
*/
Enum getSortDir();
/**
* @return {@link ViewItems}
*/
Enum getSortDisplay();
}
@@ -0,0 +1,50 @@
package appeng.client.gui.widgets;
/**
* AEBaseGui controlled Tooltip Interface.
*
*/
public interface ITooltip
{
/**
* returns the tooltip message.
*
* @return
*/
String getMsg();
/**
* x Location for the object that triggers the tooltip.
*
* @return xPosition
*/
int xPos();
/**
* y Location for the object that triggers the tooltip.
*
* @return yPosition
*/
int yPos();
/**
* Width of the object that triggers the tooltip.
*
* @return width
*/
int getWidth();
/**
* Height for the object that triggers the tooltip.
*
* @return height
*/
int getHeight();
/**
* @return true if button being drawn
*/
boolean isVisible();
}
@@ -0,0 +1,28 @@
package appeng.client.gui.widgets;
import net.minecraft.client.gui.FontRenderer;
import net.minecraft.client.gui.GuiTextField;
public class MEGuiTextField extends GuiTextField
{
int posX;
int posY;
int myWidth;
int myHeight;
public MEGuiTextField(FontRenderer par1FontRenderer, int xPos, int yPos, int width, int height) {
super( par1FontRenderer, xPos, yPos, width, height );
posX = xPos;
posY = yPos;
myWidth = width;
myHeight = height;
}
public boolean isMouseIn(int xCoord, int yCoord)
{
return xCoord >= posX && xCoord < posX + myWidth && yCoord >= posY && yCoord < posY + myHeight;
}
}

Some files were not shown because too many files have changed in this diff Show More