This commit is contained in:
AlgorithmX2 2014-05-27 12:07:20 -05:00
commit ec58bdb879
24 changed files with 240 additions and 99 deletions

View file

@ -694,7 +694,7 @@ public class AEBaseBlock extends BlockContainer implements IAEFeature
{
memc.setMemoryCardContents( is, name, data );
memc.notifyUser( player, MemoryCardMessages.SETTINGS_SAVED );
return false;
return true;
}
}
}

View file

@ -54,7 +54,7 @@ public class BlockCableBus extends AEBaseBlock
if ( noTesrTile.isInstance( te ) )
return (T) te;
if ( tesrTile.isInstance( te ) )
if ( tesrTile != null && tesrTile.isInstance( te ) )
return (T) te;
return null;
@ -277,13 +277,15 @@ public class BlockCableBus extends AEBaseBlock
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 )
return ((TileCableBus) te).cb;
out = ((TileCableBus) te).cb;
if ( AppEng.instance.isIntegrationEnabled( "FMP" ) )
return ((IFMP) AppEng.instance.getIntegration( "FMP" )).getCableContainer( te );
else if ( AppEng.instance.isIntegrationEnabled( "FMP" ) )
out = ((IFMP) AppEng.instance.getIntegration( "FMP" )).getCableContainer( te );
return nullCB;
return out == null ? nullCB : out;
}
/**

View file

@ -1,7 +1,6 @@
package appeng.client.gui;
import java.io.IOException;
import java.text.DecimalFormat;
import java.util.Collection;
import java.util.Iterator;
import java.util.LinkedList;
@ -24,7 +23,6 @@ import org.lwjgl.input.Mouse;
import org.lwjgl.opengl.GL11;
import org.lwjgl.opengl.GL12;
import appeng.api.config.PowerUnits;
import appeng.api.storage.data.IAEItemStack;
import appeng.client.gui.widgets.GuiScrollbar;
import appeng.client.gui.widgets.ITooltip;
@ -42,7 +40,6 @@ import appeng.container.slot.SlotFake;
import appeng.container.slot.SlotInaccessable;
import appeng.container.slot.SlotOutput;
import appeng.container.slot.SlotRestrictedInput;
import appeng.core.AEConfig;
import appeng.core.AELog;
import appeng.core.AppEng;
import appeng.core.sync.network.NetworkHandler;
@ -59,39 +56,6 @@ public abstract class AEBaseGui extends GuiContainer
protected List<InternalSlotME> meSlots = new LinkedList<InternalSlotME>();
protected GuiScrollbar myScrollBar = null;
protected String formatPowerLong(long n, boolean isRate)
{
double p = ((double) n) / 100;
PowerUnits displayUnits = AEConfig.instance.selectedPowerUnit();
p = PowerUnits.AE.convertTo( displayUnits, p );
int offset = 0;
String Lvl = "";
String preFixes[] = new String[] { "k", "M", "G", "T", "P", "T", "P", "E", "Z", "Y" };
String unitName = displayUnits.name();
if ( displayUnits == PowerUnits.WA )
unitName = "J";
if ( displayUnits == PowerUnits.KJ )
{
Lvl = preFixes[offset];
unitName = "J";
offset++;
}
while (p > 1000 && offset < preFixes.length)
{
p /= 1000;
Lvl = preFixes[offset];
offset++;
}
DecimalFormat df = new DecimalFormat( "#.##" );
return df.format( p ) + " " + Lvl + unitName + (isRate ? "/t" : "");
}
public AEBaseGui(Container container) {
super( container );
}

View file

@ -138,11 +138,11 @@ public class GuiNetworkStatus extends AEBaseGui implements ISortSource
fontRendererObj.drawString( GuiText.NetworkDetails.getLocal(), 8, 6, 4210752 );
fontRendererObj.drawString( GuiText.StoredPower.getLocal() + ": " + formatPowerLong( ns.currentPower, false ), 13, 16, 4210752 );
fontRendererObj.drawString( GuiText.MaxPower.getLocal() + ": " + formatPowerLong( ns.maxPower, false ), 13, 26, 4210752 );
fontRendererObj.drawString( GuiText.StoredPower.getLocal() + ": " + Platform.formatPowerLong( ns.currentPower, false ), 13, 16, 4210752 );
fontRendererObj.drawString( GuiText.MaxPower.getLocal() + ": " + Platform.formatPowerLong( ns.maxPower, false ), 13, 26, 4210752 );
fontRendererObj.drawString( GuiText.PowerInputRate.getLocal() + ": " + formatPowerLong( ns.avgAddition, true ), 13, 143 - 10, 4210752 );
fontRendererObj.drawString( GuiText.PowerUsageRate.getLocal() + ": " + formatPowerLong( ns.powerUsage, true ), 13, 143 - 20, 4210752 );
fontRendererObj.drawString( GuiText.PowerInputRate.getLocal() + ": " + Platform.formatPowerLong( ns.avgAddition, true ), 13, 143 - 10, 4210752 );
fontRendererObj.drawString( GuiText.PowerUsageRate.getLocal() + ": " + Platform.formatPowerLong( ns.powerUsage, true ), 13, 143 - 20, 4210752 );
int sectionLength = 30;
@ -183,7 +183,7 @@ public class GuiNetworkStatus extends AEBaseGui implements ISortSource
ToolTip = ToolTip + ("\n" + GuiText.Installed.getLocal() + ": " + (refStack.getStackSize()));
if ( refStack.getCountRequestable() > 0 )
ToolTip = ToolTip + ("\n" + GuiText.EnergyDrain.getLocal() + ": " + formatPowerLong( refStack.getCountRequestable(), true ));
ToolTip = ToolTip + ("\n" + GuiText.EnergyDrain.getLocal() + ": " + Platform.formatPowerLong( refStack.getCountRequestable(), true ));
toolPosX = x * sectionLength + xo + sectionLength - 8;
toolPosY = y * 18 + yo;
@ -266,7 +266,7 @@ public class GuiNetworkStatus extends AEBaseGui implements ISortSource
currenttip.remove( 1 );
currenttip.add( GuiText.Installed.getLocal() + ": " + (myStack.getStackSize()) );
currenttip.add( GuiText.EnergyDrain.getLocal() + ": " + formatPowerLong( myStack.getCountRequestable(), true ) );
currenttip.add( GuiText.EnergyDrain.getLocal() + ": " + Platform.formatPowerLong( myStack.getCountRequestable(), true ) );
drawTooltip( x, y, 0, join( currenttip, "\n" ) );
}

View file

@ -12,6 +12,7 @@ import appeng.container.implementations.ContainerSpatialIOPort;
import appeng.core.AEConfig;
import appeng.core.localization.GuiText;
import appeng.tile.spatial.TileSpatialIOPort;
import appeng.util.Platform;
public class GuiSpatialIOPort extends AEBaseGui
{
@ -58,9 +59,9 @@ public class GuiSpatialIOPort extends AEBaseGui
@Override
public void drawFG(int offsetX, int offsetY, int mouseX, int mouseY)
{
fontRendererObj.drawString( GuiText.StoredPower.getLocal() + ": " + formatPowerLong( csiop.currentPower, false ), 13, 21, 4210752 );
fontRendererObj.drawString( GuiText.MaxPower.getLocal() + ": " + formatPowerLong( csiop.maxPower, false ), 13, 31, 4210752 );
fontRendererObj.drawString( GuiText.RequiredPower.getLocal() + ": " + formatPowerLong( csiop.reqPower, false ), 13, 78, 4210752 );
fontRendererObj.drawString( GuiText.StoredPower.getLocal() + ": " + Platform.formatPowerLong( csiop.currentPower, false ), 13, 21, 4210752 );
fontRendererObj.drawString( GuiText.MaxPower.getLocal() + ": " + Platform.formatPowerLong( csiop.maxPower, false ), 13, 31, 4210752 );
fontRendererObj.drawString( GuiText.RequiredPower.getLocal() + ": " + Platform.formatPowerLong( csiop.reqPower, false ), 13, 78, 4210752 );
fontRendererObj.drawString( GuiText.Efficiency.getLocal() + ": " + (((float) csiop.eff) / 100) + "%", 13, 88, 4210752 );
fontRendererObj.drawString( getGuiDisplayName( GuiText.SpatialIOPort.getLocal() ), 8, 6, 4210752 );

View file

@ -809,9 +809,14 @@ public abstract class AEBaseContainer extends Container
long maxSize = ais.getItemStack().getMaxStackSize();
ais.setStackSize( maxSize );
ais = cellInv.extractItems( ais, Actionable.SIMULATE, mySrc );
if ( ais != null )
{
long stackSize = Math.min( maxSize, ais.getStackSize() );
ais.setStackSize( (stackSize + 1) >> 1 );
ais = Platform.poweredExtraction( powerSrc, cellInv, ais, mySrc );
}
if ( ais != null )
player.inventory.setItemStack( ais.getItemStack() );
else

View file

@ -5,6 +5,7 @@ import java.util.List;
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.util.ForgeDirection;
import appeng.api.networking.security.BaseActionSource;
import appeng.api.storage.IExternalStorageHandler;
import appeng.api.storage.IExternalStorageRegistry;
import appeng.api.storage.StorageChannel;
@ -21,15 +22,15 @@ public class ExternalStorageRegistry implements IExternalStorageRegistry
}
@Override
public IExternalStorageHandler getHandler(TileEntity te, ForgeDirection d, StorageChannel chan)
public IExternalStorageHandler getHandler(TileEntity te, ForgeDirection d, StorageChannel chan, BaseActionSource mySrc)
{
for (IExternalStorageHandler x : Handlers)
{
if ( x.canHandle( te, d, chan ) )
if ( x.canHandle( te, d, chan, mySrc ) )
return x;
}
if ( lastHandler.canHandle( te, d, chan ) )
if ( lastHandler.canHandle( te, d, chan, mySrc ) )
return lastHandler;
return null;

View file

@ -14,7 +14,7 @@ public class ExternalIInv implements IExternalStorageHandler
{
@Override
public boolean canHandle(TileEntity te, ForgeDirection d, StorageChannel channel)
public boolean canHandle(TileEntity te, ForgeDirection d, StorageChannel channel, BaseActionSource mySrc)
{
return channel == StorageChannel.ITEMS && te instanceof IInventory;
}

View file

@ -7,7 +7,7 @@ public enum PlayerMessages
{
ChestCannotReadStorageCell, InvalidMachine, LoadedSettings, SavedSettings, MachineNotPowered,
isNowLocked, isNowUnlocked, AmmoDepleted, CommunicationError, OutOfRange, DeviceNotPowered;
isNowLocked, isNowUnlocked, AmmoDepleted, CommunicationError, OutOfRange, DeviceNotPowered, SettingCleared;
String getName()
{

View file

@ -7,6 +7,9 @@ import java.io.IOException;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import appeng.api.AEApi;
import appeng.api.implementations.items.IMemoryCard;
import appeng.api.implementations.items.MemoryCardMessages;
import appeng.core.sync.AppEngPacket;
import appeng.core.sync.network.INetworkInfo;
import appeng.items.tools.ToolNetworkTool;
@ -37,6 +40,12 @@ public class PacketClick extends AppEngPacket
ToolNetworkTool tnt = (ToolNetworkTool) is.getItem();
tnt.serverSideToolLogic( is, player, player.worldObj, x, y, z, side, hitX, hitY, hitZ );
}
else if ( is != null && AEApi.instance().items().itemMemoryCard.sameAs( is ) )
{
IMemoryCard mem = (IMemoryCard) is.getItem();
mem.notifyUser( player, MemoryCardMessages.SETTINGS_CLEARED );
is.setTagCompound( null );
}
}
// api

View file

@ -12,7 +12,7 @@ public class BCPipeHandler implements IExternalStorageHandler
{
@Override
public boolean canHandle(TileEntity te, ForgeDirection d, StorageChannel chan)
public boolean canHandle(TileEntity te, ForgeDirection d, StorageChannel chan, BaseActionSource mySrc)
{
return chan == StorageChannel.ITEMS && BC.instance.isPipe( te, d );
}

View file

@ -8,6 +8,7 @@ import mcp.mobius.waila.api.IWailaDataProvider;
import mcp.mobius.waila.api.IWailaRegistrar;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.util.Vec3;
@ -25,6 +26,8 @@ import appeng.core.AppEng;
import appeng.core.localization.WailaText;
import appeng.integration.BaseModule;
import appeng.tile.misc.TileCharger;
import appeng.tile.networking.TileEnergyCell;
import appeng.util.Platform;
import cpw.mods.fml.common.event.FMLInterModComms;
public class Waila extends BaseModule implements IWailaDataProvider
@ -90,6 +93,18 @@ public class Waila extends BaseModule implements IWailaDataProvider
}
}
if ( ThingOfInterest instanceof TileEnergyCell )
{
NBTTagCompound c = accessor.getNBTData();
if ( c != null && c.hasKey( "internalCurrentPower" ) )
{
TileEnergyCell tec = (TileEnergyCell) ThingOfInterest;
long power = (long) (100 * c.getDouble( "internalCurrentPower" ));
currenttip.add( WailaText.Contains + ": " + Platform.formatPowerLong( power, false ) + " / "
+ Platform.formatPowerLong( (long) (100 * tec.getAEMaxPower()), false ) );
}
}
if ( ThingOfInterest instanceof IPartStorageMonitor )
{
IPartStorageMonitor psm = (IPartStorageMonitor) ThingOfInterest;

View file

@ -14,7 +14,7 @@ public class FactorizationHandler implements IExternalStorageHandler
{
@Override
public boolean canHandle(TileEntity te, ForgeDirection d, StorageChannel chan)
public boolean canHandle(TileEntity te, ForgeDirection d, StorageChannel chan, BaseActionSource mySrc)
{
return chan == StorageChannel.ITEMS && FZ.instance.isBarrel( te );
}

View file

@ -74,6 +74,7 @@ public class MFRDSU implements IMEInventory<IAEItemStack>
{
if ( request.getStackSize() >= is.stackSize )
{
is = is.copy();
if ( mode == Actionable.MODULATE )
dsu.setStoredItemCount( 0 );
return AEItemStack.create( is );

View file

@ -14,7 +14,7 @@ public class MFRDSUHandler implements IExternalStorageHandler
{
@Override
public boolean canHandle(TileEntity te, ForgeDirection d, StorageChannel chan)
public boolean canHandle(TileEntity te, ForgeDirection d, StorageChannel chan, BaseActionSource mySrc)
{
return chan == StorageChannel.ITEMS && DSU.instance.isDSU( te );
}

View file

@ -25,15 +25,35 @@ public class ToolMemoryCard extends AEBaseItem implements IMemoryCard
setMaxStackSize( 1 );
}
/**
* Find the localized string...
*
* @param name
* @return
*/
private String getLocalizedName(String... name)
{
for (String n : name)
{
String l = StatCollector.translateToLocal( n );
if ( !l.equals( n ) )
return l;
}
for (String n : name)
return n;
return "";
}
@Override
public void addInformation(ItemStack i, EntityPlayer p, List l, boolean b)
{
l.add( StatCollector.translateToLocal( getSettingsName( i ) ) );
l.add( getLocalizedName( getSettingsName( i ) + ".name", getSettingsName( i ) ) );
NBTTagCompound data = getData( i );
if ( data.hasKey( "tooltip" ) )
{
l.add( StatCollector.translateToLocal( data.getString( "tooltip" ) ) );
}
l.add( StatCollector.translateToLocal( getLocalizedName( data.getString( "tooltip" ) + ".name", data.getString( "tooltip" ) ) ) );
}
@Override
@ -68,6 +88,20 @@ public class ToolMemoryCard extends AEBaseItem implements IMemoryCard
return (NBTTagCompound) o.copy();
}
@Override
public boolean onItemUse(ItemStack is, EntityPlayer player, World w, int x, int y, int z, int side, float hx, float hy, float hz)
{
if ( player.isSneaking() && !w.isRemote )
{
IMemoryCard mem = (IMemoryCard) is.getItem();
mem.notifyUser( player, MemoryCardMessages.SETTINGS_CLEARED );
is.setTagCompound( null );
return true;
}
else
return super.onItemUse( is, player, w, x, y, z, side, hx, hy, hz );
}
@Override
public void notifyUser(EntityPlayer player, MemoryCardMessages msg)
{
@ -76,6 +110,9 @@ public class ToolMemoryCard extends AEBaseItem implements IMemoryCard
switch (msg)
{
case SETTINGS_CLEARED:
player.addChatMessage( PlayerMessages.SettingCleared.get() );
break;
case INVALID_MACHINE:
player.addChatMessage( PlayerMessages.InvalidMachine.get() );
break;

View file

@ -16,10 +16,10 @@ public class AEExternalHandler implements IExternalStorageHandler
{
@Override
public boolean canHandle(TileEntity te, ForgeDirection d, StorageChannel channel)
public boolean canHandle(TileEntity te, ForgeDirection d, StorageChannel channel, BaseActionSource mySrc)
{
if ( channel == StorageChannel.ITEMS && te instanceof ITileStorageMonitorable )
return true;
return ((ITileStorageMonitorable) te).getMonitorable( d, mySrc ) != null;
return te instanceof TileCondenser;
}

View file

@ -170,6 +170,8 @@ public class CableBusContainer implements AEMultiTile, ICableBusContainer
is.stackSize = 1;
IPart bp = bi.createPartFromItemStack( is );
if ( bp != null )
{
if ( bp instanceof IPartCable )
{
boolean canPlace = true;
@ -191,6 +193,7 @@ public class CableBusContainer implements AEMultiTile, ICableBusContainer
return getPart( side ) == null;
}
}
}
return false;
}
@ -701,7 +704,7 @@ public class CableBusContainer implements AEMultiTile, ICableBusContainer
p.readFromNBT( extra );
}
else
throw new RuntimeException( "Invalid NBT For CableBus Container." );
throw new RuntimeException( "Invalid NBT For CableBus Container: " + iss.getItem().getClass().getName() + " is not a valid part." );
}
}
else

