From 3d120025e1123051405db13f19b4f723803541d0 Mon Sep 17 00:00:00 2001 From: Prototik Date: Mon, 12 May 2014 17:56:07 +0800 Subject: [PATCH 1/2] Remove unnecessary extends for ISidedBatteryProvider interface --- .../api/mj/ISidedBatteryProvider.java | 10 +++---- api/buildcraft/api/mj/MjAPI.java | 26 +++++++++---------- 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/api/buildcraft/api/mj/ISidedBatteryProvider.java b/api/buildcraft/api/mj/ISidedBatteryProvider.java index 3ffc8584..46adb69d 100644 --- a/api/buildcraft/api/mj/ISidedBatteryProvider.java +++ b/api/buildcraft/api/mj/ISidedBatteryProvider.java @@ -1,15 +1,15 @@ /** - * Copyright (c) 2014, Prototik and the BuildFactory Team - * http://buildfactory.org/ + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com * - * BuildFactory is distributed under the terms of the Minecraft Mod Public + * BuildCraft is distributed under the terms of the Minecraft Mod Public * License 1.0, or MMPL. Please check the contents of the license located in - * http://buildfactory.org/license + * http://www.mod-buildcraft.com/MMPL-1.0.txt */ package buildcraft.api.mj; import net.minecraftforge.common.util.ForgeDirection; -public interface ISidedBatteryProvider extends IBatteryProvider { +public interface ISidedBatteryProvider { IBatteryObject getMjBattery(String kind, ForgeDirection direction); } diff --git a/api/buildcraft/api/mj/MjAPI.java b/api/buildcraft/api/mj/MjAPI.java index 08cb2dc5..1a64b803 100755 --- a/api/buildcraft/api/mj/MjAPI.java +++ b/api/buildcraft/api/mj/MjAPI.java @@ -65,21 +65,21 @@ public final class MjAPI { return null; } + IBatteryObject battery = null; + + if (o instanceof ISidedBatteryProvider) { + battery = ((ISidedBatteryProvider) o).getMjBattery(kind, side); + if (battery == null && side != ForgeDirection.UNKNOWN) { + battery = ((ISidedBatteryProvider) o).getMjBattery(kind, ForgeDirection.UNKNOWN); + } + } + if (o instanceof IBatteryProvider) { - IBatteryObject battery; + battery = ((IBatteryProvider) o).getMjBattery(kind); + } - if (o instanceof ISidedBatteryProvider) { - battery = ((ISidedBatteryProvider) o).getMjBattery(kind, side); - if (battery == null && side != ForgeDirection.UNKNOWN) { - battery = ((ISidedBatteryProvider) o).getMjBattery(kind, ForgeDirection.UNKNOWN); - } - } else { - battery = ((IBatteryProvider) o).getMjBattery(kind); - } - - if (battery != null) { - return battery; - } + if (battery != null) { + return battery; } BatteryField f = getMjBatteryField(o.getClass(), kind, side); From 08edcf1759c884cb95b66c53427bbd4b3f3d9751 Mon Sep 17 00:00:00 2001 From: Leon LoeseR Date: Mon, 12 May 2014 20:22:17 +0200 Subject: [PATCH 2/2] Fix drain method causing dupe glitches... ...if using them mixed Before the one accepting a FluidStack always returned null if the targeted tank was empty, but the one under it wasnt, the one w/ int doesnt have the problem. --- common/buildcraft/factory/TileTank.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/common/buildcraft/factory/TileTank.java b/common/buildcraft/factory/TileTank.java index 3205106c..337ba3a5 100644 --- a/common/buildcraft/factory/TileTank.java +++ b/common/buildcraft/factory/TileTank.java @@ -204,7 +204,8 @@ public class TileTank extends TileBuildCraft implements IFluidHandler { if (resource == null) { return null; } - if (!resource.isFluidEqual(tank.getFluid())) { + TileTank bottom = getBottomTank(); + if (!resource.isFluidEqual(bottom.tank.getFluid())) { return null; } return drain(from, resource.amount, doDrain);