diff --git a/api/buildcraft/api/statements/IBlockDefaultTriggers.java b/api/buildcraft/api/statements/IBlockDefaultTriggers.java new file mode 100644 index 00000000..8a2a421d --- /dev/null +++ b/api/buildcraft/api/statements/IBlockDefaultTriggers.java @@ -0,0 +1,23 @@ +/** + * Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com + * + * The BuildCraft API is distributed under the terms of the MIT License. + * Please check the contents of the license, which should be located + * as "LICENSE.API" in the BuildCraft source code distribution. + */ +package buildcraft.api.statements; + +import net.minecraftforge.common.util.ForgeDirection; + +/** + * A tile entity implementing this interface will be able to prevent BuildCraft from + * adding default triggers. + * + * This does not block other statement providers from adding triggers or actions. + * See IOverrideDefaultStatements for a more aggressive approach. + */ +public interface IBlockDefaultTriggers { + boolean blockInventoryTriggers(ForgeDirection side); + boolean blockFluidHandlerTriggers(ForgeDirection side); +} diff --git a/api/buildcraft/api/statements/StatementManager.java b/api/buildcraft/api/statements/StatementManager.java index 5a9857f7..55721faf 100644 --- a/api/buildcraft/api/statements/StatementManager.java +++ b/api/buildcraft/api/statements/StatementManager.java @@ -88,16 +88,16 @@ public final class StatementManager { } public static List getExternalActions(ForgeDirection side, TileEntity entity) { - List result = new LinkedList(); + List result; if (entity instanceof IOverrideDefaultStatements) { result = ((IOverrideDefaultStatements) entity).overrideActions(); if (result != null) { return result; - } else { - result = new LinkedList(); } } + + result = new LinkedList(); for (IActionProvider provider : actionProviders) { Collection toAdd = provider.getExternalActions(side, entity); diff --git a/common/buildcraft/core/statements/DefaultTriggerProvider.java b/common/buildcraft/core/statements/DefaultTriggerProvider.java index 33910db6..fa1001e4 100644 --- a/common/buildcraft/core/statements/DefaultTriggerProvider.java +++ b/common/buildcraft/core/statements/DefaultTriggerProvider.java @@ -19,6 +19,8 @@ import net.minecraftforge.fluids.FluidTankInfo; import net.minecraftforge.fluids.IFluidHandler; import buildcraft.BuildCraftCore; + +import buildcraft.api.statements.IBlockDefaultTriggers; import buildcraft.api.statements.IStatementContainer; import buildcraft.api.statements.ITriggerExternal; import buildcraft.api.statements.ITriggerInternal; @@ -31,7 +33,15 @@ public class DefaultTriggerProvider implements ITriggerProvider { public LinkedList getExternalTriggers(ForgeDirection side, TileEntity tile) { LinkedList res = new LinkedList(); - if (tile instanceof IInventory) { + boolean blockInventoryTriggers = false; + boolean blockFluidHandlerTriggers = false; + + if (tile instanceof IBlockDefaultTriggers) { + blockInventoryTriggers = ((IBlockDefaultTriggers) tile).blockInventoryTriggers(side); + blockFluidHandlerTriggers = ((IBlockDefaultTriggers) tile).blockFluidHandlerTriggers(side); + } + + if (!blockInventoryTriggers && tile instanceof IInventory) { boolean isSided = tile instanceof ISidedInventory; boolean addTriggers = false; @@ -51,7 +61,7 @@ public class DefaultTriggerProvider implements ITriggerProvider { } } - if (tile instanceof IFluidHandler) { + if (!blockFluidHandlerTriggers && tile instanceof IFluidHandler) { FluidTankInfo[] tanks = ((IFluidHandler) tile).getTankInfo(side.getOpposite()); if (tanks != null && tanks.length > 0) { res.add(BuildCraftCore.triggerEmptyFluid); diff --git a/common/buildcraft/energy/TileEngineIron.java b/common/buildcraft/energy/TileEngineIron.java index 60559890..8716b433 100644 --- a/common/buildcraft/energy/TileEngineIron.java +++ b/common/buildcraft/energy/TileEngineIron.java @@ -8,9 +8,6 @@ */ package buildcraft.energy; -import java.util.LinkedList; -import java.util.List; - import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.Container; import net.minecraft.inventory.ICrafting; @@ -26,7 +23,6 @@ import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.FluidTankInfo; import net.minecraftforge.fluids.IFluidHandler; -import buildcraft.BuildCraftCore; import buildcraft.BuildCraftEnergy; import buildcraft.api.core.StackKey; @@ -34,9 +30,7 @@ import buildcraft.api.fuels.BuildcraftFuelRegistry; import buildcraft.api.fuels.ICoolant; import buildcraft.api.fuels.IFuel; import buildcraft.api.fuels.ISolidCoolant; -import buildcraft.api.statements.IActionExternal; -import buildcraft.api.statements.IOverrideDefaultStatements; -import buildcraft.api.statements.ITriggerExternal; +import buildcraft.api.statements.IBlockDefaultTriggers; import buildcraft.api.transport.IItemPipe; import buildcraft.core.GuiIds; @@ -46,7 +40,7 @@ import buildcraft.core.lib.fluids.TankManager; import buildcraft.core.lib.fluids.TankUtils; import buildcraft.core.lib.inventory.InvUtils; -public class TileEngineIron extends TileEngineWithInventory implements IFluidHandler, IOverrideDefaultStatements { +public class TileEngineIron extends TileEngineWithInventory implements IFluidHandler, IBlockDefaultTriggers { public static int MAX_LIQUID = FluidContainerRegistry.BUCKET_VOLUME * 10; public static float HEAT_PER_RF = 0.00023F; @@ -477,31 +471,12 @@ public class TileEngineIron extends TileEngineWithInventory implements IFluidHan } @Override - public List overrideTriggers() { - List triggers = new LinkedList(); - - triggers.add(BuildCraftCore.triggerEmptyInventory); - triggers.add(BuildCraftCore.triggerContainsInventory); - triggers.add(BuildCraftCore.triggerSpaceInventory); - triggers.add(BuildCraftCore.triggerFullInventory); - - triggers.add(BuildCraftEnergy.triggerBlueEngineHeat); - triggers.add(BuildCraftEnergy.triggerGreenEngineHeat); - triggers.add(BuildCraftEnergy.triggerYellowEngineHeat); - triggers.add(BuildCraftEnergy.triggerRedEngineHeat); - triggers.add(BuildCraftEnergy.triggerEngineOverheat); - - triggers.add(BuildCraftEnergy.triggerCoolantBelow25); - triggers.add(BuildCraftEnergy.triggerCoolantBelow50); - - triggers.add(BuildCraftEnergy.triggerFuelBelow25); - triggers.add(BuildCraftEnergy.triggerFuelBelow50); - - return triggers; + public boolean blockInventoryTriggers(ForgeDirection side) { + return false; } @Override - public List overrideActions() { - return null; + public boolean blockFluidHandlerTriggers(ForgeDirection side) { + return true; } } diff --git a/common/buildcraft/energy/statements/EnergyStatementProvider.java b/common/buildcraft/energy/statements/EnergyStatementProvider.java index b5f55f25..cf2dde78 100644 --- a/common/buildcraft/energy/statements/EnergyStatementProvider.java +++ b/common/buildcraft/energy/statements/EnergyStatementProvider.java @@ -21,6 +21,7 @@ import buildcraft.api.statements.ITriggerExternal; import buildcraft.api.statements.ITriggerInternal; import buildcraft.api.statements.ITriggerProvider; import buildcraft.core.lib.engines.TileEngineBase; +import buildcraft.energy.TileEngineIron; public class EnergyStatementProvider implements ITriggerProvider { @@ -41,6 +42,14 @@ public class EnergyStatementProvider implements ITriggerProvider { triggers.add(BuildCraftEnergy.triggerEngineOverheat); } + if (tile instanceof TileEngineIron) { + triggers.add(BuildCraftEnergy.triggerCoolantBelow25); + triggers.add(BuildCraftEnergy.triggerCoolantBelow50); + + triggers.add(BuildCraftEnergy.triggerFuelBelow25); + triggers.add(BuildCraftEnergy.triggerFuelBelow50); + } + return triggers; }