This commit is contained in:
AlgorithmX2
2014-05-27 12:07:20 -05:00
24 changed files with 240 additions and 99 deletions
+1 -1
View File
@@ -694,7 +694,7 @@ public class AEBaseBlock extends BlockContainer implements IAEFeature
{ {
memc.setMemoryCardContents( is, name, data ); memc.setMemoryCardContents( is, name, data );
memc.notifyUser( player, MemoryCardMessages.SETTINGS_SAVED ); memc.notifyUser( player, MemoryCardMessages.SETTINGS_SAVED );
return false; return true;
} }
} }
} }
+7 -5
View File
@@ -54,7 +54,7 @@ public class BlockCableBus extends AEBaseBlock
if ( noTesrTile.isInstance( te ) ) if ( noTesrTile.isInstance( te ) )
return (T) te; return (T) te;
if ( tesrTile.isInstance( te ) ) if ( tesrTile != null && tesrTile.isInstance( te ) )
return (T) te; return (T) te;
return null; return null;
@@ -277,13 +277,15 @@ public class BlockCableBus extends AEBaseBlock
private ICableBusContainer cb(IBlockAccess w, int x, int y, int z) private ICableBusContainer cb(IBlockAccess w, int x, int y, int z)
{ {
TileEntity te = w.getTileEntity( x, y, z ); TileEntity te = w.getTileEntity( x, y, z );
ICableBusContainer out = null;
if ( te instanceof TileCableBus ) if ( te instanceof TileCableBus )
return ((TileCableBus) te).cb; out = ((TileCableBus) te).cb;
if ( AppEng.instance.isIntegrationEnabled( "FMP" ) ) else if ( AppEng.instance.isIntegrationEnabled( "FMP" ) )
return ((IFMP) AppEng.instance.getIntegration( "FMP" )).getCableContainer( te ); out = ((IFMP) AppEng.instance.getIntegration( "FMP" )).getCableContainer( te );
return nullCB; return out == null ? nullCB : out;
} }
/** /**
-36
View File
@@ -1,7 +1,6 @@
package appeng.client.gui; package appeng.client.gui;
import java.io.IOException; import java.io.IOException;
import java.text.DecimalFormat;
import java.util.Collection; import java.util.Collection;
import java.util.Iterator; import java.util.Iterator;
import java.util.LinkedList; import java.util.LinkedList;
@@ -24,7 +23,6 @@ import org.lwjgl.input.Mouse;
import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL11;
import org.lwjgl.opengl.GL12; import org.lwjgl.opengl.GL12;
import appeng.api.config.PowerUnits;
import appeng.api.storage.data.IAEItemStack; import appeng.api.storage.data.IAEItemStack;
import appeng.client.gui.widgets.GuiScrollbar; import appeng.client.gui.widgets.GuiScrollbar;
import appeng.client.gui.widgets.ITooltip; import appeng.client.gui.widgets.ITooltip;
@@ -42,7 +40,6 @@ import appeng.container.slot.SlotFake;
import appeng.container.slot.SlotInaccessable; import appeng.container.slot.SlotInaccessable;
import appeng.container.slot.SlotOutput; import appeng.container.slot.SlotOutput;
import appeng.container.slot.SlotRestrictedInput; import appeng.container.slot.SlotRestrictedInput;
import appeng.core.AEConfig;
import appeng.core.AELog; import appeng.core.AELog;
import appeng.core.AppEng; import appeng.core.AppEng;
import appeng.core.sync.network.NetworkHandler; import appeng.core.sync.network.NetworkHandler;
@@ -59,39 +56,6 @@ public abstract class AEBaseGui extends GuiContainer
protected List<InternalSlotME> meSlots = new LinkedList<InternalSlotME>(); protected List<InternalSlotME> meSlots = new LinkedList<InternalSlotME>();
protected GuiScrollbar myScrollBar = null; 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) { public AEBaseGui(Container container) {
super( container ); super( container );
} }
@@ -138,11 +138,11 @@ public class GuiNetworkStatus extends AEBaseGui implements ISortSource
fontRendererObj.drawString( GuiText.NetworkDetails.getLocal(), 8, 6, 4210752 ); fontRendererObj.drawString( GuiText.NetworkDetails.getLocal(), 8, 6, 4210752 );
fontRendererObj.drawString( GuiText.StoredPower.getLocal() + ": " + formatPowerLong( ns.currentPower, false ), 13, 16, 4210752 ); fontRendererObj.drawString( GuiText.StoredPower.getLocal() + ": " + Platform.formatPowerLong( ns.currentPower, false ), 13, 16, 4210752 );
fontRendererObj.drawString( GuiText.MaxPower.getLocal() + ": " + formatPowerLong( ns.maxPower, false ), 13, 26, 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.PowerInputRate.getLocal() + ": " + Platform.formatPowerLong( ns.avgAddition, true ), 13, 143 - 10, 4210752 );
fontRendererObj.drawString( GuiText.PowerUsageRate.getLocal() + ": " + formatPowerLong( ns.powerUsage, true ), 13, 143 - 20, 4210752 ); fontRendererObj.drawString( GuiText.PowerUsageRate.getLocal() + ": " + Platform.formatPowerLong( ns.powerUsage, true ), 13, 143 - 20, 4210752 );
int sectionLength = 30; int sectionLength = 30;
@@ -183,7 +183,7 @@ public class GuiNetworkStatus extends AEBaseGui implements ISortSource
ToolTip = ToolTip + ("\n" + GuiText.Installed.getLocal() + ": " + (refStack.getStackSize())); ToolTip = ToolTip + ("\n" + GuiText.Installed.getLocal() + ": " + (refStack.getStackSize()));
if ( refStack.getCountRequestable() > 0 ) 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; toolPosX = x * sectionLength + xo + sectionLength - 8;
toolPosY = y * 18 + yo; toolPosY = y * 18 + yo;
@@ -266,7 +266,7 @@ public class GuiNetworkStatus extends AEBaseGui implements ISortSource
currenttip.remove( 1 ); currenttip.remove( 1 );
currenttip.add( GuiText.Installed.getLocal() + ": " + (myStack.getStackSize()) ); 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" ) ); drawTooltip( x, y, 0, join( currenttip, "\n" ) );
} }
@@ -12,6 +12,7 @@ import appeng.container.implementations.ContainerSpatialIOPort;
import appeng.core.AEConfig; import appeng.core.AEConfig;
import appeng.core.localization.GuiText; import appeng.core.localization.GuiText;
import appeng.tile.spatial.TileSpatialIOPort; import appeng.tile.spatial.TileSpatialIOPort;
import appeng.util.Platform;
public class GuiSpatialIOPort extends AEBaseGui public class GuiSpatialIOPort extends AEBaseGui
{ {
@@ -58,9 +59,9 @@ public class GuiSpatialIOPort extends AEBaseGui
@Override @Override
public void drawFG(int offsetX, int offsetY, int mouseX, int mouseY) 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.StoredPower.getLocal() + ": " + Platform.formatPowerLong( csiop.currentPower, false ), 13, 21, 4210752 );
fontRendererObj.drawString( GuiText.MaxPower.getLocal() + ": " + formatPowerLong( csiop.maxPower, false ), 13, 31, 4210752 ); fontRendererObj.drawString( GuiText.MaxPower.getLocal() + ": " + Platform.formatPowerLong( csiop.maxPower, false ), 13, 31, 4210752 );
fontRendererObj.drawString( GuiText.RequiredPower.getLocal() + ": " + formatPowerLong( csiop.reqPower, false ), 13, 78, 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( GuiText.Efficiency.getLocal() + ": " + (((float) csiop.eff) / 100) + "%", 13, 88, 4210752 );
fontRendererObj.drawString( getGuiDisplayName( GuiText.SpatialIOPort.getLocal() ), 8, 6, 4210752 ); fontRendererObj.drawString( getGuiDisplayName( GuiText.SpatialIOPort.getLocal() ), 8, 6, 4210752 );
+8 -3
View File
@@ -809,9 +809,14 @@ public abstract class AEBaseContainer extends Container
long maxSize = ais.getItemStack().getMaxStackSize(); long maxSize = ais.getItemStack().getMaxStackSize();
ais.setStackSize( maxSize ); ais.setStackSize( maxSize );
ais = cellInv.extractItems( ais, Actionable.SIMULATE, mySrc ); ais = cellInv.extractItems( ais, Actionable.SIMULATE, mySrc );
long stackSize = Math.min( maxSize, ais.getStackSize() );
ais.setStackSize( (stackSize + 1) >> 1 ); if ( ais != null )
ais = Platform.poweredExtraction( powerSrc, cellInv, ais, mySrc ); {
long stackSize = Math.min( maxSize, ais.getStackSize() );
ais.setStackSize( (stackSize + 1) >> 1 );
ais = Platform.poweredExtraction( powerSrc, cellInv, ais, mySrc );
}
if ( ais != null ) if ( ais != null )
player.inventory.setItemStack( ais.getItemStack() ); player.inventory.setItemStack( ais.getItemStack() );
else else
@@ -5,6 +5,7 @@ import java.util.List;
import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.common.util.ForgeDirection;
import appeng.api.networking.security.BaseActionSource;
import appeng.api.storage.IExternalStorageHandler; import appeng.api.storage.IExternalStorageHandler;
import appeng.api.storage.IExternalStorageRegistry; import appeng.api.storage.IExternalStorageRegistry;
import appeng.api.storage.StorageChannel; import appeng.api.storage.StorageChannel;
@@ -21,15 +22,15 @@ public class ExternalStorageRegistry implements IExternalStorageRegistry
} }
@Override @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) for (IExternalStorageHandler x : Handlers)
{ {
if ( x.canHandle( te, d, chan ) ) if ( x.canHandle( te, d, chan, mySrc ) )
return x; return x;
} }
if ( lastHandler.canHandle( te, d, chan ) ) if ( lastHandler.canHandle( te, d, chan, mySrc ) )
return lastHandler; return lastHandler;
return null; return null;
@@ -14,7 +14,7 @@ public class ExternalIInv implements IExternalStorageHandler
{ {
@Override @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; return channel == StorageChannel.ITEMS && te instanceof IInventory;
} }
+1 -1
View File
@@ -7,7 +7,7 @@ public enum PlayerMessages
{ {
ChestCannotReadStorageCell, InvalidMachine, LoadedSettings, SavedSettings, MachineNotPowered, ChestCannotReadStorageCell, InvalidMachine, LoadedSettings, SavedSettings, MachineNotPowered,
isNowLocked, isNowUnlocked, AmmoDepleted, CommunicationError, OutOfRange, DeviceNotPowered; isNowLocked, isNowUnlocked, AmmoDepleted, CommunicationError, OutOfRange, DeviceNotPowered, SettingCleared;
String getName() String getName()
{ {
+9
View File
@@ -7,6 +7,9 @@ import java.io.IOException;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack; 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.AppEngPacket;
import appeng.core.sync.network.INetworkInfo; import appeng.core.sync.network.INetworkInfo;
import appeng.items.tools.ToolNetworkTool; import appeng.items.tools.ToolNetworkTool;
@@ -37,6 +40,12 @@ public class PacketClick extends AppEngPacket
ToolNetworkTool tnt = (ToolNetworkTool) is.getItem(); ToolNetworkTool tnt = (ToolNetworkTool) is.getItem();
tnt.serverSideToolLogic( is, player, player.worldObj, x, y, z, side, hitX, hitY, hitZ ); 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 // api
@@ -12,7 +12,7 @@ public class BCPipeHandler implements IExternalStorageHandler
{ {
@Override @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 ); return chan == StorageChannel.ITEMS && BC.instance.isPipe( te, d );
} }
+15
View File
@@ -8,6 +8,7 @@ import mcp.mobius.waila.api.IWailaDataProvider;
import mcp.mobius.waila.api.IWailaRegistrar; import mcp.mobius.waila.api.IWailaRegistrar;
import net.minecraft.inventory.IInventory; import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.MovingObjectPosition; import net.minecraft.util.MovingObjectPosition;
import net.minecraft.util.Vec3; import net.minecraft.util.Vec3;
@@ -25,6 +26,8 @@ import appeng.core.AppEng;
import appeng.core.localization.WailaText; import appeng.core.localization.WailaText;
import appeng.integration.BaseModule; import appeng.integration.BaseModule;
import appeng.tile.misc.TileCharger; import appeng.tile.misc.TileCharger;
import appeng.tile.networking.TileEnergyCell;
import appeng.util.Platform;
import cpw.mods.fml.common.event.FMLInterModComms; import cpw.mods.fml.common.event.FMLInterModComms;
public class Waila extends BaseModule implements IWailaDataProvider 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 ) if ( ThingOfInterest instanceof IPartStorageMonitor )
{ {
IPartStorageMonitor psm = (IPartStorageMonitor) ThingOfInterest; IPartStorageMonitor psm = (IPartStorageMonitor) ThingOfInterest;
@@ -14,7 +14,7 @@ public class FactorizationHandler implements IExternalStorageHandler
{ {
@Override @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 ); return chan == StorageChannel.ITEMS && FZ.instance.isBarrel( te );
} }
+1
View File
@@ -74,6 +74,7 @@ public class MFRDSU implements IMEInventory<IAEItemStack>
{ {
if ( request.getStackSize() >= is.stackSize ) if ( request.getStackSize() >= is.stackSize )
{ {
is = is.copy();
if ( mode == Actionable.MODULATE ) if ( mode == Actionable.MODULATE )
dsu.setStoredItemCount( 0 ); dsu.setStoredItemCount( 0 );
return AEItemStack.create( is ); return AEItemStack.create( is );
@@ -14,7 +14,7 @@ public class MFRDSUHandler implements IExternalStorageHandler
{ {
@Override @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 ); return chan == StorageChannel.ITEMS && DSU.instance.isDSU( te );
} }
+41 -4
View File
@@ -25,15 +25,35 @@ public class ToolMemoryCard extends AEBaseItem implements IMemoryCard
setMaxStackSize( 1 ); 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 @Override
public void addInformation(ItemStack i, EntityPlayer p, List l, boolean b) 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 ); NBTTagCompound data = getData( i );
if ( data.hasKey( "tooltip" ) ) if ( data.hasKey( "tooltip" ) )
{ l.add( StatCollector.translateToLocal( getLocalizedName( data.getString( "tooltip" ) + ".name", data.getString( "tooltip" ) ) ) );
l.add( StatCollector.translateToLocal( data.getString( "tooltip" ) ) );
}
} }
@Override @Override
@@ -68,6 +88,20 @@ public class ToolMemoryCard extends AEBaseItem implements IMemoryCard
return (NBTTagCompound) o.copy(); 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 @Override
public void notifyUser(EntityPlayer player, MemoryCardMessages msg) public void notifyUser(EntityPlayer player, MemoryCardMessages msg)
{ {
@@ -76,6 +110,9 @@ public class ToolMemoryCard extends AEBaseItem implements IMemoryCard
switch (msg) switch (msg)
{ {
case SETTINGS_CLEARED:
player.addChatMessage( PlayerMessages.SettingCleared.get() );
break;
case INVALID_MACHINE: case INVALID_MACHINE:
player.addChatMessage( PlayerMessages.InvalidMachine.get() ); player.addChatMessage( PlayerMessages.InvalidMachine.get() );
break; break;
+2 -2
View File
@@ -16,10 +16,10 @@ public class AEExternalHandler implements IExternalStorageHandler
{ {
@Override @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 ) if ( channel == StorageChannel.ITEMS && te instanceof ITileStorageMonitorable )
return true; return ((ITileStorageMonitorable) te).getMonitorable( d, mySrc ) != null;
return te instanceof TileCondenser; return te instanceof TileCondenser;
} }
+19 -16
View File
@@ -170,25 +170,28 @@ public class CableBusContainer implements AEMultiTile, ICableBusContainer
is.stackSize = 1; is.stackSize = 1;
IPart bp = bi.createPartFromItemStack( is ); IPart bp = bi.createPartFromItemStack( is );
if ( bp instanceof IPartCable ) if ( bp != null )
{ {
boolean canPlace = true; if ( bp instanceof IPartCable )
for (ForgeDirection d : ForgeDirection.VALID_DIRECTIONS) {
if ( getPart( d ) != null && !getPart( d ).canBePlacedOn( ((IPartCable) bp).supportsBuses() ) ) boolean canPlace = true;
canPlace = false; for (ForgeDirection d : ForgeDirection.VALID_DIRECTIONS)
if ( getPart( d ) != null && !getPart( d ).canBePlacedOn( ((IPartCable) bp).supportsBuses() ) )
canPlace = false;
if ( !canPlace ) if ( !canPlace )
return false; return false;
return getPart( ForgeDirection.UNKNOWN ) == null; return getPart( ForgeDirection.UNKNOWN ) == null;
} }
else if ( !(bp instanceof IPartCable) && side != ForgeDirection.UNKNOWN ) else if ( !(bp instanceof IPartCable) && side != ForgeDirection.UNKNOWN )
{ {
IPart cable = getPart( ForgeDirection.UNKNOWN ); IPart cable = getPart( ForgeDirection.UNKNOWN );
if ( cable != null && !bp.canBePlacedOn( ((IPartCable) cable).supportsBuses() ) ) if ( cable != null && !bp.canBePlacedOn( ((IPartCable) cable).supportsBuses() ) )
return false; return false;
return getPart( side ) == null; return getPart( side ) == null;
}
} }
} }
return false; return false;
@@ -701,7 +704,7 @@ public class CableBusContainer implements AEMultiTile, ICableBusContainer
p.readFromNBT( extra ); p.readFromNBT( extra );
} }
else 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 else
+16
View File
@@ -28,6 +28,7 @@ import appeng.api.parts.SelectedPart;
import appeng.core.AELog; import appeng.core.AELog;
import appeng.core.AppEng; import appeng.core.AppEng;
import appeng.core.sync.network.NetworkHandler; import appeng.core.sync.network.NetworkHandler;
import appeng.core.sync.packets.PacketClick;
import appeng.core.sync.packets.PacketPartPlacement; import appeng.core.sync.packets.PacketPartPlacement;
import appeng.facade.IFacadeItem; import appeng.facade.IFacadeItem;
import appeng.integration.abstraction.IBC; import appeng.integration.abstraction.IBC;
@@ -61,6 +62,21 @@ public class PartPlacement
if ( te instanceof IPartHost ) if ( te instanceof IPartHost )
event.setCanceled( true ); 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 ) else if ( event.action == Action.RIGHT_CLICK_BLOCK && event.entityPlayer.worldObj.isRemote )
{ {
+22 -2
View File
@@ -388,8 +388,28 @@ public class PartFormationPlane extends PartUpgradeable implements ICellContaine
worked = true; worked = true;
if ( type == Actionable.MODULATE ) if ( type == Actionable.MODULATE )
{ {
i.onItemUse( is, player, w, x, y, z, side.ordinal(), side.offsetX, side.offsetY, side.offsetZ ); if ( i instanceof IPlantable )
maxStorage = maxStorage - is.stackSize; {
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 else
maxStorage = 1; maxStorage = 1;
+1 -1
View File
@@ -241,7 +241,7 @@ public class PartStorageBus extends PartUpgradeable implements IGridTickable, IC
monitor = null; monitor = null;
if ( target != 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 ) if ( esh != null )
{ {
IMEInventory inv = esh.getInventory( target, side.getOpposite(), StorageChannel.ITEMS, mySrc ); IMEInventory inv = esh.getInventory( target, side.getOpposite(), StorageChannel.ITEMS, mySrc );
+2 -1
View File
@@ -56,7 +56,8 @@ public class TileEnergyCell extends AENetworkTile implements IAEPowerStorage
@Override @Override
public void writeToNBT(NBTTagCompound data) public void writeToNBT(NBTTagCompound data)
{ {
data.setDouble( "internalCurrentPower", internalCurrentPower ); if ( !worldObj.isRemote )
data.setDouble( "internalCurrentPower", internalCurrentPower );
} }
@Override @Override
+34 -11
View File
@@ -78,6 +78,7 @@ public class TileChest extends AENetworkPowerTile implements IMEChest, IFluidHan
static final int sides[] = new int[] { 0 }; static final int sides[] = new int[] { 0 };
static final int front[] = new int[] { 1 }; static final int front[] = new int[] { 1 };
static final int noslots[] = new int[] {};
AppEngInternalInventory inv = new AppEngInternalInventory( this, 2 ); AppEngInternalInventory inv = new AppEngInternalInventory( this, 2 );
BaseActionSource mySrc = new MachineSource( this ); BaseActionSource mySrc = new MachineSource( this );
@@ -473,31 +474,53 @@ public class TileChest extends AENetworkPowerTile implements IMEChest, IFluidHan
@Override @Override
public boolean canExtractItem(int i, ItemStack itemstack, int j) public boolean canExtractItem(int i, ItemStack itemstack, int j)
{ {
return false; return i == 1;
} }
@Override @Override
public boolean canInsertItem(int i, ItemStack itemstack, int j) public boolean canInsertItem(int i, ItemStack itemstack, int j)
{ {
try if ( i == 1 )
{ {
IMEInventory<IAEItemStack> cell = getHandler( StorageChannel.ITEMS ); if ( AEApi.instance().registries().cell().getCellInventory( itemstack, StorageChannel.ITEMS ) != null )
IAEItemStack returns = cell.injectItems( AEApi.instance().storage().createItemStack( inv.getStackInSlot( 0 ) ), Actionable.SIMULATE, mySrc ); return true;
return returns == null || returns.getStackSize() != itemstack.stackSize; if ( AEApi.instance().registries().cell().getCellInventory( itemstack, StorageChannel.FLUIDS ) != null )
return true;
} }
catch (ChestNoHandler t) else
{ {
try
{
IMEInventory<IAEItemStack> cell = getHandler( StorageChannel.ITEMS );
IAEItemStack returns = cell.injectItems( AEApi.instance().storage().createItemStack( inv.getStackInSlot( 0 ) ), Actionable.SIMULATE, mySrc );
return returns == null || returns.getStackSize() != itemstack.stackSize;
}
catch (ChestNoHandler t)
{
}
} }
return false; return false;
} }
@Override @Override
public int[] getAccessibleSlotsBySide(ForgeDirection side) public int[] getAccessibleSlotsBySide(ForgeDirection side)
{ {
if ( side == getForward() ) if ( ForgeDirection.SOUTH == side )
return front; return front;
return sides;
if ( gridProxy.isActive() )
{
try
{
if ( getHandler( StorageChannel.ITEMS ) != null )
return sides;
}
catch (ChestNoHandler e)
{
// nope!
}
}
return noslots;
} }
@Override @Override
@@ -652,7 +675,7 @@ public class TileChest extends AENetworkPowerTile implements IMEChest, IFluidHan
{ {
IMEInventoryHandler h = getHandler( StorageChannel.FLUIDS ); IMEInventoryHandler h = getHandler( StorageChannel.FLUIDS );
if ( h.getChannel() == 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) catch (ChestNoHandler e)
{ {
@@ -708,7 +731,7 @@ public class TileChest extends AENetworkPowerTile implements IMEChest, IFluidHan
@Override @Override
public IStorageMonitorable getMonitorable(ForgeDirection side, BaseActionSource src) public IStorageMonitorable getMonitorable(ForgeDirection side, BaseActionSource src)
{ {
if ( Platform.canAccess( gridProxy, src ) ) if ( Platform.canAccess( gridProxy, src ) && side != getForward() )
return this; return this;
return null; return null;
} }
+43
View File
@@ -1,6 +1,7 @@
package appeng.util; package appeng.util;
import java.lang.reflect.Field; import java.lang.reflect.Field;
import java.text.DecimalFormat;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
import java.util.EnumSet; import java.util.EnumSet;
@@ -52,6 +53,7 @@ import appeng.api.config.AccessRestriction;
import appeng.api.config.Actionable; import appeng.api.config.Actionable;
import appeng.api.config.FuzzyMode; import appeng.api.config.FuzzyMode;
import appeng.api.config.PowerMultiplier; import appeng.api.config.PowerMultiplier;
import appeng.api.config.PowerUnits;
import appeng.api.config.SearchBoxMode; import appeng.api.config.SearchBoxMode;
import appeng.api.config.SecurityPermissions; import appeng.api.config.SecurityPermissions;
import appeng.api.config.SortOrder; 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.IAETagCompound;
import appeng.api.storage.data.IItemList; import appeng.api.storage.data.IItemList;
import appeng.api.util.AEItemDefinition; import appeng.api.util.AEItemDefinition;
import appeng.core.AEConfig;
import appeng.core.AELog; import appeng.core.AELog;
import appeng.core.AppEng; import appeng.core.AppEng;
import appeng.core.sync.GuiBridge; import appeng.core.sync.GuiBridge;
@@ -127,6 +130,46 @@ public class Platform
return rdnSrc.nextFloat(); 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) public static ForgeDirection crossProduct(ForgeDirection forward, ForgeDirection up)
{ {
int west_x = forward.offsetY * up.offsetZ - forward.offsetZ * up.offsetY; int west_x = forward.offsetY * up.offsetZ - forward.offsetZ * up.offsetY;