Merge branch 'marmot' into BuildCraft-5.0.x
This commit is contained in:
commit
87562542c9
9 changed files with 123 additions and 3 deletions
Binary file not shown.
After Width: | Height: | Size: 196 B |
Binary file not shown.
After Width: | Height: | Size: 206 B |
Binary file not shown.
After Width: | Height: | Size: 206 B |
|
@ -57,10 +57,11 @@ gate.trigger.engine.blue=Engine Blue
|
|||
gate.trigger.engine.green=Engine Green
|
||||
gate.trigger.engine.yellow=Engine Yellow
|
||||
gate.trigger.engine.red=Engine Red
|
||||
gate.trigger.fluid.emtpy=Tank Empty
|
||||
gate.trigger.fluid.empty=Tank Empty
|
||||
gate.trigger.fluid.contains=Fluid in Tank
|
||||
gate.trigger.fluid.space=Space for Fluid
|
||||
gate.trigger.fluid.full=Tank Full
|
||||
gate.trigger.fluidlevel.below=Contains < %d%%
|
||||
gate.trigger.inventory.empty=Inventory Empty
|
||||
gate.trigger.inventory.contains=Items in Inventory
|
||||
gate.trigger.inventory.space=Space in Inventory
|
||||
|
|
|
@ -67,6 +67,7 @@ import buildcraft.core.triggers.BCTrigger;
|
|||
import buildcraft.core.triggers.DefaultActionProvider;
|
||||
import buildcraft.core.triggers.DefaultTriggerProvider;
|
||||
import buildcraft.core.triggers.TriggerFluidContainer;
|
||||
import buildcraft.core.triggers.TriggerFluidContainerLevel;
|
||||
import buildcraft.core.triggers.TriggerInventory;
|
||||
import buildcraft.core.triggers.TriggerInventoryLevel;
|
||||
import buildcraft.core.triggers.TriggerMachine;
|
||||
|
@ -145,6 +146,9 @@ public class BuildCraftCore extends BuildCraftMod {
|
|||
public static BCTrigger triggerInventoryBelow25 = new TriggerInventoryLevel(TriggerInventoryLevel.TriggerType.BELOW_25);
|
||||
public static BCTrigger triggerInventoryBelow50 = new TriggerInventoryLevel(TriggerInventoryLevel.TriggerType.BELOW_50);
|
||||
public static BCTrigger triggerInventoryBelow75 = new TriggerInventoryLevel(TriggerInventoryLevel.TriggerType.BELOW_75);
|
||||
public static BCTrigger triggerFluidContainerBelow25 = new TriggerFluidContainerLevel(TriggerFluidContainerLevel.TriggerType.BELOW_25);
|
||||
public static BCTrigger triggerFluidContainerBelow50 = new TriggerFluidContainerLevel(TriggerFluidContainerLevel.TriggerType.BELOW_50);
|
||||
public static BCTrigger triggerFluidContainerBelow75 = new TriggerFluidContainerLevel(TriggerFluidContainerLevel.TriggerType.BELOW_75);
|
||||
public static BCAction actionRedstone = new ActionRedstoneOutput();
|
||||
public static BCAction actionOn = new ActionMachineControl(Mode.On);
|
||||
public static BCAction actionOff = new ActionMachineControl(Mode.Off);
|
||||
|
|
|
@ -51,7 +51,12 @@ public class ActionTriggerIconProvider implements IIconProvider {
|
|||
public static final int Trigger_Inventory_Below25 = 33;
|
||||
public static final int Trigger_Inventory_Below50 = 34;
|
||||
public static final int Trigger_Inventory_Below75 = 35;
|
||||
public static final int MAX = 39;
|
||||
public static final int Trigger_FluidContainer_Below25 = 36;
|
||||
public static final int Trigger_FluidContainer_Below50 = 37;
|
||||
public static final int Trigger_FluidContainer_Below75 = 38;
|
||||
|
||||
public static final int MAX = 45;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
private final IIcon[] icons = new IIcon[MAX];
|
||||
|
||||
|
@ -104,5 +109,8 @@ public class ActionTriggerIconProvider implements IIconProvider {
|
|||
icons[ActionTriggerIconProvider.Trigger_Inventory_Below25] = iconRegister.registerIcon("buildcraft:triggers/trigger_inventory_below25");
|
||||
icons[ActionTriggerIconProvider.Trigger_Inventory_Below50] = iconRegister.registerIcon("buildcraft:triggers/trigger_inventory_below50");
|
||||
icons[ActionTriggerIconProvider.Trigger_Inventory_Below75] = iconRegister.registerIcon("buildcraft:triggers/trigger_inventory_below75");
|
||||
icons[ActionTriggerIconProvider.Trigger_FluidContainer_Below25] = iconRegister.registerIcon("buildcraft:triggers/trigger_liquidcontainer_below25");
|
||||
icons[ActionTriggerIconProvider.Trigger_FluidContainer_Below50] = iconRegister.registerIcon("buildcraft:triggers/trigger_liquidcontainer_below50");
|
||||
icons[ActionTriggerIconProvider.Trigger_FluidContainer_Below75] = iconRegister.registerIcon("buildcraft:triggers/trigger_liquidcontainer_below75");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -41,6 +41,9 @@ public class DefaultTriggerProvider implements ITriggerProvider {
|
|||
res.add(BuildCraftCore.triggerContainsFluid);
|
||||
res.add(BuildCraftCore.triggerSpaceFluid);
|
||||
res.add(BuildCraftCore.triggerFullFluid);
|
||||
res.add(BuildCraftCore.triggerFluidContainerBelow25);
|
||||
res.add(BuildCraftCore.triggerFluidContainerBelow50);
|
||||
res.add(BuildCraftCore.triggerFluidContainerBelow75);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
101
common/buildcraft/core/triggers/TriggerFluidContainerLevel.java
Normal file
101
common/buildcraft/core/triggers/TriggerFluidContainerLevel.java
Normal file
|
@ -0,0 +1,101 @@
|
|||
/**
|
||||
* Copyright (c) SpaceToad, 2011 http://www.mod-buildcraft.com
|
||||
*
|
||||
* 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://www.mod-buildcraft.com/MMPL-1.0.txt
|
||||
*/
|
||||
package buildcraft.core.triggers;
|
||||
|
||||
import buildcraft.api.gates.ITileTrigger;
|
||||
import buildcraft.api.gates.ITriggerParameter;
|
||||
import buildcraft.core.triggers.TriggerInventoryLevel.TriggerType;
|
||||
import buildcraft.core.utils.StringUtils;
|
||||
import java.util.Locale;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
import net.minecraftforge.fluids.FluidContainerRegistry;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.FluidTankInfo;
|
||||
import net.minecraftforge.fluids.IFluidHandler;
|
||||
|
||||
public class TriggerFluidContainerLevel extends BCTrigger implements ITileTrigger {
|
||||
|
||||
public enum TriggerType {
|
||||
|
||||
BELOW_25(0.25F), BELOW_50(0.5F), BELOW_75(0.75F);
|
||||
|
||||
public final float level;
|
||||
|
||||
private TriggerType(float level) {
|
||||
this.level = level;
|
||||
}
|
||||
};
|
||||
|
||||
public TriggerType type;
|
||||
|
||||
public TriggerFluidContainerLevel(TriggerType type) {
|
||||
super("buildcraft:fluid." + type.name().toLowerCase(Locale.ENGLISH), "buildcraft.fluid." + type.name().toLowerCase(Locale.ENGLISH));
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasParameter() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return String.format(StringUtils.localize("gate.trigger.fluidlevel.below"), (int) (type.level * 100));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isTriggerActive(ForgeDirection side, TileEntity tile, ITriggerParameter parameter) {
|
||||
if (tile instanceof IFluidHandler) {
|
||||
IFluidHandler container = (IFluidHandler) tile;
|
||||
|
||||
FluidStack searchedFluid = null;
|
||||
|
||||
if (parameter != null && parameter.getItemStack() != null) {
|
||||
searchedFluid = FluidContainerRegistry.getFluidForFilledItem(parameter.getItemStack());
|
||||
}
|
||||
|
||||
if (searchedFluid != null) {
|
||||
searchedFluid.amount = 1;
|
||||
}
|
||||
|
||||
FluidTankInfo[] liquids = container.getTankInfo(side);
|
||||
if (liquids == null || liquids.length == 0)
|
||||
return false;
|
||||
|
||||
for (FluidTankInfo c : liquids) {
|
||||
if (c.fluid == null) {
|
||||
if ( searchedFluid == null){
|
||||
return true;
|
||||
}
|
||||
return container.fill(side, searchedFluid, false) > 0;
|
||||
}
|
||||
|
||||
if (searchedFluid == null || searchedFluid.isFluidEqual(c.fluid)) {
|
||||
float percentage = (float) c.fluid.amount / (float) c.capacity;
|
||||
return percentage < type.level;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getIconIndex() {
|
||||
switch (type) {
|
||||
case BELOW_25:
|
||||
return ActionTriggerIconProvider.Trigger_FluidContainer_Below25;
|
||||
case BELOW_50:
|
||||
return ActionTriggerIconProvider.Trigger_FluidContainer_Below50;
|
||||
case BELOW_75:
|
||||
default:
|
||||
return ActionTriggerIconProvider.Trigger_FluidContainer_Below75;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -148,7 +148,7 @@ public class TileEngineIron extends TileEngineWithInventory implements IFluidHan
|
|||
|
||||
lastPowered = true;
|
||||
|
||||
if (burnTime > 0 || fuel.amount > 0) {
|
||||
if (burnTime > 0 || (fuel != null && fuel.amount > 0)) {
|
||||
if (burnTime > 0) {
|
||||
burnTime--;
|
||||
}
|
||||
|
@ -425,6 +425,9 @@ public class TileEngineIron extends TileEngineWithInventory implements IFluidHan
|
|||
triggers.add(BuildCraftCore.triggerContainsFluid);
|
||||
triggers.add(BuildCraftCore.triggerSpaceFluid);
|
||||
triggers.add(BuildCraftCore.triggerFullFluid);
|
||||
triggers.add(BuildCraftCore.triggerFluidContainerBelow25);
|
||||
triggers.add(BuildCraftCore.triggerFluidContainerBelow50);
|
||||
triggers.add(BuildCraftCore.triggerFluidContainerBelow75);
|
||||
|
||||
return triggers;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue