From 6e1a0aabb66455e134bb77ca5541d83bcd75c06a Mon Sep 17 00:00:00 2001 From: AlgorithmX2 Date: Sat, 24 May 2014 10:29:45 -0500 Subject: [PATCH 01/12] Server doesn't have noTesr Tiles. --- block/networking/BlockCableBus.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/block/networking/BlockCableBus.java b/block/networking/BlockCableBus.java index 608feca0..a135bba6 100644 --- a/block/networking/BlockCableBus.java +++ b/block/networking/BlockCableBus.java @@ -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; From 82a8e2d045e075fd4623260ff942f544bf4a22b5 Mon Sep 17 00:00:00 2001 From: AlgorithmX2 Date: Sat, 24 May 2014 11:02:24 -0500 Subject: [PATCH 02/12] Fixed http://openeye.openmods.info/crashes/df3cca6850f2c037b6adb8d8d641b22f Improved Exception for http://openeye.openmods.info/crashes/d2df850ad1915a015a80f9f7cef56ac3 Improved Exception for http://openeye.openmods.info/crashes/c8a3f70288f017726c5acd09ea91a2b0 --- parts/CableBusContainer.java | 35 +++++++++++++++++++---------------- 1 file changed, 19 insertions(+), 16 deletions(-) diff --git a/parts/CableBusContainer.java b/parts/CableBusContainer.java index 83241f36..d7b2e43a 100644 --- a/parts/CableBusContainer.java +++ b/parts/CableBusContainer.java @@ -170,25 +170,28 @@ public class CableBusContainer implements AEMultiTile, ICableBusContainer is.stackSize = 1; IPart bp = bi.createPartFromItemStack( is ); - if ( bp instanceof IPartCable ) + if ( bp != null ) { - boolean canPlace = true; - for (ForgeDirection d : ForgeDirection.VALID_DIRECTIONS) - if ( getPart( d ) != null && !getPart( d ).canBePlacedOn( ((IPartCable) bp).supportsBuses() ) ) - canPlace = false; + if ( bp instanceof IPartCable ) + { + boolean canPlace = true; + for (ForgeDirection d : ForgeDirection.VALID_DIRECTIONS) + if ( getPart( d ) != null && !getPart( d ).canBePlacedOn( ((IPartCable) bp).supportsBuses() ) ) + canPlace = false; - if ( !canPlace ) - return false; + if ( !canPlace ) + return false; - return getPart( ForgeDirection.UNKNOWN ) == null; - } - else if ( !(bp instanceof IPartCable) && side != ForgeDirection.UNKNOWN ) - { - IPart cable = getPart( ForgeDirection.UNKNOWN ); - if ( cable != null && !bp.canBePlacedOn( ((IPartCable) cable).supportsBuses() ) ) - return false; + return getPart( ForgeDirection.UNKNOWN ) == null; + } + else if ( !(bp instanceof IPartCable) && side != ForgeDirection.UNKNOWN ) + { + IPart cable = getPart( ForgeDirection.UNKNOWN ); + if ( cable != null && !bp.canBePlacedOn( ((IPartCable) cable).supportsBuses() ) ) + return false; - return getPart( side ) == null; + 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 From d5cfa12f76ededfb87a3d9276069480fd66ba2b1 Mon Sep 17 00:00:00 2001 From: AlgorithmX2 Date: Sat, 24 May 2014 18:22:50 -0500 Subject: [PATCH 03/12] Added Energy Cells Charge levels to Waila --- client/gui/AEBaseGui.java | 36 ---------------- .../gui/implementations/GuiNetworkStatus.java | 12 +++--- .../gui/implementations/GuiSpatialIOPort.java | 7 +-- integration/modules/Waila.java | 15 +++++++ util/Platform.java | 43 +++++++++++++++++++ 5 files changed, 68 insertions(+), 45 deletions(-) diff --git a/client/gui/AEBaseGui.java b/client/gui/AEBaseGui.java index 3b497527..f12fe739 100644 --- a/client/gui/AEBaseGui.java +++ b/client/gui/AEBaseGui.java @@ -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 meSlots = new LinkedList(); 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 ); } diff --git a/client/gui/implementations/GuiNetworkStatus.java b/client/gui/implementations/GuiNetworkStatus.java index c20a7202..c1319d04 100644 --- a/client/gui/implementations/GuiNetworkStatus.java +++ b/client/gui/implementations/GuiNetworkStatus.java @@ -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" ) ); } diff --git a/client/gui/implementations/GuiSpatialIOPort.java b/client/gui/implementations/GuiSpatialIOPort.java index f66deb75..7905624d 100644 --- a/client/gui/implementations/GuiSpatialIOPort.java +++ b/client/gui/implementations/GuiSpatialIOPort.java @@ -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 ); diff --git a/integration/modules/Waila.java b/integration/modules/Waila.java index 18fc485c..07d5da1e 100644 --- a/integration/modules/Waila.java +++ b/integration/modules/Waila.java @@ -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 ) + { + 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; diff --git a/util/Platform.java b/util/Platform.java index 5e29ab5b..06377493 100644 --- a/util/Platform.java +++ b/util/Platform.java @@ -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; From 1b207a17e9fba7dade75ea9f3905ef8462a18127 Mon Sep 17 00:00:00 2001 From: AlgorithmX2 Date: Sat, 24 May 2014 18:23:23 -0500 Subject: [PATCH 04/12] API Update. --- core/features/registries/ExternalStorageRegistry.java | 7 ++++--- core/features/registries/entries/ExternalIInv.java | 2 +- integration/modules/BCHelpers/BCPipeHandler.java | 2 +- integration/modules/helpers/FactorizationHandler.java | 2 +- integration/modules/helpers/MFRDSUHandler.java | 2 +- me/storage/AEExternalHandler.java | 4 ++-- parts/misc/PartStorageBus.java | 2 +- 7 files changed, 11 insertions(+), 10 deletions(-) diff --git a/core/features/registries/ExternalStorageRegistry.java b/core/features/registries/ExternalStorageRegistry.java index b1fcc0f2..c7efc258 100644 --- a/core/features/registries/ExternalStorageRegistry.java +++ b/core/features/registries/ExternalStorageRegistry.java @@ -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; diff --git a/core/features/registries/entries/ExternalIInv.java b/core/features/registries/entries/ExternalIInv.java index 166d9309..2efe6995 100644 --- a/core/features/registries/entries/ExternalIInv.java +++ b/core/features/registries/entries/ExternalIInv.java @@ -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; } diff --git a/integration/modules/BCHelpers/BCPipeHandler.java b/integration/modules/BCHelpers/BCPipeHandler.java index 4d4a76e2..13c0edd9 100644 --- a/integration/modules/BCHelpers/BCPipeHandler.java +++ b/integration/modules/BCHelpers/BCPipeHandler.java @@ -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 ); } diff --git a/integration/modules/helpers/FactorizationHandler.java b/integration/modules/helpers/FactorizationHandler.java index 903a6e0c..7eaea510 100644 --- a/integration/modules/helpers/FactorizationHandler.java +++ b/integration/modules/helpers/FactorizationHandler.java @@ -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 ); } diff --git a/integration/modules/helpers/MFRDSUHandler.java b/integration/modules/helpers/MFRDSUHandler.java index 11aa7bb0..a8c297b4 100644 --- a/integration/modules/helpers/MFRDSUHandler.java +++ b/integration/modules/helpers/MFRDSUHandler.java @@ -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 ); } diff --git a/me/storage/AEExternalHandler.java b/me/storage/AEExternalHandler.java index de03ba4f..4edd5fcd 100644 --- a/me/storage/AEExternalHandler.java +++ b/me/storage/AEExternalHandler.java @@ -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; } diff --git a/parts/misc/PartStorageBus.java b/parts/misc/PartStorageBus.java index e2ef5c16..8c0d2371 100644 --- a/parts/misc/PartStorageBus.java +++ b/parts/misc/PartStorageBus.java @@ -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 ); From aa6d05af2e9d8ef5fbe1247cd6236ebaa8b07abb Mon Sep 17 00:00:00 2001 From: AlgorithmX2 Date: Sat, 24 May 2014 18:23:40 -0500 Subject: [PATCH 05/12] Fixed a potential crash when picking up items. --- container/AEBaseContainer.java | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/container/AEBaseContainer.java b/container/AEBaseContainer.java index ec595a52..59c65e8d 100644 --- a/container/AEBaseContainer.java +++ b/container/AEBaseContainer.java @@ -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 ); - long stackSize = Math.min( maxSize, ais.getStackSize() ); - ais.setStackSize( (stackSize + 1) >> 1 ); - ais = Platform.poweredExtraction( powerSrc, cellInv, ais, 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 From a861f09b01a5bf50f786745929d0754ac546ea14 Mon Sep 17 00:00:00 2001 From: AlgorithmX2 Date: Sat, 24 May 2014 18:25:22 -0500 Subject: [PATCH 06/12] ME Chest insertion behavior fixed. ME Chest drive slot now properly accessible from front drive face. ME Chests can now function as tanks. ( fluid cells from extra cells ) ME Chests now return an empty slot list when they have no storage cells ( thus disconnecting from pipes. ) Fixed https://github.com/M3gaFr3ak/ExtraCells2/issues/18 --- tile/storage/TileChest.java | 43 ++++++++++++++++++++++++++++--------- 1 file changed, 33 insertions(+), 10 deletions(-) diff --git a/tile/storage/TileChest.java b/tile/storage/TileChest.java index bc22dc25..2acb5cc9 100644 --- a/tile/storage/TileChest.java +++ b/tile/storage/TileChest.java @@ -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 ); @@ -479,25 +480,47 @@ public class TileChest extends AENetworkPowerTile implements IMEChest, IFluidHan @Override public boolean canInsertItem(int i, ItemStack itemstack, int j) { - try + if ( i == 1 ) { - IMEInventory 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; + if ( AEApi.instance().registries().cell().getCellInventory( itemstack, StorageChannel.ITEMS ) != null ) + return true; + if ( AEApi.instance().registries().cell().getCellInventory( itemstack, StorageChannel.FLUIDS ) != null ) + return true; } - catch (ChestNoHandler t) + else { + try + { + IMEInventory 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; } @Override public int[] getAccessibleSlotsBySide(ForgeDirection side) { - if ( side == getForward() ) + if ( ForgeDirection.SOUTH == side ) return front; - return sides; + + if ( gridProxy.isActive() ) + { + try + { + if ( getHandler( StorageChannel.ITEMS ) != null ) + return sides; + } + catch (ChestNoHandler e) + { + // nope! + } + } + return noslots; } @Override @@ -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; } From baefedc4b885de45d2c9805be5c1d75ea9ac030b Mon Sep 17 00:00:00 2001 From: AlgorithmX2 Date: Sat, 24 May 2014 23:49:24 -0500 Subject: [PATCH 07/12] ME Chest can have its drive removed via automation via the front slot. --- tile/storage/TileChest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tile/storage/TileChest.java b/tile/storage/TileChest.java index 2acb5cc9..d24394a6 100644 --- a/tile/storage/TileChest.java +++ b/tile/storage/TileChest.java @@ -474,7 +474,7 @@ public class TileChest extends AENetworkPowerTile implements IMEChest, IFluidHan @Override public boolean canExtractItem(int i, ItemStack itemstack, int j) { - return false; + return i == 1; } @Override From 8f474b8baf09c7d02449c796c31bc53b0cae7fd1 Mon Sep 17 00:00:00 2001 From: AlgorithmX2 Date: Sat, 24 May 2014 23:55:13 -0500 Subject: [PATCH 08/12] Fixed http://openeye.openmods.info/crashes/e9ee0132c58b39e5d6b41983e239b77f Fixed http://openeye.openmods.info/crashes/90d72b392a1e968ef7dab98f5a65d1d8 --- block/networking/BlockCableBus.java | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/block/networking/BlockCableBus.java b/block/networking/BlockCableBus.java index a135bba6..886e2d18 100644 --- a/block/networking/BlockCableBus.java +++ b/block/networking/BlockCableBus.java @@ -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; } /** From 4cf6f4e5f971d868ad88f01161c90cce52f1cfdb Mon Sep 17 00:00:00 2001 From: AlgorithmX2 Date: Sun, 25 May 2014 11:06:59 -0500 Subject: [PATCH 09/12] Don't Show Energy Cell info if the NBT Came from the client. --- integration/modules/Waila.java | 2 +- tile/networking/TileEnergyCell.java | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/integration/modules/Waila.java b/integration/modules/Waila.java index 07d5da1e..fab80cc7 100644 --- a/integration/modules/Waila.java +++ b/integration/modules/Waila.java @@ -96,7 +96,7 @@ public class Waila extends BaseModule implements IWailaDataProvider if ( ThingOfInterest instanceof TileEnergyCell ) { NBTTagCompound c = accessor.getNBTData(); - if ( c != null ) + if ( c != null && c.hasKey( "internalCurrentPower" ) ) { TileEnergyCell tec = (TileEnergyCell) ThingOfInterest; long power = (long) (100 * c.getDouble( "internalCurrentPower" )); diff --git a/tile/networking/TileEnergyCell.java b/tile/networking/TileEnergyCell.java index 961bbd37..51ff7dc4 100644 --- a/tile/networking/TileEnergyCell.java +++ b/tile/networking/TileEnergyCell.java @@ -56,7 +56,8 @@ public class TileEnergyCell extends AENetworkTile implements IAEPowerStorage @Override public void writeToNBT(NBTTagCompound data) { - data.setDouble( "internalCurrentPower", internalCurrentPower ); + if ( !worldObj.isRemote ) + data.setDouble( "internalCurrentPower", internalCurrentPower ); } @Override From cbc2486161a028d0b7314c23995648586272312e Mon Sep 17 00:00:00 2001 From: AlgorithmX2 Date: Sun, 25 May 2014 17:43:42 -0500 Subject: [PATCH 10/12] Copy Item Stack before manipulating DSU. --- integration/modules/helpers/MFRDSU.java | 1 + 1 file changed, 1 insertion(+) diff --git a/integration/modules/helpers/MFRDSU.java b/integration/modules/helpers/MFRDSU.java index 6b999005..0acd63cf 100644 --- a/integration/modules/helpers/MFRDSU.java +++ b/integration/modules/helpers/MFRDSU.java @@ -74,6 +74,7 @@ public class MFRDSU implements IMEInventory { if ( request.getStackSize() >= is.stackSize ) { + is = is.copy(); if ( mode == Actionable.MODULATE ) dsu.setStoredItemCount( 0 ); return AEItemStack.create( is ); From 6b0fa0f142fe83c568b4333fd1c4731a3d7b2e3c Mon Sep 17 00:00:00 2001 From: AlgorithmX2 Date: Sun, 25 May 2014 18:32:16 -0500 Subject: [PATCH 11/12] Clear Memory Card When Shift Clicking on a non-machine / air. Fixed Tooltip to properly localize names. --- block/AEBaseBlock.java | 2 +- core/localization/PlayerMessages.java | 2 +- core/sync/packets/PacketClick.java | 9 ++++++ items/tools/ToolMemoryCard.java | 45 ++++++++++++++++++++++++--- parts/PartPlacement.java | 16 ++++++++++ 5 files changed, 68 insertions(+), 6 deletions(-) diff --git a/block/AEBaseBlock.java b/block/AEBaseBlock.java index 8088535b..fc6c1d93 100644 --- a/block/AEBaseBlock.java +++ b/block/AEBaseBlock.java @@ -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; } } } diff --git a/core/localization/PlayerMessages.java b/core/localization/PlayerMessages.java index 56bb615b..64424fba 100644 --- a/core/localization/PlayerMessages.java +++ b/core/localization/PlayerMessages.java @@ -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() { diff --git a/core/sync/packets/PacketClick.java b/core/sync/packets/PacketClick.java index e2d1c1a1..63b5b169 100644 --- a/core/sync/packets/PacketClick.java +++ b/core/sync/packets/PacketClick.java @@ -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 diff --git a/items/tools/ToolMemoryCard.java b/items/tools/ToolMemoryCard.java index 90a8d36a..1d820c32 100644 --- a/items/tools/ToolMemoryCard.java +++ b/items/tools/ToolMemoryCard.java @@ -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; diff --git a/parts/PartPlacement.java b/parts/PartPlacement.java index f942ce4c..aea4aa16 100644 --- a/parts/PartPlacement.java +++ b/parts/PartPlacement.java @@ -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 ) { From 3ac94550e53d27b33d1f8a97bb1950408dd1339b Mon Sep 17 00:00:00 2001 From: AlgorithmX2 Date: Mon, 26 May 2014 10:58:41 -0500 Subject: [PATCH 12/12] Seeds can now be planted via Formation Planes. --- parts/automation/PartFormationPlane.java | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/parts/automation/PartFormationPlane.java b/parts/automation/PartFormationPlane.java index f29d3ac4..add143f6 100644 --- a/parts/automation/PartFormationPlane.java +++ b/parts/automation/PartFormationPlane.java @@ -388,8 +388,28 @@ 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 ); - maxStorage = maxStorage - is.stackSize; + 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;