View file

@ -28,6 +28,7 @@ import appeng.api.parts.SelectedPart;
import appeng.core.AELog;
import appeng.core.AppEng;
import appeng.core.sync.network.NetworkHandler;
import appeng.core.sync.packets.PacketClick;
import appeng.core.sync.packets.PacketPartPlacement;
import appeng.facade.IFacadeItem;
import appeng.integration.abstraction.IBC;
@ -61,6 +62,21 @@ public class PartPlacement
if ( te instanceof IPartHost )
event.setCanceled( true );
}
else if ( event.entityPlayer != null )
{
ItemStack held = event.entityPlayer.getHeldItem();
if ( event.entityPlayer.isSneaking() && held != null && AEApi.instance().items().itemMemoryCard.sameAs( held ) )
{
try
{
NetworkHandler.instance.sendToServer( new PacketClick( event.x, event.y, event.z, event.face, 0, 0, 0 ) );
}
catch (IOException e)
{
// :P
}
}
}
}
else if ( event.action == Action.RIGHT_CLICK_BLOCK && event.entityPlayer.worldObj.isRemote )
{

View file

@ -388,9 +388,29 @@ public class PartFormationPlane extends PartUpgradeable implements ICellContaine
worked = true;
if ( type == Actionable.MODULATE )
{
i.onItemUse( is, player, w, x, y, z, side.ordinal(), side.offsetX, side.offsetY, side.offsetZ );
if ( i instanceof IPlantable )
{
boolean Worked = false;
if ( Worked == false && side.offsetX == 0 && side.offsetZ == 0 )
Worked = i.onItemUse( is, player, w, x + side.offsetX, y + side.offsetY, z + side.offsetZ, side.getOpposite().ordinal(),
side.offsetX, side.offsetY, side.offsetZ );
if ( Worked == false && side.offsetY == 0 )
Worked = i.onItemUse( is, player, w, x, y - 1, z, ForgeDirection.UP.ordinal(), side.offsetX, side.offsetY, side.offsetZ );
if ( Worked == false )
Worked = i.onItemUse( is, player, w, x, y, z, side.getOpposite().ordinal(), side.offsetX, side.offsetY, side.offsetZ );
if ( Worked )
maxStorage = maxStorage - is.stackSize;
}
else
{
i.onItemUse( is, player, w, x, y, z, side.getOpposite().ordinal(), side.offsetX, side.offsetY, side.offsetZ );
maxStorage = maxStorage - is.stackSize;
}
}
else
maxStorage = 1;
}

