From 71fc2d1b5cba2326716e0f4ab0c93c322242ff91 Mon Sep 17 00:00:00 2001 From: AlgorithmX2 Date: Thu, 18 Sep 2014 11:30:59 -0500 Subject: [PATCH 01/10] Fixed Incomplete Null Check for MEMonitorIInventory --- me/storage/MEMonitorIInventory.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/me/storage/MEMonitorIInventory.java b/me/storage/MEMonitorIInventory.java index 981738eba..979025cb8 100644 --- a/me/storage/MEMonitorIInventory.java +++ b/me/storage/MEMonitorIInventory.java @@ -229,7 +229,7 @@ public class MEMonitorIInventory implements IMEInventory, IMEMonit { for (CachedItemStack cis : end.values()) { - if ( cis != null ) + if ( cis != null && cis.aeStack != null ) { IAEItemStack a = cis.aeStack.copy(); a.setStackSize( -a.getStackSize() ); From 7745263a471b2c853102660fd9435aa38b2b0da6 Mon Sep 17 00:00:00 2001 From: AlgorithmX2 Date: Thu, 18 Sep 2014 13:14:32 -0500 Subject: [PATCH 02/10] Add black cube around Spatial, add super dark grey fog / skycolor to prevent night vision from making you blind. --- client/render/SpatialSkyRender.java | 59 ++++++++++++++++++++++++++--- spatial/StorageWorldProvider.java | 14 +++++-- 2 files changed, 64 insertions(+), 9 deletions(-) diff --git a/client/render/SpatialSkyRender.java b/client/render/SpatialSkyRender.java index c77c3419b..b4d16d163 100644 --- a/client/render/SpatialSkyRender.java +++ b/client/render/SpatialSkyRender.java @@ -41,10 +41,58 @@ public class SpatialSkyRender extends IRenderHandler fade /= 1000; fade = 0.15f * (1.0f - Math.abs( (fade - 1.0f) * (fade - 1.0f) )); - if ( fade > 0.0f ) - { - GL11.glPushAttrib( GL11.GL_ALL_ATTRIB_BITS ); + GL11.glPushAttrib( GL11.GL_ALL_ATTRIB_BITS ); + GL11.glDisable(GL11.GL_FOG); + GL11.glDisable(GL11.GL_ALPHA_TEST); + GL11.glDisable(GL11.GL_BLEND); + GL11.glDepthMask(false); + GL11.glColor4f( 0.0f, 0.0f, 0.0f, 1.0f ); + Tessellator tessellator = Tessellator.instance; + + for (int i = 0; i < 6; ++i) + { + GL11.glPushMatrix(); + + if (i == 1) + { + GL11.glRotatef(90.0F, 1.0F, 0.0F, 0.0F); + } + + if (i == 2) + { + GL11.glRotatef(-90.0F, 1.0F, 0.0F, 0.0F); + } + + if (i == 3) + { + GL11.glRotatef(180.0F, 1.0F, 0.0F, 0.0F); + } + + if (i == 4) + { + GL11.glRotatef(90.0F, 0.0F, 0.0F, 1.0F); + } + + if (i == 5) + { + GL11.glRotatef(-90.0F, 0.0F, 0.0F, 1.0F); + } + + tessellator.startDrawingQuads(); + tessellator.setColorOpaque_I(0); + tessellator.addVertexWithUV(-100.0D, -100.0D, -100.0D, 0.0D, 0.0D); + tessellator.addVertexWithUV(-100.0D, -100.0D, 100.0D, 0.0D, 16.0D); + tessellator.addVertexWithUV(100.0D, -100.0D, 100.0D, 16.0D, 16.0D); + tessellator.addVertexWithUV(100.0D, -100.0D, -100.0D, 16.0D, 0.0D); + tessellator.draw(); + GL11.glPopMatrix(); + } + + GL11.glDepthMask(true); + + if ( fade > 0.0f ) + { GL11.glDisable( GL11.GL_FOG ); GL11.glDisable( GL11.GL_ALPHA_TEST ); GL11.glEnable( GL11.GL_BLEND ); @@ -52,7 +100,6 @@ public class SpatialSkyRender extends IRenderHandler GL11.glEnable( GL11.GL_FOG ); GL11.glDisable( GL11.GL_FOG ); GL11.glDisable( GL11.GL_ALPHA_TEST ); - GL11.glEnable( GL11.GL_BLEND ); GL11.glDisable( GL11.GL_TEXTURE_2D ); OpenGlHelper.glBlendFunc( 770, 771, 1, 0 ); RenderHelper.disableStandardItemLighting(); @@ -60,9 +107,11 @@ public class SpatialSkyRender extends IRenderHandler GL11.glColor4f( fade, fade, fade, 1.0f ); GL11.glCallList( dspList ); - GL11.glPopAttrib(); } + GL11.glPopAttrib(); + + GL11.glColor4f(1.0f, 1.0f, 1.0f, 1.0f); } private void renderTwinkles() diff --git a/spatial/StorageWorldProvider.java b/spatial/StorageWorldProvider.java index adb810859..31721e280 100644 --- a/spatial/StorageWorldProvider.java +++ b/spatial/StorageWorldProvider.java @@ -38,6 +38,12 @@ public class StorageWorldProvider extends WorldProvider super.worldChunkMgr = new WorldChunkManagerHell( Registration.instance.storageBiome, 0.0F ); } + @SideOnly(Side.CLIENT) + public float[] calcSunriseSunsetColors(float p_76560_1_, float p_76560_2_) + { + return null; + } + @Override public float getStarBrightness(float par1) { @@ -77,7 +83,7 @@ public class StorageWorldProvider extends WorldProvider @Override public Vec3 getSkyColor(Entity cameraEntity, float partialTicks) { - return Vec3.createVectorHelper( 0.0, 0.0, 0.0 ); + return Vec3.createVectorHelper( 0.07, 0.07, 0.07 ); } @Override @@ -96,13 +102,13 @@ public class StorageWorldProvider extends WorldProvider @SideOnly(Side.CLIENT) public boolean isSkyColored() { - return false; + return true; } @Override public Vec3 getFogColor(float par1, float par2) { - return Vec3.createVectorHelper( 0.0, 0.0, 0.0 ); + return Vec3.createVectorHelper( 0.07, 0.07, 0.07 ); } @Override @@ -116,7 +122,7 @@ public class StorageWorldProvider extends WorldProvider { return "Storage Cell"; } - + @Override public IRenderHandler getSkyRenderer() { From 73cda63a787ca1eff6be8dd2f0903f373d6ce07c Mon Sep 17 00:00:00 2001 From: AlgorithmX2 Date: Thu, 18 Sep 2014 20:30:26 -0500 Subject: [PATCH 03/10] Fix Crafting Dupe on Extraction, if extraction fails roll back and fail. --- crafting/CraftingTreeNode.java | 6 ++- crafting/MECraftingInventory.java | 53 +++++++++++++++++-- .../implementations/CraftingCPUCluster.java | 46 +++++++++------- 3 files changed, 79 insertions(+), 26 deletions(-) diff --git a/crafting/CraftingTreeNode.java b/crafting/CraftingTreeNode.java index 1d07cf3c9..55dbe6129 100644 --- a/crafting/CraftingTreeNode.java +++ b/crafting/CraftingTreeNode.java @@ -44,7 +44,8 @@ public class CraftingTreeNode boolean sim; - public CraftingTreeNode(ICraftingGrid cc, CraftingJob job, IAEItemStack wat, CraftingTreeProcess par, int slot, int depth) { + public CraftingTreeNode(ICraftingGrid cc, CraftingJob job, IAEItemStack wat, CraftingTreeProcess par, int slot, int depth) + { what = wat; parent = par; this.slot = slot; @@ -206,7 +207,8 @@ public class CraftingTreeNode if ( available != null ) { - subInv.commit( src ); + if ( !subInv.commit( src ) ) + throw new CraftBranchFailure( what, l ); bytes += available.getStackSize(); l -= available.getStackSize(); diff --git a/crafting/MECraftingInventory.java b/crafting/MECraftingInventory.java index c44c465ae..edb418fc0 100644 --- a/crafting/MECraftingInventory.java +++ b/crafting/MECraftingInventory.java @@ -153,18 +153,59 @@ public class MECraftingInventory implements IMEInventory return StorageChannel.ITEMS; } - public void commit(BaseActionSource src) + public boolean commit(BaseActionSource src) { + IItemList added = AEApi.instance().storage().createItemList(); + IItemList pulled = AEApi.instance().storage().createItemList(); + boolean failed = false; + + if ( logExtracted ) + { + for (IAEItemStack extra : extractedCache) + { + IAEItemStack result = null; + pulled.add( result = target.extractItems( extra, Actionable.MODULATE, src ) ); + + if ( result == null || result.getStackSize() != extra.getStackSize() ) + { + failed = true; + break; + } + } + } + + if ( failed ) + { + for (IAEItemStack is : pulled) + target.injectItems( is, Actionable.MODULATE, src ); + + return false; + } + if ( logInjections ) { for (IAEItemStack injec : injectedCache) - target.injectItems( injec, Actionable.MODULATE, src ); + { + IAEItemStack result = null; + added.add( result = target.injectItems( injec, Actionable.MODULATE, src ) ); + + if ( result != null ) + { + failed = true; + break; + } + } } - if ( logExtracted ) + if ( failed ) { - for (IAEItemStack extra : extractedCache) - target.extractItems( extra, Actionable.MODULATE, src ); + for (IAEItemStack is : added) + target.extractItems( is, Actionable.MODULATE, src ); + + for (IAEItemStack is : pulled) + target.injectItems( is, Actionable.MODULATE, src ); + + return false; } if ( logMissing && par != null ) @@ -172,6 +213,8 @@ public class MECraftingInventory implements IMEInventory for (IAEItemStack extra : missingCache) par.addMissing( extra ); } + + return true; } public void addMissing(IAEItemStack extra) diff --git a/me/cluster/implementations/CraftingCPUCluster.java b/me/cluster/implementations/CraftingCPUCluster.java index 8eaa87d3b..030b0fd2e 100644 --- a/me/cluster/implementations/CraftingCPUCluster.java +++ b/me/cluster/implementations/CraftingCPUCluster.java @@ -198,7 +198,8 @@ public class CraftingCPUCluster implements IAECluster, ICraftingCPU return inventory; } - public CraftingCPUCluster(WorldCoord _min, WorldCoord _max) { + public CraftingCPUCluster(WorldCoord _min, WorldCoord _max) + { min = _min; max = _max; } @@ -786,32 +787,39 @@ public class CraftingCPUCluster implements IAECluster, ICraftingCPU { waitingFor.resetStatus(); ((CraftingJob) job).tree.setJob( ci, this, src ); - ci.commit( src ); - finalOutput = job.getOutput(); - waiting = false; - isComplete = false; - markDirty(); + if ( ci.commit( src ) ) + { + finalOutput = job.getOutput(); + waiting = false; + isComplete = false; + markDirty(); - updateCPU(); - String craftID = generateCraftingID(); + updateCPU(); + String craftID = generateCraftingID(); - myLastLink = new CraftingLink( generateLinkData( craftID, requestingMachine == null, false ), this ); + myLastLink = new CraftingLink( generateLinkData( craftID, requestingMachine == null, false ), this ); - if ( requestingMachine == null ) - return myLastLink; + if ( requestingMachine == null ) + return myLastLink; - ICraftingLink whatLink = new CraftingLink( generateLinkData( craftID, requestingMachine == null, true ), requestingMachine ); + ICraftingLink whatLink = new CraftingLink( generateLinkData( craftID, requestingMachine == null, true ), requestingMachine ); - submitLink( myLastLink ); - submitLink( whatLink ); + submitLink( myLastLink ); + submitLink( whatLink ); - IItemList list; - getListOfItem( list = AEApi.instance().storage().createItemList(), CraftingItemList.ALL ); + IItemList list; + getListOfItem( list = AEApi.instance().storage().createItemList(), CraftingItemList.ALL ); - for (IAEItemStack ge : list) - postChange( ge, machineSrc ); + for (IAEItemStack ge : list) + postChange( ge, machineSrc ); - return whatLink; + return whatLink; + } + else + { + tasks.clear(); + inventory.getItemList().resetStatus(); + } } catch (CraftBranchFailure e) { From 57d23dd2a7cccbb7c276a46b1b86c510a2fc4300 Mon Sep 17 00:00:00 2001 From: AlgorithmX2 Date: Thu, 18 Sep 2014 20:31:11 -0500 Subject: [PATCH 04/10] Fix Crafting Dupe on Calculation, Test Item types for real quantities as they are needed. --- crafting/CraftingJob.java | 8 +++- crafting/MECraftingInventory.java | 62 +++++++++++++++++++++++++++++-- 2 files changed, 64 insertions(+), 6 deletions(-) diff --git a/crafting/CraftingJob.java b/crafting/CraftingJob.java index 4709e9d94..f0b608d0d 100644 --- a/crafting/CraftingJob.java +++ b/crafting/CraftingJob.java @@ -47,7 +47,8 @@ public class CraftingJob implements Runnable, ICraftingJob return output; } - public CraftingJob(World w, NBTTagCompound data) { + public CraftingJob(World w, NBTTagCompound data) + { world = wrapWorld( w ); storage = AEApi.instance().storage().createItemList(); prophecies = new HashSet(); @@ -65,7 +66,8 @@ public class CraftingJob implements Runnable, ICraftingJob return availableCheck.extractItems( available, Actionable.MODULATE, this.actionSrc ); } - public CraftingJob(World w, IGrid grid, BaseActionSource actionSrc, IAEItemStack what, ICraftingCallback callback) { + public CraftingJob(World w, IGrid grid, BaseActionSource actionSrc, IAEItemStack what, ICraftingCallback callback) + { world = wrapWorld( w ); output = what.copy(); storage = AEApi.instance().storage().createItemList(); @@ -76,6 +78,8 @@ public class CraftingJob implements Runnable, ICraftingJob ICraftingGrid cc = grid.getCache( ICraftingGrid.class ); IStorageGrid sg = grid.getCache( IStorageGrid.class ); original = new MECraftingInventory( sg.getItemInventory(), false, false, false ); + original.filterPermissions( actionSrc ); + tree = getCraftingTree( cc, what ); availableCheck = null; } diff --git a/crafting/MECraftingInventory.java b/crafting/MECraftingInventory.java index edb418fc0..bfc986946 100644 --- a/crafting/MECraftingInventory.java +++ b/crafting/MECraftingInventory.java @@ -16,6 +16,9 @@ public class MECraftingInventory implements IMEInventory final IMEInventory target; final IItemList localCache; + private BaseActionSource usePermissions = null; + private final IItemList permissionsCache = AEApi.instance().storage().createItemList(); + final boolean logExtracted; final IItemList extractedCache; @@ -25,7 +28,28 @@ public class MECraftingInventory implements IMEInventory final boolean logMissing; final IItemList missingCache; - public MECraftingInventory() { + private void filter(IAEItemStack input, BaseActionSource src) + { + if ( usePermissions != null && input != null ) + { + if ( permissionsCache.findPrecise( input ) == null ) + { + IAEItemStack what = input.copy(); + what.setStackSize( 1 ); + permissionsCache.add( what ); + + IAEItemStack localItem = localCache.findPrecise( input ); + if ( localItem != null ) + { + IAEItemStack realSize = target.extractItems( input, Actionable.SIMULATE, usePermissions ); + localItem.setStackSize( realSize == null ? 0 : realSize.getStackSize() ); + } + } + } + } + + public MECraftingInventory() + { localCache = AEApi.instance().storage().createItemList(); extractedCache = null; injectedCache = null; @@ -37,11 +61,16 @@ public class MECraftingInventory implements IMEInventory par = null; } - public MECraftingInventory(MECraftingInventory parrent) { + public MECraftingInventory(MECraftingInventory parrent) + { this.target = parrent; this.logExtracted = parrent.logExtracted; this.logInjections = parrent.logInjections; this.logMissing = parrent.logMissing; + this.usePermissions = parrent.usePermissions; + + for (IAEItemStack is : parrent.permissionsCache) + permissionsCache.add( is ); if ( logMissing ) missingCache = AEApi.instance().storage().createItemList(); @@ -63,12 +92,21 @@ public class MECraftingInventory implements IMEInventory par = parrent; } - public MECraftingInventory(IMEInventory target, boolean logExtracted, boolean logInjections, boolean logMissing) { + public MECraftingInventory(IMEInventory target, boolean logExtracted, boolean logInjections, boolean logMissing) + { this.target = target; this.logExtracted = logExtracted; this.logInjections = logInjections; this.logMissing = logMissing; + if ( target instanceof MECraftingInventory ) + { + MECraftingInventory parrent = (MECraftingInventory) target; + this.usePermissions = parrent.usePermissions; + for (IAEItemStack is : parrent.permissionsCache) + permissionsCache.add( is ); + } + if ( logMissing ) missingCache = AEApi.instance().storage().createItemList(); else @@ -88,12 +126,19 @@ public class MECraftingInventory implements IMEInventory par = null; } + public void filterPermissions(BaseActionSource src) + { + usePermissions = src; + } + @Override public IAEItemStack injectItems(IAEItemStack input, Actionable mode, BaseActionSource src) { if ( input == null ) return null; + filter( input, src ); + if ( mode == Actionable.MODULATE ) { if ( logInjections ) @@ -110,6 +155,8 @@ public class MECraftingInventory implements IMEInventory if ( request == null ) return null; + filter( request, src ); + IAEItemStack list = localCache.findPrecise( request ); if ( list == null || list.getStackSize() == 0 ) return null; @@ -160,7 +207,7 @@ public class MECraftingInventory implements IMEInventory boolean failed = false; if ( logExtracted ) - { + { for (IAEItemStack extra : extractedCache) { IAEItemStack result = null; @@ -227,5 +274,12 @@ public class MECraftingInventory implements IMEInventory IAEItemStack list = localCache.findPrecise( what ); if ( list != null ) list.setStackSize( 0 ); + + if ( usePermissions != null ) + { + IAEItemStack hmm = what.copy(); + hmm.setStackSize( 1 ); + permissionsCache.add( hmm ); + } } } From db50a549cf2488b5e4c40ca9c86f9b7f950e60e3 Mon Sep 17 00:00:00 2001 From: AlgorithmX2 Date: Thu, 18 Sep 2014 20:33:19 -0500 Subject: [PATCH 05/10] Non Networked ME Chests can now have items inserted into them. --- tile/storage/TileChest.java | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/tile/storage/TileChest.java b/tile/storage/TileChest.java index 676eb7d40..0984a43fa 100644 --- a/tile/storage/TileChest.java +++ b/tile/storage/TileChest.java @@ -146,7 +146,8 @@ public class TileChest extends AENetworkPowerTile implements IMEChest, IFluidHan private class invManger extends AETileEventHandler { - public invManger() { + public invManger() + { super( TileEventType.TICK, TileEventType.NETWORK, TileEventType.WORLD_NBT ); } @@ -264,7 +265,8 @@ public class TileChest extends AENetworkPowerTile implements IMEChest, IFluidHan recalculateDisplay(); } - public TileChest() { + public TileChest() + { internalMaxPower = PowerMultiplier.CONFIG.multiply( 40 ); gridProxy.setFlags( GridFlags.REQUIRE_CHANNEL ); addNewHandler( new invManger() ); @@ -299,7 +301,8 @@ public class TileChest extends AENetworkPowerTile implements IMEChest, IFluidHan final StorageChannel chan; - public ChestNetNotifier(StorageChannel chan) { + public ChestNetNotifier(StorageChannel chan) + { this.chan = chan; } @@ -343,7 +346,8 @@ public class TileChest extends AENetworkPowerTile implements IMEChest, IFluidHan class ChestMonitorHandler extends MEMonitorHandler { - public ChestMonitorHandler(IMEInventoryHandler t) { + public ChestMonitorHandler(IMEInventoryHandler t) + { super( t ); } @@ -520,7 +524,7 @@ public class TileChest extends AENetworkPowerTile implements IMEChest, IFluidHan if ( ForgeDirection.SOUTH == side ) return front; - if ( gridProxy.isActive() ) + if ( isPowered() ) { try { From b7684d37eaad12adb2b5a8e5ca4c00c13b2fec9b Mon Sep 17 00:00:00 2001 From: AlgorithmX2 Date: Thu, 18 Sep 2014 20:47:56 -0500 Subject: [PATCH 06/10] Removed dragging behavior for fake slots from left right button. --- client/gui/AEBaseGui.java | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/client/gui/AEBaseGui.java b/client/gui/AEBaseGui.java index 2464fc270..9195e7a65 100644 --- a/client/gui/AEBaseGui.java +++ b/client/gui/AEBaseGui.java @@ -67,7 +67,8 @@ public abstract class AEBaseGui extends GuiContainer static public boolean switchingGuis; private boolean subGui; - public AEBaseGui(Container container) { + public AEBaseGui(Container container) + { super( container ); subGui = switchingGuis; switchingGuis = false; @@ -417,14 +418,17 @@ public abstract class AEBaseGui extends GuiContainer if ( slot instanceof SlotFake && itemstack != null ) { - try + if ( c == 0 ) { - PacketInventoryAction p = new PacketInventoryAction( InventoryAction.PICKUP_OR_SETDOWN, slot.slotNumber, 0 ); - NetworkHandler.instance.sendToServer( p ); - } - catch (IOException e) - { - AELog.error( e ); + try + { + PacketInventoryAction p = new PacketInventoryAction( InventoryAction.PICKUP_OR_SETDOWN, slot.slotNumber, 0 ); + NetworkHandler.instance.sendToServer( p ); + } + catch (IOException e) + { + AELog.error( e ); + } } } else From 961cb8e4a91b901bcc9394bc4acad6f68269d77f Mon Sep 17 00:00:00 2001 From: AlgorithmX2 Date: Thu, 18 Sep 2014 22:56:31 -0500 Subject: [PATCH 07/10] very silly fix cause Reika decided to pair the wheat with its technical block. --- core/Registration.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/core/Registration.java b/core/Registration.java index 7c83f0ff8..74a9c4a69 100644 --- a/core/Registration.java +++ b/core/Registration.java @@ -9,6 +9,7 @@ import net.minecraft.world.biome.BiomeGenBase; import net.minecraftforge.common.ChestGenHooks; import net.minecraftforge.common.DimensionManager; import net.minecraftforge.common.MinecraftForge; +import net.minecraftforge.oredict.OreDictionary; import net.minecraftforge.oredict.RecipeSorter; import net.minecraftforge.oredict.RecipeSorter.Category; import appeng.api.AEApi; @@ -186,7 +187,8 @@ public class Registration public RecipeHandler recipeHandler; public BiomeGenBase storageBiome; - private Registration() { + private Registration() + { recipeHandler = new RecipeHandler(); } @@ -704,6 +706,9 @@ public class Registration mr.whiteListTileEntity( net.minecraft.tileentity.TileEntityNote.class ); mr.whiteListTileEntity( net.minecraft.tileentity.TileEntityHopper.class ); + // very silly fix cause Reika decided to pair the item with a block. + OreDictionary.registerOre( "itemWheat", net.minecraft.init.Items.wheat ); + /** * Whitelist AE2 */ From d9060b7ca59db5e6510d8c2ed52643c87d1b69ee Mon Sep 17 00:00:00 2001 From: AlgorithmX2 Date: Fri, 19 Sep 2014 11:20:06 -0500 Subject: [PATCH 08/10] Undo broken caching feature; replace with special case for IMEMonitors should at least be more optimized then two loops. --- crafting/CraftingJob.java | 3 +- crafting/MECraftingInventory.java | 81 ++++++++++++------------------- 2 files changed, 31 insertions(+), 53 deletions(-) diff --git a/crafting/CraftingJob.java b/crafting/CraftingJob.java index f0b608d0d..5ddf0e77a 100644 --- a/crafting/CraftingJob.java +++ b/crafting/CraftingJob.java @@ -77,8 +77,7 @@ public class CraftingJob implements Runnable, ICraftingJob this.callback = callback; ICraftingGrid cc = grid.getCache( ICraftingGrid.class ); IStorageGrid sg = grid.getCache( IStorageGrid.class ); - original = new MECraftingInventory( sg.getItemInventory(), false, false, false ); - original.filterPermissions( actionSrc ); + original = new MECraftingInventory( sg.getItemInventory(), actionSrc, false, false, false ); tree = getCraftingTree( cc, what ); availableCheck = null; diff --git a/crafting/MECraftingInventory.java b/crafting/MECraftingInventory.java index bfc986946..781afe642 100644 --- a/crafting/MECraftingInventory.java +++ b/crafting/MECraftingInventory.java @@ -4,6 +4,7 @@ import appeng.api.AEApi; import appeng.api.config.Actionable; import appeng.api.networking.security.BaseActionSource; import appeng.api.storage.IMEInventory; +import appeng.api.storage.IMEMonitor; import appeng.api.storage.StorageChannel; import appeng.api.storage.data.IAEItemStack; import appeng.api.storage.data.IItemList; @@ -16,9 +17,6 @@ public class MECraftingInventory implements IMEInventory final IMEInventory target; final IItemList localCache; - private BaseActionSource usePermissions = null; - private final IItemList permissionsCache = AEApi.instance().storage().createItemList(); - final boolean logExtracted; final IItemList extractedCache; @@ -28,26 +26,6 @@ public class MECraftingInventory implements IMEInventory final boolean logMissing; final IItemList missingCache; - private void filter(IAEItemStack input, BaseActionSource src) - { - if ( usePermissions != null && input != null ) - { - if ( permissionsCache.findPrecise( input ) == null ) - { - IAEItemStack what = input.copy(); - what.setStackSize( 1 ); - permissionsCache.add( what ); - - IAEItemStack localItem = localCache.findPrecise( input ); - if ( localItem != null ) - { - IAEItemStack realSize = target.extractItems( input, Actionable.SIMULATE, usePermissions ); - localItem.setStackSize( realSize == null ? 0 : realSize.getStackSize() ); - } - } - } - } - public MECraftingInventory() { localCache = AEApi.instance().storage().createItemList(); @@ -67,10 +45,6 @@ public class MECraftingInventory implements IMEInventory this.logExtracted = parrent.logExtracted; this.logInjections = parrent.logInjections; this.logMissing = parrent.logMissing; - this.usePermissions = parrent.usePermissions; - - for (IAEItemStack is : parrent.permissionsCache) - permissionsCache.add( is ); if ( logMissing ) missingCache = AEApi.instance().storage().createItemList(); @@ -92,20 +66,41 @@ public class MECraftingInventory implements IMEInventory par = parrent; } - public MECraftingInventory(IMEInventory target, boolean logExtracted, boolean logInjections, boolean logMissing) + public MECraftingInventory(IMEMonitor target, BaseActionSource src, boolean logExtracted, boolean logInjections, boolean logMissing) { this.target = target; this.logExtracted = logExtracted; this.logInjections = logInjections; this.logMissing = logMissing; - if ( target instanceof MECraftingInventory ) - { - MECraftingInventory parrent = (MECraftingInventory) target; - this.usePermissions = parrent.usePermissions; - for (IAEItemStack is : parrent.permissionsCache) - permissionsCache.add( is ); - } + if ( logMissing ) + missingCache = AEApi.instance().storage().createItemList(); + else + missingCache = null; + + if ( logExtracted ) + extractedCache = AEApi.instance().storage().createItemList(); + else + extractedCache = null; + + if ( logInjections ) + injectedCache = AEApi.instance().storage().createItemList(); + else + injectedCache = null; + + localCache = AEApi.instance().storage().createItemList(); + for ( IAEItemStack is : target.getStorageList() ) + localCache.add( target.extractItems(is, Actionable.SIMULATE, src ) ); + + par = null; + } + + public MECraftingInventory(IMEInventory target, boolean logExtracted, boolean logInjections, boolean logMissing) + { + this.target = target; + this.logExtracted = logExtracted; + this.logInjections = logInjections; + this.logMissing = logMissing; if ( logMissing ) missingCache = AEApi.instance().storage().createItemList(); @@ -126,19 +121,12 @@ public class MECraftingInventory implements IMEInventory par = null; } - public void filterPermissions(BaseActionSource src) - { - usePermissions = src; - } - @Override public IAEItemStack injectItems(IAEItemStack input, Actionable mode, BaseActionSource src) { if ( input == null ) return null; - filter( input, src ); - if ( mode == Actionable.MODULATE ) { if ( logInjections ) @@ -155,8 +143,6 @@ public class MECraftingInventory implements IMEInventory if ( request == null ) return null; - filter( request, src ); - IAEItemStack list = localCache.findPrecise( request ); if ( list == null || list.getStackSize() == 0 ) return null; @@ -274,12 +260,5 @@ public class MECraftingInventory implements IMEInventory IAEItemStack list = localCache.findPrecise( what ); if ( list != null ) list.setStackSize( 0 ); - - if ( usePermissions != null ) - { - IAEItemStack hmm = what.copy(); - hmm.setStackSize( 1 ); - permissionsCache.add( hmm ); - } } } From 68cc7fd5f71ad3877287bbf7853cc4b2e9d135a4 Mon Sep 17 00:00:00 2001 From: AlgorithmX2 Date: Fri, 19 Sep 2014 20:34:25 -0500 Subject: [PATCH 09/10] Fixed Fake Slot Dragging Behavior ( Fixed Bug: #1108 ) --- client/gui/AEBaseGui.java | 22 +++++++++++++++++++--- container/AEBaseContainer.java | 12 +++++++++++- helpers/InventoryAction.java | 2 +- 3 files changed, 31 insertions(+), 5 deletions(-) diff --git a/client/gui/AEBaseGui.java b/client/gui/AEBaseGui.java index 9195e7a65..65bafe005 100644 --- a/client/gui/AEBaseGui.java +++ b/client/gui/AEBaseGui.java @@ -4,9 +4,11 @@ import java.io.IOException; import java.text.DecimalFormat; import java.text.ParseException; import java.util.Collection; +import java.util.HashSet; import java.util.Iterator; import java.util.LinkedList; import java.util.List; +import java.util.Set; import java.util.concurrent.TimeUnit; import net.minecraft.client.Minecraft; @@ -159,6 +161,8 @@ public abstract class AEBaseGui extends GuiContainer @Override protected void mouseClicked(int xCoord, int yCoord, int btn) { + drag_click.clear(); + if ( btn == 1 ) { for (Object o : this.buttonList) @@ -171,6 +175,7 @@ public abstract class AEBaseGui extends GuiContainer } } } + super.mouseClicked( xCoord, yCoord, btn ); } @@ -179,6 +184,9 @@ public abstract class AEBaseGui extends GuiContainer ItemStack dbl_whichItem; Slot bl_clicked; + // dragy + Set drag_click = new HashSet(); + @Override protected void handleMouseClick(Slot slot, int slotIdx, int ctrlDown, int key) { @@ -189,6 +197,9 @@ public abstract class AEBaseGui extends GuiContainer InventoryAction action = null; action = ctrlDown == 1 ? InventoryAction.SPLIT_OR_PLACESINGLE : InventoryAction.PICKUP_OR_SETDOWN; + if ( drag_click.size() > 1 ) + return; + if ( action != null ) { try @@ -418,12 +429,17 @@ public abstract class AEBaseGui extends GuiContainer if ( slot instanceof SlotFake && itemstack != null ) { - if ( c == 0 ) + drag_click.add( slot ); + if ( drag_click.size() > 1 ) { try { - PacketInventoryAction p = new PacketInventoryAction( InventoryAction.PICKUP_OR_SETDOWN, slot.slotNumber, 0 ); - NetworkHandler.instance.sendToServer( p ); + for (Slot dr : drag_click) + { + PacketInventoryAction p = new PacketInventoryAction( c == 0 ? InventoryAction.PICKUP_OR_SETDOWN : InventoryAction.PLACE_SINGLE, + dr.slotNumber, 0 ); + NetworkHandler.instance.sendToServer( p ); + } } catch (IOException e) { diff --git a/container/AEBaseContainer.java b/container/AEBaseContainer.java index 05735d60a..9cf1dc2e8 100644 --- a/container/AEBaseContainer.java +++ b/container/AEBaseContainer.java @@ -676,7 +676,7 @@ public abstract class AEBaseContainer extends Container else addSlotToContainer( new SlotPlayerHotBar( inventoryPlayer, i, 8 + i * 18 + offset_x, 58 + offset_y ) ); } - + for (int i = 0; i < 3; i++) { for (int j = 0; j < 9; j++) @@ -731,6 +731,16 @@ public abstract class AEBaseContainer extends Container else s.putStack( hand.copy() ); + break; + case PLACE_SINGLE: + + if ( hand != null ) + { + ItemStack is = hand.copy(); + is.stackSize = 1; + s.putStack( is ); + } + break; case SPLIT_OR_PLACESINGLE: diff --git a/helpers/InventoryAction.java b/helpers/InventoryAction.java index 661a1e3ba..de7589318 100644 --- a/helpers/InventoryAction.java +++ b/helpers/InventoryAction.java @@ -9,5 +9,5 @@ public enum InventoryAction CRAFT_STACK, CRAFT_ITEM, CRAFT_SHIFT, // extra... - MOVE_REGION, PICKUP_SINGLE, UPDATE_HAND, ROLLUP, ROLLDOWN, AUTOCRAFT + MOVE_REGION, PICKUP_SINGLE, UPDATE_HAND, ROLLUP, ROLLDOWN, AUTOCRAFT, PLACE_SINGLE } From 4533d1893b4ebe883ac28d52478f0f91afda555c Mon Sep 17 00:00:00 2001 From: AlgorithmX2 Date: Fri, 19 Sep 2014 21:00:07 -0500 Subject: [PATCH 10/10] Fixed Bug: #1109 - Autocraft calculation issue when trying to split --- crafting/MECraftingInventory.java | 38 ++++++++++++++++++------------- 1 file changed, 22 insertions(+), 16 deletions(-) diff --git a/crafting/MECraftingInventory.java b/crafting/MECraftingInventory.java index 781afe642..365fdc7a4 100644 --- a/crafting/MECraftingInventory.java +++ b/crafting/MECraftingInventory.java @@ -89,9 +89,9 @@ public class MECraftingInventory implements IMEInventory injectedCache = null; localCache = AEApi.instance().storage().createItemList(); - for ( IAEItemStack is : target.getStorageList() ) - localCache.add( target.extractItems(is, Actionable.SIMULATE, src ) ); - + for (IAEItemStack is : target.getStorageList()) + localCache.add( target.extractItems( is, Actionable.SIMULATE, src ) ); + par = null; } @@ -147,21 +147,27 @@ public class MECraftingInventory implements IMEInventory if ( list == null || list.getStackSize() == 0 ) return null; - if ( mode == Actionable.MODULATE && logExtracted ) - extractedCache.add( request ); - if ( list.getStackSize() >= request.getStackSize() ) { if ( mode == Actionable.MODULATE ) + { list.decStackSize( request.getStackSize() ); + if ( logExtracted ) + extractedCache.add( request ); + } return request; } IAEItemStack ret = request.copy(); ret.setStackSize( list.getStackSize() ); + if ( mode == Actionable.MODULATE ) + { list.reset(); + if ( logExtracted ) + extractedCache.add( ret ); + } return ret; } @@ -192,14 +198,14 @@ public class MECraftingInventory implements IMEInventory IItemList pulled = AEApi.instance().storage().createItemList(); boolean failed = false; - if ( logExtracted ) + if ( logInjections ) { - for (IAEItemStack extra : extractedCache) + for (IAEItemStack injec : injectedCache) { IAEItemStack result = null; - pulled.add( result = target.extractItems( extra, Actionable.MODULATE, src ) ); + added.add( result = target.injectItems( injec, Actionable.MODULATE, src ) ); - if ( result == null || result.getStackSize() != extra.getStackSize() ) + if ( result != null ) { failed = true; break; @@ -209,20 +215,20 @@ public class MECraftingInventory implements IMEInventory if ( failed ) { - for (IAEItemStack is : pulled) - target.injectItems( is, Actionable.MODULATE, src ); + for (IAEItemStack is : added) + target.extractItems( is, Actionable.MODULATE, src ); return false; } - if ( logInjections ) + if ( logExtracted ) { - for (IAEItemStack injec : injectedCache) + for (IAEItemStack extra : extractedCache) { IAEItemStack result = null; - added.add( result = target.injectItems( injec, Actionable.MODULATE, src ) ); + pulled.add( result = target.extractItems( extra, Actionable.MODULATE, src ) ); - if ( result != null ) + if ( result == null || result.getStackSize() != extra.getStackSize() ) { failed = true; break;