From 6203b172f6380c6865a9fbb48e1acd0642b3e82c Mon Sep 17 00:00:00 2001 From: AlgorithmX2 Date: Mon, 7 Apr 2014 21:31:36 -0500 Subject: [PATCH 01/10] Better Solution for extra energy injection. ( Fixes Crash ) --- parts/p2p/PartP2PIC2Power.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/parts/p2p/PartP2PIC2Power.java b/parts/p2p/PartP2PIC2Power.java index 170022500..578b7d8d3 100644 --- a/parts/p2p/PartP2PIC2Power.java +++ b/parts/p2p/PartP2PIC2Power.java @@ -131,6 +131,15 @@ public class PartP2PIC2Power extends PartP2PTunnel implements i Options.add( o ); } + if ( Options.isEmpty() ) + { + for (PartP2PIC2Power o : outs) + Options.add( o ); + } + + if ( Options.isEmpty() ) + return amount; + PartP2PIC2Power x = (PartP2PIC2Power) Platform.pickRandom( Options ); if ( x != null && x.OutputPacket <= 0.001 ) { From 316822fe71f9578549de12ee728e85a2568febc0 Mon Sep 17 00:00:00 2001 From: AlgorithmX2 Date: Tue, 8 Apr 2014 22:12:01 -0500 Subject: [PATCH 02/10] Better Errors in GuiBridge. --- core/sync/GuiBridge.java | 30 ++++++++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/core/sync/GuiBridge.java b/core/sync/GuiBridge.java index 5d2eb4534..923ddb085 100644 --- a/core/sync/GuiBridge.java +++ b/core/sync/GuiBridge.java @@ -54,6 +54,7 @@ import appeng.container.implementations.ContainerUpgradeable; import appeng.container.implementations.ContainerVibrationChamber; import appeng.container.implementations.ContainerWireless; import appeng.container.implementations.ContainerWirelessTerm; +import appeng.core.AELog; import appeng.helpers.IInterfaceHost; import appeng.helpers.IPriorityHost; import appeng.helpers.WirelessTerminalGuiObject; @@ -197,7 +198,16 @@ public enum GuiBridge implements IGuiHandler Constructor[] c = Container.getConstructors(); if ( c.length == 0 ) throw new AppEngException( "Invalid Gui Class" ); - return findConstructor( c, inventory, tE ).newInstance( inventory, tE ); + + Constructor target = findConstructor( c, inventory, tE ); + + if ( target == null ) + { + AELog.severe( "Cannot find " + Container.getName() + "( " + typeName( inventory ) + ", " + typeName( tE ) + " )" ); + return null; + } + + return target.newInstance( inventory, tE ); } catch (Throwable t) { @@ -213,7 +223,15 @@ public enum GuiBridge implements IGuiHandler if ( c.length == 0 ) throw new AppEngException( "Invalid Gui Class" ); - return findConstructor( c, inventory, tE ).newInstance( inventory, tE ); + Constructor target = findConstructor( c, inventory, tE ); + + if ( target == null ) + { + AELog.severe( "Cannot find " + Container.getName() + "( " + typeName( inventory ) + ", " + typeName( tE ) + " )" ); + return null; + } + + return target.newInstance( inventory, tE ); } catch (Throwable t) { @@ -221,6 +239,14 @@ public enum GuiBridge implements IGuiHandler } } + private String typeName(Object inventory) + { + if ( inventory == null ) + return "NULL"; + + return inventory.getClass().getName(); + } + private Constructor findConstructor(Constructor[] c, InventoryPlayer inventory, Object tE) { for (Constructor con : c) From be1b22a3ee9af758e88abf7e22dcec68efe5047f Mon Sep 17 00:00:00 2001 From: AlgorithmX2 Date: Tue, 8 Apr 2014 22:14:03 -0500 Subject: [PATCH 03/10] Crash, no log! --- core/sync/GuiBridge.java | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/core/sync/GuiBridge.java b/core/sync/GuiBridge.java index 923ddb085..cde0902f0 100644 --- a/core/sync/GuiBridge.java +++ b/core/sync/GuiBridge.java @@ -54,7 +54,6 @@ import appeng.container.implementations.ContainerUpgradeable; import appeng.container.implementations.ContainerVibrationChamber; import appeng.container.implementations.ContainerWireless; import appeng.container.implementations.ContainerWirelessTerm; -import appeng.core.AELog; import appeng.helpers.IInterfaceHost; import appeng.helpers.IPriorityHost; import appeng.helpers.WirelessTerminalGuiObject; @@ -203,8 +202,7 @@ public enum GuiBridge implements IGuiHandler if ( target == null ) { - AELog.severe( "Cannot find " + Container.getName() + "( " + typeName( inventory ) + ", " + typeName( tE ) + " )" ); - return null; + throw new RuntimeException( "Cannot find " + Container.getName() + "( " + typeName( inventory ) + ", " + typeName( tE ) + " )" ); } return target.newInstance( inventory, tE ); @@ -227,8 +225,7 @@ public enum GuiBridge implements IGuiHandler if ( target == null ) { - AELog.severe( "Cannot find " + Container.getName() + "( " + typeName( inventory ) + ", " + typeName( tE ) + " )" ); - return null; + throw new RuntimeException( "Cannot find " + Container.getName() + "( " + typeName( inventory ) + ", " + typeName( tE ) + " )" ); } return target.newInstance( inventory, tE ); From 344c9eb3702c6beeb67354927a3486250e93db97 Mon Sep 17 00:00:00 2001 From: AlgorithmX2 Date: Tue, 8 Apr 2014 23:26:04 -0500 Subject: [PATCH 04/10] Allow Subclasses of PlayerInventory. --- core/sync/GuiBridge.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/sync/GuiBridge.java b/core/sync/GuiBridge.java index cde0902f0..235723138 100644 --- a/core/sync/GuiBridge.java +++ b/core/sync/GuiBridge.java @@ -251,7 +251,7 @@ public enum GuiBridge implements IGuiHandler Class[] types = con.getParameterTypes(); if ( types.length == 2 ) { - if ( types[0] == inventory.getClass() && types[1].isAssignableFrom( tE.getClass() ) ) + if ( types[0].isAssignableFrom( inventory.getClass() ) && types[1].isAssignableFrom( tE.getClass() ) ) return con; } } From db6a958a6f292623b488a831f42c7586de5e22f5 Mon Sep 17 00:00:00 2001 From: AlgorithmX2 Date: Wed, 9 Apr 2014 14:22:17 -0500 Subject: [PATCH 05/10] Fix Interface Crash caused by negative items. --- helpers/DualityInterface.java | 12 +++++++++--- parts/misc/PartToggleBus.java | 1 - 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/helpers/DualityInterface.java b/helpers/DualityInterface.java index c7d7d7911..45985e3e4 100644 --- a/helpers/DualityInterface.java +++ b/helpers/DualityInterface.java @@ -156,6 +156,12 @@ public class DualityInterface implements IGridTickable, ISegmentedInventory, ISt private void updatePlan(int slot) { IAEItemStack req = config.getAEStackInSlot( slot ); + if ( req != null && req.getStackSize() <= 0 ) + { + config.setInventorySlotContents(slot, null); + req = null; + } + ItemStack Stored = storage.getStackInSlot( slot ); if ( req == null && Stored != null ) @@ -242,7 +248,7 @@ public class DualityInterface implements IGridTickable, ISegmentedInventory, ISt changed = true; ItemStack issue = adaptor.addItems( aquired.getItemStack() ); if ( issue != null ) - throw new RuntimeException( "bad attempt at managining inventory. ( addItems )" ); + throw new RuntimeException( "bad attempt at managing inventory. ( addItems )" ); } } else if ( itemStack.getStackSize() < 0 ) @@ -263,9 +269,9 @@ public class DualityInterface implements IGridTickable, ISegmentedInventory, ISt changed = true; ItemStack removed = adaptor.removeItems( (int) diff, null, null ); if ( removed == null ) - throw new RuntimeException( "bad attempt at managining inventory. ( addItems )" ); + throw new RuntimeException( "bad attempt at managing inventory. ( addItems )" ); else if ( removed.stackSize != diff ) - throw new RuntimeException( "bad attempt at managining inventory. ( addItems )" ); + throw new RuntimeException( "bad attempt at managing inventory. ( addItems )" ); } } // else wtf? diff --git a/parts/misc/PartToggleBus.java b/parts/misc/PartToggleBus.java index cb9790623..fc71b3430 100644 --- a/parts/misc/PartToggleBus.java +++ b/parts/misc/PartToggleBus.java @@ -15,7 +15,6 @@ import org.lwjgl.opengl.GL11; import appeng.api.AEApi; import appeng.api.exceptions.FailedConnection; -import appeng.api.networking.GridFlags; import appeng.api.networking.IGridConnection; import appeng.api.networking.IGridNode; import appeng.api.parts.IPartCollsionHelper; From ac0c562b023e3be58e071efde98c0122e4f1b378 Mon Sep 17 00:00:00 2001 From: AlgorithmX2 Date: Wed, 9 Apr 2014 14:22:36 -0500 Subject: [PATCH 06/10] Fixed Channel requirements for illuminated panels. --- parts/reporting/PartCraftingMonitor.java | 2 +- parts/reporting/PartDarkMonitor.java | 2 +- parts/reporting/PartMonitor.java | 5 +++-- parts/reporting/PartPatternTerminal.java | 2 +- parts/reporting/PartSemiDarkMonitor.java | 3 +-- parts/reporting/PartStorageMonitor.java | 4 ++-- parts/reporting/PartTerminal.java | 4 ++-- 7 files changed, 11 insertions(+), 11 deletions(-) diff --git a/parts/reporting/PartCraftingMonitor.java b/parts/reporting/PartCraftingMonitor.java index ef947769f..6158b8a81 100644 --- a/parts/reporting/PartCraftingMonitor.java +++ b/parts/reporting/PartCraftingMonitor.java @@ -7,7 +7,7 @@ public class PartCraftingMonitor extends PartMonitor { public PartCraftingMonitor(ItemStack is) { - super( PartCraftingMonitor.class, is ); + super( PartCraftingMonitor.class, is,true ); frontBright = CableBusTextures.PartCraftingMonitor_Bright; frontColored = CableBusTextures.PartCraftingMonitor_Colored; frontDark = CableBusTextures.PartCraftingMonitor_Dark; diff --git a/parts/reporting/PartDarkMonitor.java b/parts/reporting/PartDarkMonitor.java index 475aad3eb..dfbb7b30c 100644 --- a/parts/reporting/PartDarkMonitor.java +++ b/parts/reporting/PartDarkMonitor.java @@ -13,7 +13,7 @@ public class PartDarkMonitor extends PartMonitor { public PartDarkMonitor(ItemStack is) { - super( PartDarkMonitor.class, is ); + super( PartDarkMonitor.class, is,false ); notLightSource = false; } diff --git a/parts/reporting/PartMonitor.java b/parts/reporting/PartMonitor.java index 4e09269c4..abbeff5e3 100644 --- a/parts/reporting/PartMonitor.java +++ b/parts/reporting/PartMonitor.java @@ -114,9 +114,10 @@ public class PartMonitor extends AEBasePart implements IPartMonitor, IPowerChann super( PartMonitor.class, is ); } - protected PartMonitor(Class c, ItemStack is) { + protected PartMonitor(Class c, ItemStack is, boolean requireChannel ) { super( c, is ); - if ( notLightSource ) + + if ( requireChannel ) proxy.setFlags( GridFlags.REQUIRE_CHANNEL ); else proxy.setIdlePowerUsage( 1.0 / 16.0 ); // lights drain a little bit. diff --git a/parts/reporting/PartPatternTerminal.java b/parts/reporting/PartPatternTerminal.java index 537494c53..21400877a 100644 --- a/parts/reporting/PartPatternTerminal.java +++ b/parts/reporting/PartPatternTerminal.java @@ -7,7 +7,7 @@ public class PartPatternTerminal extends PartMonitor { public PartPatternTerminal(ItemStack is) { - super( PartPatternTerminal.class, is ); + super( PartPatternTerminal.class, is, true ); frontBright = CableBusTextures.PartPatternTerm_Bright; frontColored = CableBusTextures.PartPatternTerm_Colored; frontDark = CableBusTextures.PartPatternTerm_Dark; diff --git a/parts/reporting/PartSemiDarkMonitor.java b/parts/reporting/PartSemiDarkMonitor.java index 8fb2f1266..0e9c898f3 100644 --- a/parts/reporting/PartSemiDarkMonitor.java +++ b/parts/reporting/PartSemiDarkMonitor.java @@ -13,8 +13,7 @@ public class PartSemiDarkMonitor extends PartMonitor { public PartSemiDarkMonitor(ItemStack is) { - super( PartSemiDarkMonitor.class, is ); - + super( PartSemiDarkMonitor.class, is,false ); notLightSource = false; } diff --git a/parts/reporting/PartStorageMonitor.java b/parts/reporting/PartStorageMonitor.java index d502fd57e..7d8899dc1 100644 --- a/parts/reporting/PartStorageMonitor.java +++ b/parts/reporting/PartStorageMonitor.java @@ -150,11 +150,11 @@ public class PartStorageMonitor extends PartMonitor implements IPartStorageMonit } protected PartStorageMonitor(Class myClass, ItemStack is) { - super( myClass, is ); + super( myClass, is,true ); } public PartStorageMonitor(ItemStack is) { - super( PartStorageMonitor.class, is ); + super( PartStorageMonitor.class, is,true ); frontBright = CableBusTextures.PartStorageMonitor_Bright; frontColored = CableBusTextures.PartStorageMonitor_Colored; frontDark = CableBusTextures.PartStorageMonitor_Dark; diff --git a/parts/reporting/PartTerminal.java b/parts/reporting/PartTerminal.java index 5e0be23e3..11806c66a 100644 --- a/parts/reporting/PartTerminal.java +++ b/parts/reporting/PartTerminal.java @@ -30,7 +30,7 @@ public class PartTerminal extends PartMonitor implements ITerminalHost, IConfigM AppEngInternalInventory viewCell = new AppEngInternalInventory( this, 5 ); public PartTerminal(Class clz, ItemStack is) { - super( clz, is ); + super( clz, is,true ); cm.registerSetting( Settings.SORT_BY, SortOrder.NAME ); cm.registerSetting( Settings.VIEW_MODE, ViewItems.ALL ); @@ -54,7 +54,7 @@ public class PartTerminal extends PartMonitor implements ITerminalHost, IConfigM } public PartTerminal(ItemStack is) { - super( PartTerminal.class, is ); + super( PartTerminal.class, is,true ); frontBright = CableBusTextures.PartTerminal_Bright; frontColored = CableBusTextures.PartTerminal_Colored; frontDark = CableBusTextures.PartTerminal_Dark; From e8c27255515981c24e3e0d06a89c67d9a02642ce Mon Sep 17 00:00:00 2001 From: AlgorithmX2 Date: Wed, 9 Apr 2014 15:41:13 -0500 Subject: [PATCH 07/10] Minor enhancement to Error message. --- core/AELog.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/AELog.java b/core/AELog.java index 283021213..3c7956c7c 100644 --- a/core/AELog.java +++ b/core/AELog.java @@ -47,7 +47,7 @@ public class AELog { if ( AEConfig.instance.isFeatureEnabled( AEFeature.Logging ) ) { - severe( "Error: " + e.getMessage() ); + severe( "Error: " + e.getClass().getName() + " : " + e.getMessage() ); e.printStackTrace(); } } From b33d0771d67dc7036a4d37222898c13be4f6810b Mon Sep 17 00:00:00 2001 From: AlgorithmX2 Date: Wed, 9 Apr 2014 19:52:13 -0500 Subject: [PATCH 08/10] Should fix CME. --- tile/storage/TileIOPort.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tile/storage/TileIOPort.java b/tile/storage/TileIOPort.java index b82d334f2..832bdefe7 100644 --- a/tile/storage/TileIOPort.java +++ b/tile/storage/TileIOPort.java @@ -380,6 +380,8 @@ public class TileIOPort extends AENetworkInvTile implements IUpgradeableHost, IC } itemsToMove -= possible; + didStuff = true; + break; } } } From 2450267957477b1f9976c36811e624eede14679f Mon Sep 17 00:00:00 2001 From: AlgorithmX2 Date: Wed, 9 Apr 2014 19:52:31 -0500 Subject: [PATCH 09/10] You don't have to be active to be removed, that's silly --- me/cache/GridStorageCache.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/me/cache/GridStorageCache.java b/me/cache/GridStorageCache.java index 5802bb2cb..34c842ef3 100644 --- a/me/cache/GridStorageCache.java +++ b/me/cache/GridStorageCache.java @@ -80,7 +80,7 @@ public class GridStorageCache implements IStorageGrid private void rmvCell(IGridNode node, ICellContainer cc) { - if ( node.isActive() && activeCellContainers.contains( cc ) ) + if ( activeCellContainers.contains( cc ) ) { inactiveCellContainers.add( cc ); activeCellContainers.remove( cc ); From 6b244b341bd6933740493d9a5c72850e43145ad4 Mon Sep 17 00:00:00 2001 From: AlgorithmX2 Date: Wed, 9 Apr 2014 20:02:34 -0500 Subject: [PATCH 10/10] Don't discriminate against blocks with custom rotation. --- block/AEBaseItemBlock.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/block/AEBaseItemBlock.java b/block/AEBaseItemBlock.java index ec82e74e9..934437aaa 100644 --- a/block/AEBaseItemBlock.java +++ b/block/AEBaseItemBlock.java @@ -123,7 +123,7 @@ public class AEBaseItemBlock extends ItemBlock if ( super.placeBlockAt( stack, player, w, x, y, z, side, hitX, hitY, hitZ, metadata ) ) { - if ( blockType.hasBlockTileEntity() && !blockType.hasCustomRotation() ) + if ( blockType.hasBlockTileEntity() ) { AEBaseTile tile = blockType.getTileEntity( w, x, y, z ); ori = tile; @@ -131,7 +131,7 @@ public class AEBaseItemBlock extends ItemBlock if ( tile == null ) return true; - if ( ori.canBeRotated() ) + if ( ori.canBeRotated() && !blockType.hasCustomRotation() ) { if ( ori.getForward() == null || ori.getUp() == null || // null tile.getForward() == ForgeDirection.UNKNOWN || ori.getUp() == ForgeDirection.UNKNOWN )