View file

@ -241,7 +241,7 @@ public class PartStorageBus extends PartUpgradeable implements IGridTickable, IC
monitor = null;
if ( target != null )
{
IExternalStorageHandler esh = AEApi.instance().registries().externalStorage().getHandler( target, side.getOpposite(), StorageChannel.ITEMS );
IExternalStorageHandler esh = AEApi.instance().registries().externalStorage().getHandler( target, side.getOpposite(), StorageChannel.ITEMS, mySrc );
if ( esh != null )
{
IMEInventory inv = esh.getInventory( target, side.getOpposite(), StorageChannel.ITEMS, mySrc );

View file

@ -56,6 +56,7 @@ public class TileEnergyCell extends AENetworkTile implements IAEPowerStorage
@Override
public void writeToNBT(NBTTagCompound data)
{
if ( !worldObj.isRemote )
data.setDouble( "internalCurrentPower", internalCurrentPower );
}

View file

@ -78,6 +78,7 @@ public class TileChest extends AENetworkPowerTile implements IMEChest, IFluidHan
static final int sides[] = new int[] { 0 };
static final int front[] = new int[] { 1 };
static final int noslots[] = new int[] {};
AppEngInternalInventory inv = new AppEngInternalInventory( this, 2 );
BaseActionSource mySrc = new MachineSource( this );
@ -473,11 +474,20 @@ public class TileChest extends AENetworkPowerTile implements IMEChest, IFluidHan
@Override
public boolean canExtractItem(int i, ItemStack itemstack, int j)
{
return false;
return i == 1;
}
@Override
public boolean canInsertItem(int i, ItemStack itemstack, int j)
{
if ( i == 1 )
{
if ( AEApi.instance().registries().cell().getCellInventory( itemstack, StorageChannel.ITEMS ) != null )
return true;
if ( AEApi.instance().registries().cell().getCellInventory( itemstack, StorageChannel.FLUIDS ) != null )
return true;
}
else
{
try
{
@ -488,17 +498,30 @@ public class TileChest extends AENetworkPowerTile implements IMEChest, IFluidHan
catch (ChestNoHandler t)
{
}
}
return false;
}
@Override
public int[] getAccessibleSlotsBySide(ForgeDirection side)
{
if ( side == getForward() )
if ( ForgeDirection.SOUTH == side )
return front;
if ( gridProxy.isActive() )
{
try
{
if ( getHandler( StorageChannel.ITEMS ) != null )
return sides;
}
catch (ChestNoHandler e)
{
// nope!
}
}
return noslots;
}
@Override
public List<IMEInventoryHandler> getCellArray(StorageChannel channel)
@ -652,7 +675,7 @@ public class TileChest extends AENetworkPowerTile implements IMEChest, IFluidHan
{
IMEInventoryHandler h = getHandler( StorageChannel.FLUIDS );
if ( h.getChannel() == StorageChannel.FLUIDS )
return new FluidTankInfo[] { new FluidTankInfo( null ) }; // eh?
return new FluidTankInfo[] { new FluidTankInfo( null, 1 ) }; // eh?
}
catch (ChestNoHandler e)
{
@ -708,7 +731,7 @@ public class TileChest extends AENetworkPowerTile implements IMEChest, IFluidHan
@Override
public IStorageMonitorable getMonitorable(ForgeDirection side, BaseActionSource src)
{
if ( Platform.canAccess( gridProxy, src ) )
if ( Platform.canAccess( gridProxy, src ) && side != getForward() )
return this;
return null;
}

View file

@ -1,6 +1,7 @@
package appeng.util;
import java.lang.reflect.Field;
import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.Collection;
import java.util.EnumSet;
@ -52,6 +53,7 @@ import appeng.api.config.AccessRestriction;
import appeng.api.config.Actionable;
import appeng.api.config.FuzzyMode;
import appeng.api.config.PowerMultiplier;
import appeng.api.config.PowerUnits;
import appeng.api.config.SearchBoxMode;
import appeng.api.config.SecurityPermissions;
import appeng.api.config.SortOrder;
@ -78,6 +80,7 @@ import appeng.api.storage.data.IAEStack;
import appeng.api.storage.data.IAETagCompound;
import appeng.api.storage.data.IItemList;
import appeng.api.util.AEItemDefinition;
import appeng.core.AEConfig;
import appeng.core.AELog;
import appeng.core.AppEng;
import appeng.core.sync.GuiBridge;
@ -127,6 +130,46 @@ public class Platform
return rdnSrc.nextFloat();
}
/**
* This displays the value for encoded longs ( double *100 )
*
* @param n
* @param isRate
* @return
*/
public static String formatPowerLong(long n, boolean isRate)
{
double p = ((double) n) / 100;
PowerUnits displayUnits = AEConfig.instance.selectedPowerUnit();
p = PowerUnits.AE.convertTo( displayUnits, p );
int offset = 0;
String Lvl = "";
String preFixes[] = new String[] { "k", "M", "G", "T", "P", "T", "P", "E", "Z", "Y" };
String unitName = displayUnits.name();
if ( displayUnits == PowerUnits.WA )
unitName = "J";
if ( displayUnits == PowerUnits.KJ )
{
Lvl = preFixes[offset];
unitName = "J";
offset++;
}
while (p > 1000 && offset < preFixes.length)
{
p /= 1000;
Lvl = preFixes[offset];
offset++;
}
DecimalFormat df = new DecimalFormat( "#.##" );
return df.format( p ) + " " + Lvl + unitName + (isRate ? "/t" : "");
}
public static ForgeDirection crossProduct(ForgeDirection forward, ForgeDirection up)
{
int west_x = forward.offsetY * up.offsetZ - forward.offsetZ * up.offsetY;