Added IBlockDefaultTriggers.
Prevent DefaultTriggerProvider from adding triggers, but allow other providers to add their own. This is a more friendly version of IOverrideDefaultTriggers.
This commit is contained in:
parent
16831f6947
commit
99ee6ab927
5 changed files with 53 additions and 36 deletions
23
api/buildcraft/api/statements/IBlockDefaultTriggers.java
Normal file
23
api/buildcraft/api/statements/IBlockDefaultTriggers.java
Normal file
|
@ -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);
|
||||||
|
}
|
|
@ -88,17 +88,17 @@ public final class StatementManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static List<IActionExternal> getExternalActions(ForgeDirection side, TileEntity entity) {
|
public static List<IActionExternal> getExternalActions(ForgeDirection side, TileEntity entity) {
|
||||||
List<IActionExternal> result = new LinkedList<IActionExternal>();
|
List<IActionExternal> result;
|
||||||
|
|
||||||
if (entity instanceof IOverrideDefaultStatements) {
|
if (entity instanceof IOverrideDefaultStatements) {
|
||||||
result = ((IOverrideDefaultStatements) entity).overrideActions();
|
result = ((IOverrideDefaultStatements) entity).overrideActions();
|
||||||
if (result != null) {
|
if (result != null) {
|
||||||
return result;
|
return result;
|
||||||
} else {
|
|
||||||
result = new LinkedList<IActionExternal>();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
result = new LinkedList<IActionExternal>();
|
||||||
|
|
||||||
for (IActionProvider provider : actionProviders) {
|
for (IActionProvider provider : actionProviders) {
|
||||||
Collection<IActionExternal> toAdd = provider.getExternalActions(side, entity);
|
Collection<IActionExternal> toAdd = provider.getExternalActions(side, entity);
|
||||||
|
|
||||||
|
|
|
@ -19,6 +19,8 @@ import net.minecraftforge.fluids.FluidTankInfo;
|
||||||
import net.minecraftforge.fluids.IFluidHandler;
|
import net.minecraftforge.fluids.IFluidHandler;
|
||||||
|
|
||||||
import buildcraft.BuildCraftCore;
|
import buildcraft.BuildCraftCore;
|
||||||
|
|
||||||
|
import buildcraft.api.statements.IBlockDefaultTriggers;
|
||||||
import buildcraft.api.statements.IStatementContainer;
|
import buildcraft.api.statements.IStatementContainer;
|
||||||
import buildcraft.api.statements.ITriggerExternal;
|
import buildcraft.api.statements.ITriggerExternal;
|
||||||
import buildcraft.api.statements.ITriggerInternal;
|
import buildcraft.api.statements.ITriggerInternal;
|
||||||
|
@ -31,7 +33,15 @@ public class DefaultTriggerProvider implements ITriggerProvider {
|
||||||
public LinkedList<ITriggerExternal> getExternalTriggers(ForgeDirection side, TileEntity tile) {
|
public LinkedList<ITriggerExternal> getExternalTriggers(ForgeDirection side, TileEntity tile) {
|
||||||
LinkedList<ITriggerExternal> res = new LinkedList<ITriggerExternal>();
|
LinkedList<ITriggerExternal> res = new LinkedList<ITriggerExternal>();
|
||||||
|
|
||||||
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 isSided = tile instanceof ISidedInventory;
|
||||||
boolean addTriggers = false;
|
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());
|
FluidTankInfo[] tanks = ((IFluidHandler) tile).getTankInfo(side.getOpposite());
|
||||||
if (tanks != null && tanks.length > 0) {
|
if (tanks != null && tanks.length > 0) {
|
||||||
res.add(BuildCraftCore.triggerEmptyFluid);
|
res.add(BuildCraftCore.triggerEmptyFluid);
|
||||||
|
|
|
@ -8,9 +8,6 @@
|
||||||
*/
|
*/
|
||||||
package buildcraft.energy;
|
package buildcraft.energy;
|
||||||
|
|
||||||
import java.util.LinkedList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
import net.minecraft.inventory.Container;
|
import net.minecraft.inventory.Container;
|
||||||
import net.minecraft.inventory.ICrafting;
|
import net.minecraft.inventory.ICrafting;
|
||||||
|
@ -26,7 +23,6 @@ import net.minecraftforge.fluids.FluidStack;
|
||||||
import net.minecraftforge.fluids.FluidTankInfo;
|
import net.minecraftforge.fluids.FluidTankInfo;
|
||||||
import net.minecraftforge.fluids.IFluidHandler;
|
import net.minecraftforge.fluids.IFluidHandler;
|
||||||
|
|
||||||
import buildcraft.BuildCraftCore;
|
|
||||||
import buildcraft.BuildCraftEnergy;
|
import buildcraft.BuildCraftEnergy;
|
||||||
|
|
||||||
import buildcraft.api.core.StackKey;
|
import buildcraft.api.core.StackKey;
|
||||||
|
@ -34,9 +30,7 @@ import buildcraft.api.fuels.BuildcraftFuelRegistry;
|
||||||
import buildcraft.api.fuels.ICoolant;
|
import buildcraft.api.fuels.ICoolant;
|
||||||
import buildcraft.api.fuels.IFuel;
|
import buildcraft.api.fuels.IFuel;
|
||||||
import buildcraft.api.fuels.ISolidCoolant;
|
import buildcraft.api.fuels.ISolidCoolant;
|
||||||
import buildcraft.api.statements.IActionExternal;
|
import buildcraft.api.statements.IBlockDefaultTriggers;
|
||||||
import buildcraft.api.statements.IOverrideDefaultStatements;
|
|
||||||
import buildcraft.api.statements.ITriggerExternal;
|
|
||||||
import buildcraft.api.transport.IItemPipe;
|
import buildcraft.api.transport.IItemPipe;
|
||||||
|
|
||||||
import buildcraft.core.GuiIds;
|
import buildcraft.core.GuiIds;
|
||||||
|
@ -46,7 +40,7 @@ import buildcraft.core.lib.fluids.TankManager;
|
||||||
import buildcraft.core.lib.fluids.TankUtils;
|
import buildcraft.core.lib.fluids.TankUtils;
|
||||||
import buildcraft.core.lib.inventory.InvUtils;
|
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 int MAX_LIQUID = FluidContainerRegistry.BUCKET_VOLUME * 10;
|
||||||
public static float HEAT_PER_RF = 0.00023F;
|
public static float HEAT_PER_RF = 0.00023F;
|
||||||
|
@ -477,31 +471,12 @@ public class TileEngineIron extends TileEngineWithInventory implements IFluidHan
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<ITriggerExternal> overrideTriggers() {
|
public boolean blockInventoryTriggers(ForgeDirection side) {
|
||||||
List<ITriggerExternal> triggers = new LinkedList<ITriggerExternal>();
|
return false;
|
||||||
|
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<IActionExternal> overrideActions() {
|
public boolean blockFluidHandlerTriggers(ForgeDirection side) {
|
||||||
return null;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,6 +21,7 @@ import buildcraft.api.statements.ITriggerExternal;
|
||||||
import buildcraft.api.statements.ITriggerInternal;
|
import buildcraft.api.statements.ITriggerInternal;
|
||||||
import buildcraft.api.statements.ITriggerProvider;
|
import buildcraft.api.statements.ITriggerProvider;
|
||||||
import buildcraft.core.lib.engines.TileEngineBase;
|
import buildcraft.core.lib.engines.TileEngineBase;
|
||||||
|
import buildcraft.energy.TileEngineIron;
|
||||||
|
|
||||||
public class EnergyStatementProvider implements ITriggerProvider {
|
public class EnergyStatementProvider implements ITriggerProvider {
|
||||||
|
|
||||||
|
@ -41,6 +42,14 @@ public class EnergyStatementProvider implements ITriggerProvider {
|
||||||
triggers.add(BuildCraftEnergy.triggerEngineOverheat);
|
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;
|
return triggers;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue