Basic reformat, hit once, hope never again

This commit is contained in:
thatsIch
2015-04-03 08:54:31 +02:00
parent 4ff1631f89
commit d34c988c88
886 changed files with 31400 additions and 30990 deletions
+58 -57
View File
@@ -18,6 +18,7 @@
package appeng.block;
import java.util.List;
import net.minecraft.block.Block;
@@ -42,71 +43,78 @@ 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)
public AEBaseItemBlock( Block id )
{
super( id );
this.blockType = (AEBaseBlock) id;
this.hasSubtypes = this.blockType.hasSubtypes;
if ( Platform.isClient() )
if( Platform.isClient() )
MinecraftForgeClient.registerItemRenderer( this, ItemRenderer.INSTANCE );
}
@Override
public int getMetadata(int dmg)
public int getMetadata( int dmg )
{
if ( this.hasSubtypes )
if( this.hasSubtypes )
return dmg;
return 0;
}
@Override
public String getUnlocalizedName(ItemStack is)
{
return this.blockType.getUnlocalizedName( is );
}
@Override
@SideOnly(Side.CLIENT)
@SuppressWarnings("unchecked")
public final void addInformation(ItemStack itemStack, EntityPlayer player, List toolTip, boolean advancedTooltips)
@SideOnly( Side.CLIENT )
@SuppressWarnings( "unchecked" )
public final void addInformation( ItemStack itemStack, EntityPlayer player, List toolTip, boolean advancedTooltips )
{
this.addCheckedInformation( itemStack, player, toolTip, advancedTooltips );
}
@SideOnly(Side.CLIENT)
public void addCheckedInformation(ItemStack itemStack, EntityPlayer player, List<String> toolTip, boolean advancedToolTips)
@SideOnly( Side.CLIENT )
public void addCheckedInformation( ItemStack itemStack, EntityPlayer player, List<String> toolTip, boolean advancedToolTips )
{
this.blockType.addInformation( itemStack, player, toolTip, advancedToolTips );
}
@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)
public boolean isBookEnchantable( ItemStack itemstack1, ItemStack itemstack2 )
{
return false;
}
@Override
public String getUnlocalizedName( ItemStack is )
{
return this.blockType.getUnlocalizedName( is );
}
@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 ( this.blockType.hasBlockTileEntity() )
if( this.blockType.hasBlockTileEntity() )
{
if ( this.blockType instanceof BlockLightDetector )
if( this.blockType instanceof BlockLightDetector )
{
up = ForgeDirection.getOrientation( side );
if ( up == ForgeDirection.UP || up == ForgeDirection.DOWN )
if( up == ForgeDirection.UP || up == ForgeDirection.DOWN )
forward = ForgeDirection.SOUTH;
else
forward = ForgeDirection.UP;
}
else if ( this.blockType instanceof BlockWireless || this.blockType instanceof BlockSkyCompass )
else if( this.blockType instanceof BlockWireless || this.blockType instanceof BlockSkyCompass )
{
forward = ForgeDirection.getOrientation( side );
if ( forward == ForgeDirection.UP || forward == ForgeDirection.DOWN )
if( forward == ForgeDirection.UP || forward == ForgeDirection.DOWN )
up = ForgeDirection.SOUTH;
else
up = ForgeDirection.UP;
@@ -115,31 +123,31 @@ public class AEBaseItemBlock extends ItemBlock
{
up = ForgeDirection.UP;
byte rotation = (byte) (MathHelper.floor_double( (player.rotationYaw * 4F) / 360F + 2.5D ) & 3);
byte rotation = (byte) ( MathHelper.floor_double( ( player.rotationYaw * 4F ) / 360F + 2.5D ) & 3 );
switch (rotation)
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;
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 )
if( player.rotationPitch > 65 )
{
up = forward.getOpposite();
forward = ForgeDirection.UP;
}
else if ( player.rotationPitch < -65 )
else if( player.rotationPitch < -65 )
{
up = forward.getOpposite();
forward = ForgeDirection.DOWN;
@@ -147,45 +155,45 @@ public class AEBaseItemBlock extends ItemBlock
}
}
if ( this.blockType instanceof IOrientableBlock )
if( this.blockType instanceof IOrientableBlock )
{
ori = ((IOrientableBlock) this.blockType).getOrientable( w, x, y, z );
ori = ( (IOrientableBlock) this.blockType ).getOrientable( w, x, y, z );
up = ForgeDirection.getOrientation( side );
forward = ForgeDirection.SOUTH;
if ( up.offsetY == 0 )
if( up.offsetY == 0 )
forward = ForgeDirection.UP;
ori.setOrientation( forward, up );
}
if ( !this.blockType.isValidOrientation( w, x, y, z, forward, up ) )
if( !this.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( super.placeBlockAt( stack, player, w, x, y, z, side, hitX, hitY, hitZ, metadata ) )
{
if ( this.blockType.hasBlockTileEntity() && !(this.blockType instanceof BlockLightDetector) )
if( this.blockType.hasBlockTileEntity() && !( this.blockType instanceof BlockLightDetector ) )
{
AEBaseTile tile = this.blockType.getTileEntity( w, x, y, z );
ori = tile;
if ( tile == null )
if( tile == null )
return true;
if ( ori.canBeRotated() && !this.blockType.hasCustomRotation() )
if( ori.canBeRotated() && !this.blockType.hasCustomRotation() )
{
if ( ori.getForward() == null || ori.getUp() == null || // null
if( ori.getForward() == null || ori.getUp() == null || // null
tile.getForward() == ForgeDirection.UNKNOWN || ori.getUp() == ForgeDirection.UNKNOWN )
ori.setOrientation( forward, up );
}
if ( tile instanceof IGridProxyable )
if( tile instanceof IGridProxyable )
{
((IGridProxyable) tile).getProxy().setOwner( player );
( (IGridProxyable) tile ).getProxy().setOwner( player );
}
tile.onPlacement( stack, player, side );
}
else if ( this.blockType instanceof IOrientableBlock )
else if( this.blockType instanceof IOrientableBlock )
{
ori.setOrientation( forward, up );
}
@@ -194,11 +202,4 @@ public class AEBaseItemBlock extends ItemBlock
}
return false;
}
@Override
public boolean isBookEnchantable(ItemStack itemstack1, ItemStack itemstack2)
{
return false;
}
}
@@ -38,40 +38,40 @@ import appeng.core.Api;
import appeng.core.localization.GuiText;
import appeng.util.Platform;
public class AEBaseItemBlockChargeable extends AEBaseItemBlock implements IAEItemPowerStorage
{
public AEBaseItemBlockChargeable(Block id) {
public AEBaseItemBlockChargeable( Block id )
{
super( id );
}
@Override
@SideOnly(Side.CLIENT)
public void addCheckedInformation(ItemStack itemStack, EntityPlayer player, List<String> toolTip, boolean advancedTooltips)
@SideOnly( Side.CLIENT )
public void addCheckedInformation( ItemStack itemStack, EntityPlayer player, List<String> toolTip, boolean advancedTooltips )
{
NBTTagCompound tag = itemStack.getTagCompound();
double internalCurrentPower = 0;
double internalMaxPower = this.getMaxEnergyCapacity();
if ( tag != null )
if( tag != null )
{
internalCurrentPower = tag.getDouble( "internalCurrentPower" );
}
double percent = internalCurrentPower / internalMaxPower;
toolTip.add( GuiText.StoredEnergy.getLocal() + ':' + MessageFormat.format( " {0,number,#} ", internalCurrentPower )
+ Platform.gui_localize( PowerUnits.AE.unlocalizedName ) + " - " + MessageFormat.format( " {0,number,#.##%} ", percent ) );
toolTip.add( GuiText.StoredEnergy.getLocal() + ':' + MessageFormat.format( " {0,number,#} ", internalCurrentPower ) + Platform.gui_localize( PowerUnits.AE.unlocalizedName ) + " - " + MessageFormat.format( " {0,number,#.##%} ", percent ) );
}
private double getMaxEnergyCapacity()
{
Block blockID = Block.getBlockFromItem( this );
final IBlockDefinition energyCell = Api.INSTANCE.definitions().blocks().energyCell();
for ( Block block : energyCell.maybeBlock().asSet() )
for( Block block : energyCell.maybeBlock().asSet() )
{
if ( blockID == block )
if( blockID == block )
{
return 200000;
}
@@ -84,25 +84,13 @@ public class AEBaseItemBlockChargeable extends AEBaseItemBlock implements IAEIte
return 0;
}
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)
public double injectAEPower( ItemStack is, double amt )
{
double internalCurrentPower = this.getInternal( is );
double internalMaxPower = this.getMaxEnergyCapacity();
internalCurrentPower += amt;
if ( internalCurrentPower > internalMaxPower )
if( internalCurrentPower > internalMaxPower )
{
amt = internalCurrentPower - internalMaxPower;
internalCurrentPower = internalMaxPower;
@@ -114,11 +102,23 @@ public class AEBaseItemBlockChargeable extends AEBaseItemBlock implements IAEIte
return 0;
}
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 extractAEPower(ItemStack is, double amt)
public double extractAEPower( ItemStack is, double amt )
{
double internalCurrentPower = this.getInternal( is );
if ( internalCurrentPower > amt )
if( internalCurrentPower > amt )
{
internalCurrentPower -= amt;
this.setInternal( is, internalCurrentPower );
@@ -131,21 +131,20 @@ public class AEBaseItemBlockChargeable extends AEBaseItemBlock implements IAEIte
}
@Override
public double getAEMaxPower(ItemStack is)
public double getAEMaxPower( ItemStack is )
{
return this.getMaxEnergyCapacity();
}
@Override
public double getAECurrentPower(ItemStack is)
public double getAECurrentPower( ItemStack is )
{
return this.getInternal( is );
}
@Override
public AccessRestriction getPowerFlow(ItemStack is)
public AccessRestriction getPowerFlow( ItemStack is )
{
return AccessRestriction.WRITE;
}
}
@@ -21,11 +21,11 @@ package appeng.block;
import java.util.EnumSet;
import com.google.common.base.Optional;
import net.minecraft.block.Block;
import net.minecraft.block.BlockStairs;
import com.google.common.base.Optional;
import appeng.core.features.AEFeature;
import appeng.core.features.IAEFeature;
import appeng.core.features.IFeatureHandler;
@@ -40,7 +40,7 @@ public abstract class AEBaseStairBlock extends BlockStairs implements IAEFeature
{
super( block, meta );
this.features = new StairBlockFeatureHandler( features, this, Optional.<String> absent() );
this.features = new StairBlockFeatureHandler( features, this, Optional.<String>absent() );
this.setBlockName( block.getUnlocalizedName() );
this.setLightOpacity( 0 );
@@ -48,18 +48,24 @@ public class BlockCraftingMonitor extends BlockCraftingUnit
this.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() )
if( direction != ForgeDirection.SOUTH.ordinal() )
{
for ( Block craftingUnitBlock : AEApi.instance().definitions().blocks().craftingUnit().maybeBlock().asSet() )
for( Block craftingUnitBlock : AEApi.instance().definitions().blocks().craftingUnit().maybeBlock().asSet() )
{
return craftingUnitBlock.getIcon( direction, metadata );
}
}
switch ( metadata )
switch( metadata )
{
default:
case 0:
@@ -69,12 +75,6 @@ public class BlockCraftingMonitor extends BlockCraftingUnit
}
}
@Override
protected Class<? extends BaseBlockRender> getRenderer()
{
return RenderBlockCraftingCPUMonitor.class;
}
@Override
@SideOnly( Side.CLIENT )
public void getCheckedSubBlocks( Item item, CreativeTabs tabs, List<ItemStack> itemStacks )
@@ -18,6 +18,7 @@
package appeng.block.crafting;
import java.util.List;
import net.minecraft.creativetab.CreativeTabs;
@@ -31,6 +32,7 @@ import cpw.mods.fml.relauncher.SideOnly;
import appeng.client.texture.ExtraBlockTextures;
import appeng.tile.crafting.TileCraftingStorageTile;
public class BlockCraftingStorage extends BlockCraftingUnit
{
public BlockCraftingStorage()
@@ -47,54 +49,54 @@ public class BlockCraftingStorage extends BlockCraftingUnit
}
@Override
public String getUnlocalizedName(ItemStack is)
public IIcon getIcon( int direction, int metadata )
{
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 this.getItemUnlocalizedName( is );
}
@Override
public IIcon getIcon(int direction, int metadata)
{
switch (metadata & (~4))
switch( metadata & ( ~4 ) )
{
default:
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:
return super.getIcon( 0, 0 );
case 1:
return ExtraBlockTextures.BlockCraftingStorage4k.getIcon();
case 2:
return ExtraBlockTextures.BlockCraftingStorage16k.getIcon();
case 3:
return ExtraBlockTextures.BlockCraftingStorage64k.getIcon();
case 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();
case 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
@SideOnly(Side.CLIENT)
public void getCheckedSubBlocks(Item item, CreativeTabs tabs, List<ItemStack> itemStacks)
@SideOnly( Side.CLIENT )
public void getCheckedSubBlocks( Item item, CreativeTabs tabs, List<ItemStack> itemStacks )
{
itemStacks.add( new ItemStack( this, 1, 0 ) );
itemStacks.add( new ItemStack( this, 1, 1 ) );
itemStacks.add( new ItemStack( this, 1, 2 ) );
itemStacks.add( new ItemStack( this, 1, 3 ) );
}
@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 this.getItemUnlocalizedName( is );
}
}
@@ -18,6 +18,7 @@
package appeng.block.crafting;
import java.util.EnumSet;
import java.util.List;
@@ -43,18 +44,11 @@ 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 BlockCraftingUnit(Class<? extends BlockCraftingUnit> childClass)
{
super( childClass, Material.iron );
this.hasSubtypes = true;
this.setFeature( EnumSet.of( AEFeature.CraftingCPU ) );
}
public BlockCraftingUnit()
{
this( BlockCraftingUnit.class );
@@ -62,13 +56,44 @@ public class BlockCraftingUnit extends AEBaseBlock
this.setTileEntity( TileCraftingTile.class );
}
public BlockCraftingUnit( Class<? extends BlockCraftingUnit> childClass )
{
super( childClass, Material.iron );
this.hasSubtypes = true;
this.setFeature( EnumSet.of( AEFeature.CraftingCPU ) );
}
@Override
public boolean onActivated(World w, int x, int y, int z, EntityPlayer p, int side, float hitX, float hitY, float hitZ)
protected Class<? extends BaseBlockRender> getRenderer()
{
return RenderBlockCraftingCPU.class;
}
@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 FLAG_FORMED:
return ExtraBlockTextures.BlockCraftingUnitFit.getIcon();
case 1 | FLAG_FORMED:
return ExtraBlockTextures.BlockCraftingAcceleratorFit.getIcon();
}
}
@Override
public boolean onActivated( World w, int x, int y, int z, EntityPlayer p, int side, float hitX, float hitY, float hitZ )
{
TileCraftingTile tg = this.getTileEntity( w, x, y, z );
if ( tg != null && !p.isSneaking() && tg.isFormed() && tg.isActive() )
if( tg != null && !p.isSneaking() && tg.isFormed() && tg.isActive() )
{
if ( Platform.isClient() )
if( Platform.isClient() )
return true;
Platform.openGUI( p, tg, ForgeDirection.getOrientation( side ), GuiBridge.GUI_CRAFTING_CPU );
@@ -79,34 +104,15 @@ public class BlockCraftingUnit extends AEBaseBlock
}
@Override
public int getDamageValue(World w, int x, int y, int z)
@SideOnly( Side.CLIENT )
public void getCheckedSubBlocks( Item item, CreativeTabs tabs, List<ItemStack> itemStacks )
{
int meta = w.getBlockMetadata( x, y, z );
return this.damageDropped( meta );
itemStacks.add( new ItemStack( this, 1, 0 ) );
itemStacks.add( new ItemStack( this, 1, 1 ) );
}
@Override
public int damageDropped(int meta)
{
return meta & 3;
}
@Override
public String getUnlocalizedName(ItemStack is)
{
if ( is.getItemDamage() == 1 )
return "tile.appliedenergistics2.BlockCraftingAccelerator";
return this.getItemUnlocalizedName( is );
}
protected String getItemUnlocalizedName(ItemStack is)
{
return super.getUnlocalizedName( is );
}
@Override
public void setRenderStateByMeta(int itemDamage)
public void setRenderStateByMeta( int itemDamage )
{
IIcon front = this.getIcon( ForgeDirection.SOUTH.ordinal(), itemDamage );
IIcon other = this.getIcon( ForgeDirection.NORTH.ordinal(), itemDamage );
@@ -114,51 +120,47 @@ public class BlockCraftingUnit extends AEBaseBlock
}
@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 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)
public void breakBlock( World w, int x, int y, int z, Block a, int b )
{
TileCraftingTile cp = this.getTileEntity( w, x, y, z );
if ( cp != null )
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)
public String getUnlocalizedName( ItemStack is )
{
if( is.getItemDamage() == 1 )
return "tile.appliedenergistics2.BlockCraftingAccelerator";
return this.getItemUnlocalizedName( is );
}
protected String getItemUnlocalizedName( ItemStack is )
{
return super.getUnlocalizedName( is );
}
@Override
public void onNeighborBlockChange( World w, int x, int y, int z, Block junk )
{
TileCraftingTile cp = this.getTileEntity( w, x, y, z );
if ( cp != null )
if( cp != null )
cp.updateMultiBlock();
}
@Override
@SideOnly(Side.CLIENT)
public void getCheckedSubBlocks(Item item, CreativeTabs tabs, List<ItemStack> itemStacks)
public int damageDropped( int meta )
{
itemStacks.add( new ItemStack( this, 1, 0 ) );
itemStacks.add( new ItemStack( this, 1, 1 ) );
return meta & 3;
}
@Override
public int getDamageValue( World w, int x, int y, int z )
{
int meta = w.getBlockMetadata( x, y, z );
return this.damageDropped( meta );
}
}
@@ -18,6 +18,7 @@
package appeng.block.crafting;
import java.util.EnumSet;
import net.minecraft.block.material.Material;
@@ -36,10 +37,14 @@ import appeng.core.sync.GuiBridge;
import appeng.tile.crafting.TileMolecularAssembler;
import appeng.util.Platform;
public class BlockMolecularAssembler extends AEBaseBlock
{
public BlockMolecularAssembler() {
public static boolean booleanAlphaPass = false;
public BlockMolecularAssembler()
{
super( BlockMolecularAssembler.class, Material.iron );
this.setFeature( EnumSet.of( AEFeature.MolecularAssembler ) );
this.setTileEntity( TileMolecularAssembler.class );
@@ -47,15 +52,6 @@ public class BlockMolecularAssembler extends AEBaseBlock
this.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()
{
@@ -63,17 +59,24 @@ public class BlockMolecularAssembler extends AEBaseBlock
}
@Override
@SideOnly(Side.CLIENT)
public boolean canRenderInPass( int pass )
{
booleanAlphaPass = pass == 1;
return pass == 0 || pass == 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)
public boolean onActivated( World w, int x, int y, int z, EntityPlayer p, int side, float hitX, float hitY, float hitZ )
{
TileMolecularAssembler tg = this.getTileEntity( w, x, y, z );
if ( tg != null && !p.isSneaking() )
if( tg != null && !p.isSneaking() )
{
Platform.openGUI( p, tg, ForgeDirection.getOrientation( side ), GuiBridge.GUI_MAC );
return true;
@@ -18,6 +18,7 @@
package appeng.block.crafting;
import net.minecraft.block.Block;
import net.minecraft.item.ItemStack;
@@ -26,27 +27,29 @@ import appeng.block.AEBaseItemBlock;
import appeng.core.AEConfig;
import appeng.core.features.AEFeature;
public class ItemCraftingStorage extends AEBaseItemBlock
{
public ItemCraftingStorage(Block id) {
public ItemCraftingStorage( Block id )
{
super( id );
}
@Override
public boolean hasContainerItem(ItemStack stack)
public ItemStack getContainerItem( ItemStack itemStack )
{
return AEConfig.instance.isFeatureEnabled( AEFeature.enableDisassemblyCrafting );
}
@Override
public ItemStack getContainerItem(ItemStack itemStack)
{
for ( ItemStack stack : AEApi.instance().definitions().blocks().craftingUnit().maybeStack( 1 ).asSet() )
for( ItemStack stack : AEApi.instance().definitions().blocks().craftingUnit().maybeStack( 1 ).asSet() )
{
return stack;
}
return null;
}
@Override
public boolean hasContainerItem( ItemStack stack )
{
return AEConfig.instance.isFeatureEnabled( AEFeature.enableDisassemblyCrafting );
}
}
@@ -18,6 +18,7 @@
package appeng.block.grindstone;
import java.util.EnumSet;
import net.minecraft.block.Block;
@@ -39,10 +40,12 @@ import appeng.core.stats.Stats;
import appeng.tile.AEBaseTile;
import appeng.tile.grindstone.TileCrank;
public class BlockCrank extends AEBaseBlock
{
public BlockCrank() {
public BlockCrank()
{
super( BlockCrank.class, Material.wood );
this.setFeature( EnumSet.of( AEFeature.GrindStone ) );
this.setTileEntity( TileCrank.class );
@@ -52,18 +55,24 @@ public class BlockCrank extends AEBaseBlock
}
@Override
public boolean onActivated(World w, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ)
public Class<? extends BaseBlockRender> getRenderer()
{
if ( player instanceof FakePlayer || player == null )
return RenderBlockCrank.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 instanceof FakePlayer || player == null )
{
this.dropCrank(w, x, y, z);
this.dropCrank( w, x, y, z );
return true;
}
AEBaseTile tile = this.getTileEntity( w, x, y, z );
if ( tile instanceof TileCrank )
if( tile instanceof TileCrank )
{
if ( ((TileCrank) tile).power() )
if( ( (TileCrank) tile ).power() )
{
Stats.TurnedCranks.addToPlayer( player, 1 );
}
@@ -72,42 +81,6 @@ public class BlockCrank extends AEBaseBlock
return true;
}
@Override
public Class<? extends BaseBlockRender> getRenderer()
{
return RenderBlockCrank.class;
}
private boolean isCrankable( World world, int x, int y, int z, ForgeDirection offset )
{
TileEntity te = world.getTileEntity( x + offset.offsetX, y + offset.offsetY, z + offset.offsetZ );
return te instanceof ICrankable && ( ( ICrankable ) te ).canCrankAttach( offset.getOpposite() );
}
private ForgeDirection findCrankable( World world, int x, int y, int z )
{
for ( ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS )
if ( this.isCrankable( world, x, y, z, dir ) )
{
return dir;
}
return ForgeDirection.UNKNOWN;
}
@Override
public boolean canPlaceBlockAt( World world, int x, int y, int z )
{
return this.findCrankable( world , x, y, z ) != ForgeDirection.UNKNOWN;
}
@Override
public boolean isValidOrientation( World world, int x, int y, int z, ForgeDirection forward, ForgeDirection up )
{
TileEntity te = world.getTileEntity( x, y, z );
return !(te instanceof TileCrank) || this.isCrankable( world, x, y, z, up.getOpposite() );
}
private void dropCrank( World world, int x, int y, int z )
{
world.func_147480_a( x, y, z, true ); // w.destroyBlock( x, y, z, true );
@@ -118,11 +91,11 @@ public class BlockCrank extends AEBaseBlock
public void onBlockPlacedBy( World world, int x, int y, int z, EntityLivingBase placer, ItemStack itemStack )
{
AEBaseTile tile = this.getTileEntity( world, x, y, z );
if ( tile != null )
if( tile != null )
{
ForgeDirection mnt = this.findCrankable( world, x, y, z );
ForgeDirection forward = ForgeDirection.UP;
if ( mnt == ForgeDirection.UP || mnt == ForgeDirection.DOWN )
if( mnt == ForgeDirection.UP || mnt == ForgeDirection.DOWN )
{
forward = ForgeDirection.SOUTH;
}
@@ -135,12 +108,36 @@ public class BlockCrank extends AEBaseBlock
}
@Override
public void onNeighborBlockChange (World world, int x, int y, int z, Block block )
public boolean isValidOrientation( World world, int x, int y, int z, ForgeDirection forward, ForgeDirection up )
{
TileEntity te = world.getTileEntity( x, y, z );
return !( te instanceof TileCrank ) || this.isCrankable( world, x, y, z, up.getOpposite() );
}
private ForgeDirection findCrankable( World world, int x, int y, int z )
{
for( ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS )
if( this.isCrankable( world, x, y, z, dir ) )
{
return dir;
}
return ForgeDirection.UNKNOWN;
}
private boolean isCrankable( World world, int x, int y, int z, ForgeDirection offset )
{
TileEntity te = world.getTileEntity( x + offset.offsetX, y + offset.offsetY, z + offset.offsetZ );
return te instanceof ICrankable && ( (ICrankable) te ).canCrankAttach( offset.getOpposite() );
}
@Override
public void onNeighborBlockChange( World world, int x, int y, int z, Block block )
{
AEBaseTile tile = this.getTileEntity( world, x, y, z );
if ( tile != null )
if( tile != null )
{
if ( !this.isCrankable( world, x, y, z, tile.getUp().getOpposite() ) )
if( !this.isCrankable( world, x, y, z, tile.getUp().getOpposite() ) )
{
this.dropCrank( world, x, y, z );
}
@@ -151,4 +148,9 @@ public class BlockCrank extends AEBaseBlock
}
}
@Override
public boolean canPlaceBlockAt( World world, int x, int y, int z )
{
return this.findCrankable( world, x, y, z ) != ForgeDirection.UNKNOWN;
}
}
@@ -18,6 +18,7 @@
package appeng.block.grindstone;
import java.util.EnumSet;
import net.minecraft.block.material.Material;
@@ -31,10 +32,12 @@ import appeng.core.sync.GuiBridge;
import appeng.tile.grindstone.TileGrinder;
import appeng.util.Platform;
public class BlockGrinder extends AEBaseBlock
{
public BlockGrinder() {
public BlockGrinder()
{
super( BlockGrinder.class, Material.rock );
this.setFeature( EnumSet.of( AEFeature.GrindStone ) );
this.setTileEntity( TileGrinder.class );
@@ -42,15 +45,14 @@ public class BlockGrinder extends AEBaseBlock
}
@Override
public boolean onActivated(World w, int x, int y, int z, EntityPlayer p, int side, float hitX, float hitY, float hitZ)
public boolean onActivated( World w, int x, int y, int z, EntityPlayer p, int side, float hitX, float hitY, float hitZ )
{
TileGrinder tg = this.getTileEntity( w, x, y, z );
if ( tg != null && !p.isSneaking() )
if( tg != null && !p.isSneaking() )
{
Platform.openGUI( p, tg, ForgeDirection.getOrientation( side ), GuiBridge.GUI_GRINDER );
return true;
}
return false;
}
}
@@ -18,6 +18,7 @@
package appeng.block.misc;
import java.util.EnumSet;
import net.minecraft.block.material.Material;
@@ -31,29 +32,30 @@ import appeng.core.sync.GuiBridge;
import appeng.tile.misc.TileCellWorkbench;
import appeng.util.Platform;
public class BlockCellWorkbench extends AEBaseBlock
{
public BlockCellWorkbench() {
public BlockCellWorkbench()
{
super( BlockCellWorkbench.class, Material.iron );
this.setFeature( EnumSet.of( AEFeature.StorageCells ) );
this.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)
public boolean onActivated( World w, int x, int y, int z, EntityPlayer p, int side, float hitX, float hitY, float hitZ )
{
if ( p.isSneaking() )
if( p.isSneaking() )
return false;
TileCellWorkbench tg = this.getTileEntity( w, x, y, z );
if ( tg != null )
if( tg != null )
{
if ( Platform.isServer() )
if( Platform.isServer() )
Platform.openGUI( p, tg, ForgeDirection.getOrientation( side ), GuiBridge.GUI_CELL_WORKBENCH );
return true;
}
return false;
}
}
@@ -48,10 +48,12 @@ import appeng.tile.AEBaseTile;
import appeng.tile.misc.TileCharger;
import appeng.util.Platform;
public class BlockCharger extends AEBaseBlock implements ICustomCollision
{
public BlockCharger() {
public BlockCharger()
{
super( BlockCharger.class, Material.iron );
this.setFeature( EnumSet.of( AEFeature.Core ) );
this.setTileEntity( TileCharger.class );
@@ -59,24 +61,6 @@ public class BlockCharger extends AEBaseBlock implements ICustomCollision
this.isFullSize = this.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 = this.getTileEntity( w, x, y, z );
if ( tc != null )
{
tc.activate( player );
}
}
return true;
}
@Override
protected Class<? extends BaseBlockRender> getRenderer()
{
@@ -84,29 +68,47 @@ public class BlockCharger extends AEBaseBlock implements ICustomCollision
}
@Override
@SideOnly(Side.CLIENT)
public void randomDisplayTick(World w, int x, int y, int z, Random r)
public boolean onActivated( World w, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ )
{
if ( !AEConfig.instance.enableEffects )
if( player.isSneaking() )
return false;
if( Platform.isServer() )
{
TileCharger tc = this.getTileEntity( w, x, y, z );
if( tc != null )
{
tc.activate( player );
}
}
return true;
}
@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 )
if( r.nextFloat() < 0.98 )
return;
AEBaseTile tile = this.getTileEntity( w, x, y, z );
if ( tile instanceof TileCharger )
if( tile instanceof TileCharger )
{
TileCharger tc = (TileCharger) tile;
if ( AEApi.instance().definitions().materials().certusQuartzCrystalCharged().isSameAs( tc.getStackInSlot( 0 ) ) )
if( AEApi.instance().definitions().materials().certusQuartzCrystalCharged().isSameAs( tc.getStackInSlot( 0 ) ) )
{
double xOff = 0.0;
double yOff = 0.0;
double zOff = 0.0;
for (int bolts = 0; bolts < 3; bolts++)
for( int bolts = 0; bolts < 3; bolts++ )
{
if ( CommonHelper.proxy.shouldAddParticles( r ) )
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( fx );
@@ -117,54 +119,54 @@ public class BlockCharger extends AEBaseBlock implements ICustomCollision
}
@Override
public Iterable<AxisAlignedBB> getSelectedBoundingBoxesFromPool(World w, int x, int y, int z, Entity e, boolean isVisual)
public Iterable<AxisAlignedBB> getSelectedBoundingBoxesFromPool( World w, int x, int y, int z, Entity e, boolean isVisual )
{
TileCharger tile = this.getTileEntity( w, x, y, z );
if ( tile != null )
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 )
if( up.offsetX != 0 )
{
bb.minX = 0;
bb.maxX = 1;
}
if ( up.offsetY != 0 )
if( up.offsetY != 0 )
{
bb.minY = 0;
bb.maxY = 1;
}
if ( up.offsetZ != 0 )
if( up.offsetZ != 0 )
{
bb.minZ = 0;
bb.maxZ = 1;
}
switch (forward)
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;
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 Collections.singletonList( bb );
@@ -173,7 +175,7 @@ public class BlockCharger extends AEBaseBlock implements ICustomCollision
}
@Override
public void addCollidingBlockToList(World w, int x, int y, int z, AxisAlignedBB bb, List<AxisAlignedBB> out, Entity e)
public void addCollidingBlockToList( World w, int x, int y, int z, AxisAlignedBB bb, List<AxisAlignedBB> out, Entity e )
{
out.add( AxisAlignedBB.getBoundingBox( 0.0, 0.0, 0.0, 1.0, 1.0, 1.0 ) );
}
@@ -18,6 +18,7 @@
package appeng.block.misc;
import java.util.EnumSet;
import net.minecraft.block.material.Material;
@@ -31,32 +32,33 @@ import appeng.core.sync.GuiBridge;
import appeng.tile.misc.TileCondenser;
import appeng.util.Platform;
public class BlockCondenser extends AEBaseBlock
{
public BlockCondenser() {
public BlockCondenser()
{
super( BlockCondenser.class, Material.iron );
this.setFeature( EnumSet.of( AEFeature.Core ) );
this.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)
public boolean onActivated( World w, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ )
{
if ( player.isSneaking() )
if( player.isSneaking() )
return false;
if ( Platform.isServer() )
if( Platform.isServer() )
{
TileCondenser tc = this.getTileEntity( w, x, y, z );
if ( tc != null && !player.isSneaking() )
if( tc != null && !player.isSneaking() )
{
Platform.openGUI( player, tc, ForgeDirection.getOrientation(side), GuiBridge.GUI_CONDENSER );
Platform.openGUI( player, tc, ForgeDirection.getOrientation( side ), GuiBridge.GUI_CONDENSER );
return true;
}
}
return true;
}
}
@@ -18,6 +18,7 @@
package appeng.block.misc;
import java.util.EnumSet;
import net.minecraft.block.material.Material;
@@ -33,10 +34,12 @@ import appeng.core.sync.GuiBridge;
import appeng.tile.misc.TileInscriber;
import appeng.util.Platform;
public class BlockInscriber extends AEBaseBlock
{
public BlockInscriber() {
public BlockInscriber()
{
super( BlockInscriber.class, Material.iron );
this.setFeature( EnumSet.of( AEFeature.Inscriber ) );
this.setTileEntity( TileInscriber.class );
@@ -51,19 +54,18 @@ public class BlockInscriber extends AEBaseBlock
}
@Override
public boolean onActivated(World w, int x, int y, int z, EntityPlayer p, int side, float hitX, float hitY, float hitZ)
public boolean onActivated( World w, int x, int y, int z, EntityPlayer p, int side, float hitX, float hitY, float hitZ )
{
if ( p.isSneaking() )
if( p.isSneaking() )
return false;
TileInscriber tg = this.getTileEntity( w, x, y, z );
if ( tg != null )
if( tg != null )
{
if ( Platform.isServer() )
if( Platform.isServer() )
Platform.openGUI( p, tg, ForgeDirection.getOrientation( side ), GuiBridge.GUI_INSCRIBER );
return true;
}
return false;
}
}
@@ -18,6 +18,7 @@
package appeng.block.misc;
import java.util.EnumSet;
import net.minecraft.block.material.Material;
@@ -34,10 +35,12 @@ import appeng.core.sync.GuiBridge;
import appeng.tile.misc.TileInterface;
import appeng.util.Platform;
public class BlockInterface extends AEBaseBlock
{
public BlockInterface() {
public BlockInterface()
{
super( BlockInterface.class, Material.iron );
this.setFeature( EnumSet.of( AEFeature.Core ) );
this.setTileEntity( TileInterface.class );
@@ -49,6 +52,22 @@ public class BlockInterface extends AEBaseBlock
return RenderBlockInterface.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;
TileInterface tg = this.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;
}
@Override
protected boolean hasCustomRotation()
{
@@ -56,27 +75,11 @@ public class BlockInterface extends AEBaseBlock
}
@Override
protected void customRotateBlock(IOrientable rotatable, ForgeDirection axis)
protected void customRotateBlock( IOrientable rotatable, ForgeDirection axis )
{
if ( rotatable instanceof TileInterface )
if( rotatable instanceof TileInterface )
{
((TileInterface) rotatable).setSide( axis );
( (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 = this.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;
}
}
@@ -18,6 +18,7 @@
package appeng.block.misc;
import java.util.EnumSet;
import java.util.Random;
@@ -30,39 +31,40 @@ import cpw.mods.fml.relauncher.SideOnly;
import appeng.core.features.AEFeature;
import appeng.tile.misc.TileLightDetector;
public class BlockLightDetector extends BlockQuartzTorch
{
public BlockLightDetector() {
public BlockLightDetector()
{
super( BlockLightDetector.class );
this.setFeature( EnumSet.of( AEFeature.LightDetector ) );
this.setTileEntity( TileLightDetector.class );
}
@Override
public void onNeighborChange(IBlockAccess world, int x, int y, int z, int tileX, int tileY, int tileZ)
public int isProvidingWeakPower( IBlockAccess w, int x, int y, int z, int side )
{
super.onNeighborChange( world, x, y, z, tileX, tileY, tileZ );
TileLightDetector tld = this.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) this.getTileEntity( w, x, y, z )).isReady() )
return ((World) w).getBlockLightValue( x, y, z ) - 6;
if( w instanceof World && ( (TileLightDetector) this.getTileEntity( w, x, y, z ) ).isReady() )
return ( (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)
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 = this.getTileEntity( world, x, y, z );
if( tld != null )
tld.updateLight();
}
@Override
@SideOnly( Side.CLIENT )
public void randomDisplayTick( World w, int x, int y, int z, Random r )
{
// cancel out lightning
}
}
+55 -54
View File
@@ -18,6 +18,7 @@
package appeng.block.misc;
import java.util.EnumSet;
import java.util.List;
import java.util.Random;
@@ -42,10 +43,12 @@ import appeng.core.features.AEFeature;
import appeng.tile.misc.TilePaint;
import appeng.util.Platform;
public class BlockPaint extends AEBaseBlock
{
public BlockPaint() {
public BlockPaint()
{
super( BlockPaint.class, new MaterialLiquid( MapColor.airColor ) );
this.setFeature( EnumSet.of( AEFeature.PaintBalls ) );
this.setTileEntity( TilePaint.class );
@@ -61,11 +64,58 @@ public class BlockPaint extends AEBaseBlock
}
@Override
public int getLightValue(IBlockAccess w, int x, int y, int z)
@SideOnly( Side.CLIENT )
public void getCheckedSubBlocks( Item item, CreativeTabs tabs, List<ItemStack> itemStacks )
{
// do nothing
}
@Override
public AxisAlignedBB getCollisionBoundingBoxFromPool( World p_149668_1_, int p_149668_2_, int p_149668_3_, int p_149668_4_ )
{
return null;
}
@Override
public boolean canCollideCheck( int p_149678_1_, boolean p_149678_2_ )
{
return false;
}
@Override
public void onNeighborBlockChange( World w, int x, int y, int z, Block junk )
{
TilePaint tp = this.getTileEntity( w, x, y, z );
if ( tp != null )
if( tp != null )
tp.onNeighborBlockChange();
}
@Override
public Item getItemDropped( int p_149650_1_, Random p_149650_2_, int p_149650_3_ )
{
return null;
}
@Override
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 void fillWithRain( World w, int x, int y, int z )
{
if( Platform.isServer() )
w.setBlock( x, y, z, Platform.AIR, 0, 3 );
}
@Override
public int getLightValue( IBlockAccess w, int x, int y, int z )
{
TilePaint tp = this.getTileEntity( w, x, y, z );
if( tp != null )
{
return tp.getLightLevel();
}
@@ -74,63 +124,14 @@ public class BlockPaint extends AEBaseBlock
}
@Override
@SideOnly(Side.CLIENT)
public void getCheckedSubBlocks(Item item, CreativeTabs tabs, List<ItemStack> itemStacks)
{
// do 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 = this.getTileEntity( w, x, y, z );
if ( tp != null )
tp.onNeighborBlockChange();
}
@Override
public AxisAlignedBB getCollisionBoundingBoxFromPool(World p_149668_1_, int p_149668_2_, int p_149668_3_, int p_149668_4_)
{
return null;
}
@Override
public boolean canCollideCheck(int p_149678_1_, boolean p_149678_2_)
{
return false;
}
@Override
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)
public boolean isReplaceable( IBlockAccess world, int x, int y, int z )
{
return true;
}
@Override
public boolean isReplaceable(IBlockAccess world, int x, int y, int z)
public boolean isAir( IBlockAccess world, int x, int y, int z )
{
return true;
}
}
@@ -18,6 +18,7 @@
package appeng.block.misc;
import java.util.EnumSet;
import java.util.Random;
@@ -44,10 +45,12 @@ import appeng.helpers.MetaRotation;
import appeng.tile.misc.TileQuartzGrowthAccelerator;
import appeng.util.Platform;
public class BlockQuartzGrowthAccelerator extends AEBaseBlock implements IOrientableBlock
{
public BlockQuartzGrowthAccelerator() {
public BlockQuartzGrowthAccelerator()
{
super( BlockQuartzGrowthAccelerator.class, Material.rock );
this.setStepSound( Block.soundTypeMetal );
this.setFeature( EnumSet.of( AEFeature.Core ) );
@@ -61,21 +64,15 @@ public class BlockQuartzGrowthAccelerator extends AEBaseBlock implements IOrient
}
@Override
public IOrientable getOrientable(final IBlockAccess w, final int x, final int y, final int z)
@SideOnly( Side.CLIENT )
public void randomDisplayTick( World w, int x, int y, int z, Random r )
{
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 )
if( !AEConfig.instance.enableEffects )
return;
TileQuartzGrowthAccelerator tileQuartzGrowthAccelerator = this.getTileEntity( w, x, y, z );
if ( tileQuartzGrowthAccelerator != null && tileQuartzGrowthAccelerator.hasPower && CommonHelper.proxy.shouldAddParticles( r ) )
if( tileQuartzGrowthAccelerator != null && tileQuartzGrowthAccelerator.hasPower && CommonHelper.proxy.shouldAddParticles( r ) )
{
double d0 = r.nextFloat() - 0.5F;
double d1 = r.nextFloat() - 0.5F;
@@ -95,34 +92,32 @@ public class BlockQuartzGrowthAccelerator extends AEBaseBlock implements IOrient
ry += up.offsetY * d0;
rz += up.offsetZ * d0;
switch (r.nextInt( 4 ))
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;
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;
@@ -143,4 +138,10 @@ public class BlockQuartzGrowthAccelerator extends AEBaseBlock implements IOrient
{
return true;
}
@Override
public IOrientable getOrientable( final IBlockAccess w, final int x, final int y, final int z )
{
return new MetaRotation( w, x, y, z );
}
}
@@ -48,21 +48,24 @@ import appeng.core.features.AEFeature;
import appeng.helpers.ICustomCollision;
import appeng.helpers.MetaRotation;
public class BlockQuartzTorch extends AEBaseBlock implements IOrientableBlock, ICustomCollision
{
protected BlockQuartzTorch(Class which) {
super( which, Material.circuits );
this.setLightOpacity( 0 );
this.isFullSize = this.isOpaque = false;
}
public BlockQuartzTorch() {
public BlockQuartzTorch()
{
this( BlockQuartzTorch.class );
this.setFeature( EnumSet.of( AEFeature.DecorativeLights ) );
this.setLightLevel( 0.9375F );
}
protected BlockQuartzTorch( Class which )
{
super( which, Material.circuits );
this.setLightOpacity( 0 );
this.isFullSize = this.isOpaque = false;
}
@Override
protected Class<? extends BaseBlockRender> getRenderer()
{
@@ -70,48 +73,18 @@ public class BlockQuartzTorch extends AEBaseBlock implements IOrientableBlock, I
}
@Override
public IOrientable getOrientable(final IBlockAccess w, final int x, final int y, final int z)
public boolean isValidOrientation( World w, int x, int y, int z, ForgeDirection forward, ForgeDirection up )
{
return new MetaRotation( w, x, y, z );
return this.canPlaceAt( w, x, y, z, up.getOpposite() );
}
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 ( this.canPlaceAt( w, x, y, z, dir ) )
return true;
return false;
}
private boolean canPlaceAt(World w, int x, int y, int z, ForgeDirection dir)
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 this.canPlaceAt( w, x, y, z, up.getOpposite() );
}
@Override
public void onNeighborBlockChange(World w, int x, int y, int z, Block id)
{
ForgeDirection up = this.getOrientable( w, x, y, z ).getUp();
if ( !this.canPlaceAt( w, x, y, z, up.getOpposite() ) )
this.dropTorch( w, x, y, z );
}
@Override
public Iterable<AxisAlignedBB> getSelectedBoundingBoxesFromPool(World w, int x, int y, int z, Entity e, boolean isVisual)
public Iterable<AxisAlignedBB> getSelectedBoundingBoxesFromPool( World w, int x, int y, int z, Entity e, boolean isVisual )
{
ForgeDirection up = this.getOrientable( w, x, y, z ).getUp();
double xOff = -0.3 * up.offsetX;
@@ -121,7 +94,7 @@ public class BlockQuartzTorch extends AEBaseBlock implements IOrientableBlock, I
}
@Override
public void addCollidingBlockToList(World w, int x, int y, int z, AxisAlignedBB bb, List out, Entity e)
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
@@ -130,22 +103,22 @@ public class BlockQuartzTorch extends AEBaseBlock implements IOrientableBlock, I
}
@Override
@SideOnly(Side.CLIENT)
public void randomDisplayTick(World w, int x, int y, int z, Random r)
@SideOnly( Side.CLIENT )
public void randomDisplayTick( World w, int x, int y, int z, Random r )
{
if ( !AEConfig.instance.enableEffects )
if( !AEConfig.instance.enableEffects )
return;
if ( r.nextFloat() < 0.98 )
if( r.nextFloat() < 0.98 )
return;
ForgeDirection up = this.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++)
for( int bolts = 0; bolts < 3; bolts++ )
{
if ( CommonHelper.proxy.shouldAddParticles( r ) )
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 );
@@ -154,10 +127,39 @@ public class BlockQuartzTorch extends AEBaseBlock implements IOrientableBlock, I
}
}
@Override
public void onNeighborBlockChange( World w, int x, int y, int z, Block id )
{
ForgeDirection up = this.getOrientable( w, x, y, z ).getUp();
if( !this.canPlaceAt( w, x, y, z, up.getOpposite() ) )
this.dropTorch( 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( this.canPlaceAt( w, x, y, z, dir ) )
return true;
return false;
}
@Override
public boolean usesMetadata()
{
return true;
}
@Override
public IOrientable getOrientable( final IBlockAccess w, final int x, final int y, final int z )
{
return new MetaRotation( w, x, y, z );
}
}
@@ -18,6 +18,7 @@
package appeng.block.misc;
import java.util.EnumSet;
import net.minecraft.block.material.Material;
@@ -33,10 +34,12 @@ import appeng.core.sync.GuiBridge;
import appeng.tile.misc.TileSecurity;
import appeng.util.Platform;
public class BlockSecurity extends AEBaseBlock
{
public BlockSecurity() {
public BlockSecurity()
{
super( BlockSecurity.class, Material.iron );
this.setFeature( EnumSet.of( AEFeature.Security ) );
this.setTileEntity( TileSecurity.class );
@@ -49,22 +52,20 @@ public class BlockSecurity extends AEBaseBlock
}
@Override
public boolean onActivated(World w, int x, int y, int z, EntityPlayer p, int side, float hitX, float hitY, float hitZ)
public boolean onActivated( World w, int x, int y, int z, EntityPlayer p, int side, float hitX, float hitY, float hitZ )
{
if ( p.isSneaking() )
if( p.isSneaking() )
return false;
TileSecurity tg = this.getTileEntity( w, x, y, z );
if ( tg != null )
if( tg != null )
{
if ( Platform.isClient() )
if( Platform.isClient() )
return true;
Platform.openGUI( p, tg, ForgeDirection.getOrientation( side ), GuiBridge.GUI_SECURITY );
return true;
}
return false;
}
}
@@ -43,10 +43,12 @@ import appeng.core.features.AEFeature;
import appeng.helpers.ICustomCollision;
import appeng.tile.misc.TileSkyCompass;
public class BlockSkyCompass extends AEBaseBlock implements ICustomCollision
{
public BlockSkyCompass() {
public BlockSkyCompass()
{
super( BlockSkyCompass.class, Material.iron );
this.setFeature( EnumSet.of( AEFeature.MeteoriteCompass ) );
this.setTileEntity( TileSkyCompass.class );
@@ -54,20 +56,49 @@ public class BlockSkyCompass extends AEBaseBlock implements ICustomCollision
this.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)
@Override
@SideOnly( Side.CLIENT )
public IIcon getIcon( int direction, int metadata )
{
return Blocks.iron_block.getIcon( direction, metadata );
}
@Override
public void registerBlockIcons( IIconRegister iconRegistry )
{
// :P
}
@Override
public boolean isValidOrientation( World w, int x, int y, int z, ForgeDirection forward, ForgeDirection up )
{
TileSkyCompass sc = this.getTileEntity( w, x, y, z );
if( sc != null )
return false;
return this.canPlaceAt( w, x, y, z, forward.getOpposite() );
}
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 void onNeighborBlockChange( World w, int x, int y, int z, Block id )
{
TileSkyCompass sc = this.getTileEntity( w, x, y, z );
ForgeDirection up = sc.getForward();
if( !this.canPlaceAt( w, x, y, z, up.getOpposite() ) )
this.dropTorch( 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 );
@@ -75,42 +106,19 @@ public class BlockSkyCompass extends AEBaseBlock implements ICustomCollision
}
@Override
public boolean canPlaceBlockAt(World w, int x, int y, int z)
public boolean canPlaceBlockAt( World w, int x, int y, int z )
{
for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS)
if ( this.canPlaceAt( w, x, y, z, dir ) )
for( ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS )
if( this.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 = this.getTileEntity( w, x, y, z );
if ( sc != null )
return false;
return this.canPlaceAt( w, x, y, z, forward.getOpposite() );
}
@Override
public void onNeighborBlockChange(World w, int x, int y, int z, Block id)
{
TileSkyCompass sc = this.getTileEntity( w, x, y, z );
ForgeDirection up = sc.getForward();
if ( !this.canPlaceAt( w, x, y, z, up.getOpposite() ) )
this.dropTorch( w, x, y, z );
}
@Override
public Iterable<AxisAlignedBB> getSelectedBoundingBoxesFromPool(World w, int x, int y, int z, Entity e, boolean isVisual)
public Iterable<AxisAlignedBB> getSelectedBoundingBoxesFromPool( World w, int x, int y, int z, Entity e, boolean isVisual )
{
TileSkyCompass tile = this.getTileEntity( w, x, y, z );
if ( tile != null )
if( tile != null )
{
ForgeDirection forward = tile.getForward();
@@ -121,46 +129,46 @@ public class BlockSkyCompass extends AEBaseBlock implements ICustomCollision
double maxY = 1;
double maxZ = 1;
switch (forward)
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;
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 Collections.singletonList( AxisAlignedBB.getBoundingBox( minX, minY, minZ, maxX, maxY, maxZ ) );
@@ -169,14 +177,8 @@ public class BlockSkyCompass extends AEBaseBlock implements ICustomCollision
}
@Override
public void addCollidingBlockToList(World w, int x, int y, int z, AxisAlignedBB bb, List out, Entity e)
public void addCollidingBlockToList( World w, int x, int y, int z, AxisAlignedBB bb, List out, Entity e )
{
}
@Override
public void registerBlockIcons(IIconRegister iconRegistry)
{
// :P
}
}
@@ -52,10 +52,12 @@ import appeng.entity.EntityTinyTNTPrimed;
import appeng.helpers.ICustomCollision;
import appeng.hooks.DispenserBehaviorTinyTNT;
public class BlockTinyTNT extends AEBaseBlock implements ICustomCollision
{
public BlockTinyTNT() {
public BlockTinyTNT()
{
super( BlockTinyTNT.class, Material.tnt );
this.setFeature( EnumSet.of( AEFeature.TinyTNT ) );
this.setLightOpacity( 1 );
@@ -67,6 +69,12 @@ public class BlockTinyTNT extends AEBaseBlock implements ICustomCollision
EntityRegistry.registerModEntity( EntityTinyTNTPrimed.class, "EntityTinyTNTPrimed", EntityIds.TINY_TNT, AppEng.instance, 16, 4, true );
}
@Override
protected Class<? extends BaseBlockRender> getRenderer()
{
return RenderTinyTNT.class;
}
@Override
public void postInit()
{
@@ -75,64 +83,15 @@ public class BlockTinyTNT extends AEBaseBlock implements ICustomCollision
}
@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)
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)
public boolean onActivated( World w, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ )
{
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 )
if( player.getCurrentEquippedItem() != null && player.getCurrentEquippedItem().getItem() == Items.flint_and_steel )
{
this.startFuse( w, x, y, z, player );
w.setBlockToAir( x, y, z );
@@ -146,19 +105,14 @@ public class BlockTinyTNT extends AEBaseBlock implements ICustomCollision
}
@Override
public void onBlockDestroyedByExplosion(World w, int x, int y, int z, Explosion exp)
public void registerBlockIcons( IIconRegister iconRegistry )
{
if ( !w.isRemote )
{
EntityTinyTNTPrimed primedTinyTNTEntity = new EntityTinyTNTPrimed( w, x + 0.5F, y + 0.5F, z + 0.5F, exp.getExplosivePlacedBy() );
primedTinyTNTEntity.fuse = w.rand.nextInt( primedTinyTNTEntity.fuse / 4 ) + primedTinyTNTEntity.fuse / 8;
w.spawnEntityInWorld( primedTinyTNTEntity );
}
// no images required.
}
public void startFuse(World w, int x, int y, int z, EntityLivingBase igniter)
public void startFuse( World w, int x, int y, int z, EntityLivingBase igniter )
{
if ( !w.isRemote )
if( !w.isRemote )
{
EntityTinyTNTPrimed primedTinyTNTEntity = new EntityTinyTNTPrimed( w, x + 0.5F, y + 0.5F, z + 0.5F, igniter );
w.spawnEntityInWorld( primedTinyTNTEntity );
@@ -167,21 +121,68 @@ public class BlockTinyTNT extends AEBaseBlock implements ICustomCollision
}
@Override
public boolean canDropFromExplosion(Explosion exp)
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 void onBlockDestroyedByExplosion( World w, int x, int y, int z, Explosion exp )
{
if( !w.isRemote )
{
EntityTinyTNTPrimed primedTinyTNTEntity = new EntityTinyTNTPrimed( w, x + 0.5F, y + 0.5F, z + 0.5F, exp.getExplosivePlacedBy() );
primedTinyTNTEntity.fuse = w.rand.nextInt( primedTinyTNTEntity.fuse / 4 ) + primedTinyTNTEntity.fuse / 8;
w.spawnEntityInWorld( primedTinyTNTEntity );
}
}
@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 boolean canDropFromExplosion( Explosion exp )
{
return false;
}
@Override
public Iterable<AxisAlignedBB> getSelectedBoundingBoxesFromPool(World w, int x, int y, int z, Entity e, boolean isVisual)
public Iterable<AxisAlignedBB> getSelectedBoundingBoxesFromPool( World w, int x, int y, int z, Entity e, boolean isVisual )
{
return Collections.singletonList( 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<AxisAlignedBB> out, Entity e)
public void addCollidingBlockToList( World w, int x, int y, int z, AxisAlignedBB bb, List<AxisAlignedBB> out, Entity e )
{
out.add( AxisAlignedBB.getBoundingBox( 0.25, 0, 0.25, 0.75, 0.5, 0.75 ) );
}
}
@@ -18,6 +18,7 @@
package appeng.block.misc;
import java.util.EnumSet;
import java.util.Random;
@@ -37,10 +38,12 @@ import appeng.tile.AEBaseTile;
import appeng.tile.misc.TileVibrationChamber;
import appeng.util.Platform;
public class BlockVibrationChamber extends AEBaseBlock
{
public BlockVibrationChamber() {
public BlockVibrationChamber()
{
super( BlockVibrationChamber.class, Material.iron );
this.setFeature( EnumSet.of( AEFeature.PowerGen ) );
this.setTileEntity( TileVibrationChamber.class );
@@ -48,15 +51,29 @@ public class BlockVibrationChamber extends AEBaseBlock
}
@Override
public boolean onActivated(World w, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ)
public IIcon getIcon( IBlockAccess w, int x, int y, int z, int s )
{
if ( player.isSneaking() )
IIcon ico = super.getIcon( w, x, y, z, s );
TileVibrationChamber tvc = this.getTileEntity( w, x, y, z );
if( tvc != null && tvc.isOn && ico == this.getRendererInstance().getTexture( ForgeDirection.SOUTH ) )
{
return ExtraBlockTextures.BlockVibrationChamberFrontOn.getIcon();
}
return ico;
}
@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() )
if( Platform.isServer() )
{
TileVibrationChamber tc = this.getTileEntity( w, x, y, z );
if ( tc != null && !player.isSneaking() )
if( tc != null && !player.isSneaking() )
{
Platform.openGUI( player, tc, ForgeDirection.getOrientation( side ), GuiBridge.GUI_VIBRATION_CHAMBER );
return true;
@@ -67,30 +84,16 @@ public class BlockVibrationChamber extends AEBaseBlock
}
@Override
public IIcon getIcon(IBlockAccess w, int x, int y, int z, int s)
public void randomDisplayTick( World w, int x, int y, int z, Random r )
{
IIcon ico = super.getIcon( w, x, y, z, s );
TileVibrationChamber tvc = this.getTileEntity( w, x, y, z );
if ( tvc != null && tvc.isOn && ico == this.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 )
if( !AEConfig.instance.enableEffects )
return;
AEBaseTile tile = this.getTileEntity( w, x, y, z );
if ( tile instanceof TileVibrationChamber )
if( tile instanceof TileVibrationChamber )
{
TileVibrationChamber tc = (TileVibrationChamber) tile;
if ( tc.isOn )
if( tc.isOn )
{
float f1 = x + 0.5F;
float f2 = y + 0.5F;
@@ -110,18 +113,17 @@ public class BlockVibrationChamber extends AEBaseBlock
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 += 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);
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", f1, f2, f3, 0.0D, 0.0D, 0.0D );
w.spawnParticle( "flame", f1, f2, f3, 0.0D, 0.0D, 0.0D );
}
}
}
}
@@ -18,6 +18,7 @@
package appeng.block.networking;
import java.util.EnumSet;
import java.util.List;
import java.util.Random;
@@ -74,29 +75,22 @@ import appeng.transformer.annotations.Integration.Interface;
import appeng.transformer.annotations.Integration.Method;
import appeng.util.Platform;
@Interface(iface = "powercrystals.minefactoryreloaded.api.rednet.connectivity.IRedNetConnection", iname = "MFR")
@Interface( iface = "powercrystals.minefactoryreloaded.api.rednet.connectivity.IRedNetConnection", iname = "MFR" )
public class BlockCableBus extends AEBaseBlock implements IRedNetConnection
{
private static final ICableBusContainer NULL_CABLE_BUS = new NullCableBusContainer();
static public Class<? extends TileEntity> noTesrTile;
static public Class<? extends TileEntity> tesrTile;
/**
* Immibis MB Support.
*/
boolean ImmibisMicroblocks_TransformableBlockMarker = true;
int myColorMultiplier = 0xffffff;
@Override
public <T extends TileEntity> T getTileEntity(IBlockAccess w, int x, int y, int z)
public BlockCableBus()
{
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 );
this.setFeature( EnumSet.of( AEFeature.Core ) );
this.setLightOpacity( 0 );
@@ -104,240 +98,41 @@ public class BlockCableBus extends AEBaseBlock implements IRedNetConnection
}
@Override
public int getRenderBlockPass()
{
if ( AEConfig.instance.isFeatureEnabled( AEFeature.AlphaPass ) )
return 1;
return 0;
}
@Override
@SideOnly(Side.CLIENT)
public boolean addHitEffects(World world, MovingObjectPosition target, EffectRenderer effectRenderer)
{
Object object = this.cb( world, target.blockX, target.blockY, target.blockZ );
if ( object instanceof IPartHost )
{
IPartHost host = (IPartHost) object;
for (ForgeDirection side : ForgeDirection.values())
{
IPart p = host.getPart( side );
IIcon ico = this.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 = target.blockX + (i1 + 0.5D) / b0;
double d1 = target.blockY + (j1 + 0.5D) / b0;
double d2 = target.blockZ + (k1 + 0.5D) / 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 - target.blockX - 0.5D, d1 - target.blockY
- 0.5D, d2 - target.blockZ - 0.5D, this, 0 )).applyColourMultiplier( target.blockX, target.blockY, target.blockZ );
fx.setParticleIcon( ico );
effectRenderer.addEffect( fx );
}
}
}
}
}
return true;
}
@Override
@SideOnly(Side.CLIENT)
public boolean addDestroyEffects(World world, int x, int y, int z, int meta, EffectRenderer effectRenderer)
{
Object object = this.cb( world, x, y, z );
if ( object instanceof IPartHost )
{
IPartHost host = (IPartHost) object;
for (ForgeDirection side : ForgeDirection.values())
{
IPart p = host.getPart( side );
IIcon ico = this.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 = x + (i1 + 0.5D) / b0;
double d1 = y + (j1 + 0.5D) / b0;
double d2 = z + (k1 + 0.5D) / b0;
EntityDiggingFX fx = (new EntityDiggingFX( world, d0, d1, d2, d0 - x - 0.5D, d1 - y - 0.5D, d2 - 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 this.cb( world, x, y, z ).isLadder( entity );
}
@Override
public boolean recolourBlock(World world, int x, int y, int z, ForgeDirection side, int colour)
{
return this.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 this.cb( world, x, y, z ).recolourBlock( side, AEColor.values()[colour], who );
}
catch (Throwable ignored)
{
}
return false;
}
@Override
public void randomDisplayTick(World world, int x, int y, int z, Random r)
public void randomDisplayTick( World world, int x, int y, int z, Random r )
{
this.cb( world, x, y, z ).randomDisplayTick( world, x, y, z, r );
}
@Override
public int getLightValue(IBlockAccess world, int x, int y, int z)
public void onNeighborBlockChange( World w, int x, int y, int z, Block meh )
{
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 this.cb( world, x, y, z ).getLightValue();
this.cb( w, x, y, z ).onNeighborChanged();
}
@Override
public ItemStack getPickBlock(MovingObjectPosition target, World world, int x, int y, int z)
public Item getItemDropped( int i, Random r, int k )
{
Vec3 v3 = target.hitVec.addVector( -x, -y, -z );
SelectedPart sp = this.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)
public int getRenderBlockPass()
{
return this.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 = this.getTileEntity( world, x, y, z );
if ( tile != null )
tile.disableDrops();
// maybe ray trace?
}
return super.removedByPlayer( world, player, x, y, z );
if( AEConfig.instance.isFeatureEnabled( AEFeature.AlphaPass ) )
return 1;
return 0;
}
@Override
public IIcon getIcon(IBlockAccess w, int x, int y, int z, int s)
public int colorMultiplier( IBlockAccess p_149720_1_, int p_149720_2_, int p_149720_3_, int p_149720_4_ )
{
return this.getIcon( s, 0 );
return this.myColorMultiplier;
}
@Override
public IIcon getIcon(int direction, int metadata)
public int isProvidingWeakPower( IBlockAccess w, int x, int y, int z, int side )
{
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)
{
return this.cb( w, x, y, z ).isProvidingWeakPower( ForgeDirection.getOrientation( side ).getOpposite() );
}
@Override
@@ -347,85 +142,316 @@ public class BlockCableBus extends AEBaseBlock implements IRedNetConnection
}
@Override
public boolean isSideSolid(IBlockAccess w, int x, int y, int z, ForgeDirection side)
{
return this.cb( w, x, y, z ).isSolidOnSide( side );
}
@Override
public void onNeighborBlockChange(World w, int x, int y, int z, Block meh)
{
this.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() )
this.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 this.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)
public void onEntityCollidedWithBlock( World w, int x, int y, int z, Entity e )
{
this.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 this.cb( w, x, y, z ).canConnectRedstone( EnumSet.of( ForgeDirection.UP, ForgeDirection.DOWN ) );
case 0:
return this.cb( w, x, y, z ).canConnectRedstone( EnumSet.of( ForgeDirection.NORTH ) );
case 1:
return this.cb( w, x, y, z ).canConnectRedstone( EnumSet.of( ForgeDirection.EAST ) );
case 2:
return this.cb( w, x, y, z ).canConnectRedstone( EnumSet.of( ForgeDirection.SOUTH ) );
case 3:
return this.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 this.cb( w, x, y, z ).isProvidingWeakPower( ForgeDirection.getOrientation( side ).getOpposite() );
}
@Override
public int isProvidingStrongPower(IBlockAccess w, int x, int y, int z, int side)
public int isProvidingStrongPower( IBlockAccess w, int x, int y, int z, int side )
{
return this.cb( w, x, y, z ).isProvidingStrongPower( ForgeDirection.getOrientation( side ).getOpposite() );
}
@Override
@SideOnly(Side.CLIENT)
public void getCheckedSubBlocks(Item item, CreativeTabs tabs, List<ItemStack> itemStacks)
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 this.cb( world, x, y, z ).getLightValue();
}
@Override
public boolean isLadder( IBlockAccess world, int x, int y, int z, EntityLivingBase entity )
{
return this.cb( world, x, y, z ).isLadder( entity );
}
@Override
public boolean isSideSolid( IBlockAccess w, int x, int y, int z, ForgeDirection side )
{
return this.cb( w, x, y, z ).isSolidOnSide( side );
}
@Override
public boolean isReplaceable( IBlockAccess world, int x, int y, int z )
{
return this.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 = this.getTileEntity( world, x, y, z );
if( tile != null )
tile.disableDrops();
// maybe ray trace?
}
return super.removedByPlayer( world, player, x, y, z );
}
@Override
public boolean canConnectRedstone( IBlockAccess w, int x, int y, int z, int side )
{
switch( side )
{
case -1:
case 4:
return this.cb( w, x, y, z ).canConnectRedstone( EnumSet.of( ForgeDirection.UP, ForgeDirection.DOWN ) );
case 0:
return this.cb( w, x, y, z ).canConnectRedstone( EnumSet.of( ForgeDirection.NORTH ) );
case 1:
return this.cb( w, x, y, z ).canConnectRedstone( EnumSet.of( ForgeDirection.EAST ) );
case 2:
return this.cb( w, x, y, z ).canConnectRedstone( EnumSet.of( ForgeDirection.SOUTH ) );
case 3:
return this.cb( w, x, y, z ).canConnectRedstone( EnumSet.of( ForgeDirection.WEST ) );
}
return false;
}
@Override
public boolean canRenderInPass( int pass )
{
BusRenderHelper.INSTANCE.setPass( pass );
if( AEConfig.instance.isFeatureEnabled( AEFeature.AlphaPass ) )
return true;
return pass == 0;
}
@Override
public ItemStack getPickBlock( MovingObjectPosition target, World world, int x, int y, int z )
{
Vec3 v3 = target.hitVec.addVector( -x, -y, -z );
SelectedPart sp = this.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
@SideOnly( Side.CLIENT )
public boolean addHitEffects( World world, MovingObjectPosition target, EffectRenderer effectRenderer )
{
Object object = this.cb( world, target.blockX, target.blockY, target.blockZ );
if( object instanceof IPartHost )
{
IPartHost host = (IPartHost) object;
for( ForgeDirection side : ForgeDirection.values() )
{
IPart p = host.getPart( side );
IIcon ico = this.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 = target.blockX + ( i1 + 0.5D ) / b0;
double d1 = target.blockY + ( j1 + 0.5D ) / b0;
double d2 = target.blockZ + ( k1 + 0.5D ) / 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 - target.blockX - 0.5D, d1 - target.blockY - 0.5D, d2 - target.blockZ - 0.5D, this, 0 ) ).applyColourMultiplier( target.blockX, target.blockY, target.blockZ );
fx.setParticleIcon( ico );
effectRenderer.addEffect( fx );
}
}
}
}
}
return true;
}
@Override
@SideOnly( Side.CLIENT )
public boolean addDestroyEffects( World world, int x, int y, int z, int meta, EffectRenderer effectRenderer )
{
Object object = this.cb( world, x, y, z );
if( object instanceof IPartHost )
{
IPartHost host = (IPartHost) object;
for( ForgeDirection side : ForgeDirection.values() )
{
IPart p = host.getPart( side );
IIcon ico = this.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 = x + ( i1 + 0.5D ) / b0;
double d1 = y + ( j1 + 0.5D ) / b0;
double d2 = z + ( k1 + 0.5D ) / b0;
EntityDiggingFX fx = ( new EntityDiggingFX( world, d0, d1, d2, d0 - x - 0.5D, d1 - y - 0.5D, d2 - z - 0.5D, this, meta ) ).applyColourMultiplier( x, y, z );
fx.setParticleIcon( ico );
effectRenderer.addEffect( fx );
}
}
}
}
}
return true;
}
@Override
public void onNeighborChange( IBlockAccess w, int x, int y, int z, int tileX, int tileY, int tileZ )
{
if( Platform.isServer() )
this.cb( w, x, y, z ).onNeighborChanged();
}
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 );
}
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 ? NULL_CABLE_BUS : out;
}
@Override
protected Class<? extends BaseBlockRender> getRenderer()
{
return RendererCableBus.class;
}
@Override
public IIcon getIcon( IBlockAccess w, int x, int y, int z, int s )
{
return this.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
public boolean onActivated( World w, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ )
{
return this.cb( w, x, y, z ).activate( player, Vec3.createVectorHelper( hitX, hitY, hitZ ) );
}
@Override
public void registerBlockIcons( IIconRegister iconRegistry )
{
}
@Override
public boolean recolourBlock( World world, int x, int y, int z, ForgeDirection side, int colour )
{
return this.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 this.cb( world, x, y, z ).recolourBlock( side, AEColor.values()[colour], who );
}
catch( Throwable ignored )
{
}
return false;
}
@Override
@SideOnly( Side.CLIENT )
public void getCheckedSubBlocks( Item item, CreativeTabs tabs, List<ItemStack> itemStacks )
{
// do nothing
}
@Override
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 void setupTile()
{
this.setTileEntity( noTesrTile = Api.INSTANCE.getPartHelper().getCombinedInstance( TileCableBus.class.getName() ) );
if ( Platform.isClient() )
if( Platform.isClient() )
{
tesrTile = Api.INSTANCE.getPartHelper().getCombinedInstance( TileCableBusTESR.class.getName() );
GameRegistry.registerTileEntity( tesrTile, "ClientOnly_TESR_CableBus" );
@@ -433,43 +459,15 @@ public class BlockCableBus extends AEBaseBlock implements IRedNetConnection
}
}
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 ? NULL_CABLE_BUS : 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)
@Method( iname = "MFR" )
public RedNetConnectionType getConnectionType( World world, int x, int y, int z, ForgeDirection side )
{
return this.cb( world, x, y, z ).canConnectRedstone( EnumSet.allOf( ForgeDirection.class ) ) ? RedNetConnectionType.CableSingle : RedNetConnectionType.None;
}
int myColorMultiplier = 0xffffff;
public void setRenderColor(int color)
public void setRenderColor( int color )
{
this.myColorMultiplier = color;
}
@Override
public int colorMultiplier(IBlockAccess p_149720_1_, int p_149720_2_, int p_149720_3_, int p_149720_4_)
{
return this.myColorMultiplier;
}
}
@@ -18,6 +18,7 @@
package appeng.block.networking;
import java.util.EnumSet;
import net.minecraft.block.Block;
@@ -30,10 +31,12 @@ import appeng.client.render.blocks.RenderBlockController;
import appeng.core.features.AEFeature;
import appeng.tile.networking.TileController;
public class BlockController extends AEBaseBlock
{
public BlockController() {
public BlockController()
{
super( BlockController.class, Material.iron );
this.setFeature( EnumSet.of( AEFeature.Channels ) );
this.setTileEntity( TileController.class );
@@ -41,10 +44,10 @@ public class BlockController extends AEBaseBlock
}
@Override
public void onNeighborBlockChange(World w, int x, int y, int z, Block id_junk)
public void onNeighborBlockChange( World w, int x, int y, int z, Block id_junk )
{
TileController tc = this.getTileEntity( w, x, y, z );
if ( tc != null )
if( tc != null )
tc.onNeighborChange( false );
}
@@ -53,5 +56,4 @@ public class BlockController extends AEBaseBlock
{
return RenderBlockController.class;
}
}
@@ -18,6 +18,7 @@
package appeng.block.networking;
import java.util.EnumSet;
import appeng.block.AEBaseBlock;
@@ -25,13 +26,14 @@ import appeng.core.features.AEFeature;
import appeng.helpers.AEGlassMaterial;
import appeng.tile.networking.TileCreativeEnergyCell;
public class BlockCreativeEnergyCell extends AEBaseBlock
{
public BlockCreativeEnergyCell() {
public BlockCreativeEnergyCell()
{
super( BlockCreativeEnergyCell.class, AEGlassMaterial.INSTANCE );
this.setFeature( EnumSet.of( AEFeature.Creative ) );
this.setTileEntity( TileCreativeEnergyCell.class );
}
}
@@ -18,6 +18,7 @@
package appeng.block.networking;
import java.util.EnumSet;
import net.minecraft.util.IIcon;
@@ -26,45 +27,45 @@ import appeng.client.texture.ExtraBlockTextures;
import appeng.core.features.AEFeature;
import appeng.tile.networking.TileDenseEnergyCell;
public class BlockDenseEnergyCell extends BlockEnergyCell
{
@Override
public double getMaxPower()
public BlockDenseEnergyCell()
{
return 200000.0 * 8.0;
}
public BlockDenseEnergyCell() {
super( BlockDenseEnergyCell.class );
this.setFeature( EnumSet.of( AEFeature.DenseEnergyCells ) );
this.setTileEntity( TileDenseEnergyCell.class );
}
@Override
public IIcon getIcon(int direction, int metadata)
public IIcon getIcon( int direction, int metadata )
{
switch (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();
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 );
}
@Override
public double getMaxPower()
{
return 200000.0 * 8.0;
}
}
@@ -18,6 +18,7 @@
package appeng.block.networking;
import java.util.EnumSet;
import net.minecraft.block.material.Material;
@@ -26,13 +27,14 @@ import appeng.block.AEBaseBlock;
import appeng.core.features.AEFeature;
import appeng.tile.networking.TileEnergyAcceptor;
public class BlockEnergyAcceptor extends AEBaseBlock
{
public BlockEnergyAcceptor() {
public BlockEnergyAcceptor()
{
super( BlockEnergyAcceptor.class, Material.iron );
this.setFeature( EnumSet.of( AEFeature.Core ) );
this.setTileEntity( TileEnergyAcceptor.class );
}
}
@@ -18,6 +18,7 @@
package appeng.block.networking;
import java.util.EnumSet;
import java.util.List;
@@ -41,27 +42,56 @@ import appeng.helpers.AEGlassMaterial;
import appeng.tile.networking.TileEnergyCell;
import appeng.util.Platform;
public class BlockEnergyCell extends AEBaseBlock
{
public double getMaxPower()
public BlockEnergyCell()
{
return 200000.0;
}
public BlockEnergyCell(Class c) {
super( c, AEGlassMaterial.INSTANCE );
}
public BlockEnergyCell() {
this( BlockEnergyCell.class );
this.setFeature( EnumSet.of( AEFeature.Core ) );
this.setTileEntity( TileEnergyCell.class );
}
public BlockEnergyCell( Class c )
{
super( c, AEGlassMaterial.INSTANCE );
}
@Override
@SideOnly(Side.CLIENT)
public void getCheckedSubBlocks(Item item, CreativeTabs tabs, List<ItemStack> itemStacks)
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
@SideOnly( Side.CLIENT )
public void getCheckedSubBlocks( Item item, CreativeTabs tabs, List<ItemStack> itemStacks )
{
super.getCheckedSubBlocks( item, tabs, itemStacks );
@@ -73,36 +103,9 @@ public class BlockEnergyCell extends AEBaseBlock
itemStacks.add( charged );
}
@Override
protected Class<? extends BaseBlockRender> getRenderer()
public double getMaxPower()
{
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 );
return 200000.0;
}
@Override
@@ -110,5 +113,4 @@ public class BlockEnergyCell extends AEBaseBlock
{
return AEBaseItemBlockChargeable.class;
}
}
@@ -39,10 +39,12 @@ import appeng.helpers.ICustomCollision;
import appeng.tile.networking.TileWireless;
import appeng.util.Platform;
public class BlockWireless extends AEBaseBlock implements ICustomCollision
{
public BlockWireless() {
public BlockWireless()
{
super( BlockWireless.class, AEGlassMaterial.INSTANCE );
this.setFeature( EnumSet.of( AEFeature.Core, AEFeature.WirelessAccessTerminal ) );
this.setTileEntity( TileWireless.class );
@@ -58,10 +60,26 @@ public class BlockWireless extends AEBaseBlock implements ICustomCollision
}
@Override
public Iterable<AxisAlignedBB> getSelectedBoundingBoxesFromPool(World w, int x, int y, int z, Entity e, boolean isVisual)
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 = this.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;
}
@Override
public Iterable<AxisAlignedBB> getSelectedBoundingBoxesFromPool( World w, int x, int y, int z, Entity e, boolean isVisual )
{
TileWireless tile = this.getTileEntity( w, x, y, z );
if ( tile != null )
if( tile != null )
{
ForgeDirection forward = tile.getForward();
@@ -72,46 +90,46 @@ public class BlockWireless extends AEBaseBlock implements ICustomCollision
double maxY = 1;
double maxZ = 1;
switch (forward)
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;
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 Collections.singletonList( AxisAlignedBB.getBoundingBox( minX, minY, minZ, maxX, maxY, maxZ ) );
@@ -120,10 +138,10 @@ public class BlockWireless extends AEBaseBlock implements ICustomCollision
}
@Override
public void addCollidingBlockToList(World w, int x, int y, int z, AxisAlignedBB bb, List<AxisAlignedBB> out, Entity e)
public void addCollidingBlockToList( World w, int x, int y, int z, AxisAlignedBB bb, List<AxisAlignedBB> out, Entity e )
{
TileWireless tile = this.getTileEntity( w, x, y, z );
if ( tile != null )
if( tile != null )
{
ForgeDirection forward = tile.getForward();
@@ -134,46 +152,46 @@ public class BlockWireless extends AEBaseBlock implements ICustomCollision
double maxY = 1;
double maxZ = 1;
switch (forward)
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;
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 ) );
@@ -181,21 +199,4 @@ public class BlockWireless extends AEBaseBlock implements ICustomCollision
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 = this.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;
}
}
@@ -46,10 +46,12 @@ import appeng.helpers.ICustomCollision;
import appeng.tile.qnb.TileQuantumBridge;
import appeng.util.Platform;
public class BlockQuantumLinkChamber extends AEBaseBlock implements ICustomCollision
{
public BlockQuantumLinkChamber() {
public BlockQuantumLinkChamber()
{
super( BlockQuantumLinkChamber.class, AEGlassMaterial.INSTANCE );
this.setFeature( EnumSet.of( AEFeature.QuantumNetworkBridge ) );
this.setTileEntity( TileQuantumBridge.class );
@@ -60,38 +62,28 @@ public class BlockQuantumLinkChamber extends AEBaseBlock implements ICustomColli
}
@Override
@SideOnly(Side.CLIENT)
public void randomDisplayTick(World w, int bx, int by, int bz, Random r)
@SideOnly( Side.CLIENT )
public void randomDisplayTick( World w, int bx, int by, int bz, Random r )
{
TileQuantumBridge bridge = this.getTileEntity( w, bx, by, bz );
if ( bridge != null )
if( bridge != null )
{
if ( bridge.hasQES() )
if( bridge.hasQES() )
{
if ( CommonHelper.proxy.shouldAddParticles( r ) )
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)
public void onNeighborBlockChange( World w, int x, int y, int z, Block pointlessNumber )
{
TileQuantumBridge bridge = this.getTileEntity( w, x, y, z );
if ( bridge != null )
if( bridge != null )
bridge.neighborUpdate();
}
@Override
public void breakBlock(World w, int x, int y, int z, Block a, int b)
{
TileQuantumBridge bridge = this.getTileEntity( w, x, y, z );
if ( bridge != null )
bridge.breakCluster();
super.breakBlock( w, x, y, z, a, b );
}
@Override
protected Class<? extends BaseBlockRender> getRenderer()
{
@@ -99,15 +91,15 @@ public class BlockQuantumLinkChamber extends AEBaseBlock implements ICustomColli
}
@Override
public boolean onActivated(World w, int x, int y, int z, EntityPlayer p, int side, float hitX, float hitY, float hitZ)
public boolean onActivated( World w, int x, int y, int z, EntityPlayer p, int side, float hitX, float hitY, float hitZ )
{
if ( p.isSneaking() )
if( p.isSneaking() )
return false;
TileQuantumBridge tg = this.getTileEntity( w, x, y, z );
if ( tg != null )
if( tg != null )
{
if ( Platform.isServer() )
if( Platform.isServer() )
Platform.openGUI( p, tg, ForgeDirection.getOrientation( side ), GuiBridge.GUI_QNB );
return true;
}
@@ -115,17 +107,26 @@ public class BlockQuantumLinkChamber extends AEBaseBlock implements ICustomColli
}
@Override
public Iterable<AxisAlignedBB> getSelectedBoundingBoxesFromPool(World w, int x, int y, int z, Entity e, boolean isVisual)
public void breakBlock( World w, int x, int y, int z, Block a, int b )
{
TileQuantumBridge bridge = this.getTileEntity( w, x, y, z );
if( bridge != null )
bridge.breakCluster();
super.breakBlock( w, x, y, z, a, b );
}
@Override
public Iterable<AxisAlignedBB> getSelectedBoundingBoxesFromPool( World w, int x, int y, int z, Entity e, boolean isVisual )
{
double OnePx = 2.0 / 16.0;
return Collections.singletonList( 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<AxisAlignedBB> out, Entity e)
public void addCollidingBlockToList( World w, int x, int y, int z, AxisAlignedBB bb, List<AxisAlignedBB> 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 ) );
}
}
@@ -36,10 +36,12 @@ import appeng.core.features.AEFeature;
import appeng.helpers.ICustomCollision;
import appeng.tile.qnb.TileQuantumBridge;
public class BlockQuantumRing extends AEBaseBlock implements ICustomCollision
{
public BlockQuantumRing() {
public BlockQuantumRing()
{
super( BlockQuantumRing.class, Material.iron );
this.setFeature( EnumSet.of( AEFeature.QuantumNetworkBridge ) );
this.setTileEntity( TileQuantumBridge.class );
@@ -50,23 +52,13 @@ public class BlockQuantumRing extends AEBaseBlock implements ICustomCollision
}
@Override
public void onNeighborBlockChange(World w, int x, int y, int z, Block pointlessNumber)
public void onNeighborBlockChange( World w, int x, int y, int z, Block pointlessNumber )
{
TileQuantumBridge bridge = this.getTileEntity( w, x, y, z );
if ( bridge != null )
if( bridge != null )
bridge.neighborUpdate();
}
@Override
public void breakBlock(World w, int x, int y, int z, Block a, int b)
{
TileQuantumBridge bridge = this.getTileEntity( w, x, y, z );
if ( bridge != null )
bridge.breakCluster();
super.breakBlock( w, x, y, z, a, b );
}
@Override
protected Class<? extends BaseBlockRender> getRenderer()
{
@@ -74,15 +66,25 @@ public class BlockQuantumRing extends AEBaseBlock implements ICustomCollision
}
@Override
public Iterable<AxisAlignedBB> getSelectedBoundingBoxesFromPool(World w, int x, int y, int z, Entity e, boolean isVisual)
public void breakBlock( World w, int x, int y, int z, Block a, int b )
{
TileQuantumBridge bridge = this.getTileEntity( w, x, y, z );
if( bridge != null )
bridge.breakCluster();
super.breakBlock( w, x, y, z, a, b );
}
@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 = this.getTileEntity( w, x, y, z );
if ( bridge != null && bridge.isCorner() )
if( bridge != null && bridge.isCorner() )
{
OnePx = 4.0 / 16.0;
}
else if ( bridge != null && bridge.isFormed() )
else if( bridge != null && bridge.isFormed() )
{
OnePx = 1.0 / 16.0;
}
@@ -90,19 +92,18 @@ public class BlockQuantumRing extends AEBaseBlock implements ICustomCollision
}
@Override
public void addCollidingBlockToList(World w, int x, int y, int z, AxisAlignedBB bb, List<AxisAlignedBB> out, Entity e)
public void addCollidingBlockToList( World w, int x, int y, int z, AxisAlignedBB bb, List<AxisAlignedBB> out, Entity e )
{
double OnePx = 2.0 / 16.0;
TileQuantumBridge bridge = this.getTileEntity( w, x, y, z );
if ( bridge != null && bridge.isCorner() )
if( bridge != null && bridge.isCorner() )
{
OnePx = 4.0 / 16.0;
}
else if ( bridge != null && bridge.isFormed() )
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 ) );
}
}
@@ -18,6 +18,7 @@
package appeng.block.solids;
import java.util.EnumSet;
import net.minecraft.block.material.Material;
@@ -25,12 +26,13 @@ import net.minecraft.block.material.Material;
import appeng.block.AEDecorativeBlock;
import appeng.core.features.AEFeature;
public class BlockQuartz extends AEDecorativeBlock
{
public BlockQuartz() {
public BlockQuartz()
{
super( BlockQuartz.class, Material.rock );
this.setFeature( EnumSet.of( AEFeature.DecorativeQuartzBlocks ) );
}
}
@@ -18,6 +18,7 @@
package appeng.block.solids;
import java.util.EnumSet;
import net.minecraft.block.material.Material;
@@ -25,12 +26,13 @@ import net.minecraft.block.material.Material;
import appeng.block.AEDecorativeBlock;
import appeng.core.features.AEFeature;
public class BlockQuartzChiseled extends AEDecorativeBlock
{
public BlockQuartzChiseled() {
public BlockQuartzChiseled()
{
super( BlockQuartzChiseled.class, Material.rock );
this.setFeature( EnumSet.of( AEFeature.DecorativeQuartzBlocks ) );
}
}
@@ -18,6 +18,7 @@
package appeng.block.solids;
import java.util.EnumSet;
import net.minecraft.block.material.Material;
@@ -32,37 +33,39 @@ import appeng.client.render.blocks.RenderQuartzGlass;
import appeng.core.features.AEFeature;
import appeng.helpers.AEGlassMaterial;
public class BlockQuartzGlass extends AEBaseBlock
{
public BlockQuartzGlass() {
public BlockQuartzGlass()
{
this( BlockQuartzGlass.class );
}
@Override
@SideOnly(Side.CLIENT)
public Class<? extends BaseBlockRender> getRenderer()
public BlockQuartzGlass( Class c )
{
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 );
this.setFeature( EnumSet.of( AEFeature.DecorativeQuartzBlocks ) );
this.setLightOpacity( 0 );
this.isOpaque = false;
}
@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 );
}
}
@@ -18,6 +18,7 @@
package appeng.block.solids;
import java.util.EnumSet;
import java.util.Random;
@@ -32,10 +33,12 @@ import appeng.core.AEConfig;
import appeng.core.CommonHelper;
import appeng.core.features.AEFeature;
public class BlockQuartzLamp extends BlockQuartzGlass
{
public BlockQuartzLamp() {
public BlockQuartzLamp()
{
super( BlockQuartzLamp.class );
this.setFeature( EnumSet.of( AEFeature.DecorativeQuartzBlocks, AEFeature.DecorativeLights ) );
this.setLightLevel( 1.0f );
@@ -43,22 +46,21 @@ public class BlockQuartzLamp extends BlockQuartzGlass
}
@Override
@SideOnly(Side.CLIENT)
public void randomDisplayTick(World w, int x, int y, int z, Random r)
@SideOnly( Side.CLIENT )
public void randomDisplayTick( World w, int x, int y, int z, Random r )
{
if ( !AEConfig.instance.enableEffects )
if( !AEConfig.instance.enableEffects )
return;
if ( CommonHelper.proxy.shouldAddParticles( r ) )
if( CommonHelper.proxy.shouldAddParticles( r ) )
{
double d0 = (r.nextFloat() - 0.5F) * 0.96D;
double d1 = (r.nextFloat() - 0.5F) * 0.96D;
double d2 = (r.nextFloat() - 0.5F) * 0.96D;
double d0 = ( r.nextFloat() - 0.5F ) * 0.96D;
double d1 = ( r.nextFloat() - 0.5F ) * 0.96D;
double d2 = ( 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( fx );
}
}
}
@@ -18,6 +18,7 @@
package appeng.block.solids;
import java.util.EnumSet;
import net.minecraft.block.material.Material;
@@ -29,24 +30,25 @@ import appeng.block.AEBaseBlock;
import appeng.core.features.AEFeature;
import appeng.helpers.MetaRotation;
public class BlockQuartzPillar extends AEBaseBlock implements IOrientableBlock
{
public BlockQuartzPillar() {
public BlockQuartzPillar()
{
super( BlockQuartzPillar.class, Material.rock );
this.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;
}
@Override
public IOrientable getOrientable( final IBlockAccess w, final int x, final int y, final int z )
{
return new MetaRotation( w, x, y, z );
}
}
@@ -18,6 +18,7 @@
package appeng.block.solids;
import java.util.EnumSet;
import java.util.List;
@@ -54,36 +55,22 @@ import appeng.integration.IntegrationType;
import appeng.integration.abstraction.IRB;
import appeng.util.Platform;
@RotatableBlockEnable
public class BlockSkyStone extends AEBaseBlock implements IOrientableBlock
{
@SideOnly(Side.CLIENT)
@SideOnly( Side.CLIENT )
IIcon Block;
@SideOnly(Side.CLIENT)
@SideOnly( Side.CLIENT )
IIcon Brick;
@SideOnly(Side.CLIENT)
@SideOnly( Side.CLIENT )
IIcon SmallBrick;
@SubscribeEvent
public void breakFaster(PlayerEvent.BreakSpeed Ev)
public BlockSkyStone()
{
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 );
this.setFeature( EnumSet.of( AEFeature.Core ) );
this.setHardness( 50 );
@@ -93,76 +80,28 @@ public class BlockSkyStone extends AEBaseBlock implements IOrientableBlock
MinecraftForge.EVENT_BUS.register( this );
}
@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;
}
}
@Override
public int damageDropped(int meta)
public int damageDropped( int meta )
{
return meta;
}
@Override
public String getUnlocalizedName(ItemStack is)
{
if ( is.getItemDamage() == 1 )
return this.getUnlocalizedName() + ".Block";
if ( is.getItemDamage() == 2 )
return this.getUnlocalizedName() + ".Brick";
if ( is.getItemDamage() == 3 )
return this.getUnlocalizedName() + ".SmallBrick";
return this.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 );
this.Block = ir.registerIcon( this.getTextureName() + ".Block" );
this.Brick = ir.registerIcon( this.getTextureName() + ".Brick" );
this.SmallBrick = ir.registerIcon( this.getTextureName() + ".SmallBrick" );
}
@Override
@SideOnly(Side.CLIENT)
public IIcon getIcon(int direction, int metadata)
{
if ( metadata == 1 )
return this.Block;
if ( metadata == 2 )
return this.Brick;
if ( metadata == 3 )
return this.SmallBrick;
return super.getIcon( direction, metadata );
}
@Override
public void setRenderStateByMeta(int metadata)
{
this.getRendererInstance().setTemporaryRenderIcon( this.getIcon( 0, metadata ) );
}
@Override
public ItemStack getPickBlock( MovingObjectPosition target, World world, int x, int y, int z, EntityPlayer player )
{
@@ -173,29 +112,10 @@ public class BlockSkyStone extends AEBaseBlock implements IOrientableBlock
}
@Override
@SideOnly(Side.CLIENT)
public void getCheckedSubBlocks(Item item, CreativeTabs tabs, List<ItemStack> itemStacks)
{
super.getCheckedSubBlocks( item, tabs, itemStacks );
itemStacks.add( new ItemStack( item, 1, 1 ) );
itemStacks.add( new ItemStack( item, 1, 2 ) );
itemStacks.add( new ItemStack( item, 1, 3 ) );
}
@Override
public void onBlockAdded(World w, int x, int y, int z)
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() )
if( Platform.isServer() )
WorldSettings.getInstance().getCompass().updateArea( w, x, y, z );
}
@@ -211,4 +131,86 @@ public class BlockSkyStone extends AEBaseBlock implements IOrientableBlock
return false;
}
@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
public String getUnlocalizedName( ItemStack is )
{
if( is.getItemDamage() == 1 )
return this.getUnlocalizedName() + ".Block";
if( is.getItemDamage() == 2 )
return this.getUnlocalizedName() + ".Brick";
if( is.getItemDamage() == 3 )
return this.getUnlocalizedName() + ".SmallBrick";
return this.getUnlocalizedName();
}
@Override
@SideOnly( Side.CLIENT )
public void registerBlockIcons( IIconRegister ir )
{
super.registerBlockIcons( ir );
this.Block = ir.registerIcon( this.getTextureName() + ".Block" );
this.Brick = ir.registerIcon( this.getTextureName() + ".Brick" );
this.SmallBrick = ir.registerIcon( this.getTextureName() + ".SmallBrick" );
}
@Override
@SideOnly( Side.CLIENT )
public IIcon getIcon( int direction, int metadata )
{
if( metadata == 1 )
return this.Block;
if( metadata == 2 )
return this.Brick;
if( metadata == 3 )
return this.SmallBrick;
return super.getIcon( direction, metadata );
}
@Override
public void setRenderStateByMeta( int metadata )
{
this.getRendererInstance().setTemporaryRenderIcon( this.getIcon( 0, metadata ) );
}
@Override
@SideOnly( Side.CLIENT )
public void getCheckedSubBlocks( Item item, CreativeTabs tabs, List<ItemStack> itemStacks )
{
super.getCheckedSubBlocks( item, tabs, itemStacks );
itemStacks.add( new ItemStack( item, 1, 1 ) );
itemStacks.add( new ItemStack( item, 1, 2 ) );
itemStacks.add( new ItemStack( item, 1, 3 ) );
}
@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 );
}
}
@@ -21,7 +21,6 @@ package appeng.block.solids;
import java.util.EnumSet;
import java.util.Random;
import javax.annotation.Nullable;
import net.minecraft.block.material.Material;
@@ -46,6 +45,11 @@ public class OreQuartz extends AEBaseBlock
private int boostBrightnessHigh;
private boolean enhanceBrightness;
public OreQuartz()
{
this( OreQuartz.class );
}
public OreQuartz( Class<? extends OreQuartz> self )
{
super( self, Material.rock );
@@ -57,27 +61,27 @@ public class OreQuartz extends AEBaseBlock
this.enhanceBrightness = false;
}
@Override
public void postInit()
{
OreDictionary.registerOre( "oreCertusQuartz", new ItemStack( this ) );
}
@Override
protected Class<? extends BaseBlockRender> getRenderer()
{
return RenderQuartzOre.class;
}
@Override
public void postInit()
{
OreDictionary.registerOre( "oreCertusQuartz", new ItemStack( this ) );
}
@Override
public int getMixedBrightnessForBlock( IBlockAccess par1iBlockAccess, int par2, int par3, int par4 )
{
int j1 = super.getMixedBrightnessForBlock( par1iBlockAccess, par2, par3, par4 );
if ( this.enhanceBrightness )
if( this.enhanceBrightness )
{
j1 = Math.max( j1 >> 20, j1 >> 4 );
if ( j1 > 4 )
if( j1 > 4 )
{
j1 += this.boostBrightnessHigh;
}
@@ -86,55 +90,63 @@ public class OreQuartz extends AEBaseBlock
j1 += this.boostBrightnessLow;
}
if ( j1 > 15 )
if( j1 > 15 )
j1 = 15;
return j1 << 20 | j1 << 4;
}
return j1;
}
public OreQuartz()
{
this( OreQuartz.class );
}
@Nullable
@Override
public Item getItemDropped( int id, Random rand, int meta )
{
for ( Item crystalItem : AEApi.instance().definitions().materials().certusQuartzCrystal().maybeItem().asSet() )
{
return crystalItem;
}
throw new MissingDefinition( "Tried to access certus quartz crystal, even though they are disabled" );
}
@Override
public int damageDropped( int id )
{
for ( ItemStack crystalStack : AEApi.instance().definitions().materials().certusQuartzCrystal().maybeStack( 1 ).asSet() )
{
return crystalStack.getItemDamage();
}
throw new MissingDefinition( "Tried to access certus quartz crystal, even though they are disabled" );
}
@Override
public int quantityDropped( Random rand )
{
return 1 + rand.nextInt( 2 );
}
@Nullable
@Override
public Item getItemDropped( int id, Random rand, int meta )
{
for( Item crystalItem : AEApi.instance().definitions().materials().certusQuartzCrystal().maybeItem().asSet() )
{
return crystalItem;
}
throw new MissingDefinition( "Tried to access certus quartz crystal, even though they are disabled" );
}
@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( this.getItemDropped( blockID, w.rand, meta ) != Item.getItemFromBlock( this ) )
{
int xp = MathHelper.getRandomIntegerInRange( w.rand, 2, 5 );
this.dropXpOnBlockBreak( w, x, y, z, xp );
}
}
@Override
public int damageDropped( int id )
{
for( ItemStack crystalStack : AEApi.instance().definitions().materials().certusQuartzCrystal().maybeStack( 1 ).asSet() )
{
return crystalStack.getItemDamage();
}
throw new MissingDefinition( "Tried to access certus quartz crystal, even though they are disabled" );
}
@Override
public int quantityDroppedWithBonus( int fortune, Random rand )
{
if ( fortune > 0 && Item.getItemFromBlock( this ) != this.getItemDropped( 0, rand, fortune ) )
if( fortune > 0 && Item.getItemFromBlock( this ) != this.getItemDropped( 0, rand, fortune ) )
{
int j = rand.nextInt( fortune + 2 ) - 1;
if ( j < 0 )
if( j < 0 )
{
j = 0;
}
@@ -147,19 +159,6 @@ public class OreQuartz extends AEBaseBlock
}
}
@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 ( this.getItemDropped( blockID, w.rand, meta ) != Item.getItemFromBlock( this ) )
{
int xp = MathHelper.getRandomIntegerInRange( w.rand, 2, 5 );
this.dropXpOnBlockBreak( w, x, y, z, xp );
}
}
public void setBoostBrightnessLow( int boostBrightnessLow )
{
this.boostBrightnessLow = boostBrightnessLow;
@@ -52,7 +52,7 @@ public class OreQuartzCharged extends OreQuartz
@Override
public Item getItemDropped( int id, Random rand, int meta )
{
for ( Item charged : AEApi.instance().definitions().materials().certusQuartzCrystalCharged().maybeItem().asSet() )
for( Item charged : AEApi.instance().definitions().materials().certusQuartzCrystalCharged().maybeItem().asSet() )
{
return charged;
}
@@ -82,7 +82,7 @@ public class OreQuartzCharged extends OreQuartz
double yOff = ( r.nextFloat() );
double zOff = ( r.nextFloat() );
switch ( r.nextInt( 6 ) )
switch( r.nextInt( 6 ) )
{
case 0:
xOff = -0.01;
@@ -107,11 +107,10 @@ public class OreQuartzCharged extends OreQuartz
break;
}
if ( CommonHelper.proxy.shouldAddParticles( r ) )
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( fx );
}
}
}
@@ -18,6 +18,7 @@
package appeng.block.spatial;
import java.util.Arrays;
import java.util.EnumSet;
import java.util.List;
@@ -42,6 +43,7 @@ import appeng.client.render.blocks.RenderNull;
import appeng.core.features.AEFeature;
import appeng.helpers.ICustomCollision;
public class BlockMatrixFrame extends AEBaseBlock implements ICustomCollision
{
@@ -62,47 +64,46 @@ public class BlockMatrixFrame extends AEBaseBlock implements ICustomCollision
}
@Override
@SideOnly(Side.CLIENT)
public void getCheckedSubBlocks(Item item, CreativeTabs tabs, List<ItemStack> itemStacks)
public void registerBlockIcons( IIconRegister iconRegistry )
{
}
@Override
@SideOnly( Side.CLIENT )
public void getCheckedSubBlocks( Item item, CreativeTabs tabs, List<ItemStack> itemStacks )
{
// do nothing
}
@Override
public void registerBlockIcons(IIconRegister iconRegistry)
{
}
@Override
public boolean canEntityDestroy(IBlockAccess world, int x, int y, int z, Entity entity)
{
return false;
}
@Override
public void onBlockExploded(World world, int x, int y, int z, Explosion explosion)
{
// Don't explode.
}
@Override
public Iterable<AxisAlignedBB> getSelectedBoundingBoxesFromPool(World w, int x, int y, int z, Entity e, boolean isVisual)
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<AxisAlignedBB> out, Entity e)
public void addCollidingBlockToList( World w, int x, int y, int z, AxisAlignedBB bb, List<AxisAlignedBB> out, Entity e )
{
out.add( AxisAlignedBB.getBoundingBox( 0.0, 0.0, 0.0, 1.0, 1.0, 1.0 ) );
}
@Override
public boolean canPlaceBlockAt(World world, int x, int y, int z)
public boolean canPlaceBlockAt( World world, int x, int y, int z )
{
return false;
}
@Override
public void onBlockExploded( World world, int x, int y, int z, Explosion explosion )
{
// Don't explode.
}
@Override
public boolean canEntityDestroy( IBlockAccess world, int x, int y, int z, Entity entity )
{
return false;
}
}
@@ -18,6 +18,7 @@
package appeng.block.spatial;
import java.util.EnumSet;
import net.minecraft.block.Block;
@@ -32,37 +33,38 @@ import appeng.core.sync.GuiBridge;
import appeng.tile.spatial.TileSpatialIOPort;
import appeng.util.Platform;
public class BlockSpatialIOPort extends AEBaseBlock
{
public BlockSpatialIOPort() {
public BlockSpatialIOPort()
{
super( BlockSpatialIOPort.class, Material.iron );
this.setFeature( EnumSet.of( AEFeature.SpatialIO ) );
this.setTileEntity( TileSpatialIOPort.class );
}
@Override
public final void onNeighborBlockChange(World w, int x, int y, int z, Block junk)
public final void onNeighborBlockChange( World w, int x, int y, int z, Block junk )
{
TileSpatialIOPort te = this.getTileEntity( w, x, y, z );
if ( te != null )
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)
public boolean onActivated( World w, int x, int y, int z, EntityPlayer p, int side, float hitX, float hitY, float hitZ )
{
if ( p.isSneaking() )
if( p.isSneaking() )
return false;
TileSpatialIOPort tg = this.getTileEntity( w, x, y, z );
if ( tg != null )
if( tg != null )
{
if ( Platform.isServer() )
if( Platform.isServer() )
Platform.openGUI( p, tg, ForgeDirection.getOrientation( side ), GuiBridge.GUI_SPATIAL_IO_PORT );
return true;
}
return false;
}
}
@@ -18,6 +18,7 @@
package appeng.block.spatial;
import java.util.EnumSet;
import net.minecraft.block.Block;
@@ -31,28 +32,30 @@ import appeng.core.features.AEFeature;
import appeng.helpers.AEGlassMaterial;
import appeng.tile.spatial.TileSpatialPylon;
public class BlockSpatialPylon extends AEBaseBlock
{
public BlockSpatialPylon() {
public BlockSpatialPylon()
{
super( BlockSpatialPylon.class, AEGlassMaterial.INSTANCE );
this.setFeature( EnumSet.of( AEFeature.SpatialIO ) );
this.setTileEntity( TileSpatialPylon.class );
}
@Override
public void onNeighborBlockChange(World w, int x, int y, int z, Block junk)
public void onNeighborBlockChange( World w, int x, int y, int z, Block junk )
{
TileSpatialPylon tsp = this.getTileEntity( w, x, y, z );
if ( tsp != null )
if( tsp != null )
tsp.onNeighborBlockChange();
}
@Override
public int getLightValue(IBlockAccess w, int x, int y, int z)
public int getLightValue( IBlockAccess w, int x, int y, int z )
{
TileSpatialPylon tsp = this.getTileEntity( w, x, y, z );
if ( tsp != null )
if( tsp != null )
return tsp.getLightValue();
return super.getLightValue( w, x, y, z );
}
@@ -62,5 +65,4 @@ public class BlockSpatialPylon extends AEBaseBlock
{
return RenderSpatialPylon.class;
}
}
@@ -18,6 +18,7 @@
package appeng.block.storage;
import java.util.EnumSet;
import net.minecraft.block.material.Material;
@@ -37,10 +38,12 @@ import appeng.core.sync.GuiBridge;
import appeng.tile.storage.TileChest;
import appeng.util.Platform;
public class BlockChest extends AEBaseBlock
{
public BlockChest() {
public BlockChest()
{
super( BlockChest.class, Material.iron );
this.setFeature( EnumSet.of( AEFeature.StorageCells, AEFeature.MEChest ) );
this.setTileEntity( TileChest.class );
@@ -53,22 +56,22 @@ public class BlockChest extends AEBaseBlock
}
@Override
public boolean onActivated(World w, int x, int y, int z, EntityPlayer p, int side, float hitX, float hitY, float hitZ)
public boolean onActivated( World w, int x, int y, int z, EntityPlayer p, int side, float hitX, float hitY, float hitZ )
{
TileChest tg = this.getTileEntity( w, x, y, z );
if ( tg != null && !p.isSneaking() )
if( tg != null && !p.isSneaking() )
{
if ( Platform.isClient() )
if( Platform.isClient() )
return true;
if ( side != tg.getUp().ordinal() )
if( side != tg.getUp().ordinal() )
{
Platform.openGUI( p, tg, ForgeDirection.getOrientation( side ), GuiBridge.GUI_CHEST );
}
else
{
ItemStack cell = tg.getStackInSlot( 1 );
if ( cell != null )
if( cell != null )
{
ICellHandler ch = AEApi.instance().registries().cell().getHandler( cell );
@@ -18,6 +18,7 @@
package appeng.block.storage;
import java.util.EnumSet;
import net.minecraft.block.material.Material;
@@ -33,10 +34,12 @@ import appeng.core.sync.GuiBridge;
import appeng.tile.storage.TileDrive;
import appeng.util.Platform;
public class BlockDrive extends AEBaseBlock
{
public BlockDrive() {
public BlockDrive()
{
super( BlockDrive.class, Material.iron );
this.setFeature( EnumSet.of( AEFeature.StorageCells, AEFeature.MEDrive ) );
this.setTileEntity( TileDrive.class );
@@ -49,19 +52,18 @@ public class BlockDrive extends AEBaseBlock
}
@Override
public boolean onActivated(World w, int x, int y, int z, EntityPlayer p, int side, float hitX, float hitY, float hitZ)
public boolean onActivated( World w, int x, int y, int z, EntityPlayer p, int side, float hitX, float hitY, float hitZ )
{
if ( p.isSneaking() )
if( p.isSneaking() )
return false;
TileDrive tg = this.getTileEntity( w, x, y, z );
if ( tg != null )
if( tg != null )
{
if ( Platform.isServer() )
if( Platform.isServer() )
Platform.openGUI( p, tg, ForgeDirection.getOrientation( side ), GuiBridge.GUI_DRIVE );
return true;
}
return false;
}
}
@@ -18,6 +18,7 @@
package appeng.block.storage;
import java.util.EnumSet;
import net.minecraft.block.Block;
@@ -32,33 +33,35 @@ import appeng.core.sync.GuiBridge;
import appeng.tile.storage.TileIOPort;
import appeng.util.Platform;
public class BlockIOPort extends AEBaseBlock
{
public BlockIOPort() {
public BlockIOPort()
{
super( BlockIOPort.class, Material.iron );
this.setFeature( EnumSet.of( AEFeature.StorageCells, AEFeature.IOPort ) );
this.setTileEntity( TileIOPort.class );
}
@Override
public final void onNeighborBlockChange(World w, int x, int y, int z, Block junk)
public final void onNeighborBlockChange( World w, int x, int y, int z, Block junk )
{
TileIOPort te = this.getTileEntity( w, x, y, z );
if ( te != null )
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)
public boolean onActivated( World w, int x, int y, int z, EntityPlayer p, int side, float hitX, float hitY, float hitZ )
{
if ( p.isSneaking() )
if( p.isSneaking() )
return false;
TileIOPort tg = this.getTileEntity( w, x, y, z );
if ( tg != null )
if( tg != null )
{
if ( Platform.isServer() )
if( Platform.isServer() )
Platform.openGUI( p, tg, ForgeDirection.getOrientation( side ), GuiBridge.GUI_IOPORT );
return true;
}
@@ -51,10 +51,12 @@ import appeng.helpers.ICustomCollision;
import appeng.tile.storage.TileSkyChest;
import appeng.util.Platform;
public class BlockSkyChest extends AEBaseBlock implements ICustomCollision
{
public BlockSkyChest() {
public BlockSkyChest()
{
super( BlockSkyChest.class, Material.rock );
this.setFeature( EnumSet.of( AEFeature.Core, AEFeature.SkyStoneChests ) );
this.setTileEntity( TileSkyChest.class );
@@ -66,31 +68,11 @@ public class BlockSkyChest extends AEBaseBlock implements ICustomCollision
}
@Override
public String getUnlocalizedName(ItemStack is)
public int damageDropped( int metadata )
{
if ( is.getItemDamage() == 1 )
return this.getUnlocalizedName() + ".Block";
return this.getUnlocalizedName();
}
@Override
public int damageDropped(int metadata) {
return metadata;
}
@Override
@SideOnly(Side.CLIENT)
public IIcon getIcon(int direction, int metadata)
{
for ( Block skyStoneBlock : AEApi.instance().definitions().blocks().skyStone().maybeBlock().asSet() )
{
return skyStoneBlock.getIcon( direction, metadata );
}
return Blocks.stone.getIcon( direction, metadata );
}
@Override
public ItemStack getPickBlock( MovingObjectPosition target, World world, int x, int y, int z, EntityPlayer player )
{
@@ -101,8 +83,40 @@ public class BlockSkyChest extends AEBaseBlock implements ICustomCollision
}
@Override
@SideOnly(Side.CLIENT)
public void getCheckedSubBlocks(Item item, CreativeTabs tabs, List<ItemStack> itemStacks)
protected Class<? extends BaseBlockRender> getRenderer()
{
return RenderBlockSkyChest.class;
}
@Override
@SideOnly( Side.CLIENT )
public IIcon getIcon( int direction, int metadata )
{
for( Block skyStoneBlock : AEApi.instance().definitions().blocks().skyStone().maybeBlock().asSet() )
{
return skyStoneBlock.getIcon( direction, metadata );
}
return Blocks.stone.getIcon( direction, metadata );
}
@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, this.getTileEntity( w, x, y, z ), ForgeDirection.getOrientation( side ), GuiBridge.GUI_SKYCHEST );
return true;
}
@Override
public void registerBlockIcons( IIconRegister iconRegistry )
{
}
@Override
@SideOnly( Side.CLIENT )
public void getCheckedSubBlocks( Item item, CreativeTabs tabs, List<ItemStack> itemStacks )
{
super.getCheckedSubBlocks( item, tabs, itemStacks );
@@ -110,28 +124,22 @@ public class BlockSkyChest extends AEBaseBlock implements ICustomCollision
}
@Override
public boolean onActivated(World w, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ)
public String getUnlocalizedName( ItemStack is )
{
if ( Platform.isServer() )
Platform.openGUI( player, this.getTileEntity( w, x, y, z ), ForgeDirection.getOrientation( side ), GuiBridge.GUI_SKYCHEST );
if( is.getItemDamage() == 1 )
return this.getUnlocalizedName() + ".Block";
return true;
return this.getUnlocalizedName();
}
@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)
public Iterable<AxisAlignedBB> getSelectedBoundingBoxesFromPool( World w, int x, int y, int z, Entity e, boolean isVisual )
{
TileSkyChest sk = this.getTileEntity( w, x, y, z );
double sc = 0.06;
ForgeDirection o = ForgeDirection.UNKNOWN;
if ( sk != null )
if( sk != null )
o = sk.getUp();
double X = o.offsetX == 0 ? 0.06 : 0.0;
@@ -142,13 +150,8 @@ public class BlockSkyChest extends AEBaseBlock implements ICustomCollision
}
@Override
public void addCollidingBlockToList(World w, int x, int y, int z, AxisAlignedBB bb, List<AxisAlignedBB> out, Entity e)
public void addCollidingBlockToList( World w, int x, int y, int z, AxisAlignedBB bb, List<AxisAlignedBB> 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)
{
}
}
+220 -219
View File
@@ -18,6 +18,7 @@
package appeng.client;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
@@ -86,64 +87,178 @@ import appeng.util.Platform;
import static net.minecraftforge.client.IItemRenderer.ItemRenderType.ENTITY;
import static net.minecraftforge.client.IItemRenderer.ItemRendererHelper.BLOCK_3D;
public class ClientHelper extends ServerHelper
{
private static final RenderItem ITEM_RENDERER = new RenderItem();
private static final RenderBlocks BLOCK_RENDERER = new RenderBlocks();
@Override
public CableRenderMode getRenderMode()
{
if ( Platform.isServer() )
return super.getRenderMode();
Minecraft mc = Minecraft.getMinecraft();
EntityPlayer player = mc.thePlayer;
return this.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)
public void postPlayerRender( RenderLivingEvent.Pre p )
{
PlayerColor player = TickHandler.INSTANCE.getPlayerColors().get( p.entity.getEntityId() );
if ( player != null )
if( player != null )
{
AEColor col = player.myColor;
float r = 0xff & (col.mediumVariant >> 16);
float g = 0xff & (col.mediumVariant >> 8);
float b = 0xff & (col.mediumVariant);
float r = 0xff & ( col.mediumVariant >> 16 );
float g = 0xff & ( col.mediumVariant >> 8 );
float b = 0xff & ( col.mediumVariant );
GL11.glColor3f( r / 255.0f, g / 255.0f, b / 255.0f );
}
}
@Override
public void doRenderItem(ItemStack itemstack, World w)
public void init()
{
if ( itemstack != null )
MinecraftForge.EVENT_BUS.register( this );
}
@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<EntityPlayer>();
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:
this.spawnAssembler( worldObj, posX, posY, posZ, o );
return;
case Vibrant:
this.spawnVibrant( worldObj, posX, posY, posZ );
return;
case Crafting:
this.spawnCrafting( worldObj, posX, posY, posZ );
return;
case Energy:
this.spawnEnergy( worldObj, posX, posY, posZ );
return;
case Lightning:
this.spawnLightning( worldObj, posX, posY, posZ );
return;
case LightningArc:
this.spawnLightningArc( worldObj, posX, posY, posZ, (Vec3) o );
return;
default:
}
}
}
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( fx );
}
private void spawnVibrant( World w, double x, double y, double z )
{
if( CommonHelper.proxy.shouldAddParticles( Platform.getRandom() ) )
{
double d0 = ( Platform.getRandomFloat() - 0.5F ) * 0.26D;
double d1 = ( Platform.getRandomFloat() - 0.5F ) * 0.26D;
double d2 = ( 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( 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( 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( 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( 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( 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 doRenderItem( ItemStack itemstack, World w )
{
if( itemstack != null )
{
EntityItem entityitem = new EntityItem( w, 0.0D, 0.0D, 0.0D, itemstack );
entityitem.getEntityItem().stackSize = 1;
@@ -158,7 +273,7 @@ public class ClientHelper extends ServerHelper
GL11.glColor4f( 1.0F, 1.0F, 1.0F, 1.0F );
// GL11.glDisable( GL11.GL_CULL_FACE );
if ( itemstack.isItemEnchanted() || itemstack.getItem().requiresMultipleRenderPasses() )
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 );
@@ -167,7 +282,7 @@ public class ClientHelper extends ServerHelper
// GL11.glScalef( 1.0f , -1.0f, 1.0f );
Block block = Block.getBlockFromItem( itemstack.getItem() );
if ( (itemstack.getItemSpriteNumber() == 0 && block != null && RenderBlocks.renderItemIn3d( block.getRenderType() )) )
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 );
@@ -175,9 +290,9 @@ public class ClientHelper extends ServerHelper
}
IItemRenderer customRenderer = MinecraftForgeClient.getItemRenderer( itemstack, ENTITY );
if ( customRenderer != null && !(itemstack.getItem() instanceof ItemBlock) )
if( customRenderer != null && !( itemstack.getItem() instanceof ItemBlock ) )
{
if ( customRenderer.shouldUseRenderHelper( ENTITY, itemstack, BLOCK_3D ) )
if( customRenderer.shouldUseRenderHelper( ENTITY, itemstack, BLOCK_3D ) )
{
GL11.glTranslatef( 0, -0.04F, 0 );
GL11.glScalef( 0.7f, 0.7f, 0.7f );
@@ -186,7 +301,7 @@ public class ClientHelper extends ServerHelper
GL11.glRotatef( -90, 0, 1, 0 );
}
}
else if ( itemstack.getItem() instanceof ItemBlock )
else if( itemstack.getItem() instanceof ItemBlock )
{
GL11.glTranslatef( 0, -0.04F, 0 );
GL11.glScalef( 1.1f, 1.1f, 1.1f );
@@ -210,7 +325,7 @@ public class ClientHelper extends ServerHelper
RenderItem.renderInFrame = false;
FontRenderer fr = Minecraft.getMinecraft().fontRenderer;
if ( !ForgeHooksClient.renderInventoryItem( BLOCK_RENDERER, Minecraft.getMinecraft().renderEngine, itemstack, true, 0, 0, 0 ) )
if( !ForgeHooksClient.renderInventoryItem( BLOCK_RENDERER, Minecraft.getMinecraft().renderEngine, itemstack, true, 0, 0, 0 ) )
{
ITEM_RENDERER.renderItemIntoGUI( fr, Minecraft.getMinecraft().renderEngine, itemstack, 0, 0, false );
}
@@ -220,12 +335,6 @@ public class ClientHelper extends ServerHelper
}
}
@Override
public void init()
{
MinecraftForge.EVENT_BUS.register( this );
}
@Override
public void postInit()
{
@@ -234,187 +343,37 @@ public class ClientHelper extends ServerHelper
RenderManager.instance.entityRenderMap.put( EntityFloatingItem.class, new RenderFloatingItem() );
}
@SubscribeEvent
public void wheelEvent(MouseEvent me)
@Override
public CableRenderMode getRenderMode()
{
if ( me.isCanceled() || me.dwheel == 0 )
return;
if( Platform.isServer() )
return super.getRenderMode();
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 );
}
return this.renderModeForPlayer( player );
}
@Override
public World getWorld()
public void triggerUpdates()
{
if ( Platform.isClient() )
return Minecraft.getMinecraft().theWorld;
else
return super.getWorld();
}
Minecraft mc = Minecraft.getMinecraft();
if( mc == null || mc.thePlayer == null || mc.theWorld == null )
return;
@Override
public void bindTileEntitySpecialRenderer(Class tile, AEBaseBlock blk)
{
BaseBlockRender bbr = blk.getRendererInstance().rendererInstance;
if ( bbr.hasTESR() && tile != null )
ClientRegistry.bindTileEntitySpecialRenderer( tile, new TESRWrapper( bbr ) );
}
EntityPlayer player = mc.thePlayer;
@Override
public List<EntityPlayer> getPlayers()
{
if ( Platform.isClient() )
{
List<EntityPlayer> o = new ArrayList<EntityPlayer>();
o.add( Minecraft.getMinecraft().thePlayer );
return o;
}
else
return super.getPlayers();
}
if( player == null )
return;
@Override
public void spawnEffect(EffectType effect, World worldObj, double posX, double posY, double posZ, Object o)
{
if ( AEConfig.instance.enableEffects )
{
switch (effect)
{
case Assembler:
this.spawnAssembler( worldObj, posX, posY, posZ, o );
return;
case Vibrant:
this.spawnVibrant( worldObj, posX, posY, posZ );
return;
case Crafting:
this.spawnCrafting( worldObj, posX, posY, posZ );
return;
case Energy:
this.spawnEnergy( worldObj, posX, posY, posZ );
return;
case Lightning:
this.spawnLightning( worldObj, posX, posY, posZ );
return;
case LightningArc:
this.spawnLightningArc( worldObj, posX, posY, posZ, (Vec3) o );
return;
default:
}
}
}
int x = (int) player.posX;
int y = (int) player.posY;
int z = (int) player.posZ;
private void spawnAssembler(World worldObj, double posX, double posY, double posZ, Object o)
{
PacketAssemblerAnimation paa = (PacketAssemblerAnimation) o;
int range = 16 * 16;
AssemblerFX fx = new AssemblerFX( Minecraft.getMinecraft().theWorld, posX, posY, posZ, 0.0D, 0.0D, 0.0D, paa.rate, paa.is );
Minecraft.getMinecraft().effectRenderer.addEffect( fx );
}
private void spawnVibrant(World w, double x, double y, double z)
{
if ( CommonHelper.proxy.shouldAddParticles( Platform.getRandom() ) )
{
double d0 = (Platform.getRandomFloat() - 0.5F) * 0.26D;
double d1 = (Platform.getRandomFloat() - 0.5F) * 0.26D;
double d2 = (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( 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( 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( 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( 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( 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;
mc.theWorld.markBlockRangeForRenderUpdate( x - range, y - range, z - range, x + range, y + range, z + range );
}
@Override
@@ -423,4 +382,46 @@ public class ClientHelper extends ServerHelper
throw new MissingCoreMod();
}
@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 );
}
}
}
@@ -18,6 +18,7 @@
package appeng.client;
public enum EffectType
{
Energy, Lightning, Vibrant, Crafting, Assembler, LightningArc
+15 -15
View File
@@ -613,6 +613,21 @@ public abstract class AEBaseGui extends GuiContainer
this.subGui = true; // in case the gui is reopened later ( i'm looking at you NEI )
}
protected Slot getSlot( int mouseX, int mouseY )
{
final List<Slot> slots = this.getInventorySlots();
for( Slot slot : slots )
{
// isPointInRegion
if( this.func_146978_c( slot.xDisplayPosition, slot.yDisplayPosition, 16, 16, mouseX, mouseY ) )
{
return slot;
}
}
return null;
}
public abstract void drawBG( int offsetX, int offsetY, int mouseX, int mouseY );
@Override
@@ -652,21 +667,6 @@ public abstract class AEBaseGui extends GuiContainer
}
}
protected Slot getSlot( int mouseX, int mouseY )
{
final List<Slot> slots = this.getInventorySlots();
for( Slot slot : slots )
{
// isPointInRegion
if( this.func_146978_c( slot.xDisplayPosition, slot.yDisplayPosition, 16, 16, mouseX, mouseY ) )
{
return slot;
}
}
return null;
}
protected boolean enableSpaceClicking()
{
return true;
@@ -18,6 +18,7 @@
package appeng.client.gui;
import java.text.NumberFormat;
import java.util.List;
import java.util.Locale;
@@ -30,19 +31,21 @@ 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) {
public AEBaseMEGui( Container container )
{
super( container );
}
public List<String> handleItemTooltip(ItemStack stack, int mouseX, int mouseY, List<String> currentToolTip)
public List<String> handleItemTooltip( ItemStack stack, int mouseX, int mouseY, List<String> currentToolTip )
{
if ( stack != null )
if( stack != null )
{
Slot s = this.getSlot( mouseX, mouseY );
if ( s instanceof SlotME )
if( s instanceof SlotME )
{
int BigNumber = AEConfig.instance.useTerminalUseLargeFont() ? 999 : 9999;
@@ -53,19 +56,19 @@ public abstract class AEBaseMEGui extends AEBaseGui
SlotME theSlotField = (SlotME) s;
myStack = theSlotField.getAEStack();
}
catch (Throwable ignore)
catch( Throwable ignore )
{
}
if ( myStack != null )
if( myStack != null )
{
if ( myStack.getStackSize() > BigNumber || (myStack.getStackSize() > 1 && stack.isItemDamaged()) )
if( myStack.getStackSize() > BigNumber || ( myStack.getStackSize() > 1 && stack.isItemDamaged() ) )
currentToolTip.add( "\u00a77Items Stored: " + NumberFormat.getNumberInstance( Locale.US ).format( myStack.getStackSize() ) );
if ( myStack.getCountRequestable() > 0 )
if( myStack.getCountRequestable() > 0 )
currentToolTip.add( "\u00a77Items Requestable: " + NumberFormat.getNumberInstance( Locale.US ).format( myStack.getCountRequestable() ) );
}
else if ( stack.stackSize > BigNumber || (stack.stackSize > 1 && stack.isItemDamaged()) )
else if( stack.stackSize > BigNumber || ( stack.stackSize > 1 && stack.isItemDamaged() ) )
{
currentToolTip.add( "\u00a77Items Stored: " + NumberFormat.getNumberInstance( Locale.US ).format( stack.stackSize ) );
}
@@ -77,10 +80,10 @@ public abstract class AEBaseMEGui extends AEBaseGui
// Vanilla version...
// protected void drawItemStackTooltip(ItemStack stack, int x, int y)
@Override
protected void renderToolTip(ItemStack stack, int x, int y)
protected void renderToolTip( ItemStack stack, int x, int y )
{
Slot s = this.getSlot( x, y );
if ( s instanceof SlotME && stack != null )
if( s instanceof SlotME && stack != null )
{
int BigNumber = AEConfig.instance.useTerminalUseLargeFont() ? 999 : 9999;
@@ -91,24 +94,24 @@ public abstract class AEBaseMEGui extends AEBaseGui
SlotME theSlotField = (SlotME) s;
myStack = theSlotField.getAEStack();
}
catch (Throwable ignore)
catch( Throwable ignore )
{
}
if ( myStack != null )
if( myStack != null )
{
@SuppressWarnings( "unchecked" )
List<String> currentToolTip = stack.getTooltip( this.mc.thePlayer, this.mc.gameSettings.advancedItemTooltips );
if ( myStack.getStackSize() > BigNumber || (myStack.getStackSize() > 1 && stack.isItemDamaged()) )
if( myStack.getStackSize() > BigNumber || ( myStack.getStackSize() > 1 && stack.isItemDamaged() ) )
currentToolTip.add( "Items Stored: " + NumberFormat.getNumberInstance( Locale.US ).format( myStack.getStackSize() ) );
if ( myStack.getCountRequestable() > 0 )
if( myStack.getCountRequestable() > 0 )
currentToolTip.add( "Items Requestable: " + NumberFormat.getNumberInstance( Locale.US ).format( myStack.getCountRequestable() ) );
this.drawTooltip( x, y, 0, join( currentToolTip, "\n" ) );
}
else if ( stack.stackSize > BigNumber )
else if( 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 ) );
@@ -119,5 +122,4 @@ public abstract class AEBaseMEGui extends AEBaseGui
super.renderToolTip( stack, x, y );
// super.drawItemStackTooltip( stack, x, y );
}
}
+7 -5
View File
@@ -18,24 +18,26 @@
package appeng.client.gui;
import net.minecraft.inventory.Container;
public class GuiNull extends AEBaseGui
{
public GuiNull(Container container) {
public GuiNull( Container container )
{
super( container );
}
@Override
public void drawBG(int offsetX, int offsetY, int mouseX, int mouseY)
public void drawFG( int offsetX, int offsetY, int mouseX, int mouseY )
{
}
@Override
public void drawFG(int offsetX, int offsetY, int mouseX, int mouseY)
public void drawBG( int offsetX, int offsetY, int mouseX, int mouseY )
{
}
}
}
@@ -32,24 +32,30 @@ import cpw.mods.fml.client.config.IConfigElement;
import appeng.core.AEConfig;
import appeng.core.AppEng;
public class AEConfigGui extends GuiConfig
{
public AEConfigGui( GuiScreen parent )
{
super( parent, getConfigElements(), AppEng.MOD_ID, false, false, GuiConfig.getAbridgedConfigPath( AEConfig.instance.getFilePath() ) );
}
private static List<IConfigElement> getConfigElements()
{
List<IConfigElement> list = new ArrayList<IConfigElement>();
for (String cat : AEConfig.instance.getCategoryNames())
for( String cat : AEConfig.instance.getCategoryNames() )
{
if ( cat.equals( "versionchecker" ) )
if( cat.equals( "versionchecker" ) )
continue;
if ( cat.equals( "settings" ) )
if( cat.equals( "settings" ) )
continue;
ConfigCategory cc = AEConfig.instance.getCategory( cat );
if ( cc.isChild() )
if( cc.isChild() )
continue;
ConfigElement ce = new ConfigElement( cc );
@@ -58,9 +64,4 @@ public class AEConfigGui extends GuiConfig
return list;
}
public AEConfigGui(GuiScreen parent) {
super( parent, getConfigElements(), AppEng.MOD_ID, false, false, GuiConfig.getAbridgedConfigPath( AEConfig.instance.getFilePath() ) );
}
}
@@ -18,6 +18,7 @@
package appeng.client.gui.config;
import java.util.Set;
import net.minecraft.client.Minecraft;
@@ -25,11 +26,12 @@ import net.minecraft.client.gui.GuiScreen;
import cpw.mods.fml.client.IModGuiFactory;
public class AEConfigGuiFactory implements IModGuiFactory
{
@Override
public void initialize(Minecraft minecraftInstance)
public void initialize( Minecraft minecraftInstance )
{
}
@@ -47,9 +49,8 @@ public class AEConfigGuiFactory implements IModGuiFactory
}
@Override
public RuntimeOptionGuiHandler getHandlerFor(RuntimeOptionCategoryElement element)
public RuntimeOptionGuiHandler getHandlerFor( RuntimeOptionCategoryElement element )
{
return null;
}
}
@@ -18,6 +18,7 @@
package appeng.client.gui.implementations;
import java.io.IOException;
import org.lwjgl.input.Mouse;
@@ -42,6 +43,7 @@ import appeng.core.sync.packets.PacketValueConfig;
import appeng.tile.misc.TileCellWorkbench;
import appeng.util.Platform;
public class GuiCellWorkbench extends GuiUpgradeable
{
@@ -52,100 +54,14 @@ public class GuiCellWorkbench extends GuiUpgradeable
GuiImgButton partition;
GuiToggleButton copyMode;
public GuiCellWorkbench(InventoryPlayer inventoryPlayer, TileCellWorkbench te) {
public GuiCellWorkbench( InventoryPlayer inventoryPlayer, TileCellWorkbench te )
{
super( new ContainerCellWorkbench( inventoryPlayer, te ) );
this.workbench = (ContainerCellWorkbench) this.inventorySlots;
this.ySize = 251;
this.tcw = te;
}
@Override
protected boolean drawUpgrades()
{
return this.workbench.availableUpgrades() > 0;
}
@Override
public void drawBG(int offsetX, int offsetY, int mouseX, int mouseY)
{
this.handleButtonVisibility();
this.bindTexture( this.getBackground() );
this.drawTexturedModalRect( offsetX, offsetY, 0, 0, 211 - 34, this.ySize );
if ( this.drawUpgrades() )
{
if ( this.workbench.availableUpgrades() <= 8 )
{
this.drawTexturedModalRect( offsetX + 177, offsetY, 177, 0, 35, 7 + this.workbench.availableUpgrades() * 18 );
this.drawTexturedModalRect( offsetX + 177, offsetY + (7 + (this.workbench.availableUpgrades()) * 18), 177, 151, 35, 7 );
}
else if ( this.workbench.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 = this.workbench.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 = this.workbench.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 ( this.hasToolbox() )
this.drawTexturedModalRect( offsetX + 178, offsetY + this.ySize - 90, 178, 161, 68, 68 );
}
@Override
protected void actionPerformed(GuiButton btn)
{
try
{
if ( btn == this.copyMode )
{
NetworkHandler.instance.sendToServer( new PacketValueConfig( "CellWorkbench.Action", "CopyMode" ) );
}
else if ( btn == this.partition )
{
NetworkHandler.instance.sendToServer( new PacketValueConfig( "CellWorkbench.Action", "Partition" ) );
}
else if ( btn == this.clear )
{
NetworkHandler.instance.sendToServer( new PacketValueConfig( "CellWorkbench.Action", "Clear" ) );
}
else if ( btn == this.fuzzyMode )
{
boolean backwards = Mouse.isButtonDown( 1 );
FuzzyMode fz = (FuzzyMode) this.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 ignored)
{
}
}
@Override
protected void addButtons()
{
@@ -160,6 +76,52 @@ public class GuiCellWorkbench extends GuiUpgradeable
this.buttonList.add( this.copyMode );
}
@Override
public void drawBG( int offsetX, int offsetY, int mouseX, int mouseY )
{
this.handleButtonVisibility();
this.bindTexture( this.getBackground() );
this.drawTexturedModalRect( offsetX, offsetY, 0, 0, 211 - 34, this.ySize );
if( this.drawUpgrades() )
{
if( this.workbench.availableUpgrades() <= 8 )
{
this.drawTexturedModalRect( offsetX + 177, offsetY, 177, 0, 35, 7 + this.workbench.availableUpgrades() * 18 );
this.drawTexturedModalRect( offsetX + 177, offsetY + ( 7 + ( this.workbench.availableUpgrades() ) * 18 ), 177, 151, 35, 7 );
}
else if( this.workbench.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 = this.workbench.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 = this.workbench.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( this.hasToolbox() )
this.drawTexturedModalRect( offsetX + 178, offsetY + this.ySize - 90, 178, 161, 68, 68 );
}
@Override
protected void handleButtonVisibility()
{
@@ -167,12 +129,12 @@ public class GuiCellWorkbench extends GuiUpgradeable
boolean hasFuzzy = false;
IInventory inv = this.workbench.getCellUpgradeInventory();
for (int x = 0; x < inv.getSizeInventory(); x++)
for( int x = 0; x < inv.getSizeInventory(); x++ )
{
ItemStack is = inv.getStackInSlot( x );
if ( is != null && is.getItem() instanceof IUpgradeModule )
if( is != null && is.getItem() instanceof IUpgradeModule )
{
if ( ((IUpgradeModule) is.getItem()).getType( is ) == Upgrades.FUZZY )
if( ( (IUpgradeModule) is.getItem() ).getType( is ) == Upgrades.FUZZY )
hasFuzzy = true;
}
}
@@ -185,9 +147,49 @@ public class GuiCellWorkbench extends GuiUpgradeable
return "guis/cellworkbench.png";
}
@Override
protected boolean drawUpgrades()
{
return this.workbench.availableUpgrades() > 0;
}
@Override
protected GuiText getName()
{
return GuiText.CellWorkbench;
}
@Override
protected void actionPerformed( GuiButton btn )
{
try
{
if( btn == this.copyMode )
{
NetworkHandler.instance.sendToServer( new PacketValueConfig( "CellWorkbench.Action", "CopyMode" ) );
}
else if( btn == this.partition )
{
NetworkHandler.instance.sendToServer( new PacketValueConfig( "CellWorkbench.Action", "Partition" ) );
}
else if( btn == this.clear )
{
NetworkHandler.instance.sendToServer( new PacketValueConfig( "CellWorkbench.Action", "Clear" ) );
}
else if( btn == this.fuzzyMode )
{
boolean backwards = Mouse.isButtonDown( 1 );
FuzzyMode fz = (FuzzyMode) this.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 ignored )
{
}
}
}
@@ -18,6 +18,7 @@
package appeng.client.gui.implementations;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.entity.player.InventoryPlayer;
@@ -30,17 +31,24 @@ import appeng.core.sync.network.NetworkHandler;
import appeng.core.sync.packets.PacketSwitchGuis;
import appeng.tile.storage.TileChest;
public class GuiChest extends AEBaseGui
{
GuiTabButton priority;
public GuiChest( InventoryPlayer inventoryPlayer, TileChest te )
{
super( new ContainerChest( inventoryPlayer, te ) );
this.ySize = 166;
}
@Override
protected void actionPerformed(GuiButton par1GuiButton)
protected void actionPerformed( GuiButton par1GuiButton )
{
super.actionPerformed( par1GuiButton );
if ( par1GuiButton == this.priority )
if( par1GuiButton == this.priority )
{
NetworkHandler.instance.sendToServer( new PacketSwitchGuis( GuiBridge.GUI_PRIORITY ) );
}
@@ -54,23 +62,17 @@ public class GuiChest extends AEBaseGui
this.buttonList.add( this.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)
{
this.bindTexture( "guis/chest.png" );
this.drawTexturedModalRect( offsetX, offsetY, 0, 0, this.xSize, this.ySize );
}
@Override
public void drawFG(int offsetX, int offsetY, int mouseX, int mouseY)
public void drawFG( int offsetX, int offsetY, int mouseX, int mouseY )
{
this.fontRendererObj.drawString( this.getGuiDisplayName( GuiText.Chest.getLocal() ), 8, 6, 4210752 );
this.fontRendererObj.drawString( GuiText.inventory.getLocal(), 8, this.ySize - 96 + 3, 4210752 );
}
@Override
public void drawBG( int offsetX, int offsetY, int mouseX, int mouseY )
{
this.bindTexture( "guis/chest.png" );
this.drawTexturedModalRect( offsetX, offsetY, 0, 0, this.xSize, this.ySize );
}
}
@@ -35,6 +35,7 @@ import appeng.core.sync.network.NetworkHandler;
import appeng.core.sync.packets.PacketConfigButton;
import appeng.tile.misc.TileCondenser;
public class GuiCondenser extends AEBaseGui
{
@@ -42,7 +43,7 @@ public class GuiCondenser extends AEBaseGui
GuiProgressBar pb;
GuiImgButton mode;
public GuiCondenser(InventoryPlayer inventoryPlayer, TileCondenser te)
public GuiCondenser( InventoryPlayer inventoryPlayer, TileCondenser te )
{
super( new ContainerCondenser( inventoryPlayer, te ) );
this.cvc = (ContainerCondenser) this.inventorySlots;
@@ -50,13 +51,13 @@ public class GuiCondenser extends AEBaseGui
}
@Override
protected void actionPerformed(GuiButton btn)
protected void actionPerformed( GuiButton btn )
{
super.actionPerformed( btn );
boolean backwards = Mouse.isButtonDown( 1 );
if ( this.mode == btn )
if( this.mode == btn )
{
NetworkHandler.instance.sendToServer( new PacketConfigButton( Settings.CONDENSER_OUTPUT, backwards ) );
}
@@ -76,22 +77,20 @@ public class GuiCondenser extends AEBaseGui
}
@Override
public void drawBG(int offsetX, int offsetY, int mouseX, int mouseY)
{
this.bindTexture( "guis/condenser.png" );
this.drawTexturedModalRect( offsetX, offsetY, 0, 0, this.xSize, this.ySize );
}
@Override
public void drawFG(int offsetX, int offsetY, int mouseX, int mouseY)
public void drawFG( int offsetX, int offsetY, int mouseX, int mouseY )
{
this.fontRendererObj.drawString( this.getGuiDisplayName( GuiText.Condenser.getLocal() ), 8, 6, 4210752 );
this.fontRendererObj.drawString( GuiText.inventory.getLocal(), 8, this.ySize - 96 + 3, 4210752 );
this.mode.set( this.cvc.output );
this.mode.fillVar = String.valueOf( this.cvc.output.requiredPower );
}
@Override
public void drawBG( int offsetX, int offsetY, int mouseX, int mouseY )
{
this.bindTexture( "guis/condenser.png" );
this.drawTexturedModalRect( offsetX, offsetY, 0, 0, this.xSize, this.ySize );
}
}
@@ -18,6 +18,7 @@
package appeng.client.gui.implementations;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.item.ItemStack;
@@ -43,6 +44,7 @@ import appeng.parts.reporting.PartCraftingTerminal;
import appeng.parts.reporting.PartPatternTerminal;
import appeng.parts.reporting.PartTerminal;
public class GuiCraftAmount extends AEBaseGui
{
private GuiNumberBox amountToCraft;
@@ -62,7 +64,8 @@ public class GuiCraftAmount extends AEBaseGui
private GuiBridge originalGui;
@Reflected
public GuiCraftAmount(InventoryPlayer inventoryPlayer, ITerminalHost te) {
public GuiCraftAmount( InventoryPlayer inventoryPlayer, ITerminalHost te )
{
super( new ContainerCraftAmount( inventoryPlayer, te ) );
}
@@ -89,13 +92,13 @@ public class GuiCraftAmount extends AEBaseGui
this.buttonList.add( this.next = new GuiButton( 0, this.guiLeft + 128, this.guiTop + 51, 38, 20, GuiText.Next.getLocal() ) );
ItemStack myIcon = null;
Object target = ((AEBaseContainer) this.inventorySlots).getTarget();
Object target = ( (AEBaseContainer) this.inventorySlots ).getTarget();
final IDefinitions definitions = AEApi.instance().definitions();
final IParts parts = definitions.parts();
if ( target instanceof WirelessTerminalGuiObject )
if( target instanceof WirelessTerminalGuiObject )
{
for ( ItemStack wirelessTerminalStack : definitions.items().wirelessTerminal().maybeStack( 1 ).asSet() )
for( ItemStack wirelessTerminalStack : definitions.items().wirelessTerminal().maybeStack( 1 ).asSet() )
{
myIcon = wirelessTerminalStack;
}
@@ -103,34 +106,34 @@ public class GuiCraftAmount extends AEBaseGui
this.originalGui = GuiBridge.GUI_WIRELESS_TERM;
}
if ( target instanceof PartTerminal )
if( target instanceof PartTerminal )
{
for ( ItemStack stack : parts.terminal().maybeStack( 1 ).asSet() )
for( ItemStack stack : parts.terminal().maybeStack( 1 ).asSet() )
{
myIcon = stack;
}
this.originalGui = GuiBridge.GUI_ME;
}
if ( target instanceof PartCraftingTerminal )
if( target instanceof PartCraftingTerminal )
{
for ( ItemStack stack : parts.craftingTerminal().maybeStack( 1 ).asSet() )
for( ItemStack stack : parts.craftingTerminal().maybeStack( 1 ).asSet() )
{
myIcon = stack;
}
this.originalGui = GuiBridge.GUI_CRAFTING_TERMINAL;
}
if ( target instanceof PartPatternTerminal )
if( target instanceof PartPatternTerminal )
{
for ( ItemStack stack : parts.patternTerminal().maybeStack( 1 ).asSet() )
for( ItemStack stack : parts.patternTerminal().maybeStack( 1 ).asSet() )
{
myIcon = stack;
}
this.originalGui = GuiBridge.GUI_PATTERN_TERMINAL;
}
if ( this.originalGui != null && myIcon != null )
if( this.originalGui != null && myIcon != null )
{
this.buttonList.add( this.originalGuiBtn = new GuiTabButton( this.guiLeft + 154, this.guiTop, myIcon, myIcon.getDisplayName(), itemRender ) );
}
@@ -145,111 +148,67 @@ public class GuiCraftAmount extends AEBaseGui
}
@Override
protected void actionPerformed(GuiButton btn)
public void drawFG( int offsetX, int offsetY, int mouseX, int mouseY )
{
super.actionPerformed( btn );
try
{
if ( btn == this.originalGuiBtn )
{
NetworkHandler.instance.sendToServer( new PacketSwitchGuis( this.originalGui ) );
}
if ( btn == this.next )
{
NetworkHandler.instance.sendToServer( new PacketCraftRequest( Integer.parseInt( this.amountToCraft.getText() ), isShiftKeyDown() ) );
}
}
catch (NumberFormatException e)
{
// nope..
this.amountToCraft.setText( "1" );
}
boolean isPlus = btn == this.plus1 || btn == this.plus10 || btn == this.plus100 || btn == this.plus1000;
boolean isMinus = btn == this.minus1 || btn == this.minus10 || btn == this.minus100 || btn == this.minus1000;
if ( isPlus || isMinus )
this.addQty( this.getQty( btn ) );
}
private void addQty(int i)
{
try
{
String out = this.amountToCraft.getText();
boolean fixed = false;
while (out.startsWith( "0" ) && out.length() > 1)
{
out = out.substring( 1 );
fixed = true;
}
if ( fixed )
this.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 );
this.amountToCraft.setText( out );
}
catch (NumberFormatException e)
{
// :P
}
this.fontRendererObj.drawString( GuiText.SelectAmount.getLocal(), 8, 6, 4210752 );
}
@Override
protected void keyTyped(char character, int key)
public void drawBG( int offsetX, int offsetY, int mouseX, int mouseY )
{
if ( !this.checkHotbarKeys( key ) )
this.next.displayString = isShiftKeyDown() ? GuiText.Start.getLocal() : GuiText.Next.getLocal();
this.bindTexture( "guis/craftAmt.png" );
this.drawTexturedModalRect( offsetX, offsetY, 0, 0, this.xSize, this.ySize );
try
{
if ( key == 28 )
Long.parseLong( this.amountToCraft.getText() );
this.next.enabled = this.amountToCraft.getText().length() > 0;
}
catch( NumberFormatException e )
{
this.next.enabled = false;
}
this.amountToCraft.drawTextBox();
}
@Override
protected void keyTyped( char character, int key )
{
if( !this.checkHotbarKeys( key ) )
{
if( key == 28 )
{
this.actionPerformed( this.next );
}
if ( (key == 211 || key == 205 || key == 203 || key == 14 || character == '-' || Character.isDigit( character ))
&& this.amountToCraft.textboxKeyTyped( character, key ) )
if( ( key == 211 || key == 205 || key == 203 || key == 14 || character == '-' || Character.isDigit( character ) ) && this.amountToCraft.textboxKeyTyped( character, key ) )
{
try
{
String out = this.amountToCraft.getText();
boolean fixed = false;
while (out.startsWith( "0" ) && out.length() > 1)
while( out.startsWith( "0" ) && out.length() > 1 )
{
out = out.substring( 1 );
fixed = true;
}
if ( fixed )
if( fixed )
this.amountToCraft.setText( out );
if ( out.length() == 0 )
if( out.length() == 0 )
out = "0";
long result = Long.parseLong( out );
if ( result < 0 )
if( result < 0 )
{
this.amountToCraft.setText( "1" );
}
}
catch (NumberFormatException e)
catch( NumberFormatException e )
{
// :P
}
@@ -262,34 +221,76 @@ public class GuiCraftAmount extends AEBaseGui
}
@Override
public void drawBG(int offsetX, int offsetY, int mouseX, int mouseY)
protected void actionPerformed( GuiButton btn )
{
this.next.displayString = isShiftKeyDown() ? GuiText.Start.getLocal() : GuiText.Next.getLocal();
this.bindTexture( "guis/craftAmt.png" );
this.drawTexturedModalRect( offsetX, offsetY, 0, 0, this.xSize, this.ySize );
super.actionPerformed( btn );
try
{
Long.parseLong( this.amountToCraft.getText() );
this.next.enabled = this.amountToCraft.getText().length() > 0;
if( btn == this.originalGuiBtn )
{
NetworkHandler.instance.sendToServer( new PacketSwitchGuis( this.originalGui ) );
}
if( btn == this.next )
{
NetworkHandler.instance.sendToServer( new PacketCraftRequest( Integer.parseInt( this.amountToCraft.getText() ), isShiftKeyDown() ) );
}
}
catch (NumberFormatException e)
catch( NumberFormatException e )
{
this.next.enabled = false;
// nope..
this.amountToCraft.setText( "1" );
}
this.amountToCraft.drawTextBox();
boolean isPlus = btn == this.plus1 || btn == this.plus10 || btn == this.plus100 || btn == this.plus1000;
boolean isMinus = btn == this.minus1 || btn == this.minus10 || btn == this.minus100 || btn == this.minus1000;
if( isPlus || isMinus )
this.addQty( this.getQty( btn ) );
}
private void addQty( int i )
{
try
{
String out = this.amountToCraft.getText();
boolean fixed = false;
while( out.startsWith( "0" ) && out.length() > 1 )
{
out = out.substring( 1 );
fixed = true;
}
if( fixed )
this.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 );
this.amountToCraft.setText( out );
}
catch( NumberFormatException e )
{
// :P
}
}
protected String getBackground()
{
return "guis/craftAmt.png";
}
@Override
public void drawFG(int offsetX, int offsetY, int mouseX, int mouseY)
{
this.fontRendererObj.drawString( GuiText.SelectAmount.getLocal(), 8, 6, 4210752 );
}
}
@@ -26,8 +26,6 @@ import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import com.google.common.base.Joiner;
import org.lwjgl.input.Mouse;
import org.lwjgl.opengl.GL11;
@@ -35,6 +33,8 @@ import net.minecraft.client.gui.GuiButton;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.item.ItemStack;
import com.google.common.base.Joiner;
import appeng.api.AEApi;
import appeng.api.storage.ITerminalHost;
import appeng.api.storage.data.IAEItemStack;
@@ -54,6 +54,7 @@ import appeng.parts.reporting.PartPatternTerminal;
import appeng.parts.reporting.PartTerminal;
import appeng.util.Platform;
public class GuiCraftConfirm extends AEBaseGui
{
@@ -68,18 +69,13 @@ public class GuiCraftConfirm extends AEBaseGui
final List<IAEItemStack> visual = new ArrayList<IAEItemStack>();
GuiBridge OriginalGui;
GuiButton cancel;
GuiButton start;
GuiButton selectCPU;
int tooltip = -1;
boolean isAutoStart()
public GuiCraftConfirm( InventoryPlayer inventoryPlayer, ITerminalHost te )
{
return ((ContainerCraftConfirm) this.inventorySlots).autoStart;
}
boolean isSimulation()
{
return ((ContainerCraftConfirm) this.inventorySlots).simulation;
}
public GuiCraftConfirm(InventoryPlayer inventoryPlayer, ITerminalHost te) {
super( new ContainerCraftConfirm( inventoryPlayer, te ) );
this.xSize = 238;
this.ySize = 206;
@@ -87,23 +83,23 @@ public class GuiCraftConfirm extends AEBaseGui
this.ccc = (ContainerCraftConfirm) this.inventorySlots;
if ( te instanceof WirelessTerminalGuiObject )
if( te instanceof WirelessTerminalGuiObject )
this.OriginalGui = GuiBridge.GUI_WIRELESS_TERM;
if ( te instanceof PartTerminal )
if( te instanceof PartTerminal )
this.OriginalGui = GuiBridge.GUI_ME;
if ( te instanceof PartCraftingTerminal )
if( te instanceof PartCraftingTerminal )
this.OriginalGui = GuiBridge.GUI_CRAFTING_TERMINAL;
if ( te instanceof PartPatternTerminal )
if( te instanceof PartPatternTerminal )
this.OriginalGui = GuiBridge.GUI_PATTERN_TERMINAL;
}
GuiButton cancel;
GuiButton start;
GuiButton selectCPU;
boolean isAutoStart()
{
return ( (ContainerCraftConfirm) this.inventorySlots ).autoStart;
}
@Override
public void initGui()
@@ -114,248 +110,50 @@ public class GuiCraftConfirm extends AEBaseGui
this.start.enabled = false;
this.buttonList.add( this.start );
this.selectCPU = new GuiButton( 0, this.guiLeft + (219 - 180) / 2, this.guiTop + this.ySize - 68, 180, 20, GuiText.CraftingCPU.getLocal() + ": "
+ GuiText.Automatic );
this.selectCPU = new GuiButton( 0, this.guiLeft + ( 219 - 180 ) / 2, this.guiTop + this.ySize - 68, 180, 20, GuiText.CraftingCPU.getLocal() + ": " + GuiText.Automatic );
this.selectCPU.enabled = false;
this.buttonList.add( this.selectCPU );
if ( this.OriginalGui != null )
if( this.OriginalGui != null )
this.cancel = new GuiButton( 0, this.guiLeft + 6, this.guiTop + this.ySize - 25, 50, 20, GuiText.Cancel.getLocal() );
this.buttonList.add( this.cancel );
}
private void updateCPUButtonText()
{
String btnTextText = GuiText.CraftingCPU.getLocal() + ": " + GuiText.Automatic.getLocal();
if ( this.ccc.selectedCpu >= 0 )// && status.selectedCpu < status.cpus.size() )
{
if ( this.ccc.myName.length() > 0 )
{
String name = this.ccc.myName.substring( 0, Math.min( 20, this.ccc.myName.length() ) );
btnTextText = GuiText.CraftingCPU.getLocal() + ": " + name;
}
else
btnTextText = GuiText.CraftingCPU.getLocal() + ": #" + this.ccc.selectedCpu;
}
if ( this.ccc.noCPU )
btnTextText = GuiText.NoCraftingCPUs.getLocal();
this.selectCPU.displayString = btnTextText;
}
@Override
protected void actionPerformed(GuiButton btn)
{
super.actionPerformed( btn );
boolean backwards = Mouse.isButtonDown( 1 );
if ( btn == this.selectCPU )
{
try
{
NetworkHandler.instance.sendToServer( new PacketValueConfig( "Terminal.Cpu", backwards ? "Prev" : "Next" ) );
}
catch (IOException e)
{
AELog.error( e );
}
}
if ( btn == this.cancel )
{
NetworkHandler.instance.sendToServer( new PacketSwitchGuis( this.OriginalGui ) );
}
if ( btn == this.start )
{
try
{
NetworkHandler.instance.sendToServer( new PacketValueConfig( "Terminal.Start", "Start" ) );
}
catch (Throwable e)
{
AELog.error( e );
}
}
}
private long getTotal(IAEItemStack is)
{
IAEItemStack a = this.storage.findPrecise( is );
IAEItemStack c = this.pending.findPrecise( is );
IAEItemStack m = this.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)
this.handleInput( this.storage, l );
break;
case 1:
for (IAEItemStack l : list)
this.handleInput( this.pending, l );
break;
case 2:
for (IAEItemStack l : list)
this.handleInput( this.missing, l );
break;
}
for (IAEItemStack l : list)
{
long amt = this.getTotal( l );
if ( amt <= 0 )
this.deleteVisualStack( l );
else
{
IAEItemStack is = this.findVisualStack( l );
is.setStackSize( amt );
}
}
this.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)
{
for (IAEItemStack o : this.visual)
{
if ( o.equals( l ) )
{
return o;
}
}
IAEItemStack stack = l.copy();
this.visual.add( stack );
return stack;
}
private void deleteVisualStack(IAEItemStack l)
{
Iterator<IAEItemStack> i = this.visual.iterator();
while (i.hasNext())
{
IAEItemStack o = i.next();
if ( o.equals( l ) )
{
i.remove();
return;
}
}
}
private void setScrollBar()
{
int size = this.visual.size();
this.myScrollBar.setTop( 19 ).setLeft( 218 ).setHeight( 114 );
this.myScrollBar.setRange( 0, (size + 2) / 3 - this.rows, 1 );
}
@Override
protected void keyTyped(char character, int key)
{
if ( !this.checkHotbarKeys( key ) )
{
if ( key == 28 )
{
this.actionPerformed( this.start );
}
super.keyTyped( character, key );
}
}
@Override
public void drawBG(int offsetX, int offsetY, int mouseX, int mouseY)
{
this.setScrollBar();
this.bindTexture( "guis/craftingreport.png" );
this.drawTexturedModalRect( offsetX, offsetY, 0, 0, this.xSize, this.ySize );
}
int tooltip = -1;
@Override
public void drawScreen(int mouse_x, int mouse_y, float btn)
public void drawScreen( int mouse_x, int mouse_y, float btn )
{
this.updateCPUButtonText();
this.start.enabled = !(this.ccc.noCPU || this.isSimulation());
this.start.enabled = !( this.ccc.noCPU || this.isSimulation() );
this.selectCPU.enabled = !this.isSimulation();
int x = 0;
int y = 0;
int gx = (this.width - this.xSize) / 2;
int gy = (this.height - this.ySize) / 2;
int gx = ( this.width - this.xSize ) / 2;
int gy = ( this.height - this.ySize ) / 2;
int offY = 23;
this.tooltip = -1;
for (int z = 0; z <= 4 * 5; z++)
for( int z = 0; z <= 4 * 5; z++ )
{
int minX = gx + 9 + x * 67;
int minY = gy + 22 + y * offY;
if ( minX < mouse_x && minX + 67 > mouse_x )
if( minX < mouse_x && minX + 67 > mouse_x )
{
if ( minY < mouse_y && minY + offY - 2 > mouse_y )
if( minY < mouse_y && minY + offY - 2 > mouse_y )
{
this.tooltip = z;
break;
}
}
x++;
if ( x > 2 )
if( x > 2 )
{
y++;
x = 0;
@@ -365,23 +163,47 @@ public class GuiCraftConfirm extends AEBaseGui
super.drawScreen( mouse_x, mouse_y, btn );
}
private void updateCPUButtonText()
{
String btnTextText = GuiText.CraftingCPU.getLocal() + ": " + GuiText.Automatic.getLocal();
if( this.ccc.selectedCpu >= 0 )// && status.selectedCpu < status.cpus.size() )
{
if( this.ccc.myName.length() > 0 )
{
String name = this.ccc.myName.substring( 0, Math.min( 20, this.ccc.myName.length() ) );
btnTextText = GuiText.CraftingCPU.getLocal() + ": " + name;
}
else
btnTextText = GuiText.CraftingCPU.getLocal() + ": #" + this.ccc.selectedCpu;
}
if( this.ccc.noCPU )
btnTextText = GuiText.NoCraftingCPUs.getLocal();
this.selectCPU.displayString = btnTextText;
}
boolean isSimulation()
{
return ( (ContainerCraftConfirm) this.inventorySlots ).simulation;
}
@Override
public void drawFG(int offsetX, int offsetY, int mouseX, int mouseY)
public void drawFG( int offsetX, int offsetY, int mouseX, int mouseY )
{
long BytesUsed = this.ccc.bytesUsed;
String byteUsed = NumberFormat.getInstance().format( BytesUsed );
String Add = BytesUsed > 0 ? (byteUsed + ' ' + GuiText.BytesUsed.getLocal()) : GuiText.CalculatingWait.getLocal();
String Add = BytesUsed > 0 ? ( byteUsed + ' ' + GuiText.BytesUsed.getLocal() ) : GuiText.CalculatingWait.getLocal();
this.fontRendererObj.drawString( GuiText.CraftingPlan.getLocal() + " - " + Add, 8, 7, 4210752 );
String dsp = null;
if ( this.isSimulation() )
if( this.isSimulation() )
dsp = GuiText.Simulation.getLocal();
else
dsp = this.ccc.cpuBytesAvail > 0 ? (GuiText.Bytes.getLocal() + ": " + this.ccc.cpuBytesAvail + " : " + GuiText.CoProcessors.getLocal() + ": " + this.ccc.cpuCoProcessors)
: GuiText.Bytes.getLocal() + ": N/A : " + GuiText.CoProcessors.getLocal() + ": N/A";
dsp = this.ccc.cpuBytesAvail > 0 ? ( GuiText.Bytes.getLocal() + ": " + this.ccc.cpuBytesAvail + " : " + GuiText.CoProcessors.getLocal() + ": " + this.ccc.cpuCoProcessors ) : GuiText.Bytes.getLocal() + ": N/A : " + GuiText.CoProcessors.getLocal() + ": N/A";
int offset = (219 - this.fontRendererObj.getStringWidth( dsp )) / 2;
int offset = ( 219 - this.fontRendererObj.getStringWidth( dsp ) ) / 2;
this.fontRendererObj.drawString( dsp, offset, 165, 4210752 );
int sectionLength = 67;
@@ -400,10 +222,10 @@ public class GuiCraftConfirm extends AEBaseGui
int offY = 23;
for (int z = viewStart; z < Math.min( viewEnd, this.visual.size() ); z++)
for( int z = viewStart; z < Math.min( viewEnd, this.visual.size() ); z++ )
{
IAEItemStack refStack = this.visual.get( z );// repo.getReferenceItem( z );
if ( refStack != null )
if( refStack != null )
{
GL11.glPushMatrix();
GL11.glScaled( 0.5, 0.5, 0.5 );
@@ -414,118 +236,284 @@ public class GuiCraftConfirm extends AEBaseGui
int lines = 0;
if ( stored != null && stored.getStackSize() > 0 )
if( stored != null && stored.getStackSize() > 0 )
lines++;
if ( pendingStack != null && pendingStack.getStackSize() > 0 )
if( pendingStack != null && pendingStack.getStackSize() > 0 )
lines++;
if ( pendingStack != null && pendingStack.getStackSize() > 0 )
if( pendingStack != null && pendingStack.getStackSize() > 0 )
lines++;
int negY = ((lines - 1) * 5) / 2;
int negY = ( ( lines - 1 ) * 5 ) / 2;
int downY = 0;
boolean red = false;
if ( stored != null && stored.getStackSize() > 0 )
if( stored != null && stored.getStackSize() > 0 )
{
String str = Long.toString( stored.getStackSize() );
if ( stored.getStackSize() >= 10000 )
if( stored.getStackSize() >= 10000 )
str = Long.toString( stored.getStackSize() / 1000 ) + 'k';
if ( stored.getStackSize() >= 10000000 )
if( stored.getStackSize() >= 10000000 )
str = Long.toString( stored.getStackSize() / 1000000 ) + 'm';
str = GuiText.FromStorage.getLocal() + ": " + str;
int w = 4 + this.fontRendererObj.getStringWidth( str );
this.fontRendererObj.drawString( str, (int) ((x * (1 + sectionLength) + xo + sectionLength - 19 - (w * 0.5)) * 2), (y * offY + yo
+ 6 - negY + downY) * 2, 4210752 );
this.fontRendererObj.drawString( str, (int) ( ( x * ( 1 + sectionLength ) + xo + sectionLength - 19 - ( w * 0.5 ) ) * 2 ), ( y * offY + yo + 6 - negY + downY ) * 2, 4210752 );
if ( this.tooltip == z - viewStart )
if( this.tooltip == z - viewStart )
lineList.add( GuiText.FromStorage.getLocal() + ": " + Long.toString( stored.getStackSize() ) );
downY += 5;
}
if ( missingStack != null && missingStack.getStackSize() > 0 )
if( missingStack != null && missingStack.getStackSize() > 0 )
{
String str = Long.toString( missingStack.getStackSize() );
if ( missingStack.getStackSize() >= 10000 )
if( missingStack.getStackSize() >= 10000 )
str = Long.toString( missingStack.getStackSize() / 1000 ) + 'k';
if ( missingStack.getStackSize() >= 10000000 )
if( missingStack.getStackSize() >= 10000000 )
str = Long.toString( missingStack.getStackSize() / 1000000 ) + 'm';
str = GuiText.Missing.getLocal() + ": " + str;
int w = 4 + this.fontRendererObj.getStringWidth( str );
this.fontRendererObj.drawString( str, (int) ((x * (1 + sectionLength) + xo + sectionLength - 19 - (w * 0.5)) * 2), (y * offY + yo
+ 6 - negY + downY) * 2, 4210752 );
this.fontRendererObj.drawString( str, (int) ( ( x * ( 1 + sectionLength ) + xo + sectionLength - 19 - ( w * 0.5 ) ) * 2 ), ( y * offY + yo + 6 - negY + downY ) * 2, 4210752 );
if ( this.tooltip == z - viewStart )
if( this.tooltip == z - viewStart )
lineList.add( GuiText.Missing.getLocal() + ": " + Long.toString( missingStack.getStackSize() ) );
red = true;
downY += 5;
}
if ( pendingStack != null && pendingStack.getStackSize() > 0 )
if( pendingStack != null && pendingStack.getStackSize() > 0 )
{
String str = Long.toString( pendingStack.getStackSize() );
if ( pendingStack.getStackSize() >= 10000 )
if( pendingStack.getStackSize() >= 10000 )
str = Long.toString( pendingStack.getStackSize() / 1000 ) + 'k';
if ( pendingStack.getStackSize() >= 10000000 )
if( pendingStack.getStackSize() >= 10000000 )
str = Long.toString( pendingStack.getStackSize() / 1000000 ) + 'm';
str = GuiText.ToCraft.getLocal() + ": " + str;
int w = 4 + this.fontRendererObj.getStringWidth( str );
this.fontRendererObj.drawString( str, (int) ((x * (1 + sectionLength) + xo + sectionLength - 19 - (w * 0.5)) * 2), (y * offY + yo
+ 6 - negY + downY) * 2, 4210752 );
this.fontRendererObj.drawString( str, (int) ( ( x * ( 1 + sectionLength ) + xo + sectionLength - 19 - ( w * 0.5 ) ) * 2 ), ( y * offY + yo + 6 - negY + downY ) * 2, 4210752 );
if ( this.tooltip == z - viewStart )
if( this.tooltip == z - viewStart )
lineList.add( GuiText.ToCraft.getLocal() + ": " + Long.toString( pendingStack.getStackSize() ) );
}
GL11.glPopMatrix();
int posX = x * (1 + sectionLength) + xo + sectionLength - 19;
int posX = x * ( 1 + sectionLength ) + xo + sectionLength - 19;
int posY = y * offY + yo;
ItemStack is = refStack.copy().getItemStack();
if ( this.tooltip == z - viewStart )
if( this.tooltip == z - viewStart )
{
dspToolTip = Platform.getItemDisplayName( is );
if ( lineList.size() > 0 )
if( lineList.size() > 0 )
dspToolTip = dspToolTip + '\n' + Joiner.on( "\n" ).join( lineList );
toolPosX = x * (1 + sectionLength) + xo + sectionLength - 8;
toolPosX = x * ( 1 + sectionLength ) + xo + sectionLength - 8;
toolPosY = y * offY + yo;
}
this.drawItem( posX, posY, is );
if ( red )
if( red )
{
int startX = x * (1 + sectionLength) + xo;
int startX = x * ( 1 + sectionLength ) + xo;
int startY = posY - 4;
drawRect( startX, startY, startX + sectionLength, startY + offY, 0x1AFF0000 );
}
x++;
if ( x > 2 )
if( x > 2 )
{
y++;
x = 0;
}
}
}
if ( this.tooltip >= 0 && dspToolTip.length() > 0 )
if( this.tooltip >= 0 && dspToolTip.length() > 0 )
{
GL11.glPushAttrib( GL11.GL_ALL_ATTRIB_BITS );
this.drawTooltip( toolPosX, toolPosY + 10, 0, dspToolTip );
GL11.glPopAttrib();
}
}
@Override
public void drawBG( int offsetX, int offsetY, int mouseX, int mouseY )
{
this.setScrollBar();
this.bindTexture( "guis/craftingreport.png" );
this.drawTexturedModalRect( offsetX, offsetY, 0, 0, this.xSize, this.ySize );
}
private void setScrollBar()
{
int size = this.visual.size();
this.myScrollBar.setTop( 19 ).setLeft( 218 ).setHeight( 114 );
this.myScrollBar.setRange( 0, ( size + 2 ) / 3 - this.rows, 1 );
}
public void postUpdate( List<IAEItemStack> list, byte ref )
{
switch( ref )
{
case 0:
for( IAEItemStack l : list )
this.handleInput( this.storage, l );
break;
case 1:
for( IAEItemStack l : list )
this.handleInput( this.pending, l );
break;
case 2:
for( IAEItemStack l : list )
this.handleInput( this.missing, l );
break;
}
for( IAEItemStack l : list )
{
long amt = this.getTotal( l );
if( amt <= 0 )
this.deleteVisualStack( l );
else
{
IAEItemStack is = this.findVisualStack( l );
is.setStackSize( amt );
}
}
this.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 long getTotal( IAEItemStack is )
{
IAEItemStack a = this.storage.findPrecise( is );
IAEItemStack c = this.pending.findPrecise( is );
IAEItemStack m = this.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;
}
private void deleteVisualStack( IAEItemStack l )
{
Iterator<IAEItemStack> i = this.visual.iterator();
while( i.hasNext() )
{
IAEItemStack o = i.next();
if( o.equals( l ) )
{
i.remove();
return;
}
}
}
private IAEItemStack findVisualStack( IAEItemStack l )
{
for( IAEItemStack o : this.visual )
{
if( o.equals( l ) )
{
return o;
}
}
IAEItemStack stack = l.copy();
this.visual.add( stack );
return stack;
}
@Override
protected void keyTyped( char character, int key )
{
if( !this.checkHotbarKeys( key ) )
{
if( key == 28 )
{
this.actionPerformed( this.start );
}
super.keyTyped( character, key );
}
}
@Override
protected void actionPerformed( GuiButton btn )
{
super.actionPerformed( btn );
boolean backwards = Mouse.isButtonDown( 1 );
if( btn == this.selectCPU )
{
try
{
NetworkHandler.instance.sendToServer( new PacketValueConfig( "Terminal.Cpu", backwards ? "Prev" : "Next" ) );
}
catch( IOException e )
{
AELog.error( e );
}
}
if( btn == this.cancel )
{
NetworkHandler.instance.sendToServer( new PacketSwitchGuis( this.OriginalGui ) );
}
if( btn == this.start )
{
try
{
NetworkHandler.instance.sendToServer( new PacketValueConfig( "Terminal.Start", "Start" ) );
}
catch( Throwable e )
{
AELog.error( e );
}
}
}
}
@@ -51,6 +51,7 @@ import appeng.core.sync.network.NetworkHandler;
import appeng.core.sync.packets.PacketValueConfig;
import appeng.util.Platform;
public class GuiCraftingCPU extends AEBaseGui implements ISortSource
{
@@ -61,6 +62,21 @@ public class GuiCraftingCPU extends AEBaseGui implements ISortSource
IItemList<IAEItemStack> pending = AEApi.instance().storage().createItemList();
List<IAEItemStack> visual = new ArrayList<IAEItemStack>();
GuiButton cancel;
int tooltip = -1;
public GuiCraftingCPU( InventoryPlayer inventoryPlayer, Object te )
{
this( new ContainerCraftingCPU( inventoryPlayer, te ) );
}
protected GuiCraftingCPU( ContainerCraftingCPU container )
{
super( container );
this.ySize = 184;
this.xSize = 238;
this.myScrollBar = new GuiScrollbar();
}
public void clearItems()
{
@@ -70,31 +86,18 @@ public class GuiCraftingCPU extends AEBaseGui implements ISortSource
this.visual = new ArrayList<IAEItemStack>();
}
protected GuiCraftingCPU(ContainerCraftingCPU container) {
super( container );
this.ySize = 184;
this.xSize = 238;
this.myScrollBar = new GuiScrollbar();
}
public GuiCraftingCPU(InventoryPlayer inventoryPlayer, Object te) {
this( new ContainerCraftingCPU( inventoryPlayer, te ) );
}
GuiButton cancel;
@Override
protected void actionPerformed(GuiButton btn)
protected void actionPerformed( GuiButton btn )
{
super.actionPerformed( btn );
if ( this.cancel == btn )
if( this.cancel == btn )
{
try
{
NetworkHandler.instance.sendToServer( new PacketValueConfig( "TileCrafting.Cancel", "Cancel" ) );
}
catch (IOException e)
catch( IOException e )
{
AELog.error( e );
}
@@ -110,162 +113,45 @@ public class GuiCraftingCPU extends AEBaseGui implements ISortSource
this.buttonList.add( this.cancel );
}
private long getTotal(IAEItemStack is)
{
IAEItemStack a = this.storage.findPrecise( is );
IAEItemStack b = this.active.findPrecise( is );
IAEItemStack c = this.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)
this.handleInput( this.storage, l );
break;
case 1:
for (IAEItemStack l : list)
this.handleInput( this.active, l );
break;
case 2:
for (IAEItemStack l : list)
this.handleInput( this.pending, l );
break;
}
for (IAEItemStack l : list)
{
long amt = this.getTotal( l );
if ( amt <= 0 )
this.deleteVisualStack( l );
else
{
IAEItemStack is = this.findVisualStack( l );
is.setStackSize( amt );
}
}
this.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)
{
for (IAEItemStack o : this.visual)
{
if ( o.equals( l ) )
{
return o;
}
}
IAEItemStack stack = l.copy();
this.visual.add( stack );
return stack;
}
private void deleteVisualStack(IAEItemStack l)
{
Iterator<IAEItemStack> i = this.visual.iterator();
while (i.hasNext())
{
IAEItemStack o = i.next();
if ( o.equals( l ) )
{
i.remove();
return;
}
}
}
private void setScrollBar()
{
int size = this.visual.size();
this.myScrollBar.setTop( 19 ).setLeft( 218 ).setHeight( 137 );
this.myScrollBar.setRange( 0, (size + 2) / 3 - this.rows, 1 );
this.myScrollBar.setRange( 0, ( size + 2 ) / 3 - this.rows, 1 );
}
@Override
public void drawBG(int offsetX, int offsetY, int mouseX, int mouseY)
{
this.bindTexture( "guis/craftingcpu.png" );
this.drawTexturedModalRect( offsetX, offsetY, 0, 0, this.xSize, this.ySize );
}
int tooltip = -1;
@Override
public void drawScreen(int mouse_x, int mouse_y, float btn)
public void drawScreen( int mouse_x, int mouse_y, float btn )
{
this.cancel.enabled = !this.visual.isEmpty();
int x = 0;
int y = 0;
int gx = (this.width - this.xSize) / 2;
int gy = (this.height - this.ySize) / 2;
int gx = ( this.width - this.xSize ) / 2;
int gy = ( this.height - this.ySize ) / 2;
int offY = 23;
this.tooltip = -1;
for (int z = 0; z <= 4 * 5; z++)
for( int z = 0; z <= 4 * 5; z++ )
{
int minX = gx + 9 + x * 67;
int minY = gy + 22 + y * offY;
if ( minX < mouse_x && minX + 67 > mouse_x )
if( minX < mouse_x && minX + 67 > mouse_x )
{
if ( minY < mouse_y && minY + offY - 2 > mouse_y )
if( minY < mouse_y && minY + offY - 2 > mouse_y )
{
this.tooltip = z;
break;
}
}
x++;
if ( x > 2 )
if( x > 2 )
{
y++;
x = 0;
@@ -276,7 +162,7 @@ public class GuiCraftingCPU extends AEBaseGui implements ISortSource
}
@Override
public void drawFG(int offsetX, int offsetY, int mouseX, int mouseY)
public void drawFG( int offsetX, int offsetY, int mouseX, int mouseY )
{
this.fontRendererObj.drawString( this.getGuiDisplayName( GuiText.CraftingStatus.getLocal() ), 8, 7, 4210752 );
@@ -296,10 +182,10 @@ public class GuiCraftingCPU extends AEBaseGui implements ISortSource
int offY = 23;
for (int z = viewStart; z < Math.min( viewEnd, this.visual.size() ); z++)
for( int z = viewStart; z < Math.min( viewEnd, this.visual.size() ); z++ )
{
IAEItemStack refStack = this.visual.get( z );// repo.getReferenceItem( z );
if ( refStack != null )
if( refStack != null )
{
GL11.glPushMatrix();
GL11.glScaled( 0.5, 0.5, 0.5 );
@@ -312,102 +198,98 @@ public class GuiCraftingCPU extends AEBaseGui implements ISortSource
boolean active = false;
boolean scheduled = false;
if ( stored != null && stored.getStackSize() > 0 )
if( stored != null && stored.getStackSize() > 0 )
{
lines++;
}
if ( activeStack != null && activeStack.getStackSize() > 0 )
if( activeStack != null && activeStack.getStackSize() > 0 )
{
lines++;
active = true;
}
if ( pendingStack != null && pendingStack.getStackSize() > 0 )
if( pendingStack != null && pendingStack.getStackSize() > 0 )
{
lines++;
scheduled = true;
}
if ( AEConfig.instance.useColoredCraftingStatus && ( active || scheduled ) )
if( AEConfig.instance.useColoredCraftingStatus && ( active || scheduled ) )
{
int bgColor = ( active ? AEColor.Green.blackVariant : AEColor.Yellow.blackVariant ) | 0x5A000000;
int startX = (x * (1 + sectionLength) + xo) * 2;
int startY = ((y * offY + yo) - 3) * 2;
drawRect( startX, startY, startX + (sectionLength * 2), startY + (offY * 2) - 2, bgColor);
int startX = ( x * ( 1 + sectionLength ) + xo ) * 2;
int startY = ( ( y * offY + yo ) - 3 ) * 2;
drawRect( startX, startY, startX + ( sectionLength * 2 ), startY + ( offY * 2 ) - 2, bgColor );
}
int negY = ((lines - 1) * 5) / 2;
int negY = ( ( lines - 1 ) * 5 ) / 2;
int downY = 0;
if ( stored != null && stored.getStackSize() > 0 )
if( stored != null && stored.getStackSize() > 0 )
{
String str = Long.toString( stored.getStackSize() );
if ( stored.getStackSize() >= 10000 )
if( stored.getStackSize() >= 10000 )
str = Long.toString( stored.getStackSize() / 1000 ) + 'k';
if ( stored.getStackSize() >= 10000000 )
if( stored.getStackSize() >= 10000000 )
str = Long.toString( stored.getStackSize() / 1000000 ) + 'm';
str = GuiText.Stored.getLocal() + ": " + str;
int w = 4 + this.fontRendererObj.getStringWidth( str );
this.fontRendererObj.drawString( str, (int) ((x * (1 + sectionLength) + xo + sectionLength - 19 - (w * 0.5)) * 2), (y * offY + yo
+ 6 - negY + downY) * 2, 4210752 );
this.fontRendererObj.drawString( str, (int) ( ( x * ( 1 + sectionLength ) + xo + sectionLength - 19 - ( w * 0.5 ) ) * 2 ), ( y * offY + yo + 6 - negY + downY ) * 2, 4210752 );
if ( this.tooltip == z - viewStart )
if( this.tooltip == z - viewStart )
lineList.add( GuiText.Stored.getLocal() + ": " + Long.toString( stored.getStackSize() ) );
downY += 5;
}
if ( activeStack != null && activeStack.getStackSize() > 0 )
if( activeStack != null && activeStack.getStackSize() > 0 )
{
String str = Long.toString( activeStack.getStackSize() );
if ( activeStack.getStackSize() >= 10000 )
if( activeStack.getStackSize() >= 10000 )
str = Long.toString( activeStack.getStackSize() / 1000 ) + 'k';
if ( activeStack.getStackSize() >= 10000000 )
if( activeStack.getStackSize() >= 10000000 )
str = Long.toString( activeStack.getStackSize() / 1000000 ) + 'm';
str = GuiText.Crafting.getLocal() + ": " + str;
int w = 4 + this.fontRendererObj.getStringWidth( str );
this.fontRendererObj.drawString( str, (int) ((x * (1 + sectionLength) + xo + sectionLength - 19 - (w * 0.5)) * 2), (y * offY + yo
+ 6 - negY + downY) * 2, 4210752 );
this.fontRendererObj.drawString( str, (int) ( ( x * ( 1 + sectionLength ) + xo + sectionLength - 19 - ( w * 0.5 ) ) * 2 ), ( y * offY + yo + 6 - negY + downY ) * 2, 4210752 );
if ( this.tooltip == z - viewStart )
if( this.tooltip == z - viewStart )
lineList.add( GuiText.Crafting.getLocal() + ": " + Long.toString( activeStack.getStackSize() ) );
downY += 5;
}
if ( pendingStack != null && pendingStack.getStackSize() > 0 )
if( pendingStack != null && pendingStack.getStackSize() > 0 )
{
String str = Long.toString( pendingStack.getStackSize() );
if ( pendingStack.getStackSize() >= 10000 )
if( pendingStack.getStackSize() >= 10000 )
str = Long.toString( pendingStack.getStackSize() / 1000 ) + 'k';
if ( pendingStack.getStackSize() >= 10000000 )
if( pendingStack.getStackSize() >= 10000000 )
str = Long.toString( pendingStack.getStackSize() / 1000000 ) + 'm';
str = GuiText.Scheduled.getLocal() + ": " + str;
int w = 4 + this.fontRendererObj.getStringWidth( str );
this.fontRendererObj.drawString( str, (int) ((x * (1 + sectionLength) + xo + sectionLength - 19 - (w * 0.5)) * 2), (y * offY + yo
+ 6 - negY + downY) * 2, 4210752 );
this.fontRendererObj.drawString( str, (int) ( ( x * ( 1 + sectionLength ) + xo + sectionLength - 19 - ( w * 0.5 ) ) * 2 ), ( y * offY + yo + 6 - negY + downY ) * 2, 4210752 );
if ( this.tooltip == z - viewStart )
if( this.tooltip == z - viewStart )
lineList.add( GuiText.Scheduled.getLocal() + ": " + Long.toString( pendingStack.getStackSize() ) );
}
GL11.glPopMatrix();
int posX = x * (1 + sectionLength) + xo + sectionLength - 19;
int posX = x * ( 1 + sectionLength ) + xo + sectionLength - 19;
int posY = y * offY + yo;
ItemStack is = refStack.copy().getItemStack();
if ( this.tooltip == z - viewStart )
if( this.tooltip == z - viewStart )
{
dspToolTip = Platform.getItemDisplayName( is );
if ( lineList.size() > 0 )
if( lineList.size() > 0 )
dspToolTip = dspToolTip + '\n' + Joiner.on( "\n" ).join( lineList );
toolPosX = x * (1 + sectionLength) + xo + sectionLength - 8;
toolPosX = x * ( 1 + sectionLength ) + xo + sectionLength - 8;
toolPosY = y * offY + yo;
}
@@ -415,22 +297,134 @@ public class GuiCraftingCPU extends AEBaseGui implements ISortSource
x++;
if ( x > 2 )
if( x > 2 )
{
y++;
x = 0;
}
}
}
if ( this.tooltip >= 0 && dspToolTip.length() > 0 )
if( this.tooltip >= 0 && dspToolTip.length() > 0 )
{
GL11.glPushAttrib( GL11.GL_ALL_ATTRIB_BITS );
this.drawTooltip( toolPosX, toolPosY + 10, 0, dspToolTip );
GL11.glPopAttrib();
}
}
@Override
public void drawBG( int offsetX, int offsetY, int mouseX, int mouseY )
{
this.bindTexture( "guis/craftingcpu.png" );
this.drawTexturedModalRect( offsetX, offsetY, 0, 0, this.xSize, this.ySize );
}
public void postUpdate( List<IAEItemStack> list, byte ref )
{
switch( ref )
{
case 0:
for( IAEItemStack l : list )
this.handleInput( this.storage, l );
break;
case 1:
for( IAEItemStack l : list )
this.handleInput( this.active, l );
break;
case 2:
for( IAEItemStack l : list )
this.handleInput( this.pending, l );
break;
}
for( IAEItemStack l : list )
{
long amt = this.getTotal( l );
if( amt <= 0 )
this.deleteVisualStack( l );
else
{
IAEItemStack is = this.findVisualStack( l );
is.setStackSize( amt );
}
}
this.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 long getTotal( IAEItemStack is )
{
IAEItemStack a = this.storage.findPrecise( is );
IAEItemStack b = this.active.findPrecise( is );
IAEItemStack c = this.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;
}
private void deleteVisualStack( IAEItemStack l )
{
Iterator<IAEItemStack> i = this.visual.iterator();
while( i.hasNext() )
{
IAEItemStack o = i.next();
if( o.equals( l ) )
{
i.remove();
return;
}
}
}
private IAEItemStack findVisualStack( IAEItemStack l )
{
for( IAEItemStack o : this.visual )
{
if( o.equals( l ) )
{
return o;
}
}
IAEItemStack stack = l.copy();
this.visual.add( stack );
return stack;
}
@Override
@@ -450,5 +444,4 @@ public class GuiCraftingCPU extends AEBaseGui implements ISortSource
{
return ViewItems.ALL;
}
}
@@ -19,8 +19,10 @@
/**
*
*/
package appeng.client.gui.implementations;
import java.io.IOException;
import org.lwjgl.input.Mouse;
@@ -46,6 +48,7 @@ import appeng.parts.reporting.PartCraftingTerminal;
import appeng.parts.reporting.PartPatternTerminal;
import appeng.parts.reporting.PartTerminal;
public class GuiCraftingStatus extends GuiCraftingCPU
{
@@ -56,7 +59,8 @@ public class GuiCraftingStatus extends GuiCraftingCPU
GuiBridge originalGui;
ItemStack myIcon = null;
public GuiCraftingStatus(InventoryPlayer inventoryPlayer, ITerminalHost te) {
public GuiCraftingStatus( InventoryPlayer inventoryPlayer, ITerminalHost te )
{
super( new ContainerCraftingStatus( inventoryPlayer, te ) );
this.status = (ContainerCraftingStatus) this.inventorySlots;
@@ -64,9 +68,9 @@ public class GuiCraftingStatus extends GuiCraftingCPU
final IDefinitions definitions = AEApi.instance().definitions();
final IParts parts = definitions.parts();
if ( target instanceof WirelessTerminalGuiObject )
if( target instanceof WirelessTerminalGuiObject )
{
for ( ItemStack wirelessTerminalStack : definitions.items().wirelessTerminal().maybeStack( 1 ).asSet() )
for( ItemStack wirelessTerminalStack : definitions.items().wirelessTerminal().maybeStack( 1 ).asSet() )
{
this.myIcon = wirelessTerminalStack;
}
@@ -74,27 +78,27 @@ public class GuiCraftingStatus extends GuiCraftingCPU
this.originalGui = GuiBridge.GUI_WIRELESS_TERM;
}
if ( target instanceof PartTerminal )
if( target instanceof PartTerminal )
{
for ( ItemStack stack : parts.terminal().maybeStack( 1 ).asSet() )
for( ItemStack stack : parts.terminal().maybeStack( 1 ).asSet() )
{
this.myIcon = stack;
}
this.originalGui = GuiBridge.GUI_ME;
}
if ( target instanceof PartCraftingTerminal )
if( target instanceof PartCraftingTerminal )
{
for ( ItemStack stack : parts.craftingTerminal().maybeStack( 1 ).asSet() )
for( ItemStack stack : parts.craftingTerminal().maybeStack( 1 ).asSet() )
{
this.myIcon = stack;
}
this.originalGui = GuiBridge.GUI_CRAFTING_TERMINAL;
}
if ( target instanceof PartPatternTerminal )
if( target instanceof PartPatternTerminal )
{
for ( ItemStack stack : parts.patternTerminal().maybeStack( 1 ).asSet() )
for( ItemStack stack : parts.patternTerminal().maybeStack( 1 ).asSet() )
{
this.myIcon = stack;
}
@@ -103,36 +107,30 @@ public class GuiCraftingStatus extends GuiCraftingCPU
}
@Override
protected void actionPerformed(GuiButton btn)
protected void actionPerformed( GuiButton btn )
{
super.actionPerformed( btn );
boolean backwards = Mouse.isButtonDown( 1 );
if ( btn == this.selectCPU )
if( btn == this.selectCPU )
{
try
{
NetworkHandler.instance.sendToServer( new PacketValueConfig( "Terminal.Cpu", backwards ? "Prev" : "Next" ) );
}
catch (IOException e)
catch( IOException e )
{
AELog.error( e );
}
}
if ( btn == this.originalGuiBtn )
if( btn == this.originalGuiBtn )
{
NetworkHandler.instance.sendToServer( new PacketSwitchGuis( this.originalGui ) );
}
}
@Override
protected String getGuiDisplayName(String in)
{
return in; // the cup name is on the button
}
@Override
public void initGui()
{
@@ -142,20 +140,27 @@ public class GuiCraftingStatus extends GuiCraftingCPU
// selectCPU.enabled = false;
this.buttonList.add( this.selectCPU );
if ( this.myIcon != null )
if( this.myIcon != null )
{
this.buttonList.add( this.originalGuiBtn = new GuiTabButton( this.guiLeft + 213, this.guiTop - 4, this.myIcon, this.myIcon.getDisplayName(), itemRender ) );
this.originalGuiBtn.hideEdge = 13;
}
}
@Override
public void drawScreen( int mouseX, int mouseY, float btn )
{
this.updateCPUButtonText();
super.drawScreen( mouseX, mouseY, btn );
}
private void updateCPUButtonText()
{
String btnTextText = GuiText.NoCraftingJobs.getLocal();
if ( this.status.selectedCpu >= 0 )// && status.selectedCpu < status.cpus.size() )
if( this.status.selectedCpu >= 0 )// && status.selectedCpu < status.cpus.size() )
{
if ( this.status.myName.length() > 0 )
if( this.status.myName.length() > 0 )
{
String name = this.status.myName.substring( 0, Math.min( 20, this.status.myName.length() ) );
btnTextText = GuiText.CPUs.getLocal() + ": " + name;
@@ -164,16 +169,15 @@ public class GuiCraftingStatus extends GuiCraftingCPU
btnTextText = GuiText.CPUs.getLocal() + ": #" + this.status.selectedCpu;
}
if ( this.status.noCPU )
if( this.status.noCPU )
btnTextText = GuiText.NoCraftingJobs.getLocal();
this.selectCPU.displayString = btnTextText;
}
@Override
public void drawScreen(int mouseX, int mouseY, float btn)
protected String getGuiDisplayName( String in )
{
this.updateCPUButtonText();
super.drawScreen( mouseX, mouseY, btn );
return in; // the cup name is on the button
}
}
@@ -18,6 +18,7 @@
package appeng.client.gui.implementations;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.Container;
@@ -34,11 +35,42 @@ import appeng.core.sync.network.NetworkHandler;
import appeng.core.sync.packets.PacketInventoryAction;
import appeng.helpers.InventoryAction;
public class GuiCraftingTerm extends GuiMEMonitorable
{
GuiImgButton clearBtn;
public GuiCraftingTerm( InventoryPlayer inventoryPlayer, ITerminalHost te )
{
super( inventoryPlayer, te, new ContainerCraftingTerm( inventoryPlayer, te ) );
this.reservedSpace = 73;
}
@Override
protected void actionPerformed( GuiButton btn )
{
super.actionPerformed( btn );
if( this.clearBtn == btn )
{
Slot s = null;
Container c = this.inventorySlots;
for( Object j : c.inventorySlots )
{
if( j instanceof SlotCraftingMatrix )
s = (Slot) j;
}
if( s != null )
{
PacketInventoryAction p;
p = new PacketInventoryAction( InventoryAction.MOVE_REGION, s.slotNumber, 0 );
NetworkHandler.instance.sendToServer( p );
}
}
}
@Override
public void initGui()
{
@@ -48,32 +80,10 @@ public class GuiCraftingTerm extends GuiMEMonitorable
}
@Override
protected void actionPerformed(GuiButton btn)
public void drawFG( int offsetX, int offsetY, int mouseX, int mouseY )
{
super.actionPerformed( btn );
if ( this.clearBtn == btn )
{
Slot s = null;
Container c = this.inventorySlots;
for (Object j : c.inventorySlots)
{
if ( j instanceof SlotCraftingMatrix )
s = (Slot) j;
}
if ( s != null )
{
PacketInventoryAction p;
p = new PacketInventoryAction( InventoryAction.MOVE_REGION, s.slotNumber, 0 );
NetworkHandler.instance.sendToServer( p );
}
}
}
public GuiCraftingTerm(InventoryPlayer inventoryPlayer, ITerminalHost te) {
super( inventoryPlayer, te, new ContainerCraftingTerm( inventoryPlayer, te ) );
this.reservedSpace = 73;
super.drawFG( offsetX, offsetY, mouseX, mouseY );
this.fontRendererObj.drawString( GuiText.CraftingTerminal.getLocal(), 8, this.ySize - 96 + 1 - this.reservedSpace, 4210752 );
}
@Override
@@ -81,12 +91,4 @@ public class GuiCraftingTerm extends GuiMEMonitorable
{
return "guis/crafting.png";
}
@Override
public void drawFG(int offsetX, int offsetY, int mouseX, int mouseY)
{
super.drawFG( offsetX, offsetY, mouseX, mouseY );
this.fontRendererObj.drawString( GuiText.CraftingTerminal.getLocal(), 8, this.ySize - 96 + 1 - this.reservedSpace, 4210752 );
}
}
@@ -18,6 +18,7 @@
package appeng.client.gui.implementations;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.entity.player.InventoryPlayer;
@@ -30,17 +31,24 @@ import appeng.core.sync.network.NetworkHandler;
import appeng.core.sync.packets.PacketSwitchGuis;
import appeng.tile.storage.TileDrive;
public class GuiDrive extends AEBaseGui
{
GuiTabButton priority;
public GuiDrive( InventoryPlayer inventoryPlayer, TileDrive te )
{
super( new ContainerDrive( inventoryPlayer, te ) );
this.ySize = 199;
}
@Override
protected void actionPerformed(GuiButton par1GuiButton)
protected void actionPerformed( GuiButton par1GuiButton )
{
super.actionPerformed( par1GuiButton );
if ( par1GuiButton == this.priority )
if( par1GuiButton == this.priority )
{
NetworkHandler.instance.sendToServer( new PacketSwitchGuis( GuiBridge.GUI_PRIORITY ) );
}
@@ -54,23 +62,17 @@ public class GuiDrive extends AEBaseGui
this.buttonList.add( this.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)
{
this.bindTexture( "guis/drive.png" );
this.drawTexturedModalRect( offsetX, offsetY, 0, 0, this.xSize, this.ySize );
}
@Override
public void drawFG(int offsetX, int offsetY, int mouseX, int mouseY)
public void drawFG( int offsetX, int offsetY, int mouseX, int mouseY )
{
this.fontRendererObj.drawString( this.getGuiDisplayName( GuiText.Drive.getLocal() ), 8, 6, 4210752 );
this.fontRendererObj.drawString( GuiText.inventory.getLocal(), 8, this.ySize - 96 + 3, 4210752 );
}
@Override
public void drawBG( int offsetX, int offsetY, int mouseX, int mouseY )
{
this.bindTexture( "guis/drive.png" );
this.drawTexturedModalRect( offsetX, offsetY, 0, 0, this.xSize, this.ySize );
}
}
@@ -50,19 +50,6 @@ public class GuiFormationPlane extends GuiUpgradeable
this.ySize = 251;
}
@Override
public void drawFG( int offsetX, int offsetY, int mouseX, int mouseY )
{
this.fontRendererObj.drawString( this.getGuiDisplayName( GuiText.FormationPlane.getLocal() ), 8, 6, 4210752 );
this.fontRendererObj.drawString( GuiText.inventory.getLocal(), 8, this.ySize - 96 + 3, 4210752 );
if ( this.fuzzyMode != null )
this.fuzzyMode.set( this.cvb.fzMode );
if ( this.placeMode != null )
this.placeMode.set( ( ( ContainerFormationPlane ) this.cvb ).placeMode );
}
@Override
protected void addButtons()
{
@@ -76,21 +63,16 @@ public class GuiFormationPlane extends GuiUpgradeable
}
@Override
protected void actionPerformed( GuiButton btn )
public void drawFG( int offsetX, int offsetY, int mouseX, int mouseY )
{
super.actionPerformed( btn );
this.fontRendererObj.drawString( this.getGuiDisplayName( GuiText.FormationPlane.getLocal() ), 8, 6, 4210752 );
this.fontRendererObj.drawString( GuiText.inventory.getLocal(), 8, this.ySize - 96 + 3, 4210752 );
boolean backwards = Mouse.isButtonDown( 1 );
if ( btn == this.priority )
{
NetworkHandler.instance.sendToServer( new PacketSwitchGuis( GuiBridge.GUI_PRIORITY ) );
}
else if ( btn == this.placeMode )
{
NetworkHandler.instance.sendToServer( new PacketConfigButton( this.placeMode.getSetting(), backwards ) );
}
if( this.fuzzyMode != null )
this.fuzzyMode.set( this.cvb.fzMode );
if( this.placeMode != null )
this.placeMode.set( ( (ContainerFormationPlane) this.cvb ).placeMode );
}
@Override
@@ -99,4 +81,20 @@ public class GuiFormationPlane extends GuiUpgradeable
return "guis/storagebus.png";
}
@Override
protected void actionPerformed( GuiButton btn )
{
super.actionPerformed( btn );
boolean backwards = Mouse.isButtonDown( 1 );
if( btn == this.priority )
{
NetworkHandler.instance.sendToServer( new PacketSwitchGuis( GuiBridge.GUI_PRIORITY ) );
}
else if( btn == this.placeMode )
{
NetworkHandler.instance.sendToServer( new PacketConfigButton( this.placeMode.getSetting(), backwards ) );
}
}
}
@@ -18,6 +18,7 @@
package appeng.client.gui.implementations;
import net.minecraft.entity.player.InventoryPlayer;
import appeng.client.gui.AEBaseGui;
@@ -25,26 +26,27 @@ 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) {
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)
{
this.bindTexture( "guis/grinder.png" );
this.drawTexturedModalRect( offsetX, offsetY, 0, 0, this.xSize, this.ySize );
}
@Override
public void drawFG(int offsetX, int offsetY, int mouseX, int mouseY)
public void drawFG( int offsetX, int offsetY, int mouseX, int mouseY )
{
this.fontRendererObj.drawString( this.getGuiDisplayName( GuiText.GrindStone.getLocal() ), 8, 6, 4210752 );
this.fontRendererObj.drawString( GuiText.inventory.getLocal(), 8, this.ySize - 96 + 3, 4210752 );
}
@Override
public void drawBG( int offsetX, int offsetY, int mouseX, int mouseY )
{
this.bindTexture( "guis/grinder.png" );
this.drawTexturedModalRect( offsetX, offsetY, 0, 0, this.xSize, this.ySize );
}
}
@@ -18,6 +18,7 @@
package appeng.client.gui.implementations;
import org.lwjgl.input.Mouse;
import net.minecraft.client.gui.GuiButton;
@@ -37,51 +38,19 @@ 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) {
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 );
final IDefinitions definitions = AEApi.instance().definitions();
for ( ItemStack cell1kStack : definitions.items().cell1k().maybeStack( 1 ).asSet() )
{
this.drawItem( offsetX + 66 - 8, offsetY + 17, cell1kStack );
}
for ( ItemStack driveStack : definitions.blocks().drive().maybeStack( 1 ).asSet() )
{
this.drawItem( offsetX + 94 + 8, offsetY + 17, driveStack );
}
}
@Override
public void drawFG(int offsetX, int offsetY, int mouseX, int mouseY)
{
this.fontRendererObj.drawString( this.getGuiDisplayName( GuiText.IOPort.getLocal() ), 8, 6, 4210752 );
this.fontRendererObj.drawString( GuiText.inventory.getLocal(), 8, this.ySize - 96 + 3, 4210752 );
if ( this.redstoneMode != null )
this.redstoneMode.set( this.cvb.rsMode );
if ( this.operationMode != null )
this.operationMode.set( ((ContainerIOPort) this.cvb).opMode );
if ( this.fullMode != null )
this.fullMode.set( ((ContainerIOPort) this.cvb).fMode );
}
@Override
protected void addButtons()
{
@@ -95,17 +64,37 @@ public class GuiIOPort extends GuiUpgradeable
}
@Override
protected void actionPerformed(GuiButton btn)
public void drawFG( int offsetX, int offsetY, int mouseX, int mouseY )
{
super.actionPerformed( btn );
this.fontRendererObj.drawString( this.getGuiDisplayName( GuiText.IOPort.getLocal() ), 8, 6, 4210752 );
this.fontRendererObj.drawString( GuiText.inventory.getLocal(), 8, this.ySize - 96 + 3, 4210752 );
boolean backwards = Mouse.isButtonDown( 1 );
if( this.redstoneMode != null )
this.redstoneMode.set( this.cvb.rsMode );
if ( btn == this.fullMode )
NetworkHandler.instance.sendToServer( new PacketConfigButton( this.fullMode.getSetting(), backwards ) );
if( this.operationMode != null )
this.operationMode.set( ( (ContainerIOPort) this.cvb ).opMode );
if ( btn == this.operationMode )
NetworkHandler.instance.sendToServer( new PacketConfigButton( this.operationMode.getSetting(), backwards ) );
if( this.fullMode != null )
this.fullMode.set( ( (ContainerIOPort) this.cvb ).fMode );
}
@Override
public void drawBG( int offsetX, int offsetY, int mouseX, int mouseY )
{
super.drawBG( offsetX, offsetY, mouseX, mouseY );
final IDefinitions definitions = AEApi.instance().definitions();
for( ItemStack cell1kStack : definitions.items().cell1k().maybeStack( 1 ).asSet() )
{
this.drawItem( offsetX + 66 - 8, offsetY + 17, cell1kStack );
}
for( ItemStack driveStack : definitions.blocks().drive().maybeStack( 1 ).asSet() )
{
this.drawItem( offsetX + 94 + 8, offsetY + 17, driveStack );
}
}
@Override
@@ -114,4 +103,17 @@ public class GuiIOPort extends GuiUpgradeable
return "guis/ioport.png";
}
@Override
protected void actionPerformed( GuiButton btn )
{
super.actionPerformed( btn );
boolean backwards = Mouse.isButtonDown( 1 );
if( btn == this.fullMode )
NetworkHandler.instance.sendToServer( new PacketConfigButton( this.fullMode.getSetting(), backwards ) );
if( btn == this.operationMode )
NetworkHandler.instance.sendToServer( new PacketConfigButton( this.operationMode.getSetting(), backwards ) );
}
}
@@ -18,6 +18,7 @@
package appeng.client.gui.implementations;
import net.minecraft.entity.player.InventoryPlayer;
import appeng.client.gui.AEBaseGui;
@@ -28,13 +29,14 @@ import appeng.container.implementations.ContainerUpgradeable;
import appeng.core.localization.GuiText;
import appeng.tile.misc.TileInscriber;
public class GuiInscriber extends AEBaseGui
{
final ContainerInscriber cvc;
GuiProgressBar pb;
public GuiInscriber(InventoryPlayer inventoryPlayer, TileInscriber te)
public GuiInscriber( InventoryPlayer inventoryPlayer, TileInscriber te )
{
super( new ContainerInscriber( inventoryPlayer, te ) );
this.cvc = (ContainerInscriber) this.inventorySlots;
@@ -42,32 +44,22 @@ public class GuiInscriber extends AEBaseGui
this.xSize = this.hasToolbox() ? 246 : 211;
}
protected boolean hasToolbox()
{
return ( (ContainerUpgradeable) this.inventorySlots ).hasToolbox();
}
@Override
public void initGui()
{
super.initGui();
this.pb = new GuiProgressBar( this.cvc, "guis/inscriber.png", 135, 39, 135, 177, 6, 18, Direction.VERTICAL );
this.pb = new GuiProgressBar( this.cvc, "guis/inscriber.png", 135, 39, 135, 177, 6, 18, Direction.VERTICAL );
this.buttonList.add( this.pb );
}
@Override
public void drawBG(int offsetX, int offsetY, int mouseX, int mouseY)
{
this.bindTexture( "guis/inscriber.png" );
this.pb.xPosition = 135 + this.guiLeft;
this.pb.yPosition = 39 + this.guiTop;
this.drawTexturedModalRect( offsetX, offsetY, 0, 0, 211 - 34, this.ySize );
if ( this.drawUpgrades() )
this.drawTexturedModalRect( offsetX + 177, offsetY, 177, 0, 35, 14 + this.cvc.availableUpgrades() * 18 );
if ( this.hasToolbox() )
this.drawTexturedModalRect( offsetX + 178, offsetY + this.ySize - 90, 178, this.ySize - 90, 68, 68 );
}
@Override
public void drawFG(int offsetX, int offsetY, int mouseX, int mouseY)
public void drawFG( int offsetX, int offsetY, int mouseX, int mouseY )
{
this.pb.setFullMsg( this.cvc.getCurrentProgress() * 100 / this.cvc.getMaxProgress() + "%" );
@@ -75,14 +67,23 @@ public class GuiInscriber extends AEBaseGui
this.fontRendererObj.drawString( GuiText.inventory.getLocal(), 8, this.ySize - 96 + 3, 4210752 );
}
@Override
public void drawBG( int offsetX, int offsetY, int mouseX, int mouseY )
{
this.bindTexture( "guis/inscriber.png" );
this.pb.xPosition = 135 + this.guiLeft;
this.pb.yPosition = 39 + this.guiTop;
this.drawTexturedModalRect( offsetX, offsetY, 0, 0, 211 - 34, this.ySize );
if( this.drawUpgrades() )
this.drawTexturedModalRect( offsetX + 177, offsetY, 177, 0, 35, 14 + this.cvc.availableUpgrades() * 18 );
if( this.hasToolbox() )
this.drawTexturedModalRect( offsetX + 178, offsetY + this.ySize - 90, 178, this.ySize - 90, 68, 68 );
}
protected boolean drawUpgrades()
{
return true;
}
protected boolean hasToolbox()
{
return ((ContainerUpgradeable) this.inventorySlots).hasToolbox();
}
}
@@ -18,6 +18,7 @@
package appeng.client.gui.implementations;
import org.lwjgl.input.Mouse;
import net.minecraft.client.gui.GuiButton;
@@ -36,6 +37,7 @@ import appeng.core.sync.packets.PacketConfigButton;
import appeng.core.sync.packets.PacketSwitchGuis;
import appeng.helpers.IInterfaceHost;
public class GuiInterface extends GuiUpgradeable
{
@@ -43,30 +45,12 @@ public class GuiInterface extends GuiUpgradeable
GuiImgButton BlockMode;
GuiToggleButton interfaceMode;
public GuiInterface(InventoryPlayer inventoryPlayer, IInterfaceHost te) {
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 == this.priority )
{
NetworkHandler.instance.sendToServer( new PacketSwitchGuis( GuiBridge.GUI_PRIORITY ) );
}
if ( btn == this.interfaceMode )
NetworkHandler.instance.sendToServer( new PacketConfigButton( Settings.INTERFACE_TERMINAL, backwards ) );
if ( btn == this.BlockMode )
NetworkHandler.instance.sendToServer( new PacketConfigButton( this.BlockMode.getSetting(), backwards ) );
}
@Override
protected void addButtons()
{
@@ -76,25 +60,18 @@ public class GuiInterface extends GuiUpgradeable
this.BlockMode = new GuiImgButton( this.guiLeft - 18, this.guiTop + 8, Settings.BLOCK, YesNo.NO );
this.buttonList.add( this.BlockMode );
this.interfaceMode = new GuiToggleButton( this.guiLeft - 18, this.guiTop + 26, 84, 85, GuiText.InterfaceTerminal.getLocal(),
GuiText.InterfaceTerminalHint.getLocal() );
this.interfaceMode = new GuiToggleButton( this.guiLeft - 18, this.guiTop + 26, 84, 85, GuiText.InterfaceTerminal.getLocal(), GuiText.InterfaceTerminalHint.getLocal() );
this.buttonList.add( this.interfaceMode );
}
@Override
protected String getBackground()
public void drawFG( int offsetX, int offsetY, int mouseX, int mouseY )
{
return "guis/interface.png";
}
if( this.BlockMode != null )
this.BlockMode.set( ( (ContainerInterface) this.cvb ).bMode );
@Override
public void drawFG(int offsetX, int offsetY, int mouseX, int mouseY)
{
if ( this.BlockMode != null )
this.BlockMode.set( ((ContainerInterface) this.cvb).bMode );
if ( this.interfaceMode != null )
this.interfaceMode.setState( ((ContainerInterface) this.cvb).iTermMode == YesNo.YES );
if( this.interfaceMode != null )
this.interfaceMode.setState( ( (ContainerInterface) this.cvb ).iTermMode == YesNo.YES );
this.fontRendererObj.drawString( this.getGuiDisplayName( GuiText.Interface.getLocal() ), 8, 6, 4210752 );
@@ -104,4 +81,29 @@ public class GuiInterface extends GuiUpgradeable
this.fontRendererObj.drawString( GuiText.inventory.getLocal(), 8, this.ySize - 96 + 3, 4210752 );
}
@Override
protected String getBackground()
{
return "guis/interface.png";
}
@Override
protected void actionPerformed( GuiButton btn )
{
super.actionPerformed( btn );
boolean backwards = Mouse.isButtonDown( 1 );
if( btn == this.priority )
{
NetworkHandler.instance.sendToServer( new PacketSwitchGuis( GuiBridge.GUI_PRIORITY ) );
}
if( btn == this.interfaceMode )
NetworkHandler.instance.sendToServer( new PacketConfigButton( Settings.INTERFACE_TERMINAL, backwards ) );
if( btn == this.BlockMode )
NetworkHandler.instance.sendToServer( new PacketConfigButton( this.BlockMode.getSetting(), backwards ) );
}
}
@@ -28,8 +28,6 @@ import java.util.Map;
import java.util.Set;
import java.util.WeakHashMap;
import com.google.common.collect.HashMultimap;
import org.lwjgl.opengl.GL11;
import net.minecraft.entity.player.InventoryPlayer;
@@ -37,6 +35,8 @@ import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import com.google.common.collect.HashMultimap;
import appeng.api.AEApi;
import appeng.client.gui.AEBaseGui;
import appeng.client.gui.widgets.GuiScrollbar;
@@ -48,6 +48,7 @@ import appeng.core.localization.GuiText;
import appeng.parts.reporting.PartMonitor;
import appeng.util.Platform;
public class GuiInterfaceTerminal extends AEBaseGui
{
@@ -66,7 +67,7 @@ public class GuiInterfaceTerminal extends AEBaseGui
private boolean refreshList = false;
private MEGuiTextField searchField;
public GuiInterfaceTerminal(InventoryPlayer inventoryPlayer, PartMonitor te)
public GuiInterfaceTerminal( InventoryPlayer inventoryPlayer, PartMonitor te )
{
super( new ContainerInterfaceTerminal( inventoryPlayer, te ) );
this.myScrollBar = new GuiScrollbar();
@@ -92,11 +93,54 @@ public class GuiInterfaceTerminal extends AEBaseGui
}
@Override
protected void mouseClicked(int xCoord, int yCoord, int btn)
public void drawFG( int offsetX, int offsetY, int mouseX, int mouseY )
{
this.fontRendererObj.drawString( this.getGuiDisplayName( GuiText.InterfaceTerminal.getLocal() ), 8, 6, 4210752 );
this.fontRendererObj.drawString( GuiText.inventory.getLocal(), 8, this.ySize - 96 + 3, 4210752 );
int offset = 17;
int ex = this.myScrollBar.getCurrentScroll();
Iterator<Object> o = this.inventorySlots.inventorySlots.iterator();
while( o.hasNext() )
{
if( o.next() instanceof SlotDisconnected )
o.remove();
}
for( int x = 0; x < LINES_ON_PAGE && ex + x < this.lines.size(); x++ )
{
Object lineObj = this.lines.get( ex + x );
if( lineObj instanceof ClientDCInternalInv )
{
ClientDCInternalInv inv = (ClientDCInternalInv) lineObj;
for( int z = 0; z < inv.inv.getSizeInventory(); z++ )
{
this.inventorySlots.inventorySlots.add( new SlotDisconnected( inv, z, z * 18 + 8, 1 + offset ) );
}
}
else if( lineObj instanceof String )
{
String name = (String) lineObj;
int rows = this.byName.get( name ).size();
if( rows > 1 )
name = name + " (" + rows + ')';
while( name.length() > 2 && this.fontRendererObj.getStringWidth( name ) > 155 )
name = name.substring( 0, name.length() - 1 );
this.fontRendererObj.drawString( name, 10, 6 + offset, 4210752 );
}
offset += 18;
}
}
@Override
protected void mouseClicked( int xCoord, int yCoord, int btn )
{
this.searchField.mouseClicked( xCoord, yCoord, btn );
if ( btn == 1 && this.searchField.isMouseIn( xCoord, yCoord ) )
if( btn == 1 && this.searchField.isMouseIn( xCoord, yCoord ) )
{
this.searchField.setText( "" );
this.refreshList();
@@ -106,26 +150,7 @@ public class GuiInterfaceTerminal extends AEBaseGui
}
@Override
protected void keyTyped(char character, int key)
{
if ( !this.checkHotbarKeys( key ) )
{
if ( character == ' ' && this.searchField.getText().length() == 0 )
return;
if ( this.searchField.textboxKeyTyped( character, key ) )
{
this.refreshList();
}
else
{
super.keyTyped( character, key );
}
}
}
@Override
public void drawBG(int offsetX, int offsetY, int mouseX, int mouseY)
public void drawBG( int offsetX, int offsetY, int mouseX, int mouseY )
{
this.bindTexture( "guis/interfaceterminal.png" );
this.drawTexturedModalRect( offsetX, offsetY, 0, 0, this.xSize, this.ySize );
@@ -133,10 +158,10 @@ public class GuiInterfaceTerminal extends AEBaseGui
int offset = 17;
int ex = this.myScrollBar.getCurrentScroll();
for (int x = 0; x < LINES_ON_PAGE && ex + x < this.lines.size(); x++)
for( int x = 0; x < LINES_ON_PAGE && ex + x < this.lines.size(); x++ )
{
Object lineObj = this.lines.get( ex + x );
if ( lineObj instanceof ClientDCInternalInv )
if( lineObj instanceof ClientDCInternalInv )
{
ClientDCInternalInv inv = (ClientDCInternalInv) lineObj;
@@ -147,65 +172,41 @@ public class GuiInterfaceTerminal extends AEBaseGui
offset += 18;
}
if ( this.searchField != null )
if( this.searchField != null )
this.searchField.drawTextBox();
}
@Override
public void drawFG(int offsetX, int offsetY, int mouseX, int mouseY)
protected void keyTyped( char character, int key )
{
this.fontRendererObj.drawString( this.getGuiDisplayName( GuiText.InterfaceTerminal.getLocal() ), 8, 6, 4210752 );
this.fontRendererObj.drawString( GuiText.inventory.getLocal(), 8, this.ySize - 96 + 3, 4210752 );
int offset = 17;
int ex = this.myScrollBar.getCurrentScroll();
Iterator<Object> o = this.inventorySlots.inventorySlots.iterator();
while (o.hasNext())
if( !this.checkHotbarKeys( key ) )
{
if ( o.next() instanceof SlotDisconnected )
o.remove();
}
if( character == ' ' && this.searchField.getText().length() == 0 )
return;
for (int x = 0; x < LINES_ON_PAGE && ex + x < this.lines.size(); x++)
{
Object lineObj = this.lines.get( ex + x );
if ( lineObj instanceof ClientDCInternalInv )
if( this.searchField.textboxKeyTyped( character, key ) )
{
ClientDCInternalInv inv = (ClientDCInternalInv) lineObj;
for (int z = 0; z < inv.inv.getSizeInventory(); z++)
{
this.inventorySlots.inventorySlots.add( new SlotDisconnected( inv, z, z * 18 + 8, 1 + offset ) );
}
this.refreshList();
}
else if ( lineObj instanceof String )
else
{
String name = (String) lineObj;
int rows = this.byName.get( name ).size();
if ( rows > 1 )
name = name + " (" + rows + ')';
while (name.length() > 2 && this.fontRendererObj.getStringWidth( name ) > 155)
name = name.substring( 0, name.length() - 1 );
this.fontRendererObj.drawString( name, 10, 6 + offset, 4210752 );
super.keyTyped( character, key );
}
offset += 18;
}
}
public void postUpdate(NBTTagCompound in)
public void postUpdate( NBTTagCompound in )
{
if ( in.getBoolean( "clear" ) )
if( in.getBoolean( "clear" ) )
{
this.byId.clear();
this.refreshList = true;
}
for (Object oKey : in.func_150296_c())
for( Object oKey : in.func_150296_c() )
{
String key = (String) oKey;
if ( key.startsWith( "=" ) )
if( key.startsWith( "=" ) )
{
try
{
@@ -213,20 +214,20 @@ public class GuiInterfaceTerminal extends AEBaseGui
NBTTagCompound invData = in.getCompoundTag( key );
ClientDCInternalInv current = this.getById( id, invData.getLong( "sortBy" ), invData.getString( "un" ) );
for (int x = 0; x < current.inv.getSizeInventory(); x++)
for( int x = 0; x < current.inv.getSizeInventory(); x++ )
{
String which = Integer.toString( x );
if ( invData.hasKey( which ) )
if( invData.hasKey( which ) )
current.inv.setInventorySlotContents( x, ItemStack.loadItemStackFromNBT( invData.getCompoundTag( which ) ) );
}
}
catch (NumberFormatException ignored)
catch( NumberFormatException ignored )
{
}
}
}
if ( this.refreshList )
if( this.refreshList )
{
this.refreshList = false;
// invalid caches on refresh
@@ -249,10 +250,10 @@ public class GuiInterfaceTerminal extends AEBaseGui
final Set<Object> cachedSearch = this.getCacheForSearchTerm( searchFilterLowerCase );
final boolean rebuild = cachedSearch.isEmpty();
for (ClientDCInternalInv entry : this.byId.values())
for( ClientDCInternalInv entry : this.byId.values() )
{
// ignore inventory if not doing a full rebuild or cache already marks it as miss.
if ( !rebuild && !cachedSearch.contains( entry ) )
if( !rebuild && !cachedSearch.contains( entry ) )
{
continue;
}
@@ -261,12 +262,12 @@ public class GuiInterfaceTerminal extends AEBaseGui
boolean found = searchFilterLowerCase.isEmpty();
// Search if the current inventory holds a pattern containing the search term.
if ( !found && !searchFilterLowerCase.isEmpty() )
if( !found && !searchFilterLowerCase.isEmpty() )
{
for (ItemStack itemStack : entry.inv)
for( ItemStack itemStack : entry.inv )
{
found = this.itemStackMatchesSearchTerm( itemStack, searchFilterLowerCase );
if ( found )
if( found )
{
break;
}
@@ -274,7 +275,7 @@ public class GuiInterfaceTerminal extends AEBaseGui
}
// if found, filter skipped or machine name matching the search term, add it
if ( found || entry.getName().toLowerCase().contains( searchFilterLowerCase ) )
if( found || entry.getName().toLowerCase().contains( searchFilterLowerCase ) )
{
this.byName.put( entry.getName(), entry );
cachedSearch.add( entry );
@@ -293,7 +294,7 @@ public class GuiInterfaceTerminal extends AEBaseGui
this.lines.clear();
this.lines.ensureCapacity( this.getMaxRows() );
for (String n : this.names)
for( String n : this.names )
{
this.lines.add( n );
@@ -307,16 +308,16 @@ public class GuiInterfaceTerminal extends AEBaseGui
this.myScrollBar.setRange( 0, this.lines.size() - LINES_ON_PAGE, 2 );
}
private boolean itemStackMatchesSearchTerm(ItemStack itemStack, String searchTerm)
private boolean itemStackMatchesSearchTerm( ItemStack itemStack, String searchTerm )
{
if ( itemStack == null )
if( itemStack == null )
{
return false;
}
NBTTagCompound encodedValue = itemStack.getTagCompound();
if ( encodedValue == null )
if( encodedValue == null )
{
return false;
}
@@ -325,19 +326,18 @@ public class GuiInterfaceTerminal extends AEBaseGui
// NBTTagList inTag = encodedValue.getTagList( "in", 10 );
NBTTagList outTag = encodedValue.getTagList( "out", 10 );
for (int i = 0; i < outTag.tagCount(); i++)
for( int i = 0; i < outTag.tagCount(); i++ )
{
ItemStack parsedItemStack = ItemStack.loadItemStackFromNBT( outTag.getCompoundTagAt( i ) );
if ( parsedItemStack != null )
if( parsedItemStack != null )
{
String displayName = Platform.getItemDisplayName( AEApi.instance().storage().createItemStack( parsedItemStack ) ).toLowerCase();
if ( displayName.contains( searchTerm ) )
if( displayName.contains( searchTerm ) )
{
return true;
}
}
}
return false;
}
@@ -348,20 +348,20 @@ public class GuiInterfaceTerminal extends AEBaseGui
* If this cache should be empty, it will populate it with an earlier cache if available or at least the cache for
* the empty string.
*
* @param searchTerm
* the corresponding search
* @param searchTerm the corresponding search
*
* @return a Set matching a superset of the search term
*/
private Set<Object> getCacheForSearchTerm(String searchTerm)
private Set<Object> getCacheForSearchTerm( String searchTerm )
{
if ( !this.cachedSearches.containsKey( searchTerm ) )
if( !this.cachedSearches.containsKey( searchTerm ) )
{
this.cachedSearches.put( searchTerm, new HashSet<Object>() );
}
Set<Object> cache = this.cachedSearches.get( searchTerm );
if ( cache.isEmpty() && searchTerm.length() > 1 )
if( cache.isEmpty() && searchTerm.length() > 1 )
{
cache.addAll( this.getCacheForSearchTerm( searchTerm.substring( 0, searchTerm.length() - 1 ) ) );
return cache;
@@ -380,11 +380,11 @@ public class GuiInterfaceTerminal extends AEBaseGui
return this.names.size() + this.byId.size();
}
private ClientDCInternalInv getById(long id, long sortBy, String string)
private ClientDCInternalInv getById( long id, long sortBy, String string )
{
ClientDCInternalInv o = this.byId.get( id );
if ( o == null )
if( o == null )
{
this.byId.put( id, o = new ClientDCInternalInv( 9, id, sortBy, string ) );
this.refreshList = true;
@@ -18,6 +18,7 @@
package appeng.client.gui.implementations;
import java.io.IOException;
import org.lwjgl.input.Mouse;
@@ -42,6 +43,7 @@ import appeng.core.sync.packets.PacketConfigButton;
import appeng.core.sync.packets.PacketValueConfig;
import appeng.parts.automation.PartLevelEmitter;
public class GuiLevelEmitter extends GuiUpgradeable
{
@@ -59,7 +61,8 @@ public class GuiLevelEmitter extends GuiUpgradeable
GuiImgButton levelMode;
GuiImgButton craftingMode;
public GuiLevelEmitter(InventoryPlayer inventoryPlayer, PartLevelEmitter te) {
public GuiLevelEmitter( InventoryPlayer inventoryPlayer, PartLevelEmitter te )
{
super( new ContainerLevelEmitter( inventoryPlayer, te ) );
}
@@ -74,7 +77,7 @@ public class GuiLevelEmitter extends GuiUpgradeable
this.level.setTextColor( 0xFFFFFF );
this.level.setVisible( true );
this.level.setFocused( true );
((ContainerLevelEmitter) this.inventorySlots).setTextField( this.level );
( (ContainerLevelEmitter) this.inventorySlots ).setTextField( this.level );
}
@Override
@@ -107,111 +110,7 @@ public class GuiLevelEmitter extends GuiUpgradeable
}
@Override
protected void actionPerformed(GuiButton btn)
{
super.actionPerformed( btn );
boolean backwards = Mouse.isButtonDown( 1 );
if ( btn == this.craftingMode )
NetworkHandler.instance.sendToServer( new PacketConfigButton( this.craftingMode.getSetting(), backwards ) );
if ( btn == this.levelMode )
NetworkHandler.instance.sendToServer( new PacketConfigButton( this.levelMode.getSetting(), backwards ) );
boolean isPlus = btn == this.plus1 || btn == this.plus10 || btn == this.plus100 || btn == this.plus1000;
boolean isMinus = btn == this.minus1 || btn == this.minus10 || btn == this.minus100 || btn == this.minus1000;
if ( isPlus || isMinus )
this.addQty( this.getQty( btn ) );
}
private void addQty(long i)
{
try
{
String Out = this.level.getText();
boolean Fixed = false;
while (Out.startsWith( "0" ) && Out.length() > 1)
{
Out = Out.substring( 1 );
Fixed = true;
}
if ( Fixed )
this.level.setText( Out );
if ( Out.length() == 0 )
Out = "0";
long result = Long.parseLong( Out );
result += i;
if ( result < 0 )
result = 0;
this.level.setText( Out = Long.toString( result ) );
NetworkHandler.instance.sendToServer( new PacketValueConfig( "LevelEmitter.Value", Out ) );
}
catch (NumberFormatException e)
{
// nope..
this.level.setText( "0" );
}
catch (IOException e)
{
AELog.error( e );
}
}
@Override
protected void handleButtonVisibility()
{
this.craftingMode.setVisibility( this.bc.getInstalledUpgrades( Upgrades.CRAFTING ) > 0 );
this.fuzzyMode.setVisibility( this.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 )) && this.level.textboxKeyTyped( character, key ) )
{
try
{
String Out = this.level.getText();
boolean Fixed = false;
while (Out.startsWith( "0" ) && Out.length() > 1)
{
Out = Out.substring( 1 );
Fixed = true;
}
if ( Fixed )
this.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)
public void drawFG( int offsetX, int offsetY, int mouseX, int mouseY )
{
boolean notCraftingMode = this.bc.getInstalledUpgrades( Upgrades.CRAFTING ) == 0;
@@ -230,20 +129,27 @@ public class GuiLevelEmitter extends GuiUpgradeable
super.drawFG( offsetX, offsetY, mouseX, mouseY );
if ( this.craftingMode != null )
this.craftingMode.set( ((ContainerLevelEmitter) this.cvb).cmType );
if( this.craftingMode != null )
this.craftingMode.set( ( (ContainerLevelEmitter) this.cvb ).cmType );
if ( this.levelMode != null )
this.levelMode.set( ((ContainerLevelEmitter) this.cvb).lvType );
if( this.levelMode != null )
this.levelMode.set( ( (ContainerLevelEmitter) this.cvb ).lvType );
}
@Override
public void drawBG(int offsetX, int offsetY, int mouseX, int mouseY)
public void drawBG( int offsetX, int offsetY, int mouseX, int mouseY )
{
super.drawBG( offsetX, offsetY, mouseX, mouseY );
this.level.drawTextBox();
}
@Override
protected void handleButtonVisibility()
{
this.craftingMode.setVisibility( this.bc.getInstalledUpgrades( Upgrades.CRAFTING ) > 0 );
this.fuzzyMode.setVisibility( this.bc.getInstalledUpgrades( Upgrades.FUZZY ) > 0 );
}
@Override
protected String getBackground()
{
@@ -255,4 +161,101 @@ public class GuiLevelEmitter extends GuiUpgradeable
{
return GuiText.LevelEmitter;
}
@Override
protected void actionPerformed( GuiButton btn )
{
super.actionPerformed( btn );
boolean backwards = Mouse.isButtonDown( 1 );
if( btn == this.craftingMode )
NetworkHandler.instance.sendToServer( new PacketConfigButton( this.craftingMode.getSetting(), backwards ) );
if( btn == this.levelMode )
NetworkHandler.instance.sendToServer( new PacketConfigButton( this.levelMode.getSetting(), backwards ) );
boolean isPlus = btn == this.plus1 || btn == this.plus10 || btn == this.plus100 || btn == this.plus1000;
boolean isMinus = btn == this.minus1 || btn == this.minus10 || btn == this.minus100 || btn == this.minus1000;
if( isPlus || isMinus )
this.addQty( this.getQty( btn ) );
}
private void addQty( long i )
{
try
{
String Out = this.level.getText();
boolean Fixed = false;
while( Out.startsWith( "0" ) && Out.length() > 1 )
{
Out = Out.substring( 1 );
Fixed = true;
}
if( Fixed )
this.level.setText( Out );
if( Out.length() == 0 )
Out = "0";
long result = Long.parseLong( Out );
result += i;
if( result < 0 )
result = 0;
this.level.setText( Out = Long.toString( result ) );
NetworkHandler.instance.sendToServer( new PacketValueConfig( "LevelEmitter.Value", Out ) );
}
catch( NumberFormatException e )
{
// nope..
this.level.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.isDigit( character ) ) && this.level.textboxKeyTyped( character, key ) )
{
try
{
String Out = this.level.getText();
boolean Fixed = false;
while( Out.startsWith( "0" ) && Out.length() > 1 )
{
Out = Out.substring( 1 );
Fixed = true;
}
if( Fixed )
this.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 );
}
}
}
}
@@ -18,6 +18,7 @@
package appeng.client.gui.implementations;
import net.minecraft.entity.player.InventoryPlayer;
import appeng.api.config.RedstoneMode;
@@ -29,12 +30,20 @@ import appeng.container.implementations.ContainerMAC;
import appeng.core.localization.GuiText;
import appeng.tile.crafting.TileMolecularAssembler;
public class GuiMAC extends GuiUpgradeable
{
final ContainerMAC container;
GuiProgressBar pb;
public GuiMAC( InventoryPlayer inventoryPlayer, TileMolecularAssembler te )
{
super( new ContainerMAC( inventoryPlayer, te ) );
this.ySize = 197;
this.container = (ContainerMAC) this.inventorySlots;
}
@Override
public void initGui()
{
@@ -45,25 +54,25 @@ public class GuiMAC extends GuiUpgradeable
}
@Override
public void drawBG(int offsetX, int offsetY, int mouseX, int mouseY)
protected void addButtons()
{
this.pb.xPosition = 148 + this.guiLeft;
this.pb.yPosition = 48 + this.guiTop;
super.drawBG( offsetX, offsetY, mouseX, mouseY );
this.redstoneMode = new GuiImgButton( this.guiLeft - 18, this.guiTop + 8, Settings.REDSTONE_CONTROLLED, RedstoneMode.IGNORE );
this.buttonList.add( this.redstoneMode );
}
@Override
public void drawFG(int offsetX, int offsetY, int mouseX, int mouseY)
public void drawFG( int offsetX, int offsetY, int mouseX, int mouseY )
{
this.pb.setFullMsg( this.container.getCurrentProgress() + "%" );
super.drawFG( offsetX, offsetY, mouseX, mouseY );
}
@Override
protected void addButtons()
public void drawBG( int offsetX, int offsetY, int mouseX, int mouseY )
{
this.redstoneMode = new GuiImgButton( this.guiLeft - 18, this.guiTop + 8, Settings.REDSTONE_CONTROLLED, RedstoneMode.IGNORE );
this.buttonList.add( this.redstoneMode );
this.pb.xPosition = 148 + this.guiLeft;
this.pb.yPosition = 48 + this.guiTop;
super.drawBG( offsetX, offsetY, mouseX, mouseY );
}
@Override
@@ -72,13 +81,6 @@ public class GuiMAC extends GuiUpgradeable
return "guis/mac.png";
}
public GuiMAC(InventoryPlayer inventoryPlayer, TileMolecularAssembler te)
{
super( new ContainerMAC( inventoryPlayer, te ) );
this.ySize = 197;
this.container = (ContainerMAC) this.inventorySlots;
}
@Override
protected GuiText getName()
{
@@ -18,6 +18,7 @@
package appeng.client.gui.implementations;
import java.io.IOException;
import java.util.List;
@@ -65,50 +66,42 @@ 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;
private static String memoryText = "";
final ItemRepo repo;
GuiText myName;
final int offsetX = 9;
final int lowerTextureOffset = 0;
final IConfigManager configSrc;
final boolean viewCell;
final ItemStack[] myCurrentViewCells = new ItemStack[5];
final ContainerMEMonitorable monitorableContainer;
GuiTabButton craftingStatusBtn;
MEGuiTextField searchField;
GuiText myName;
int perRow = 9;
int reservedSpace = 0;
final int lowerTextureOffset = 0;
boolean customSortOrder = true;
int rows = 0;
int maxRows = Integer.MAX_VALUE;
int standardSize;
final IConfigManager configSrc;
GuiImgButton ViewBox;
GuiImgButton SortByBox;
GuiImgButton SortDirBox;
GuiImgButton searchBoxSettings;
GuiImgButton terminalStyleBox;
final boolean viewCell;
final ItemStack[] myCurrentViewCells = new ItemStack[5];
final ContainerMEMonitorable monitorableContainer;
public GuiMEMonitorable(InventoryPlayer inventoryPlayer, ITerminalHost te) {
public GuiMEMonitorable( InventoryPlayer inventoryPlayer, ITerminalHost te )
{
this( inventoryPlayer, te, new ContainerMEMonitorable( inventoryPlayer, te ) );
}
public GuiMEMonitorable(InventoryPlayer inventoryPlayer, ITerminalHost te, ContainerMEMonitorable c) {
public GuiMEMonitorable( InventoryPlayer inventoryPlayer, ITerminalHost te, ContainerMEMonitorable c )
{
super( c );
this.myScrollBar = new GuiScrollbar();
@@ -117,31 +110,31 @@ public class GuiMEMonitorable extends AEBaseMEGui implements ISortSource, IConfi
this.xSize = 185;
this.ySize = 204;
if ( te instanceof IViewCellStorage )
if( te instanceof IViewCellStorage )
this.xSize += 33;
this.standardSize = this.xSize;
this.configSrc = ((IConfigurableObject) this.inventorySlots).getConfigManager();
(this.monitorableContainer = (ContainerMEMonitorable) this.inventorySlots).gui = this;
this.configSrc = ( (IConfigurableObject) this.inventorySlots ).getConfigManager();
( this.monitorableContainer = (ContainerMEMonitorable) this.inventorySlots ).gui = this;
this.viewCell = te instanceof IViewCellStorage;
if ( te instanceof TileSecurity )
if( te instanceof TileSecurity )
this.myName = GuiText.Security;
else if ( te instanceof WirelessTerminalGuiObject )
else if( te instanceof WirelessTerminalGuiObject )
this.myName = GuiText.WirelessTerminal;
else if ( te instanceof IPortableCell )
else if( te instanceof IPortableCell )
this.myName = GuiText.PortableCell;
else if ( te instanceof IMEChest )
else if( te instanceof IMEChest )
this.myName = GuiText.Chest;
else if ( te instanceof PartTerminal )
else if( te instanceof PartTerminal )
this.myName = GuiText.Terminal;
}
public void postUpdate(List<IAEItemStack> list)
public void postUpdate( List<IAEItemStack> list )
{
for (IAEItemStack is : list)
for( IAEItemStack is : list )
this.repo.postUpdate( is );
this.repo.updateView();
@@ -151,7 +144,49 @@ public class GuiMEMonitorable extends AEBaseMEGui implements ISortSource, IConfi
private void setScrollBar()
{
this.myScrollBar.setTop( 18 ).setLeft( 175 ).setHeight( this.rows * 18 - 2 );
this.myScrollBar.setRange( 0, (this.repo.size() + this.perRow - 1) / this.perRow - this.rows, Math.max( 1, this.rows / 6 ) );
this.myScrollBar.setRange( 0, ( this.repo.size() + this.perRow - 1 ) / this.perRow - this.rows, Math.max( 1, this.rows / 6 ) );
}
@Override
protected void actionPerformed( GuiButton btn )
{
if( btn == this.craftingStatusBtn )
{
NetworkHandler.instance.sendToServer( new PacketSwitchGuis( GuiBridge.GUI_CRAFTING_STATUS ) );
}
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 == this.terminalStyleBox )
AEConfig.instance.settings.putSetting( iBtn.getSetting(), next );
else if( btn == this.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 )
this.re_init();
}
}
}
public void re_init()
@@ -160,18 +195,11 @@ public class GuiMEMonitorable extends AEBaseMEGui implements ISortSource, IConfi
this.initGui();
}
@Override
public void onGuiClosed()
{
super.onGuiClosed();
memoryText = this.searchField.getText();
}
@Override
public void initGui()
{
this.maxRows = this.getMaxRows();
this.perRow = AEConfig.instance.getConfigManager().getSetting( Settings.TERMINAL_STYLE ) != TerminalStyle.FULL ? 9 : 9 + ((this.width - this.standardSize) / 18);
this.perRow = AEConfig.instance.getConfigManager().getSetting( Settings.TERMINAL_STYLE ) != TerminalStyle.FULL ? 9 : 9 + ( ( this.width - this.standardSize ) / 18 );
boolean hasNEI = AppEng.instance.isIntegrationEnabled( IntegrationType.NEI );
@@ -182,29 +210,29 @@ public class GuiMEMonitorable extends AEBaseMEGui implements ISortSource, IConfi
int extraSpace = this.height - magicNumber - NEI - top - this.reservedSpace;
this.rows = (int) Math.floor( extraSpace / 18 );
if ( this.rows > this.maxRows )
if( this.rows > this.maxRows )
{
top += (this.rows - this.maxRows) * 18 / 2;
top += ( this.rows - this.maxRows ) * 18 / 2;
this.rows = this.maxRows;
}
if ( hasNEI )
if( hasNEI )
this.rows--;
if ( this.rows < 3 )
if( this.rows < 3 )
this.rows = 3;
this.meSlots.clear();
for (int y = 0; y < this.rows; y++)
for( int y = 0; y < this.rows; y++ )
{
for (int x = 0; x < this.perRow; x++)
for( int x = 0; x < this.perRow; x++ )
{
this.meSlots.add( new InternalSlotME( this.repo, x + y * this.perRow, this.offsetX + x * 18, 18 + y * 18 ) );
}
}
if ( AEConfig.instance.getConfigManager().getSetting( Settings.TERMINAL_STYLE ) != TerminalStyle.FULL )
this.xSize = this.standardSize + ((this.perRow - 9) * 18);
if( AEConfig.instance.getConfigManager().getSetting( Settings.TERMINAL_STYLE ) != TerminalStyle.FULL )
this.xSize = this.standardSize + ( ( this.perRow - 9 ) * 18 );
else
this.xSize = this.standardSize;
@@ -216,17 +244,17 @@ public class GuiMEMonitorable extends AEBaseMEGui implements ISortSource, IConfi
this.ySize = magicNumber + this.rows * 18 + this.reservedSpace;
// this.guiTop = top;
int unusedSpace = this.height - this.ySize;
this.guiTop = (int) Math.floor( unusedSpace / (unusedSpace < 0 ? 3.8f : 2.0f) );
this.guiTop = (int) Math.floor( unusedSpace / ( unusedSpace < 0 ? 3.8f : 2.0f ) );
int offset = this.guiTop + 8;
if ( this.customSortOrder )
if( this.customSortOrder )
{
this.buttonList.add( this.SortByBox = new GuiImgButton( this.guiLeft - 18, offset, Settings.SORT_BY, this.configSrc.getSetting( Settings.SORT_BY ) ) );
offset += 20;
}
if ( this.viewCell || this instanceof GuiWirelessTerm )
if( this.viewCell || this instanceof GuiWirelessTerm )
{
this.buttonList.add( this.ViewBox = new GuiImgButton( this.guiLeft - 18, offset, Settings.VIEW_MODE, this.configSrc.getSetting( Settings.VIEW_MODE ) ) );
offset += 20;
@@ -235,14 +263,12 @@ public class GuiMEMonitorable extends AEBaseMEGui implements ISortSource, IConfi
this.buttonList.add( this.SortDirBox = new GuiImgButton( this.guiLeft - 18, offset, Settings.SORT_DIRECTION, this.configSrc.getSetting( Settings.SORT_DIRECTION ) ) );
offset += 20;
this.buttonList.add( this.searchBoxSettings = new GuiImgButton( this.guiLeft - 18, offset, Settings.SEARCH_MODE, AEConfig.instance.settings
.getSetting( Settings.SEARCH_MODE ) ) );
this.buttonList.add( this.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 )
if( !( this instanceof GuiMEPortableCell ) || this instanceof GuiWirelessTerm )
{
this.buttonList.add( this.terminalStyleBox = new GuiImgButton( this.guiLeft - 18, offset, Settings.TERMINAL_STYLE, AEConfig.instance.settings
.getSetting( Settings.TERMINAL_STYLE ) ) );
this.buttonList.add( this.terminalStyleBox = new GuiImgButton( this.guiLeft - 18, offset, Settings.TERMINAL_STYLE, AEConfig.instance.settings.getSetting( Settings.TERMINAL_STYLE ) ) );
}
this.searchField = new MEGuiTextField( this.fontRendererObj, this.guiLeft + Math.max( 80, this.offsetX ), this.guiTop + 4, 90, 12 );
@@ -251,10 +277,9 @@ public class GuiMEMonitorable extends AEBaseMEGui implements ISortSource, IConfi
this.searchField.setTextColor( 0xFFFFFF );
this.searchField.setVisible( true );
if ( this.viewCell || this instanceof GuiWirelessTerm )
if( this.viewCell || this instanceof GuiWirelessTerm )
{
this.buttonList.add( this.craftingStatusBtn = new GuiTabButton( this.guiLeft + 170, this.guiTop - 4, 2 + 11 * 16, GuiText.CraftingStatus.getLocal(),
itemRender ) );
this.buttonList.add( this.craftingStatusBtn = new GuiTabButton( this.guiLeft + 170, this.guiTop - 4, 2 + 11 * 16, GuiText.CraftingStatus.getLocal(), itemRender ) );
this.craftingStatusBtn.hideEdge = 13;
}
@@ -262,7 +287,7 @@ public class GuiMEMonitorable extends AEBaseMEGui implements ISortSource, IConfi
Enum setting = AEConfig.instance.settings.getSetting( Settings.SEARCH_MODE );
this.searchField.setFocused( SearchBoxMode.AUTOSEARCH == setting || SearchBoxMode.NEI_AUTOSEARCH == setting );
if ( this.isSubGui() )
if( this.isSubGui() )
{
this.searchField.setText( memoryText );
this.repo.searchString = memoryText;
@@ -273,18 +298,18 @@ public class GuiMEMonitorable extends AEBaseMEGui implements ISortSource, IConfi
CraftingGridOffsetX = Integer.MAX_VALUE;
CraftingGridOffsetY = Integer.MAX_VALUE;
for (Object s : this.inventorySlots.inventorySlots)
for( Object s : this.inventorySlots.inventorySlots )
{
if ( s instanceof AppEngSlot )
if( s instanceof AppEngSlot )
{
if ( ((AppEngSlot) s).xDisplayPosition < 197 )
if( ( (AppEngSlot) s ).xDisplayPosition < 197 )
this.repositionSlot( (AppEngSlot) s );
}
if ( s instanceof SlotCraftingMatrix || s instanceof SlotFakeCraftingMatrix )
if( s instanceof SlotCraftingMatrix || s instanceof SlotFakeCraftingMatrix )
{
Slot g = (Slot) s;
if ( g.xDisplayPosition > 0 && g.yDisplayPosition > 0 )
if( g.xDisplayPosition > 0 && g.yDisplayPosition > 0 )
{
CraftingGridOffsetX = Math.min( CraftingGridOffsetX, g.xDisplayPosition );
CraftingGridOffsetY = Math.min( CraftingGridOffsetY, g.yDisplayPosition );
@@ -296,64 +321,24 @@ public class GuiMEMonitorable extends AEBaseMEGui implements ISortSource, IConfi
CraftingGridOffsetY -= 6;
}
protected void repositionSlot(AppEngSlot s)
@Override
public void drawFG( int offsetX, int offsetY, int mouseX, int mouseY )
{
s.yDisplayPosition = s.defY + this.ySize - 78 - 5;
this.fontRendererObj.drawString( this.getGuiDisplayName( this.myName.getLocal() ), 8, 6, 4210752 );
this.fontRendererObj.drawString( GuiText.inventory.getLocal(), 8, this.ySize - 96 + 3, 4210752 );
}
@Override
protected void actionPerformed(GuiButton btn)
{
if ( btn == this.craftingStatusBtn )
{
NetworkHandler.instance.sendToServer( new PacketSwitchGuis( GuiBridge.GUI_CRAFTING_STATUS ) );
}
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 == this.terminalStyleBox )
AEConfig.instance.settings.putSetting( iBtn.getSetting(), next );
else if ( btn == this.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 )
this.re_init();
}
}
}
@Override
protected void mouseClicked(int xCoord, int yCoord, int btn)
protected void mouseClicked( int xCoord, int yCoord, int btn )
{
Enum searchMode = AEConfig.instance.settings.getSetting( Settings.SEARCH_MODE );
if ( searchMode != SearchBoxMode.AUTOSEARCH && searchMode != SearchBoxMode.NEI_AUTOSEARCH )
if( searchMode != SearchBoxMode.AUTOSEARCH && searchMode != SearchBoxMode.NEI_AUTOSEARCH )
{
this.searchField.mouseClicked( xCoord, yCoord, btn );
}
if ( btn == 1 && this.searchField.isMouseIn( xCoord, yCoord ) )
if( btn == 1 && this.searchField.isMouseIn( xCoord, yCoord ) )
{
this.searchField.setText( "" );
this.repo.searchString = "";
@@ -365,14 +350,79 @@ public class GuiMEMonitorable extends AEBaseMEGui implements ISortSource, IConfi
}
@Override
protected void keyTyped(char character, int key)
public void onGuiClosed()
{
if ( !this.checkHotbarKeys( key ) )
super.onGuiClosed();
memoryText = this.searchField.getText();
}
@Override
public void drawBG( int offsetX, int offsetY, int mouseX, int mouseY )
{
int x_width = 197;
this.bindTexture( this.getBackground() );
this.drawTexturedModalRect( offsetX, offsetY, 0, 0, x_width, 18 );
if( this.viewCell || ( this instanceof GuiSecurity ) )
this.drawTexturedModalRect( offsetX + x_width, offsetY, x_width, 0, 46, 128 );
for( int x = 0; x < this.rows; x++ )
this.drawTexturedModalRect( offsetX, offsetY + 18 + x * 18, 0, 18, x_width, 18 );
this.drawTexturedModalRect( offsetX, offsetY + 16 + this.rows * 18 + this.lowerTextureOffset, 0, 106 - 18 - 18, x_width, 99 + this.reservedSpace - this.lowerTextureOffset );
if( this.viewCell )
{
if ( character == ' ' && this.searchField.getText().length() == 0 )
boolean update = false;
for( int i = 0; i < 5; i++ )
{
if( this.myCurrentViewCells[i] != this.monitorableContainer.cellView[i].getStack() )
{
update = true;
this.myCurrentViewCells[i] = this.monitorableContainer.cellView[i].getStack();
}
}
if( update )
this.repo.setViewCell( this.myCurrentViewCells );
}
if( this.searchField != null )
this.searchField.drawTextBox();
}
protected String getBackground()
{
return "guis/terminal.png";
}
@Override
protected boolean isPowered()
{
return this.repo.hasPower();
}
int getMaxRows()
{
return AEConfig.instance.getConfigManager().getSetting( Settings.TERMINAL_STYLE ) == TerminalStyle.SMALL ? 6 : Integer.MAX_VALUE;
}
protected void repositionSlot( AppEngSlot s )
{
s.yDisplayPosition = s.defY + this.ySize - 78 - 5;
}
@Override
protected void keyTyped( char character, int key )
{
if( !this.checkHotbarKeys( key ) )
{
if( character == ' ' && this.searchField.getText().length() == 0 )
return;
if ( this.searchField.textboxKeyTyped( character, key ) )
if( this.searchField.textboxKeyTyped( character, key ) )
{
this.repo.searchString = this.searchField.getText();
this.repo.updateView();
@@ -392,55 +442,6 @@ public class GuiMEMonitorable extends AEBaseMEGui implements ISortSource, IConfi
super.updateScreen();
}
@Override
public void drawBG(int offsetX, int offsetY, int mouseX, int mouseY)
{
int x_width = 197;
this.bindTexture( this.getBackground() );
this.drawTexturedModalRect( offsetX, offsetY, 0, 0, x_width, 18 );
if ( this.viewCell || (this instanceof GuiSecurity) )
this.drawTexturedModalRect( offsetX + x_width, offsetY, x_width, 0, 46, 128 );
for (int x = 0; x < this.rows; x++)
this.drawTexturedModalRect( offsetX, offsetY + 18 + x * 18, 0, 18, x_width, 18 );
this.drawTexturedModalRect( offsetX, offsetY + 16 + this.rows * 18 + this.lowerTextureOffset, 0, 106 - 18 - 18, x_width, 99 + this.reservedSpace - this.lowerTextureOffset );
if ( this.viewCell )
{
boolean update = false;
for (int i = 0; i < 5; i++)
{
if ( this.myCurrentViewCells[i] != this.monitorableContainer.cellView[i].getStack() )
{
update = true;
this.myCurrentViewCells[i] = this.monitorableContainer.cellView[i].getStack();
}
}
if ( update )
this.repo.setViewCell( this.myCurrentViewCells );
}
if ( this.searchField != null )
this.searchField.drawTextBox();
}
protected String getBackground()
{
return "guis/terminal.png";
}
@Override
public void drawFG(int offsetX, int offsetY, int mouseX, int mouseY)
{
this.fontRendererObj.drawString( this.getGuiDisplayName( this.myName.getLocal() ), 8, 6, 4210752 );
this.fontRendererObj.drawString( GuiText.inventory.getLocal(), 8, this.ySize - 96 + 3, 4210752 );
}
@Override
public Enum getSortBy()
{
@@ -460,29 +461,17 @@ public class GuiMEMonitorable extends AEBaseMEGui implements ISortSource, IConfi
}
@Override
public void updateSetting(IConfigManager manager, Enum settingName, Enum newValue)
public void updateSetting( IConfigManager manager, Enum settingName, Enum newValue )
{
if ( this.SortByBox != null )
if( this.SortByBox != null )
this.SortByBox.set( this.configSrc.getSetting( Settings.SORT_BY ) );
if ( this.SortDirBox != null )
if( this.SortDirBox != null )
this.SortDirBox.set( this.configSrc.getSetting( Settings.SORT_DIRECTION ) );
if ( this.ViewBox != null )
if( this.ViewBox != null )
this.ViewBox.set( this.configSrc.getSetting( Settings.VIEW_MODE ) );
this.repo.updateView();
}
@Override
protected boolean isPowered()
{
return this.repo.hasPower();
}
int getMaxRows()
{
return AEConfig.instance.getConfigManager().getSetting( Settings.TERMINAL_STYLE ) == TerminalStyle.SMALL ? 6 : Integer.MAX_VALUE;
}
}
@@ -18,15 +18,18 @@
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) {
public GuiMEPortableCell( InventoryPlayer inventoryPlayer, IPortableCell te )
{
super( inventoryPlayer, te, new ContainerMEPortableCell( inventoryPlayer, null ) );
}
@@ -46,15 +46,17 @@ import appeng.core.AEConfig;
import appeng.core.localization.GuiText;
import appeng.util.Platform;
public class GuiNetworkStatus extends AEBaseGui implements ISortSource
{
final ItemRepo repo;
GuiImgButton units;
final int rows = 4;
GuiImgButton units;
int tooltip = -1;
public GuiNetworkStatus(InventoryPlayer inventoryPlayer, INetworkTool te) {
public GuiNetworkStatus( InventoryPlayer inventoryPlayer, INetworkTool te )
{
super( new ContainerNetworkStatus( inventoryPlayer, te ) );
this.ySize = 153;
this.xSize = 195;
@@ -64,13 +66,13 @@ public class GuiNetworkStatus extends AEBaseGui implements ISortSource
}
@Override
protected void actionPerformed(GuiButton btn)
protected void actionPerformed( GuiButton btn )
{
super.actionPerformed( btn );
boolean backwards = Mouse.isButtonDown( 1 );
if ( btn == this.units )
if( btn == this.units )
{
AEConfig.instance.nextPowerUnit( backwards );
this.units.set( AEConfig.instance.selectedPowerUnit() );
@@ -86,62 +88,34 @@ public class GuiNetworkStatus extends AEBaseGui implements ISortSource
this.buttonList.add( this.units );
}
public void postUpdate(List<IAEItemStack> list)
{
this.repo.clear();
for (IAEItemStack is : list)
this.repo.postUpdate( is );
this.repo.updateView();
this.setScrollBar();
}
private void setScrollBar()
{
int size = this.repo.size();
this.myScrollBar.setTop( 39 ).setLeft( 175 ).setHeight( 78 );
this.myScrollBar.setRange( 0, (size + 4) / 5 - this.rows, 1 );
}
@Override
public void drawBG(int offsetX, int offsetY, int mouseX, int mouseY)
{
this.bindTexture( "guis/networkstatus.png" );
this.drawTexturedModalRect( offsetX, offsetY, 0, 0, this.xSize, this.ySize );
}
int tooltip = -1;
@Override
public void drawScreen(int mouse_x, int mouse_y, float btn)
public void drawScreen( int mouse_x, int mouse_y, float btn )
{
int x = 0;
int y = 0;
int gx = (this.width - this.xSize) / 2;
int gy = (this.height - this.ySize) / 2;
int gx = ( this.width - this.xSize ) / 2;
int gy = ( this.height - this.ySize ) / 2;
this.tooltip = -1;
for (int z = 0; z <= 4 * 5; z++)
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( minX < mouse_x && minX + 28 > mouse_x )
{
if ( minY < mouse_y && minY + 20 > mouse_y )
if( minY < mouse_y && minY + 20 > mouse_y )
{
this.tooltip = z;
break;
}
}
x++;
if ( x > 4 )
if( x > 4 )
{
y++;
x = 0;
@@ -152,7 +126,7 @@ public class GuiNetworkStatus extends AEBaseGui implements ISortSource
}
@Override
public void drawFG(int offsetX, int offsetY, int mouseX, int mouseY)
public void drawFG( int offsetX, int offsetY, int mouseX, int mouseY )
{
ContainerNetworkStatus ns = (ContainerNetworkStatus) this.inventorySlots;
@@ -177,32 +151,31 @@ public class GuiNetworkStatus extends AEBaseGui implements ISortSource
int toolPosX = 0;
int toolPosY = 0;
for (int z = viewStart; z < Math.min( viewEnd, this.repo.size() ); z++)
for( int z = viewStart; z < Math.min( viewEnd, this.repo.size() ); z++ )
{
IAEItemStack refStack = this.repo.getReferenceItem( z );
if ( refStack != null )
if( refStack != null )
{
GL11.glPushMatrix();
GL11.glScaled( 0.5, 0.5, 0.5 );
String str = Long.toString( refStack.getStackSize() );
if ( refStack.getStackSize() >= 10000 )
if( refStack.getStackSize() >= 10000 )
str = Long.toString( refStack.getStackSize() / 1000 ) + 'k';
int w = this.fontRendererObj.getStringWidth( str );
this.fontRendererObj.drawString( str, (int) ((x * sectionLength + xo + sectionLength - 19 - (w * 0.5)) * 2), (y * 18 + yo + 6) * 2,
4210752 );
this.fontRendererObj.drawString( str, (int) ( ( x * sectionLength + xo + sectionLength - 19 - ( w * 0.5 ) ) * 2 ), ( y * 18 + yo + 6 ) * 2, 4210752 );
GL11.glPopMatrix();
int posX = x * sectionLength + xo + sectionLength - 18;
int posY = y * 18 + yo;
if ( this.tooltip == z - viewStart )
if( this.tooltip == z - viewStart )
{
toolTip = Platform.getItemDisplayName( this.repo.getItem( z ) );
toolTip += ( '\n' + GuiText.Installed.getLocal() + ": " + ( refStack.getStackSize() ) );
if ( refStack.getCountRequestable() > 0 )
if( refStack.getCountRequestable() > 0 )
toolTip += ( '\n' + GuiText.EnergyDrain.getLocal() + ": " + Platform.formatPowerLong( refStack.getCountRequestable(), true ) );
toolPosX = x * sectionLength + xo + sectionLength - 8;
@@ -213,31 +186,54 @@ public class GuiNetworkStatus extends AEBaseGui implements ISortSource
x++;
if ( x > 4 )
if( x > 4 )
{
y++;
x = 0;
}
}
}
if ( this.tooltip >= 0 && toolTip.length() > 0 )
if( this.tooltip >= 0 && toolTip.length() > 0 )
{
GL11.glPushAttrib( GL11.GL_ALL_ATTRIB_BITS );
this.drawTooltip( toolPosX, toolPosY + 10, 0, toolTip );
GL11.glPopAttrib();
}
}
@Override
public void drawBG( int offsetX, int offsetY, int mouseX, int mouseY )
{
this.bindTexture( "guis/networkstatus.png" );
this.drawTexturedModalRect( offsetX, offsetY, 0, 0, this.xSize, this.ySize );
}
public void postUpdate( List<IAEItemStack> list )
{
this.repo.clear();
for( IAEItemStack is : list )
this.repo.postUpdate( is );
this.repo.updateView();
this.setScrollBar();
}
private void setScrollBar()
{
int size = this.repo.size();
this.myScrollBar.setTop( 39 ).setLeft( 175 ).setHeight( 78 );
this.myScrollBar.setRange( 0, ( size + 4 ) / 5 - this.rows, 1 );
}
// @Override - NEI
public List<String> handleItemTooltip(ItemStack stack, int mouseX, int mouseY, List<String> currentToolTip)
public List<String> handleItemTooltip( ItemStack stack, int mouseX, int mouseY, List<String> currentToolTip )
{
if ( stack != null )
if( stack != null )
{
Slot s = this.getSlot( mouseX, mouseY );
if ( s instanceof SlotME )
if( s instanceof SlotME )
{
IAEItemStack myStack = null;
@@ -246,15 +242,14 @@ public class GuiNetworkStatus extends AEBaseGui implements ISortSource
SlotME theSlotField = (SlotME) s;
myStack = theSlotField.getAEStack();
}
catch (Throwable ignore)
catch( Throwable ignore )
{
}
if ( myStack != null )
if( myStack != null )
{
while (currentToolTip.size() > 1)
while( currentToolTip.size() > 1 )
currentToolTip.remove( 1 );
}
}
}
@@ -262,10 +257,10 @@ public class GuiNetworkStatus extends AEBaseGui implements ISortSource
}
// Vanilla version...
protected void drawItemStackTooltip(ItemStack stack, int x, int y)
protected void drawItemStackTooltip( ItemStack stack, int x, int y )
{
Slot s = this.getSlot( x, y );
if ( s instanceof SlotME && stack != null )
if( s instanceof SlotME && stack != null )
{
IAEItemStack myStack = null;
@@ -274,18 +269,18 @@ public class GuiNetworkStatus extends AEBaseGui implements ISortSource
SlotME theSlotField = (SlotME) s;
myStack = theSlotField.getAEStack();
}
catch (Throwable ignore)
catch( Throwable ignore )
{
}
if ( myStack != null )
if( myStack != null )
{
List currentToolTip = stack.getTooltip( this.mc.thePlayer, this.mc.gameSettings.advancedItemTooltips );
while (currentToolTip.size() > 1)
while( currentToolTip.size() > 1 )
currentToolTip.remove( 1 );
currentToolTip.add( GuiText.Installed.getLocal() + ": " + (myStack.getStackSize()) );
currentToolTip.add( GuiText.Installed.getLocal() + ": " + ( myStack.getStackSize() ) );
currentToolTip.add( GuiText.EnergyDrain.getLocal() + ": " + Platform.formatPowerLong( myStack.getCountRequestable(), true ) );
this.drawTooltip( x, y, 0, join( currentToolTip, "\n" ) );
@@ -18,6 +18,7 @@
package appeng.client.gui.implementations;
import java.io.IOException;
import net.minecraft.client.gui.GuiButton;
@@ -32,27 +33,29 @@ 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) {
public GuiNetworkTool( InventoryPlayer inventoryPlayer, INetworkTool te )
{
super( new ContainerNetworkTool( inventoryPlayer, te ) );
this.ySize = 166;
}
@Override
protected void actionPerformed(GuiButton btn)
protected void actionPerformed( GuiButton btn )
{
super.actionPerformed( btn );
try
{
if ( btn == this.tFacades )
if( btn == this.tFacades )
NetworkHandler.instance.sendToServer( new PacketValueConfig( "NetworkTool", "Toggle" ) );
}
catch (IOException e)
catch( IOException e )
{
AELog.error( e );
}
@@ -69,20 +72,19 @@ public class GuiNetworkTool extends AEBaseGui
}
@Override
public void drawBG(int offsetX, int offsetY, int mouseX, int mouseY)
public void drawFG( int offsetX, int offsetY, int mouseX, int mouseY )
{
this.bindTexture( "guis/toolbox.png" );
this.drawTexturedModalRect( offsetX, offsetY, 0, 0, this.xSize, this.ySize );
}
@Override
public void drawFG(int offsetX, int offsetY, int mouseX, int mouseY)
{
if ( this.tFacades != null )
this.tFacades.setState( ((ContainerNetworkTool) this.inventorySlots).facadeMode );
if( this.tFacades != null )
this.tFacades.setState( ( (ContainerNetworkTool) this.inventorySlots ).facadeMode );
this.fontRendererObj.drawString( this.getGuiDisplayName( GuiText.NetworkTool.getLocal() ), 8, 6, 4210752 );
this.fontRendererObj.drawString( GuiText.inventory.getLocal(), 8, this.ySize - 96 + 3, 4210752 );
}
@Override
public void drawBG( int offsetX, int offsetY, int mouseX, int mouseY )
{
this.bindTexture( "guis/toolbox.png" );
this.drawTexturedModalRect( offsetX, offsetY, 0, 0, this.xSize, this.ySize );
}
}
@@ -18,6 +18,7 @@
package appeng.client.gui.implementations;
import java.io.IOException;
import net.minecraft.client.gui.GuiButton;
@@ -36,6 +37,7 @@ import appeng.core.localization.GuiText;
import appeng.core.sync.network.NetworkHandler;
import appeng.core.sync.packets.PacketValueConfig;
public class GuiPatternTerm extends GuiMEMonitorable
{
@@ -47,50 +49,37 @@ public class GuiPatternTerm extends GuiMEMonitorable
GuiImgButton encodeBtn;
GuiImgButton clearBtn;
@Override
public void initGui()
public GuiPatternTerm( InventoryPlayer inventoryPlayer, ITerminalHost te )
{
super.initGui();
this.buttonList.add( this.tabCraftButton = new GuiTabButton( this.guiLeft + 173, this.guiTop + this.ySize - 177, new ItemStack( Blocks.crafting_table ),
GuiText.CraftingPattern.getLocal(), itemRender ) );
this.buttonList.add( this.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;
this.buttonList.add( this.clearBtn = new GuiImgButton( this.guiLeft + 74, this.guiTop + this.ySize - 163, Settings.ACTIONS, ActionItems.CLOSE ) );
this.clearBtn.halfSize = true;
this.buttonList.add( this.encodeBtn = new GuiImgButton( this.guiLeft + 147, this.guiTop + this.ySize - 142, Settings.ACTIONS, ActionItems.ENCODE ) );
super( inventoryPlayer, te, new ContainerPatternTerm( inventoryPlayer, te ) );
this.container = (ContainerPatternTerm) this.inventorySlots;
this.reservedSpace = 81;
}
@Override
protected void actionPerformed(GuiButton btn)
protected void actionPerformed( GuiButton btn )
{
super.actionPerformed( btn );
try
{
if ( this.tabCraftButton == btn || this.tabProcessButton == btn )
if( this.tabCraftButton == btn || this.tabProcessButton == btn )
{
NetworkHandler.instance.sendToServer( new PacketValueConfig( "PatternTerminal.CraftMode", this.tabProcessButton == btn ? "1" : "0" ) );
}
if ( this.encodeBtn == btn )
if( this.encodeBtn == btn )
{
NetworkHandler.instance.sendToServer( new PacketValueConfig( "PatternTerminal.Encode", "1" ) );
}
if ( this.clearBtn == btn )
if( this.clearBtn == btn )
{
NetworkHandler.instance.sendToServer( new PacketValueConfig( "PatternTerminal.Clear", "1" ) );
}
}
catch (IOException e)
catch( IOException e )
{
// TODO Auto-generated catch block
e.printStackTrace();
@@ -103,32 +92,26 @@ public class GuiPatternTerm extends GuiMEMonitorable
}
@Override
protected void repositionSlot(AppEngSlot s)
public void initGui()
{
if ( s.isPlayerSide() )
s.yDisplayPosition = s.defY + this.ySize - 78 - 5;
else
s.yDisplayPosition = s.defY + this.ySize - 78 - 3;
}
super.initGui();
this.buttonList.add( this.tabCraftButton = new GuiTabButton( this.guiLeft + 173, this.guiTop + this.ySize - 177, new ItemStack( Blocks.crafting_table ), GuiText.CraftingPattern.getLocal(), itemRender ) );
this.buttonList.add( this.tabProcessButton = new GuiTabButton( this.guiLeft + 173, this.guiTop + this.ySize - 177, new ItemStack( Blocks.furnace ), GuiText.ProcessingPattern.getLocal(), itemRender ) );
public GuiPatternTerm(InventoryPlayer inventoryPlayer, ITerminalHost te) {
super( inventoryPlayer, te, new ContainerPatternTerm( inventoryPlayer, te ) );
this.container = (ContainerPatternTerm) this.inventorySlots;
this.reservedSpace = 81;
// buttonList.add( substitutionsBtn = new GuiImgButton( this.guiLeft + 84, this.guiTop + this.ySize - 163,
// Settings.ACTIONS, ActionItems.SUBSTITUTION ) );
// substitutionsBtn.halfSize = true;
this.buttonList.add( this.clearBtn = new GuiImgButton( this.guiLeft + 74, this.guiTop + this.ySize - 163, Settings.ACTIONS, ActionItems.CLOSE ) );
this.clearBtn.halfSize = true;
this.buttonList.add( this.encodeBtn = new GuiImgButton( this.guiLeft + 147, this.guiTop + this.ySize - 142, Settings.ACTIONS, ActionItems.ENCODE ) );
}
@Override
protected String getBackground()
public void drawFG( int offsetX, int offsetY, int mouseX, int mouseY )
{
if ( this.container.craftingMode )
return "guis/pattern.png";
return "guis/pattern2.png";
}
@Override
public void drawFG(int offsetX, int offsetY, int mouseX, int mouseY)
{
if ( !this.container.craftingMode )
if( !this.container.craftingMode )
{
this.tabCraftButton.visible = false;
this.tabProcessButton.visible = true;
@@ -143,4 +126,20 @@ public class GuiPatternTerm extends GuiMEMonitorable
this.fontRendererObj.drawString( GuiText.PatternTerminal.getLocal(), 8, this.ySize - 96 + 2 - this.reservedSpace, 4210752 );
}
@Override
protected String getBackground()
{
if( this.container.craftingMode )
return "guis/pattern.png";
return "guis/pattern2.png";
}
@Override
protected void repositionSlot( AppEngSlot s )
{
if( s.isPlayerSide() )
s.yDisplayPosition = s.defY + this.ySize - 78 - 5;
else
s.yDisplayPosition = s.defY + this.ySize - 78 - 3;
}
}
@@ -18,6 +18,7 @@
package appeng.client.gui.implementations;
import java.io.IOException;
import net.minecraft.client.gui.GuiButton;
@@ -48,6 +49,7 @@ import appeng.tile.misc.TileInterface;
import appeng.tile.storage.TileChest;
import appeng.tile.storage.TileDrive;
public class GuiPriority extends AEBaseGui
{
@@ -65,7 +67,8 @@ public class GuiPriority extends AEBaseGui
GuiBridge OriginalGui;
public GuiPriority(InventoryPlayer inventoryPlayer, IPriorityHost te) {
public GuiPriority( InventoryPlayer inventoryPlayer, IPriorityHost te )
{
super( new ContainerPriority( inventoryPlayer, te ) );
}
@@ -90,32 +93,32 @@ public class GuiPriority extends AEBaseGui
this.buttonList.add( this.minus1000 = new GuiButton( 0, this.guiLeft + 120, this.guiTop + 69, 38, 20, "-" + d ) );
ItemStack myIcon = null;
Object target = ((AEBaseContainer) this.inventorySlots).getTarget();
Object target = ( (AEBaseContainer) this.inventorySlots ).getTarget();
final IDefinitions definitions = AEApi.instance().definitions();
final IParts parts = definitions.parts();
final IBlocks blocks = definitions.blocks();
if ( target instanceof PartStorageBus )
if( target instanceof PartStorageBus )
{
for ( ItemStack storageBusStack :parts.storageBus().maybeStack( 1 ).asSet() )
for( ItemStack storageBusStack : parts.storageBus().maybeStack( 1 ).asSet() )
{
myIcon = storageBusStack;
}
this.OriginalGui = GuiBridge.GUI_STORAGEBUS;
}
if ( target instanceof PartFormationPlane )
if( target instanceof PartFormationPlane )
{
for ( ItemStack formationPlaneStack : parts.formationPlane().maybeStack( 1 ).asSet() )
for( ItemStack formationPlaneStack : parts.formationPlane().maybeStack( 1 ).asSet() )
{
myIcon = formationPlaneStack;
}
this.OriginalGui = GuiBridge.GUI_FORMATION_PLANE;
}
if ( target instanceof TileDrive )
if( target instanceof TileDrive )
{
for ( ItemStack driveStack : blocks.drive().maybeStack( 1 ).asSet() )
for( ItemStack driveStack : blocks.drive().maybeStack( 1 ).asSet() )
{
myIcon = driveStack;
}
@@ -123,9 +126,9 @@ public class GuiPriority extends AEBaseGui
this.OriginalGui = GuiBridge.GUI_DRIVE;
}
if ( target instanceof TileChest )
if( target instanceof TileChest )
{
for ( ItemStack chestStack : blocks.chest().maybeStack( 1 ).asSet() )
for( ItemStack chestStack : blocks.chest().maybeStack( 1 ).asSet() )
{
myIcon = chestStack;
}
@@ -133,9 +136,9 @@ public class GuiPriority extends AEBaseGui
this.OriginalGui = GuiBridge.GUI_CHEST;
}
if ( target instanceof TileInterface )
if( target instanceof TileInterface )
{
for ( ItemStack interfaceStack : blocks.iface().maybeStack( 1 ).asSet() )
for( ItemStack interfaceStack : blocks.iface().maybeStack( 1 ).asSet() )
{
myIcon = interfaceStack;
}
@@ -143,16 +146,16 @@ public class GuiPriority extends AEBaseGui
this.OriginalGui = GuiBridge.GUI_INTERFACE;
}
if ( target instanceof PartInterface )
if( target instanceof PartInterface )
{
for ( ItemStack interfaceStack : parts.iface().maybeStack( 1 ).asSet() )
for( ItemStack interfaceStack : parts.iface().maybeStack( 1 ).asSet() )
{
myIcon = interfaceStack;
}
this.OriginalGui = GuiBridge.GUI_INTERFACE;
}
if ( this.OriginalGui != null && myIcon != null )
if( this.OriginalGui != null && myIcon != null )
this.buttonList.add( this.originalGuiBtn = new GuiTabButton( this.guiLeft + 154, this.guiTop, myIcon, myIcon.getDisplayName(), itemRender ) );
this.priority = new GuiNumberBox( this.fontRendererObj, this.guiLeft + 62, this.guiTop + 57, 59, this.fontRendererObj.FONT_HEIGHT, Long.class );
@@ -161,15 +164,30 @@ public class GuiPriority extends AEBaseGui
this.priority.setTextColor( 0xFFFFFF );
this.priority.setVisible( true );
this.priority.setFocused( true );
((ContainerPriority) this.inventorySlots).setTextField( this.priority );
( (ContainerPriority) this.inventorySlots ).setTextField( this.priority );
}
@Override
protected void actionPerformed(GuiButton btn)
public void drawFG( int offsetX, int offsetY, int mouseX, int mouseY )
{
this.fontRendererObj.drawString( GuiText.Priority.getLocal(), 8, 6, 4210752 );
}
@Override
public void drawBG( int offsetX, int offsetY, int mouseX, int mouseY )
{
this.bindTexture( "guis/priority.png" );
this.drawTexturedModalRect( offsetX, offsetY, 0, 0, this.xSize, this.ySize );
this.priority.drawTextBox();
}
@Override
protected void actionPerformed( GuiButton btn )
{
super.actionPerformed( btn );
if ( btn == this.originalGuiBtn )
if( btn == this.originalGuiBtn )
{
NetworkHandler.instance.sendToServer( new PacketSwitchGuis( this.OriginalGui ) );
}
@@ -177,27 +195,27 @@ public class GuiPriority extends AEBaseGui
boolean isPlus = btn == this.plus1 || btn == this.plus10 || btn == this.plus100 || btn == this.plus1000;
boolean isMinus = btn == this.minus1 || btn == this.minus10 || btn == this.minus100 || btn == this.minus1000;
if ( isPlus || isMinus )
if( isPlus || isMinus )
this.addQty( this.getQty( btn ) );
}
private void addQty(int i)
private void addQty( int i )
{
try
{
String out = this.priority.getText();
boolean fixed = false;
while (out.startsWith( "0" ) && out.length() > 1)
while( out.startsWith( "0" ) && out.length() > 1 )
{
out = out.substring( 1 );
fixed = true;
}
if ( fixed )
if( fixed )
this.priority.setText( out );
if ( out.length() == 0 )
if( out.length() == 0 )
out = "0";
long result = Long.parseLong( out );
@@ -207,45 +225,44 @@ public class GuiPriority extends AEBaseGui
NetworkHandler.instance.sendToServer( new PacketValueConfig( "PriorityHost.Priority", out ) );
}
catch(NumberFormatException e )
catch( NumberFormatException e )
{
// nope..
this.priority.setText( "0" );
}
catch (IOException e)
catch( IOException e )
{
AELog.error( e );
}
}
@Override
protected void keyTyped(char character, int key)
protected void keyTyped( char character, int key )
{
if ( !this.checkHotbarKeys( key ) )
if( !this.checkHotbarKeys( key ) )
{
if ( (key == 211 || key == 205 || key == 203 || key == 14 || character == '-' || Character.isDigit( character ))
&& this.priority.textboxKeyTyped( character, key ) )
if( ( key == 211 || key == 205 || key == 203 || key == 14 || character == '-' || Character.isDigit( character ) ) && this.priority.textboxKeyTyped( character, key ) )
{
try
{
String out = this.priority.getText();
boolean fixed = false;
while (out.startsWith( "0" ) && out.length() > 1)
while( out.startsWith( "0" ) && out.length() > 1 )
{
out = out.substring( 1 );
fixed = true;
}
if ( fixed )
if( fixed )
this.priority.setText( out );
if ( out.length() == 0 )
if( out.length() == 0 )
out = "0";
NetworkHandler.instance.sendToServer( new PacketValueConfig( "PriorityHost.Priority", out ) );
}
catch (IOException e)
catch( IOException e )
{
AELog.error( e );
}
@@ -257,23 +274,8 @@ public class GuiPriority extends AEBaseGui
}
}
@Override
public void drawBG(int offsetX, int offsetY, int mouseX, int mouseY)
{
this.bindTexture( "guis/priority.png" );
this.drawTexturedModalRect( offsetX, offsetY, 0, 0, this.xSize, this.ySize );
this.priority.drawTextBox();
}
protected String getBackground()
{
return "guis/priority.png";
}
@Override
public void drawFG(int offsetX, int offsetY, int mouseX, int mouseY)
{
this.fontRendererObj.drawString( GuiText.Priority.getLocal(), 8, 6, 4210752 );
}
}
@@ -18,6 +18,7 @@
package appeng.client.gui.implementations;
import net.minecraft.entity.player.InventoryPlayer;
import appeng.client.gui.AEBaseGui;
@@ -25,26 +26,27 @@ 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) {
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)
{
this.bindTexture( "guis/chest.png" );
this.drawTexturedModalRect( offsetX, offsetY, 0, 0, this.xSize, this.ySize );
}
@Override
public void drawFG(int offsetX, int offsetY, int mouseX, int mouseY)
public void drawFG( int offsetX, int offsetY, int mouseX, int mouseY )
{
this.fontRendererObj.drawString( this.getGuiDisplayName( GuiText.QuantumLinkChamber.getLocal() ), 8, 6, 4210752 );
this.fontRendererObj.drawString( GuiText.inventory.getLocal(), 8, this.ySize - 96 + 3, 4210752 );
}
@Override
public void drawBG( int offsetX, int offsetY, int mouseX, int mouseY )
{
this.bindTexture( "guis/chest.png" );
this.drawTexturedModalRect( offsetX, offsetY, 0, 0, this.xSize, this.ySize );
}
}
@@ -18,6 +18,7 @@
package appeng.client.gui.implementations;
import java.io.IOException;
import net.minecraft.client.gui.GuiTextField;
@@ -31,12 +32,14 @@ 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) {
public GuiQuartzKnife( InventoryPlayer inventoryPlayer, QuartzKnifeObj te )
{
super( new ContainerQuartzKnife( inventoryPlayer, te ) );
this.ySize = 184;
}
@@ -55,7 +58,14 @@ public class GuiQuartzKnife extends AEBaseGui
}
@Override
public void drawBG(int offsetX, int offsetY, int mouseX, int mouseY)
public void drawFG( int offsetX, int offsetY, int mouseX, int mouseY )
{
this.fontRendererObj.drawString( this.getGuiDisplayName( GuiText.QuartzCuttingKnife.getLocal() ), 8, 6, 4210752 );
this.fontRendererObj.drawString( GuiText.inventory.getLocal(), 8, this.ySize - 96 + 3, 4210752 );
}
@Override
public void drawBG( int offsetX, int offsetY, int mouseX, int mouseY )
{
this.bindTexture( "guis/quartzknife.png" );
this.drawTexturedModalRect( offsetX, offsetY, 0, 0, this.xSize, this.ySize );
@@ -63,17 +73,17 @@ public class GuiQuartzKnife extends AEBaseGui
}
@Override
protected void keyTyped(char character, int key)
protected void keyTyped( char character, int key )
{
if ( this.name.textboxKeyTyped( character, key ) )
if( this.name.textboxKeyTyped( character, key ) )
{
try
{
String Out = this.name.getText();
((ContainerQuartzKnife) this.inventorySlots).setName( Out );
( (ContainerQuartzKnife) this.inventorySlots ).setName( Out );
NetworkHandler.instance.sendToServer( new PacketValueConfig( "QuartzKnife.Name", Out ) );
}
catch (IOException e)
catch( IOException e )
{
AELog.error( e );
}
@@ -83,12 +93,4 @@ public class GuiQuartzKnife extends AEBaseGui
super.keyTyped( character, key );
}
}
@Override
public void drawFG(int offsetX, int offsetY, int mouseX, int mouseY)
{
this.fontRendererObj.drawString( this.getGuiDisplayName( GuiText.QuartzCuttingKnife.getLocal() ), 8, 6, 4210752 );
this.fontRendererObj.drawString( GuiText.inventory.getLocal(), 8, this.ySize - 96 + 3, 4210752 );
}
}
@@ -33,10 +33,18 @@ 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) {
GuiToggleButton inject;
GuiToggleButton extract;
GuiToggleButton craft;
GuiToggleButton build;
GuiToggleButton security;
public GuiSecurity( InventoryPlayer inventoryPlayer, ITerminalHost te )
{
super( inventoryPlayer, te, new ContainerSecurity( inventoryPlayer, te ) );
this.customSortOrder = false;
this.reservedSpace = 33;
@@ -46,11 +54,36 @@ public class GuiSecurity extends GuiMEMonitorable
this.standardSize = this.xSize;
}
GuiToggleButton inject;
GuiToggleButton extract;
GuiToggleButton craft;
GuiToggleButton build;
GuiToggleButton security;
@Override
protected void actionPerformed( net.minecraft.client.gui.GuiButton btn )
{
super.actionPerformed( btn );
SecurityPermissions toggleSetting = null;
if( btn == this.inject )
toggleSetting = SecurityPermissions.INJECT;
if( btn == this.extract )
toggleSetting = SecurityPermissions.EXTRACT;
if( btn == this.craft )
toggleSetting = SecurityPermissions.CRAFT;
if( btn == this.build )
toggleSetting = SecurityPermissions.BUILD;
if( btn == this.security )
toggleSetting = SecurityPermissions.SECURITY;
if( toggleSetting != null )
{
try
{
NetworkHandler.instance.sendToServer( new PacketValueConfig( "TileSecurity.ToggleOption", toggleSetting.name() ) );
}
catch( IOException e )
{
AELog.error( e );
}
}
}
@Override
public void initGui()
@@ -58,52 +91,22 @@ public class GuiSecurity extends GuiMEMonitorable
super.initGui();
int top = this.guiTop + this.ySize - 116;
this.buttonList.add( this.inject = new GuiToggleButton( this.guiLeft + 56, top, 11 * 16, 12 * 16, SecurityPermissions.INJECT
.getUnlocalizedName(), SecurityPermissions.INJECT.getUnlocalizedTip() ) );
this.buttonList.add( this.inject = new GuiToggleButton( this.guiLeft + 56, top, 11 * 16, 12 * 16, SecurityPermissions.INJECT.getUnlocalizedName(), SecurityPermissions.INJECT.getUnlocalizedTip() ) );
this.buttonList.add( this.extract = new GuiToggleButton( this.guiLeft + 56 + 18, top, 11 * 16 + 1, 12 * 16 + 1, SecurityPermissions.EXTRACT
.getUnlocalizedName(), SecurityPermissions.EXTRACT.getUnlocalizedTip() ) );
this.buttonList.add( this.extract = new GuiToggleButton( this.guiLeft + 56 + 18, top, 11 * 16 + 1, 12 * 16 + 1, SecurityPermissions.EXTRACT.getUnlocalizedName(), SecurityPermissions.EXTRACT.getUnlocalizedTip() ) );
this.buttonList.add( this.craft = new GuiToggleButton( this.guiLeft + 56 + 18 * 2, top, 11 * 16 + 2, 12 * 16 + 2, SecurityPermissions.CRAFT.getUnlocalizedName(),
SecurityPermissions.CRAFT.getUnlocalizedTip() ) );
this.buttonList.add( this.craft = new GuiToggleButton( this.guiLeft + 56 + 18 * 2, top, 11 * 16 + 2, 12 * 16 + 2, SecurityPermissions.CRAFT.getUnlocalizedName(), SecurityPermissions.CRAFT.getUnlocalizedTip() ) );
this.buttonList.add( this.build = new GuiToggleButton( this.guiLeft + 56 + 18 * 3, top, 11 * 16 + 3, 12 * 16 + 3, SecurityPermissions.BUILD.getUnlocalizedName(),
SecurityPermissions.BUILD.getUnlocalizedTip() ) );
this.buttonList.add( this.build = new GuiToggleButton( this.guiLeft + 56 + 18 * 3, top, 11 * 16 + 3, 12 * 16 + 3, SecurityPermissions.BUILD.getUnlocalizedName(), SecurityPermissions.BUILD.getUnlocalizedTip() ) );
this.buttonList.add( this.security = new GuiToggleButton( this.guiLeft + 56 + 18 * 4, top, 11 * 16 + 4, 12 * 16 + 4, SecurityPermissions.SECURITY
.getUnlocalizedName(), SecurityPermissions.SECURITY.getUnlocalizedTip() ) );
this.buttonList.add( this.security = new GuiToggleButton( this.guiLeft + 56 + 18 * 4, top, 11 * 16 + 4, 12 * 16 + 4, SecurityPermissions.SECURITY.getUnlocalizedName(), SecurityPermissions.SECURITY.getUnlocalizedTip() ) );
}
@Override
protected void actionPerformed(net.minecraft.client.gui.GuiButton btn)
public void drawFG( int offsetX, int offsetY, int mouseX, int mouseY )
{
super.actionPerformed( btn );
SecurityPermissions toggleSetting = null;
if ( btn == this.inject )
toggleSetting = SecurityPermissions.INJECT;
if ( btn == this.extract )
toggleSetting = SecurityPermissions.EXTRACT;
if ( btn == this.craft )
toggleSetting = SecurityPermissions.CRAFT;
if ( btn == this.build )
toggleSetting = SecurityPermissions.BUILD;
if ( btn == this.security )
toggleSetting = SecurityPermissions.SECURITY;
if ( toggleSetting != null )
{
try
{
NetworkHandler.instance.sendToServer( new PacketValueConfig( "TileSecurity.ToggleOption", toggleSetting.name() ) );
}
catch (IOException e)
{
AELog.error( e );
}
}
super.drawFG( offsetX, offsetY, mouseX, mouseY );
this.fontRendererObj.drawString( GuiText.SecurityCardEditor.getLocal(), 8, this.ySize - 96 + 1 - this.reservedSpace, 4210752 );
}
@Override
@@ -111,26 +114,18 @@ public class GuiSecurity extends GuiMEMonitorable
{
ContainerSecurity cs = (ContainerSecurity) this.inventorySlots;
this.inject.setState( (cs.security & (1 << SecurityPermissions.INJECT.ordinal())) > 0 );
this.extract.setState( (cs.security & (1 << SecurityPermissions.EXTRACT.ordinal())) > 0 );
this.craft.setState( (cs.security & (1 << SecurityPermissions.CRAFT.ordinal())) > 0 );
this.build.setState( (cs.security & (1 << SecurityPermissions.BUILD.ordinal())) > 0 );
this.security.setState( (cs.security & (1 << SecurityPermissions.SECURITY.ordinal())) > 0 );
this.inject.setState( ( cs.security & ( 1 << SecurityPermissions.INJECT.ordinal() ) ) > 0 );
this.extract.setState( ( cs.security & ( 1 << SecurityPermissions.EXTRACT.ordinal() ) ) > 0 );
this.craft.setState( ( cs.security & ( 1 << SecurityPermissions.CRAFT.ordinal() ) ) > 0 );
this.build.setState( ( cs.security & ( 1 << SecurityPermissions.BUILD.ordinal() ) ) > 0 );
this.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 );
this.fontRendererObj.drawString( GuiText.SecurityCardEditor.getLocal(), 8, this.ySize - 96 + 1 - this.reservedSpace, 4210752 );
}
@Override
public Enum getSortBy()
{
return SortOrder.NAME;
}
}
@@ -18,6 +18,7 @@
package appeng.client.gui.implementations;
import net.minecraft.entity.player.InventoryPlayer;
import appeng.client.gui.AEBaseGui;
@@ -27,32 +28,33 @@ 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) {
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)
{
this.bindTexture( "guis/skychest.png" );
this.drawTexturedModalRect( offsetX, offsetY, 0, 0, this.xSize, this.ySize );
}
@Override
public void drawFG(int offsetX, int offsetY, int mouseX, int mouseY)
public void drawFG( int offsetX, int offsetY, int mouseX, int mouseY )
{
this.fontRendererObj.drawString( this.getGuiDisplayName( GuiText.SkyChest.getLocal() ), 8, 8, 4210752 );
this.fontRendererObj.drawString( GuiText.inventory.getLocal(), 8, this.ySize - 96 + 2, 4210752 );
}
@Override
public void drawBG( int offsetX, int offsetY, int mouseX, int mouseY )
{
this.bindTexture( "guis/skychest.png" );
this.drawTexturedModalRect( offsetX, offsetY, 0, 0, this.xSize, this.ySize );
}
@Override
protected boolean enableSpaceClicking()
{
return !AppEng.instance.isIntegrationEnabled( IntegrationType.InvTweaks );
}
}
@@ -33,26 +33,28 @@ import appeng.core.localization.GuiText;
import appeng.tile.spatial.TileSpatialIOPort;
import appeng.util.Platform;
public class GuiSpatialIOPort extends AEBaseGui
{
final ContainerSpatialIOPort container;
GuiImgButton units;
public GuiSpatialIOPort(InventoryPlayer inventoryPlayer, TileSpatialIOPort te) {
public GuiSpatialIOPort( InventoryPlayer inventoryPlayer, TileSpatialIOPort te )
{
super( new ContainerSpatialIOPort( inventoryPlayer, te ) );
this.ySize = 199;
this.container = (ContainerSpatialIOPort) this.inventorySlots;
}
@Override
protected void actionPerformed(GuiButton btn)
protected void actionPerformed( GuiButton btn )
{
super.actionPerformed( btn );
boolean backwards = Mouse.isButtonDown( 1 );
if ( btn == this.units )
if( btn == this.units )
{
AEConfig.instance.nextPowerUnit( backwards );
this.units.set( AEConfig.instance.selectedPowerUnit() );
@@ -69,22 +71,21 @@ public class GuiSpatialIOPort extends AEBaseGui
}
@Override
public void drawBG(int offsetX, int offsetY, int mouseX, int mouseY)
{
this.bindTexture( "guis/spatialio.png" );
this.drawTexturedModalRect( offsetX, offsetY, 0, 0, this.xSize, this.ySize );
}
@Override
public void drawFG(int offsetX, int offsetY, int mouseX, int mouseY)
public void drawFG( int offsetX, int offsetY, int mouseX, int mouseY )
{
this.fontRendererObj.drawString( GuiText.StoredPower.getLocal() + ": " + Platform.formatPowerLong( this.container.currentPower, false ), 13, 21, 4210752 );
this.fontRendererObj.drawString( GuiText.MaxPower.getLocal() + ": " + Platform.formatPowerLong( this.container.maxPower, false ), 13, 31, 4210752 );
this.fontRendererObj.drawString( GuiText.RequiredPower.getLocal() + ": " + Platform.formatPowerLong( this.container.reqPower, false ), 13, 78, 4210752 );
this.fontRendererObj.drawString( GuiText.Efficiency.getLocal() + ": " + (((float) this.container.eff) / 100) + '%', 13, 88, 4210752 );
this.fontRendererObj.drawString( GuiText.Efficiency.getLocal() + ": " + ( ( (float) this.container.eff ) / 100 ) + '%', 13, 88, 4210752 );
this.fontRendererObj.drawString( this.getGuiDisplayName( GuiText.SpatialIOPort.getLocal() ), 8, 6, 4210752 );
this.fontRendererObj.drawString( GuiText.inventory.getLocal(), 8, this.ySize - 96, 4210752 );
}
@Override
public void drawBG( int offsetX, int offsetY, int mouseX, int mouseY )
{
this.bindTexture( "guis/spatialio.png" );
this.drawTexturedModalRect( offsetX, offsetY, 0, 0, this.xSize, this.ySize );
}
}
@@ -18,6 +18,7 @@
package appeng.client.gui.implementations;
import java.io.IOException;
import org.lwjgl.input.Mouse;
@@ -42,6 +43,7 @@ import appeng.core.sync.packets.PacketSwitchGuis;
import appeng.core.sync.packets.PacketValueConfig;
import appeng.parts.misc.PartStorageBus;
public class GuiStorageBus extends GuiUpgradeable
{
@@ -51,27 +53,12 @@ public class GuiStorageBus extends GuiUpgradeable
GuiImgButton partition;
GuiImgButton clear;
public GuiStorageBus(InventoryPlayer inventoryPlayer, PartStorageBus te) {
public GuiStorageBus( InventoryPlayer inventoryPlayer, PartStorageBus te )
{
super( new ContainerStorageBus( inventoryPlayer, te ) );
this.ySize = 251;
}
@Override
public void drawFG(int offsetX, int offsetY, int mouseX, int mouseY)
{
this.fontRendererObj.drawString( this.getGuiDisplayName( GuiText.StorageBus.getLocal() ), 8, 6, 4210752 );
this.fontRendererObj.drawString( GuiText.inventory.getLocal(), 8, this.ySize - 96 + 3, 4210752 );
if ( this.fuzzyMode != null )
this.fuzzyMode.set( this.cvb.fzMode );
if ( this.storageFilter != null )
this.storageFilter.set( ((ContainerStorageBus) this.cvb).storageFilter );
if ( this.rwMode != null )
this.rwMode.set( ((ContainerStorageBus) this.cvb).rwMode );
}
@Override
protected void addButtons()
{
@@ -91,34 +78,19 @@ public class GuiStorageBus extends GuiUpgradeable
}
@Override
protected void actionPerformed(GuiButton btn)
public void drawFG( int offsetX, int offsetY, int mouseX, int mouseY )
{
super.actionPerformed( btn );
this.fontRendererObj.drawString( this.getGuiDisplayName( GuiText.StorageBus.getLocal() ), 8, 6, 4210752 );
this.fontRendererObj.drawString( GuiText.inventory.getLocal(), 8, this.ySize - 96 + 3, 4210752 );
boolean backwards = Mouse.isButtonDown( 1 );
if( this.fuzzyMode != null )
this.fuzzyMode.set( this.cvb.fzMode );
try
{
if ( btn == this.partition )
NetworkHandler.instance.sendToServer( new PacketValueConfig( "StorageBus.Action", "Partition" ) );
if( this.storageFilter != null )
this.storageFilter.set( ( (ContainerStorageBus) this.cvb ).storageFilter );
else if ( btn == this.clear )
NetworkHandler.instance.sendToServer( new PacketValueConfig( "StorageBus.Action", "Clear" ) );
else if ( btn == this.priority )
NetworkHandler.instance.sendToServer( new PacketSwitchGuis( GuiBridge.GUI_PRIORITY ) );
else if ( btn == this.rwMode )
NetworkHandler.instance.sendToServer( new PacketConfigButton( this.rwMode.getSetting(), backwards ) );
else if ( btn == this.storageFilter )
NetworkHandler.instance.sendToServer( new PacketConfigButton( this.storageFilter.getSetting(), backwards ) );
}
catch (IOException e)
{
AELog.error( e );
}
if( this.rwMode != null )
this.rwMode.set( ( (ContainerStorageBus) this.cvb ).rwMode );
}
@Override
@@ -127,4 +99,33 @@ public class GuiStorageBus extends GuiUpgradeable
return "guis/storagebus.png";
}
@Override
protected void actionPerformed( GuiButton btn )
{
super.actionPerformed( btn );
boolean backwards = Mouse.isButtonDown( 1 );
try
{
if( btn == this.partition )
NetworkHandler.instance.sendToServer( new PacketValueConfig( "StorageBus.Action", "Partition" ) );
else if( btn == this.clear )
NetworkHandler.instance.sendToServer( new PacketValueConfig( "StorageBus.Action", "Clear" ) );
else if( btn == this.priority )
NetworkHandler.instance.sendToServer( new PacketSwitchGuis( GuiBridge.GUI_PRIORITY ) );
else if( btn == this.rwMode )
NetworkHandler.instance.sendToServer( new PacketConfigButton( this.rwMode.getSetting(), backwards ) );
else if( btn == this.storageFilter )
NetworkHandler.instance.sendToServer( new PacketConfigButton( this.storageFilter.getSetting(), backwards ) );
}
catch( IOException e )
{
AELog.error( e );
}
}
}
@@ -18,6 +18,7 @@
package appeng.client.gui.implementations;
import org.lwjgl.input.Mouse;
import net.minecraft.client.gui.GuiButton;
@@ -37,6 +38,7 @@ import appeng.core.sync.network.NetworkHandler;
import appeng.core.sync.packets.PacketConfigButton;
import appeng.parts.automation.PartImportBus;
public class GuiUpgradeable extends AEBaseGui
{
@@ -47,11 +49,13 @@ public class GuiUpgradeable extends AEBaseGui
GuiImgButton fuzzyMode;
GuiImgButton craftMode;
public GuiUpgradeable(InventoryPlayer inventoryPlayer, IUpgradeableHost te) {
public GuiUpgradeable( InventoryPlayer inventoryPlayer, IUpgradeableHost te )
{
this( new ContainerUpgradeable( inventoryPlayer, te ) );
}
public GuiUpgradeable(ContainerUpgradeable te) {
public GuiUpgradeable( ContainerUpgradeable te )
{
super( te );
this.cvb = te;
@@ -60,6 +64,11 @@ public class GuiUpgradeable extends AEBaseGui
this.ySize = 184;
}
protected boolean hasToolbox()
{
return ( (ContainerUpgradeable) this.inventorySlots ).hasToolbox();
}
@Override
public void initGui()
{
@@ -79,43 +88,42 @@ public class GuiUpgradeable extends AEBaseGui
}
@Override
protected void actionPerformed(GuiButton btn)
public void drawFG( int offsetX, int offsetY, int mouseX, int mouseY )
{
super.actionPerformed( btn );
this.fontRendererObj.drawString( this.getGuiDisplayName( this.getName().getLocal() ), 8, 6, 4210752 );
this.fontRendererObj.drawString( GuiText.inventory.getLocal(), 8, this.ySize - 96 + 3, 4210752 );
boolean backwards = Mouse.isButtonDown( 1 );
if( this.redstoneMode != null )
this.redstoneMode.set( this.cvb.rsMode );
if ( btn == this.redstoneMode )
NetworkHandler.instance.sendToServer( new PacketConfigButton( this.redstoneMode.getSetting(), backwards ) );
if( this.fuzzyMode != null )
this.fuzzyMode.set( this.cvb.fzMode );
if ( btn == this.craftMode )
NetworkHandler.instance.sendToServer( new PacketConfigButton( this.craftMode.getSetting(), backwards ) );
if ( btn == this.fuzzyMode )
NetworkHandler.instance.sendToServer( new PacketConfigButton( this.fuzzyMode.getSetting(), backwards ) );
}
protected boolean hasToolbox()
{
return ((ContainerUpgradeable) this.inventorySlots).hasToolbox();
if( this.craftMode != null )
this.craftMode.set( this.cvb.cMode );
}
@Override
public void drawBG(int offsetX, int offsetY, int mouseX, int mouseY)
public void drawBG( int offsetX, int offsetY, int mouseX, int mouseY )
{
this.handleButtonVisibility();
this.bindTexture( this.getBackground() );
this.drawTexturedModalRect( offsetX, offsetY, 0, 0, 211 - 34, this.ySize );
if ( this.drawUpgrades() )
if( this.drawUpgrades() )
this.drawTexturedModalRect( offsetX + 177, offsetY, 177, 0, 35, 14 + this.cvb.availableUpgrades() * 18 );
if ( this.hasToolbox() )
if( this.hasToolbox() )
this.drawTexturedModalRect( offsetX + 178, offsetY + this.ySize - 90, 178, this.ySize - 90, 68, 68 );
}
protected boolean drawUpgrades()
protected void handleButtonVisibility()
{
return true;
if( this.redstoneMode != null )
this.redstoneMode.setVisibility( this.bc.getInstalledUpgrades( Upgrades.REDSTONE ) > 0 );
if( this.fuzzyMode != null )
this.fuzzyMode.setVisibility( this.bc.getInstalledUpgrades( Upgrades.FUZZY ) > 0 );
if( this.craftMode != null )
this.craftMode.setVisibility( this.bc.getInstalledUpgrades( Upgrades.CRAFTING ) > 0 );
}
protected String getBackground()
@@ -123,30 +131,9 @@ public class GuiUpgradeable extends AEBaseGui
return "guis/bus.png";
}
protected void handleButtonVisibility()
protected boolean drawUpgrades()
{
if ( this.redstoneMode != null )
this.redstoneMode.setVisibility( this.bc.getInstalledUpgrades( Upgrades.REDSTONE ) > 0 );
if ( this.fuzzyMode != null )
this.fuzzyMode.setVisibility( this.bc.getInstalledUpgrades( Upgrades.FUZZY ) > 0 );
if ( this.craftMode != null )
this.craftMode.setVisibility( this.bc.getInstalledUpgrades( Upgrades.CRAFTING ) > 0 );
}
@Override
public void drawFG(int offsetX, int offsetY, int mouseX, int mouseY)
{
this.fontRendererObj.drawString( this.getGuiDisplayName( this.getName().getLocal() ), 8, 6, 4210752 );
this.fontRendererObj.drawString( GuiText.inventory.getLocal(), 8, this.ySize - 96 + 3, 4210752 );
if ( this.redstoneMode != null )
this.redstoneMode.set( this.cvb.rsMode );
if ( this.fuzzyMode != null )
this.fuzzyMode.set( this.cvb.fzMode );
if ( this.craftMode != null )
this.craftMode.set( this.cvb.cMode );
return true;
}
protected GuiText getName()
@@ -154,4 +141,20 @@ public class GuiUpgradeable extends AEBaseGui
return this.bc instanceof PartImportBus ? GuiText.ImportBus : GuiText.ExportBus;
}
@Override
protected void actionPerformed( GuiButton btn )
{
super.actionPerformed( btn );
boolean backwards = Mouse.isButtonDown( 1 );
if( btn == this.redstoneMode )
NetworkHandler.instance.sendToServer( new PacketConfigButton( this.redstoneMode.getSetting(), backwards ) );
if( btn == this.craftMode )
NetworkHandler.instance.sendToServer( new PacketConfigButton( this.craftMode.getSetting(), backwards ) );
if( btn == this.fuzzyMode )
NetworkHandler.instance.sendToServer( new PacketConfigButton( this.fuzzyMode.getSetting(), backwards ) );
}
}
@@ -18,6 +18,7 @@
package appeng.client.gui.implementations;
import org.lwjgl.opengl.GL11;
import net.minecraft.entity.player.InventoryPlayer;
@@ -29,13 +30,14 @@ import appeng.container.implementations.ContainerVibrationChamber;
import appeng.core.localization.GuiText;
import appeng.tile.misc.TileVibrationChamber;
public class GuiVibrationChamber extends AEBaseGui
{
final ContainerVibrationChamber cvc;
GuiProgressBar pb;
public GuiVibrationChamber(InventoryPlayer inventoryPlayer, TileVibrationChamber te)
public GuiVibrationChamber( InventoryPlayer inventoryPlayer, TileVibrationChamber te )
{
super( new ContainerVibrationChamber( inventoryPlayer, te ) );
this.cvc = (ContainerVibrationChamber) this.inventorySlots;
@@ -52,16 +54,7 @@ public class GuiVibrationChamber extends AEBaseGui
}
@Override
public void drawBG(int offsetX, int offsetY, int mouseX, int mouseY)
{
this.bindTexture( "guis/vibchamber.png" );
this.pb.xPosition = 99 + this.guiLeft;
this.pb.yPosition = 36 + this.guiTop;
this.drawTexturedModalRect( offsetX, offsetY, 0, 0, this.xSize, this.ySize );
}
@Override
public void drawFG(int offsetX, int offsetY, int mouseX, int mouseY)
public void drawFG( int offsetX, int offsetY, int mouseX, int mouseY )
{
this.fontRendererObj.drawString( this.getGuiDisplayName( GuiText.VibrationChamber.getLocal() ), 8, 6, 4210752 );
this.fontRendererObj.drawString( GuiText.inventory.getLocal(), 8, this.ySize - 96 + 3, 4210752 );
@@ -71,7 +64,7 @@ public class GuiVibrationChamber extends AEBaseGui
this.pb.setFullMsg( this.cvc.aePerTick * this.cvc.getCurrentProgress() / 100 + " ae/t" );
if ( this.cvc.getCurrentProgress() > 0 )
if( this.cvc.getCurrentProgress() > 0 )
{
int i1 = this.cvc.getCurrentProgress();
this.bindTexture( "guis/vibchamber.png" );
@@ -80,4 +73,12 @@ public class GuiVibrationChamber extends AEBaseGui
}
}
@Override
public void drawBG( int offsetX, int offsetY, int mouseX, int mouseY )
{
this.bindTexture( "guis/vibchamber.png" );
this.pb.xPosition = 99 + this.guiLeft;
this.pb.yPosition = 36 + this.guiTop;
this.drawTexturedModalRect( offsetX, offsetY, 0, 0, this.xSize, this.ySize );
}
}
@@ -18,6 +18,7 @@
package appeng.client.gui.implementations;
import org.lwjgl.input.Mouse;
import net.minecraft.client.gui.GuiButton;
@@ -32,19 +33,26 @@ import appeng.core.localization.GuiText;
import appeng.tile.networking.TileWireless;
import appeng.util.Platform;
public class GuiWireless extends AEBaseGui
{
GuiImgButton units;
public GuiWireless( InventoryPlayer inventoryPlayer, TileWireless te )
{
super( new ContainerWireless( inventoryPlayer, te ) );
this.ySize = 166;
}
@Override
protected void actionPerformed(GuiButton btn)
protected void actionPerformed( GuiButton btn )
{
super.actionPerformed( btn );
boolean backwards = Mouse.isButtonDown( 1 );
if ( btn == this.units )
if( btn == this.units )
{
AEConfig.instance.nextPowerUnit( backwards );
this.units.set( AEConfig.instance.selectedPowerUnit() );
@@ -60,36 +68,30 @@ public class GuiWireless extends AEBaseGui
this.buttonList.add( this.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)
{
this.bindTexture( "guis/wireless.png" );
this.drawTexturedModalRect( offsetX, offsetY, 0, 0, this.xSize, this.ySize );
}
@Override
public void drawFG(int offsetX, int offsetY, int mouseX, int mouseY)
public void drawFG( int offsetX, int offsetY, int mouseX, int mouseY )
{
this.fontRendererObj.drawString( this.getGuiDisplayName( GuiText.Wireless.getLocal() ), 8, 6, 4210752 );
this.fontRendererObj.drawString( GuiText.inventory.getLocal(), 8, this.ySize - 96 + 3, 4210752 );
ContainerWireless cw = (ContainerWireless) this.inventorySlots;
if ( cw.range > 0 )
if( cw.range > 0 )
{
String firstMessage = GuiText.Range.getLocal() + ": " + (cw.range / 10.0) + " m";
String firstMessage = GuiText.Range.getLocal() + ": " + ( cw.range / 10.0 ) + " m";
String secondMessage = GuiText.PowerUsageRate.getLocal() + ": " + Platform.formatPowerLong( cw.drain, true );
int strWidth = Math.max( this.fontRendererObj.getStringWidth( firstMessage ), this.fontRendererObj.getStringWidth( secondMessage ) );
int cOffset = (this.xSize / 2) - (strWidth / 2);
int cOffset = ( this.xSize / 2 ) - ( strWidth / 2 );
this.fontRendererObj.drawString( firstMessage, cOffset, 20, 4210752 );
this.fontRendererObj.drawString( secondMessage, cOffset, 20 + 12, 4210752 );
}
}
@Override
public void drawBG( int offsetX, int offsetY, int mouseX, int mouseY )
{
this.bindTexture( "guis/wireless.png" );
this.drawTexturedModalRect( offsetX, offsetY, 0, 0, this.xSize, this.ySize );
}
}
@@ -18,14 +18,17 @@
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) {
public GuiWirelessTerm( InventoryPlayer inventoryPlayer, IPortableCell te )
{
super( inventoryPlayer, te );
this.maxRows = Integer.MAX_VALUE;
}
@@ -72,7 +72,7 @@ public class GuiImgButton extends GuiButton implements ITooltip
this.width = 16;
this.height = 16;
if ( appearances == null )
if( appearances == null )
{
appearances = new HashMap<EnumPair, ButtonAppearance>();
this.registerApp( 16 * 7, Settings.CONDENSER_OUTPUT, CondenserOutput.TRASH, ButtonToolTips.CondenserOutput, ButtonToolTips.Trash );
@@ -165,7 +165,7 @@ public class GuiImgButton extends GuiButton implements ITooltip
{
ButtonAppearance a = new ButtonAppearance();
a.displayName = title.getUnlocalized();
a.displayValue = ( String ) ( hint instanceof String ? hint : ( ( ButtonToolTips ) hint ).getUnlocalized() );
a.displayValue = (String) ( hint instanceof String ? hint : ( (ButtonToolTips) hint ).getUnlocalized() );
a.index = iconIndex;
appearances.put( new EnumPair( setting, val ), a );
}
@@ -179,11 +179,11 @@ public class GuiImgButton extends GuiButton implements ITooltip
@Override
public void drawButton( Minecraft par1Minecraft, int par2, int par3 )
{
if ( this.visible )
if( this.visible )
{
int iconIndex = this.getIconIndex();
if ( this.halfSize )
if( this.halfSize )
{
this.width = 8;
this.height = 8;
@@ -192,7 +192,7 @@ public class GuiImgButton extends GuiButton implements ITooltip
GL11.glTranslatef( this.xPosition, this.yPosition, 0.0F );
GL11.glScalef( 0.5f, 0.5f, 0.5f );
if ( this.enabled )
if( this.enabled )
GL11.glColor4f( 1.0f, 1.0f, 1.0f, 1.0f );
else
GL11.glColor4f( 0.5f, 0.5f, 0.5f, 1.0f );
@@ -200,7 +200,7 @@ public class GuiImgButton extends GuiButton implements ITooltip
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_y = (int) Math.floor( iconIndex / 16 );
int uv_x = iconIndex - uv_y * 16;
this.drawTexturedModalRect( 0, 0, 256 - 16, 256 - 16, 16, 16 );
@@ -211,7 +211,7 @@ public class GuiImgButton extends GuiButton implements ITooltip
}
else
{
if ( this.enabled )
if( this.enabled )
GL11.glColor4f( 1.0f, 1.0f, 1.0f, 1.0f );
else
GL11.glColor4f( 0.5f, 0.5f, 0.5f, 1.0f );
@@ -219,7 +219,7 @@ public class GuiImgButton extends GuiButton implements ITooltip
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_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 );
@@ -232,10 +232,10 @@ public class GuiImgButton extends GuiButton implements ITooltip
private int getIconIndex()
{
if ( this.buttonSetting != null && this.currentValue != null )
if( this.buttonSetting != null && this.currentValue != null )
{
ButtonAppearance app = appearances.get( new EnumPair( this.buttonSetting, this.currentValue ) );
if ( app == null )
if( app == null )
return 256 - 1;
return app.index;
}
@@ -244,7 +244,7 @@ public class GuiImgButton extends GuiButton implements ITooltip
public Settings getSetting()
{
return ( Settings ) this.buttonSetting;
return (Settings) this.buttonSetting;
}
public Enum getCurrentValue()
@@ -258,36 +258,36 @@ public class GuiImgButton extends GuiButton implements ITooltip
String displayName = null;
String displayValue = null;
if ( this.buttonSetting != null && this.currentValue != null )
if( this.buttonSetting != null && this.currentValue != null )
{
ButtonAppearance buttonAppearance = appearances.get( new EnumPair( this.buttonSetting, this.currentValue ) );
if ( buttonAppearance == null )
if( buttonAppearance == null )
return "No Such Message";
displayName = buttonAppearance.displayName;
displayValue = buttonAppearance.displayValue;
}
if ( displayName != null )
if( displayName != null )
{
String name = StatCollector.translateToLocal( displayName );
String value = StatCollector.translateToLocal( displayValue );
if ( name == null || name.isEmpty() )
if( name == null || name.isEmpty() )
name = displayName;
if ( value == null || value.isEmpty() )
if( value == null || value.isEmpty() )
value = displayValue;
if ( this.fillVar != null )
if( this.fillVar != null )
value = COMPILE.matcher( value ).replaceFirst( this.fillVar );
value = PATTERN_NEW_LINE.matcher( value ).replaceAll( "\n" );
StringBuilder sb = new StringBuilder( value );
int i = sb.lastIndexOf( "\n" );
if ( i <= 0 )
if( i <= 0 )
i = 0;
while ( i + 30 < sb.length() && ( i = sb.lastIndexOf( " ", i + 30 ) ) != -1 )
while( i + 30 < sb.length() && ( i = sb.lastIndexOf( " ", i + 30 ) ) != -1 )
{
sb.replace( i, i + 1, "\n" );
}
@@ -329,7 +329,7 @@ public class GuiImgButton extends GuiButton implements ITooltip
public void set( Enum e )
{
if ( this.currentValue != e )
if( this.currentValue != e )
{
this.currentValue = e;
}
@@ -356,15 +356,16 @@ public class GuiImgButton extends GuiButton implements ITooltip
@Override
public boolean equals( Object obj )
{
if ( obj == null )
if( obj == null )
return false;
if ( this.getClass() != obj.getClass() )
if( this.getClass() != obj.getClass() )
return false;
EnumPair other = ( EnumPair ) obj;
EnumPair other = (EnumPair) obj;
return other.setting == this.setting && other.value == this.value;
}
}
private static class ButtonAppearance
{
public int index;
@@ -18,6 +18,7 @@
package appeng.client.gui.widgets;
import net.minecraft.client.gui.FontRenderer;
import net.minecraft.client.gui.GuiTextField;
@@ -27,31 +28,30 @@ 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) {
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_)
public void writeText( String p_146191_1_ )
{
String original = this.getText();
super.writeText( p_146191_1_ );
try
{
if ( this.type == int.class || this.type == Integer.class )
if( this.type == int.class || this.type == Integer.class )
Integer.parseInt( this.getText() );
else if ( this.type == long.class || this.type == Long.class )
else if( this.type == long.class || this.type == Long.class )
Long.parseLong( this.getText() );
else if ( this.type == double.class || this.type == Double.class )
else if( this.type == double.class || this.type == Double.class )
Double.parseDouble( this.getText() );
}
catch(NumberFormatException e )
catch( NumberFormatException e )
{
this.setText( original );
}
}
}
@@ -26,29 +26,24 @@ import net.minecraft.util.ResourceLocation;
import appeng.container.interfaces.IProgressProvider;
import appeng.core.localization.GuiText;
public class GuiProgressBar extends GuiButton implements ITooltip
{
public enum Direction
{
HORIZONTAL, VERTICAL
}
private final IProgressProvider source;
private final ResourceLocation texture;
private final int fill_u;
private final int fill_v;
private final Direction layout;
private String fullMsg;
private final String titleName;
private String fullMsg;
public GuiProgressBar(IProgressProvider source, String texture, int posX, int posY, int u, int y, int _width, int _height, Direction dir)
public GuiProgressBar( IProgressProvider source, String texture, int posX, int posY, int u, int y, int _width, int _height, Direction dir )
{
this( source, texture, posX, posY, u, y, _width, _height, dir, null );
}
public GuiProgressBar(IProgressProvider source, String texture, int posX, int posY, int u, int y, int _width, int _height, Direction dir, String title)
public GuiProgressBar( IProgressProvider source, String texture, int posX, int posY, int u, int y, int _width, int _height, Direction dir, String title )
{
super( posX, posY, _width, "" );
this.source = source;
@@ -64,22 +59,22 @@ public class GuiProgressBar extends GuiButton implements ITooltip
}
@Override
public void drawButton(Minecraft par1Minecraft, int par2, int par3)
public void drawButton( Minecraft par1Minecraft, int par2, int par3 )
{
if ( this.visible )
if( this.visible )
{
par1Minecraft.getTextureManager().bindTexture( this.texture );
int max = this.source.getMaxProgress();
int current = this.source.getCurrentProgress();
if ( this.layout == Direction.VERTICAL )
if( this.layout == Direction.VERTICAL )
{
int diff = this.height - (max > 0 ? (this.height * current) / max : 0);
int diff = this.height - ( max > 0 ? ( this.height * current ) / max : 0 );
this.drawTexturedModalRect( this.xPosition, this.yPosition + diff, this.fill_u, this.fill_v + diff, this.width, this.height - diff );
}
else
{
int diff = this.width - (max > 0 ? (this.width * current) / max : 0);
int diff = this.width - ( max > 0 ? ( this.width * current ) / max : 0 );
this.drawTexturedModalRect( this.xPosition, this.yPosition, this.fill_u + diff, this.fill_v, this.width - diff, this.height );
}
@@ -87,7 +82,7 @@ public class GuiProgressBar extends GuiButton implements ITooltip
}
}
public void setFullMsg(String msg)
public void setFullMsg( String msg )
{
this.fullMsg = msg;
}
@@ -95,10 +90,10 @@ public class GuiProgressBar extends GuiButton implements ITooltip
@Override
public String getMessage()
{
if ( this.fullMsg != null )
if( this.fullMsg != null )
return this.fullMsg;
return (this.titleName != null ? this.titleName : "") + '\n' + this.source.getCurrentProgress() + ' ' + GuiText.Of.getLocal() + ' ' + this.source.getMaxProgress();
return ( this.titleName != null ? this.titleName : "" ) + '\n' + this.source.getCurrentProgress() + ' ' + GuiText.Of.getLocal() + ' ' + this.source.getMaxProgress();
}
@Override
@@ -131,4 +126,8 @@ public class GuiProgressBar extends GuiButton implements ITooltip
return true;
}
public enum Direction
{
HORIZONTAL, VERTICAL
}
}
@@ -18,10 +18,12 @@
package appeng.client.gui.widgets;
import org.lwjgl.opengl.GL11;
import appeng.client.gui.AEBaseGui;
public class GuiScrollbar implements IScrollSource
{
@@ -35,23 +37,18 @@ public class GuiScrollbar implements IScrollSource
private int minScroll = 0;
private int currentScroll = 0;
private void applyRange()
{
this.currentScroll = Math.max( Math.min( this.currentScroll, this.maxScroll ), this.minScroll );
}
public void draw(AEBaseGui g)
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 ( this.getRange() == 0 )
if( this.getRange() == 0 )
{
g.drawTexturedModalRect( this.displayX, this.displayY, 232 + this.width, 0, this.width, 15 );
}
else
{
int offset = (this.currentScroll - this.minScroll) * (this.height - 15) / this.getRange();
int offset = ( this.currentScroll - this.minScroll ) * ( this.height - 15 ) / this.getRange();
g.drawTexturedModalRect( this.displayX, offset + this.displayY, 232, 0, this.width, 15 );
}
}
@@ -66,85 +63,89 @@ public class GuiScrollbar implements IScrollSource
return this.displayX;
}
public GuiScrollbar setLeft( int v )
{
this.displayX = v;
return this;
}
public int getTop()
{
return this.displayY;
}
public GuiScrollbar setTop( int v )
{
this.displayY = v;
return this;
}
public int getWidth()
{
return this.width;
}
public int getHeight()
{
return this.height;
}
public GuiScrollbar setLeft(int v)
{
this.displayX = v;
return this;
}
public GuiScrollbar setTop(int v)
{
this.displayY = v;
return this;
}
public GuiScrollbar setWidth(int v)
public GuiScrollbar setWidth( int v )
{
this.width = v;
return this;
}
public GuiScrollbar setHeight(int v)
public int getHeight()
{
return this.height;
}
public GuiScrollbar setHeight( int v )
{
this.height = v;
return this;
}
public void setRange(int min, int max, int pageSize)
public void setRange( int min, int max, int pageSize )
{
this.minScroll = min;
this.maxScroll = max;
this.pageSize = pageSize;
if ( this.minScroll > this.maxScroll )
if( this.minScroll > this.maxScroll )
this.maxScroll = this.minScroll;
this.applyRange();
}
private void applyRange()
{
this.currentScroll = Math.max( Math.min( this.currentScroll, this.maxScroll ), this.minScroll );
}
@Override
public int getCurrentScroll()
{
return this.currentScroll;
}
public void click(AEBaseGui aeBaseGui, int x, int y)
public void click( AEBaseGui aeBaseGui, int x, int y )
{
if ( this.getRange() == 0 )
if( this.getRange() == 0 )
return;
if ( x > this.displayX && x <= this.displayX + this.width )
if( x > this.displayX && x <= this.displayX + this.width )
{
if ( y > this.displayY && y <= this.displayY + this.height )
if( y > this.displayY && y <= this.displayY + this.height )
{
this.currentScroll = (y - this.displayY);
this.currentScroll = this.minScroll + ((this.currentScroll * 2 * this.getRange() / this.height));
this.currentScroll = (this.currentScroll + 1) >> 1;
this.currentScroll = ( y - this.displayY );
this.currentScroll = this.minScroll + ( ( this.currentScroll * 2 * this.getRange() / this.height ) );
this.currentScroll = ( this.currentScroll + 1 ) >> 1;
this.applyRange();
}
}
}
public void wheel(int delta)
public void wheel( int delta )
{
delta = Math.max( Math.min( -delta, 1 ), -1 );
this.currentScroll += delta * this.pageSize;
this.applyRange();
}
}
@@ -56,11 +56,11 @@ public class GuiTabButton extends GuiButton implements ITooltip
/**
* Using itemstack as an icon
*
* @param x x pos of button
* @param y y pos of button
* @param ico used icon
* @param x x pos of button
* @param y y pos of button
* @param ico used icon
* @param message mouse over message
* @param ir renderer
* @param ir renderer
*/
public GuiTabButton( int x, int y, ItemStack ico, String message, RenderItem ir )
{
@@ -77,7 +77,7 @@ public class GuiTabButton extends GuiButton implements ITooltip
@Override
public void drawButton( Minecraft minecraft, int x, int y )
{
if ( this.visible )
if( this.visible )
{
GL11.glColor4f( 1.0f, 1.0f, 1.0f, 1.0f );
minecraft.renderEngine.bindTexture( ExtraBlockTextures.GuiTexture( "guis/states.png" ) );
@@ -89,9 +89,9 @@ public class GuiTabButton extends GuiButton implements ITooltip
this.drawTexturedModalRect( this.xPosition, this.yPosition, uv_x * 16, 0, 25, 22 );
if ( this.myIcon >= 0 )
if( this.myIcon >= 0 )
{
int uv_y = ( int ) Math.floor( this.myIcon / 16 );
int uv_y = (int) Math.floor( this.myIcon / 16 );
uv_x = this.myIcon - uv_y * 16;
this.drawTexturedModalRect( offsetX + this.xPosition + 3, this.yPosition + 3, uv_x * 16, uv_y * 16, 16, 16 );
@@ -99,7 +99,7 @@ public class GuiTabButton extends GuiButton implements ITooltip
this.mouseDragged( minecraft, x, y );
if ( this.myItem != null )
if( this.myItem != null )
{
this.zLevel = 100.0F;
this.itemRenderer.zLevel = 100.0F;
@@ -62,7 +62,7 @@ public class GuiToggleButton extends GuiButton implements ITooltip
@Override
public void drawButton( Minecraft par1Minecraft, int par2, int par3 )
{
if ( this.visible )
if( this.visible )
{
int iconIndex = this.getIconIndex();
@@ -70,7 +70,7 @@ public class GuiToggleButton extends GuiButton implements ITooltip
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_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 );
@@ -87,23 +87,23 @@ public class GuiToggleButton extends GuiButton implements ITooltip
@Override
public String getMessage()
{
if ( this.displayName != null )
if( this.displayName != null )
{
String name = StatCollector.translateToLocal( this.displayName );
String value = StatCollector.translateToLocal( this.displayHint );
if ( name == null || name.isEmpty() )
if( name == null || name.isEmpty() )
name = this.displayName;
if ( value == null || value.isEmpty() )
if( value == null || value.isEmpty() )
value = this.displayHint;
value = PATTERN_NEW_LINE.matcher( value ).replaceAll( "\n" );
StringBuilder sb = new StringBuilder( value );
int i = sb.lastIndexOf( "\n" );
if ( i <= 0 )
if( i <= 0 )
i = 0;
while ( i + 30 < sb.length() && ( i = sb.lastIndexOf( " ", i + 30 ) ) != -1 )
while( i + 30 < sb.length() && ( i = sb.lastIndexOf( " ", i + 30 ) ) != -1 )
{
sb.replace( i, i + 1, "\n" );
}
@@ -18,9 +18,9 @@
package appeng.client.gui.widgets;
public interface IScrollSource
{
int getCurrentScroll();
}
@@ -18,9 +18,11 @@
package appeng.client.gui.widgets;
import appeng.api.config.SortDir;
import appeng.api.config.ViewItems;
public interface ISortSource
{
@@ -38,5 +40,4 @@ public interface ISortSource
* @return {@link ViewItems}
*/
Enum getSortDisplay();
}
@@ -18,9 +18,9 @@
package appeng.client.gui.widgets;
/**
* AEBaseGui controlled Tooltip Interface.
*
*/
public interface ITooltip
{
@@ -64,5 +64,4 @@ public interface ITooltip
* @return true if button being drawn
*/
boolean isVisible();
}
@@ -22,6 +22,7 @@ package appeng.client.gui.widgets;
import net.minecraft.client.gui.FontRenderer;
import net.minecraft.client.gui.GuiTextField;
/**
* A modified version of the Minecraft text field.
* You can initialize it over the full element span.
@@ -44,10 +45,10 @@ public class MEGuiTextField extends GuiTextField
* Pays attention to the '_' caret.
*
* @param fontRenderer renderer for the strings
* @param xPos absolute left position
* @param yPos absolute top position
* @param width absolute width
* @param height absolute height
* @param xPos absolute left position
* @param yPos absolute top position
* @param width absolute width
* @param height absolute height
*/
public MEGuiTextField( FontRenderer fontRenderer, int xPos, int yPos, int width, int height )
{
@@ -18,11 +18,13 @@
package appeng.client.me;
import net.minecraft.util.StatCollector;
import appeng.tile.inventory.AppEngInternalInventory;
import appeng.util.ItemSorters;
public class ClientDCInternalInv implements Comparable<ClientDCInternalInv>
{
@@ -31,7 +33,8 @@ public class ClientDCInternalInv implements Comparable<ClientDCInternalInv>
final public long id;
final public long sortBy;
public ClientDCInternalInv(int size, long id, long sortBy, String unlocalizedName) {
public ClientDCInternalInv( int size, long id, long sortBy, String unlocalizedName )
{
this.inv = new AppEngInternalInventory( null, size );
this.unlocalizedName = unlocalizedName;
this.id = id;
@@ -41,15 +44,14 @@ public class ClientDCInternalInv implements Comparable<ClientDCInternalInv>
public String getName()
{
String s = StatCollector.translateToLocal( this.unlocalizedName + ".name" );
if ( s.equals( this.unlocalizedName + ".name" ) )
if( s.equals( this.unlocalizedName + ".name" ) )
return StatCollector.translateToLocal( this.unlocalizedName );
return s;
}
@Override
public int compareTo(ClientDCInternalInv o)
public int compareTo( ClientDCInternalInv o )
{
return ItemSorters.compareLong( this.sortBy, o.sortBy );
}
}
@@ -18,20 +18,22 @@
package appeng.client.me;
import net.minecraft.item.ItemStack;
import appeng.api.storage.data.IAEItemStack;
public class InternalSlotME
{
private final ItemRepo repo;
public final int offset;
public final int xPos;
public final int yPos;
private final ItemRepo repo;
public InternalSlotME(ItemRepo def, int offset, int displayX, int displayY) {
public InternalSlotME( ItemRepo def, int offset, int displayX, int displayY )
{
this.repo = def;
this.offset = offset;
this.xPos = displayX;
+57 -59
View File
@@ -18,6 +18,7 @@
package appeng.client.me;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.util.ArrayList;
@@ -44,6 +45,7 @@ import appeng.util.ItemSorters;
import appeng.util.Platform;
import appeng.util.prioitylist.IPartitionList;
public class ItemRepo
{
@@ -56,42 +58,45 @@ public class ItemRepo
public int rowSize = 9;
public String searchString = "";
IPartitionList<IAEItemStack> myPartitionList;
private String innerSearch = "";
private String NEIWord = null;
private boolean hasPower;
public ItemRepo(IScrollSource src, ISortSource sortSrc)
public ItemRepo( IScrollSource src, ISortSource sortSrc )
{
this.src = src;
this.sortSrc = sortSrc;
}
public IAEItemStack getReferenceItem(int idx)
public IAEItemStack getReferenceItem( int idx )
{
idx += this.src.getCurrentScroll() * this.rowSize;
if ( idx >= this.view.size() )
if( idx >= this.view.size() )
return null;
return this.view.get( idx );
}
public ItemStack getItem(int idx)
public ItemStack getItem( int idx )
{
idx += this.src.getCurrentScroll() * this.rowSize;
if ( idx >= this.dsp.size() )
if( idx >= this.dsp.size() )
return null;
return this.dsp.get( idx );
}
void setSearch(String search)
void setSearch( String search )
{
this.searchString = search == null ? "" : search;
}
public void postUpdate(IAEItemStack is)
public void postUpdate( IAEItemStack is )
{
IAEItemStack st = this.list.findPrecise( is );
if ( st != null )
if( st != null )
{
st.reset();
st.add( is );
@@ -100,40 +105,12 @@ public class ItemRepo
this.list.add( is );
}
IPartitionList<IAEItemStack> myPartitionList;
public void setViewCell(ItemStack[] list)
public void setViewCell( ItemStack[] list )
{
this.myPartitionList = ItemViewCell.createFilter( list );
this.updateView();
}
private String NEIWord = null;
private void updateNEI(String filter)
{
try
{
if ( this.NEIWord == null || !this.NEIWord.equals( filter ) )
{
Class c = ReflectionHelper.getClass( this.getClass().getClassLoader(), "codechicken.nei.LayoutManager" );
Field fldSearchField = c.getField( "searchField" );
Object searchField = fldSearchField.get( c );
Method a = searchField.getClass().getMethod( "setText", String.class );
Method b = searchField.getClass().getMethod( "onTextChange", String.class );
this.NEIWord = filter;
a.invoke( searchField, filter );
b.invoke( searchField, "" );
}
}
catch (Throwable ignore)
{
}
}
public void updateView()
{
this.view.clear();
@@ -144,7 +121,7 @@ public class ItemRepo
Enum viewMode = this.sortSrc.getSortDisplay();
Enum searchMode = AEConfig.instance.settings.getSetting( Settings.SEARCH_MODE );
if ( searchMode == SearchBoxMode.NEI_AUTOSEARCH || searchMode == SearchBoxMode.NEI_MANUAL_SEARCH )
if( searchMode == SearchBoxMode.NEI_AUTOSEARCH || searchMode == SearchBoxMode.NEI_MANUAL_SEARCH )
this.updateNEI( this.searchString );
this.innerSearch = this.searchString;
@@ -152,7 +129,7 @@ public class ItemRepo
// boolean terminalSearchMods = Configuration.INSTANCE.settings.getSetting( Settings.SEARCH_MODS ) != YesNo.NO;
boolean searchMod = false;
if ( this.innerSearch.startsWith( "@" ) )
if( this.innerSearch.startsWith( "@" ) )
{
searchMod = true;
this.innerSearch = this.innerSearch.substring( 1 );
@@ -163,52 +140,52 @@ public class ItemRepo
{
m = Pattern.compile( this.innerSearch.toLowerCase(), Pattern.CASE_INSENSITIVE );
}
catch (Throwable ignore)
catch( Throwable ignore )
{
try
{
m = Pattern.compile( Pattern.quote( this.innerSearch.toLowerCase() ), Pattern.CASE_INSENSITIVE );
}
catch (Throwable __)
catch( Throwable __ )
{
return;
}
}
boolean notDone = false;
for (IAEItemStack is : this.list)
for( IAEItemStack is : this.list )
{
if ( this.myPartitionList != null )
if( this.myPartitionList != null )
{
if ( !this.myPartitionList.isListed( is ) )
if( !this.myPartitionList.isListed( is ) )
continue;
}
if ( viewMode == ViewItems.CRAFTABLE && !is.isCraftable() )
if( viewMode == ViewItems.CRAFTABLE && !is.isCraftable() )
continue;
if ( viewMode == ViewItems.CRAFTABLE )
if( viewMode == ViewItems.CRAFTABLE )
{
is = is.copy();
is.setStackSize( 0 );
}
if ( viewMode == ViewItems.STORED && is.getStackSize() == 0 )
if( viewMode == ViewItems.STORED && is.getStackSize() == 0 )
continue;
String dspName = searchMod ? Platform.getModId( is ) : Platform.getItemDisplayName( is );
notDone = true;
if ( m.matcher( dspName.toLowerCase() ).find() )
if( m.matcher( dspName.toLowerCase() ).find() )
{
this.view.add( is );
notDone = false;
}
if ( terminalSearchToolTips && notDone )
if( terminalSearchToolTips && notDone )
{
for (Object lp : Platform.getTooltip( is ))
if ( lp instanceof String && m.matcher( (String) lp ).find() )
for( Object lp : Platform.getTooltip( is ) )
if( lp instanceof String && m.matcher( (String) lp ).find() )
{
this.view.add( is );
notDone = false;
@@ -228,19 +205,43 @@ public class ItemRepo
ItemSorters.Direction = (appeng.api.config.SortDir) SortDir;
ItemSorters.init();
if ( SortBy == SortOrder.MOD )
if( SortBy == SortOrder.MOD )
Collections.sort( this.view, ItemSorters.CONFIG_BASED_SORT_BY_MOD );
else if ( SortBy == SortOrder.AMOUNT )
else if( SortBy == SortOrder.AMOUNT )
Collections.sort( this.view, ItemSorters.CONFIG_BASED_SORT_BY_SIZE );
else if ( SortBy == SortOrder.INVTWEAKS )
else if( SortBy == SortOrder.INVTWEAKS )
Collections.sort( this.view, ItemSorters.CONFIG_BASED_SORT_BY_INV_TWEAKS );
else
Collections.sort( this.view, ItemSorters.CONFIG_BASED_SORT_BY_NAME );
for (IAEItemStack is : this.view)
for( IAEItemStack is : this.view )
this.dsp.add( is.getItemStack() );
}
private void updateNEI( String filter )
{
try
{
if( this.NEIWord == null || !this.NEIWord.equals( filter ) )
{
Class c = ReflectionHelper.getClass( this.getClass().getClassLoader(), "codechicken.nei.LayoutManager" );
Field fldSearchField = c.getField( "searchField" );
Object searchField = fldSearchField.get( c );
Method a = searchField.getClass().getMethod( "setText", String.class );
Method b = searchField.getClass().getMethod( "onTextChange", String.class );
this.NEIWord = filter;
a.invoke( searchField, filter );
b.invoke( searchField, "" );
}
}
catch( Throwable ignore )
{
}
}
public int size()
{
return this.view.size();
@@ -251,16 +252,13 @@ public class ItemRepo
this.list.resetStatus();
}
private boolean hasPower;
public boolean hasPower()
{
return this.hasPower;
}
public void setPower(boolean hasPower)
public void setPower( boolean hasPower )
{
this.hasPower = hasPower;
}
}

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