From fede238251ab89c1553a928087804b6cc13bb9bb Mon Sep 17 00:00:00 2001 From: AlgorithmX2 Date: Tue, 3 Jun 2014 12:08:33 -0500 Subject: [PATCH 1/4] Formation Planes can now Place Heads. --- parts/automation/PartFormationPlane.java | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/parts/automation/PartFormationPlane.java b/parts/automation/PartFormationPlane.java index add143f6c..7e89cebad 100644 --- a/parts/automation/PartFormationPlane.java +++ b/parts/automation/PartFormationPlane.java @@ -9,6 +9,7 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.IInventory; import net.minecraft.item.Item; import net.minecraft.item.ItemBlock; +import net.minecraft.item.ItemSkull; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; @@ -379,7 +380,7 @@ public class PartFormationPlane extends PartUpgradeable implements ICellContaine if ( w.getBlock( x, y, z ).isReplaceable( w, x, y, z ) ) { - if ( i instanceof ItemBlock || i instanceof IPlantable ) + if ( i instanceof ItemBlock || i instanceof IPlantable || i instanceof ItemSkull ) { EntityPlayer player = Platform.getPlayer( (WorldServer) w ); Platform.configurePlayer( player, side, tile ); @@ -388,7 +389,7 @@ public class PartFormationPlane extends PartUpgradeable implements ICellContaine worked = true; if ( type == Actionable.MODULATE ) { - if ( i instanceof IPlantable ) + if ( i instanceof IPlantable || i instanceof ItemSkull ) { boolean Worked = false; @@ -396,14 +397,16 @@ public class PartFormationPlane extends PartUpgradeable implements ICellContaine 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.offsetX == 0 && side.offsetZ == 0 ) + Worked = i.onItemUse( is, player, w, x-side.offsetX, y-side.offsetY, z-side.offsetZ, side.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; + maxStorage = maxStorage - is.stackSize; } else { From e6c80df3c86295708a7674d66ebf3f85505b511a Mon Sep 17 00:00:00 2001 From: AlgorithmX2 Date: Tue, 3 Jun 2014 13:00:10 -0500 Subject: [PATCH 2/4] Added support for parts too. --- parts/automation/PartFormationPlane.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/parts/automation/PartFormationPlane.java b/parts/automation/PartFormationPlane.java index 7e89cebad..5f1a8d610 100644 --- a/parts/automation/PartFormationPlane.java +++ b/parts/automation/PartFormationPlane.java @@ -34,6 +34,7 @@ import appeng.api.networking.security.BaseActionSource; import appeng.api.parts.IPart; import appeng.api.parts.IPartCollsionHelper; import appeng.api.parts.IPartHost; +import appeng.api.parts.IPartItem; import appeng.api.parts.IPartRenderHelper; import appeng.api.storage.ICellContainer; import appeng.api.storage.IMEInventory; @@ -380,7 +381,7 @@ public class PartFormationPlane extends PartUpgradeable implements ICellContaine if ( w.getBlock( x, y, z ).isReplaceable( w, x, y, z ) ) { - if ( i instanceof ItemBlock || i instanceof IPlantable || i instanceof ItemSkull ) + if ( i instanceof ItemBlock || i instanceof IPlantable || i instanceof ItemSkull || i instanceof IPartItem ) { EntityPlayer player = Platform.getPlayer( (WorldServer) w ); Platform.configurePlayer( player, side, tile ); From 09ef3cc2314cbc5bb79d1e5dfe34eb81ec64d9a3 Mon Sep 17 00:00:00 2001 From: AlgorithmX2 Date: Tue, 3 Jun 2014 20:32:33 -0500 Subject: [PATCH 3/4] Protect AE2 from BC's shenanigans. --- integration/modules/BC.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/integration/modules/BC.java b/integration/modules/BC.java index 17babcd7a..020079bd6 100644 --- a/integration/modules/BC.java +++ b/integration/modules/BC.java @@ -319,7 +319,8 @@ public class BC extends BaseModule implements IBC if ( blk == null || blk.length < 1 ) return null; - return new ItemStack( blk[0], 1, meta[0] ); + if ( blk[0] != null ) + return new ItemStack( blk[0], 1, meta[0] ); } catch (Throwable t) { @@ -329,7 +330,8 @@ public class BC extends BaseModule implements IBC try { Block blk = ItemFacade.getBlock( facade ); - return new ItemStack( blk, 1, ItemFacade.getMetaData( facade ) ); + if ( blk != null ) + return new ItemStack( blk, 1, ItemFacade.getMetaData( facade ) ); } catch (Throwable t) { From 885bdbf9d51515520e7bbbe4d49a306e3205bb0d Mon Sep 17 00:00:00 2001 From: AlgorithmX2 Date: Tue, 3 Jun 2014 20:33:04 -0500 Subject: [PATCH 4/4] More intelligent funneling demand. --- tile/networking/TileController.java | 4 ++-- tile/networking/TileEnergyAcceptor.java | 14 ++++++++++++++ tile/powersink/AERootPoweredTile.java | 6 +++--- tile/powersink/IC2.java | 2 +- tile/powersink/MinecraftJoules5.java | 2 +- tile/powersink/MinecraftJoules6.java | 2 +- tile/powersink/RedstoneFlux.java | 4 ++-- 7 files changed, 24 insertions(+), 10 deletions(-) diff --git a/tile/networking/TileController.java b/tile/networking/TileController.java index beb5ffdfc..4516513c1 100644 --- a/tile/networking/TileController.java +++ b/tile/networking/TileController.java @@ -39,7 +39,7 @@ public class TileController extends AENetworkPowerTile implements IAEPowerStorag } @Override - protected double getFunnelPowerDemand() + protected double getFunnelPowerDemand(double maxRecived) { try { @@ -48,7 +48,7 @@ public class TileController extends AENetworkPowerTile implements IAEPowerStorag catch (GridAccessException e) { // no grid? use local... - return super.getFunnelPowerDemand(); + return super.getFunnelPowerDemand( maxRecived ); } } diff --git a/tile/networking/TileEnergyAcceptor.java b/tile/networking/TileEnergyAcceptor.java index b44f96f3c..29a262fcb 100644 --- a/tile/networking/TileEnergyAcceptor.java +++ b/tile/networking/TileEnergyAcceptor.java @@ -57,6 +57,20 @@ public class TileEnergyAcceptor extends AENetworkPowerTile } }; + @Override + protected double getFunnelPowerDemand(double maxRequired) + { + try + { + IEnergyGrid grid = gridProxy.getEnergy(); + return grid.getEnergyDemand( maxRequired ); + } + catch (GridAccessException e) + { + return super.getFunnelPowerDemand( maxRequired ); + } + } + @Override protected double funnelPowerIntoStorage(double newPower, Actionable mode) { diff --git a/tile/powersink/AERootPoweredTile.java b/tile/powersink/AERootPoweredTile.java index 283862306..b6c3cadfd 100644 --- a/tile/powersink/AERootPoweredTile.java +++ b/tile/powersink/AERootPoweredTile.java @@ -65,12 +65,12 @@ public abstract class AERootPoweredTile extends AEBaseInvTile implements IAEPowe addNewHandler( new AEPoweredRootHandler() ); } - final protected double getExternalPowerDemand(PowerUnits externalUnit) + final protected double getExternalPowerDemand(PowerUnits externalUnit, double maxPowerRequired) { - return PowerUnits.AE.convertTo( externalUnit, Math.max( 0.0, getFunnelPowerDemand() ) ); + return PowerUnits.AE.convertTo( externalUnit, Math.max( 0.0, getFunnelPowerDemand( externalUnit.convertTo( PowerUnits.AE, maxPowerRequired ) ) ) ); } - protected double getFunnelPowerDemand() + protected double getFunnelPowerDemand(double maxRequired) { return internalMaxPower - internalCurrentPower; } diff --git a/tile/powersink/IC2.java b/tile/powersink/IC2.java index 680caab4f..9f92355af 100644 --- a/tile/powersink/IC2.java +++ b/tile/powersink/IC2.java @@ -27,7 +27,7 @@ public abstract class IC2 extends MinecraftJoules6 implements IEnergySink @Override final public double demandedEnergyUnits() { - return getExternalPowerDemand( PowerUnits.EU ); + return getExternalPowerDemand( PowerUnits.EU, Double.MAX_VALUE ); } @Override diff --git a/tile/powersink/MinecraftJoules5.java b/tile/powersink/MinecraftJoules5.java index 001c77aa0..d16c58f30 100644 --- a/tile/powersink/MinecraftJoules5.java +++ b/tile/powersink/MinecraftJoules5.java @@ -55,7 +55,7 @@ public abstract class MinecraftJoules5 extends AERootPoweredTile implements IPow @Method(iname = "MJ5") final public void doWork(PowerHandler workProvider) { - float requred = (float) getExternalPowerDemand( PowerUnits.MJ ); + float requred = (float) getExternalPowerDemand( PowerUnits.MJ, bcPowerWrapper.getPowerReceiver().getEnergyStored() ); double failed = injectExternalPower( PowerUnits.MJ, bcPowerWrapper.useEnergy( 0.0f, requred, true ) ); if ( failed > 0.01 ) bcPowerWrapper.addEnergy( (float) failed ); diff --git a/tile/powersink/MinecraftJoules6.java b/tile/powersink/MinecraftJoules6.java index a4588668c..bab841c35 100644 --- a/tile/powersink/MinecraftJoules6.java +++ b/tile/powersink/MinecraftJoules6.java @@ -23,7 +23,7 @@ public abstract class MinecraftJoules6 extends MinecraftJoules5 implements IBatt @Method(iname = "MJ6") public double getEnergyRequested() { - return getExternalPowerDemand( PowerUnits.MJ ); + return getExternalPowerDemand( PowerUnits.MJ, Double.MAX_VALUE ); } @Override diff --git a/tile/powersink/RedstoneFlux.java b/tile/powersink/RedstoneFlux.java index 765cda86c..962e9ce5e 100644 --- a/tile/powersink/RedstoneFlux.java +++ b/tile/powersink/RedstoneFlux.java @@ -14,14 +14,14 @@ public abstract class RedstoneFlux extends RotaryCraft implements IEnergyHandler { if ( simulate ) { - double demand = getExternalPowerDemand( PowerUnits.RF ); + double demand = getExternalPowerDemand( PowerUnits.RF, maxReceive ); if ( demand > maxReceive ) return maxReceive; return (int) Math.floor( maxReceive - demand ); } else { - int demand = (int) Math.floor( getExternalPowerDemand( PowerUnits.RF ) ); + int demand = (int) Math.floor( getExternalPowerDemand( PowerUnits.RF, maxReceive ) ); int ignored = 0; int insertAmt = maxReceive;