added support for rotating actions and triggers, close #1515

This commit is contained in:
SpaceToad 2014-03-19 11:59:40 +01:00
parent 2d3d70f6db
commit 43f0c5cf5c
25 changed files with 292 additions and 99 deletions

View file

@ -8,10 +8,10 @@
*/ */
package buildcraft.api.gates; package buildcraft.api.gates;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.util.IIcon; import net.minecraft.util.IIcon;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public interface IAction { public interface IAction {
@ -26,4 +26,6 @@ public interface IAction {
boolean hasParameter(); boolean hasParameter();
String getDescription(); String getDescription();
IAction rotateLeft();
} }

View file

@ -8,10 +8,10 @@
*/ */
package buildcraft.api.gates; package buildcraft.api.gates;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.util.IIcon; import net.minecraft.util.IIcon;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public interface ITrigger { public interface ITrigger {
@ -49,4 +49,10 @@ public interface ITrigger {
* trigger parameter available so this subprogram is final. * trigger parameter available so this subprogram is final.
*/ */
ITriggerParameter createParameter(); ITriggerParameter createParameter();
/**
* This returns the trigger after a left rotation. Used in particular in
* blueprints orientation.
*/
ITrigger rotateLeft();
} }

View file

@ -8,9 +8,10 @@
*/ */
package buildcraft.builders.triggers; package buildcraft.builders.triggers;
import buildcraft.api.filler.IFillerPattern;
import buildcraft.core.triggers.*;
import net.minecraft.util.IIcon; import net.minecraft.util.IIcon;
import buildcraft.api.filler.IFillerPattern;
import buildcraft.api.gates.IAction;
import buildcraft.core.triggers.BCAction;
public class ActionFiller extends BCAction { public class ActionFiller extends BCAction {
@ -35,4 +36,9 @@ public class ActionFiller extends BCAction {
public int getTextureMap() { public int getTextureMap() {
return 0; return 0;
} }
@Override
public IAction rotateLeft() {
return this;
}
} }

View file

@ -8,9 +8,11 @@
*/ */
package buildcraft.core.triggers; package buildcraft.core.triggers;
import buildcraft.core.utils.StringUtils;
import java.util.Locale; import java.util.Locale;
import buildcraft.api.gates.IAction;
import buildcraft.core.utils.StringUtils;
public class ActionMachineControl extends BCAction { public class ActionMachineControl extends BCAction {
public enum Mode { public enum Mode {
@ -42,4 +44,9 @@ public class ActionMachineControl extends BCAction {
return ActionTriggerIconProvider.Action_MachineControl_Loop; return ActionTriggerIconProvider.Action_MachineControl_Loop;
} }
} }
@Override
public IAction rotateLeft() {
return this;
}
} }

View file

@ -8,6 +8,8 @@
*/ */
package buildcraft.core.triggers; package buildcraft.core.triggers;
import buildcraft.api.gates.IAction;
public class ActionRedstoneOutput extends BCAction { public class ActionRedstoneOutput extends BCAction {
public ActionRedstoneOutput() { public ActionRedstoneOutput() {
@ -23,4 +25,9 @@ public class ActionRedstoneOutput extends BCAction {
public int getIconIndex() { public int getIconIndex() {
return ActionTriggerIconProvider.Trigger_RedstoneInput_Active; return ActionTriggerIconProvider.Trigger_RedstoneInput_Active;
} }
@Override
public IAction rotateLeft() {
return this;
}
} }

View file

@ -8,16 +8,18 @@
*/ */
package buildcraft.core.triggers; package buildcraft.core.triggers;
import buildcraft.api.gates.ITileTrigger;
import buildcraft.api.gates.ITriggerParameter;
import buildcraft.core.utils.StringUtils;
import java.util.Locale; import java.util.Locale;
import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.common.util.ForgeDirection;
import net.minecraftforge.fluids.FluidContainerRegistry; import net.minecraftforge.fluids.FluidContainerRegistry;
import net.minecraftforge.fluids.FluidStack; 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.api.gates.ITileTrigger;
import buildcraft.api.gates.ITrigger;
import buildcraft.api.gates.ITriggerParameter;
import buildcraft.core.utils.StringUtils;
public class TriggerFluidContainer extends BCTrigger implements ITileTrigger { public class TriggerFluidContainer extends BCTrigger implements ITileTrigger {
@ -34,10 +36,11 @@ public class TriggerFluidContainer extends BCTrigger implements ITileTrigger {
@Override @Override
public boolean hasParameter() { public boolean hasParameter() {
if (state == State.Contains || state == State.Space) if (state == State.Contains || state == State.Space) {
return true; return true;
else } else {
return false; return false;
}
} }
@Override @Override
@ -61,27 +64,31 @@ public class TriggerFluidContainer extends BCTrigger implements ITileTrigger {
} }
FluidTankInfo[] liquids = container.getTankInfo(side); FluidTankInfo[] liquids = container.getTankInfo(side);
if (liquids == null || liquids.length == 0) if (liquids == null || liquids.length == 0) {
return false; return false;
}
switch (state) { switch (state) {
case Empty: case Empty:
for (FluidTankInfo c : liquids) { for (FluidTankInfo c : liquids) {
if (c.fluid != null && c.fluid.amount > 0 && (searchedFluid == null || searchedFluid.isFluidEqual(c.fluid))) if (c.fluid != null && c.fluid.amount > 0 && (searchedFluid == null || searchedFluid.isFluidEqual(c.fluid))) {
return false; return false;
}
} }
return true; return true;
case Contains: case Contains:
for (FluidTankInfo c : liquids) { for (FluidTankInfo c : liquids) {
if (c.fluid != null && c.fluid.amount > 0 && (searchedFluid == null || searchedFluid.isFluidEqual(c.fluid))) if (c.fluid != null && c.fluid.amount > 0 && (searchedFluid == null || searchedFluid.isFluidEqual(c.fluid))) {
return true; return true;
}
} }
return false; return false;
case Space: case Space:
if (searchedFluid == null) { if (searchedFluid == null) {
for (FluidTankInfo c : liquids) { for (FluidTankInfo c : liquids) {
if (c.fluid == null || c.fluid.amount < c.capacity) if (c.fluid == null || c.fluid.amount < c.capacity) {
return true; return true;
}
} }
return false; return false;
} }
@ -89,8 +96,9 @@ public class TriggerFluidContainer extends BCTrigger implements ITileTrigger {
case Full: case Full:
if (searchedFluid == null) { if (searchedFluid == null) {
for (FluidTankInfo c : liquids) { for (FluidTankInfo c : liquids) {
if (c.fluid == null || c.fluid.amount < c.capacity) if (c.fluid == null || c.fluid.amount < c.capacity) {
return false; return false;
}
} }
return true; return true;
} }
@ -114,4 +122,9 @@ public class TriggerFluidContainer extends BCTrigger implements ITileTrigger {
return ActionTriggerIconProvider.Trigger_FluidContainer_Full; return ActionTriggerIconProvider.Trigger_FluidContainer_Full;
} }
} }
@Override
public ITrigger rotateLeft() {
return this;
}
} }

View file

@ -8,31 +8,32 @@
*/ */
package buildcraft.core.triggers; 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 java.util.Locale;
import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.common.util.ForgeDirection;
import net.minecraftforge.fluids.FluidContainerRegistry; import net.minecraftforge.fluids.FluidContainerRegistry;
import net.minecraftforge.fluids.FluidStack; 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.api.gates.ITileTrigger;
import buildcraft.api.gates.ITrigger;
import buildcraft.api.gates.ITriggerParameter;
import buildcraft.core.utils.StringUtils;
public class TriggerFluidContainerLevel extends BCTrigger implements ITileTrigger { public class TriggerFluidContainerLevel extends BCTrigger implements ITileTrigger {
public enum TriggerType { public enum TriggerType {
BELOW_25(0.25F), BELOW_50(0.5F), BELOW_75(0.75F); BELOW_25(0.25F), BELOW_50(0.5F), BELOW_75(0.75F);
public final float level; public final float level;
private TriggerType(float level) { private TriggerType(float level) {
this.level = level; this.level = level;
} }
}; };
public TriggerType type; public TriggerType type;
public TriggerFluidContainerLevel(TriggerType type) { public TriggerFluidContainerLevel(TriggerType type) {
@ -66,8 +67,9 @@ public class TriggerFluidContainerLevel extends BCTrigger implements ITileTrigge
} }
FluidTankInfo[] liquids = container.getTankInfo(side); FluidTankInfo[] liquids = container.getTankInfo(side);
if (liquids == null || liquids.length == 0) if (liquids == null || liquids.length == 0) {
return false; return false;
}
for (FluidTankInfo c : liquids) { for (FluidTankInfo c : liquids) {
if (c.fluid == null) { if (c.fluid == null) {
@ -76,7 +78,7 @@ public class TriggerFluidContainerLevel extends BCTrigger implements ITileTrigge
} }
return container.fill(side, searchedFluid, false) > 0; return container.fill(side, searchedFluid, false) > 0;
} }
if (searchedFluid == null || searchedFluid.isFluidEqual(c.fluid)) { if (searchedFluid == null || searchedFluid.isFluidEqual(c.fluid)) {
float percentage = (float) c.fluid.amount / (float) c.capacity; float percentage = (float) c.fluid.amount / (float) c.capacity;
return percentage < type.level; return percentage < type.level;
@ -99,4 +101,9 @@ public class TriggerFluidContainerLevel extends BCTrigger implements ITileTrigge
return ActionTriggerIconProvider.Trigger_FluidContainer_Below75; return ActionTriggerIconProvider.Trigger_FluidContainer_Below75;
} }
} }
@Override
public ITrigger rotateLeft() {
return this;
}
} }

View file

@ -8,18 +8,20 @@
*/ */
package buildcraft.core.triggers; package buildcraft.core.triggers;
import java.util.Locale;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.util.ForgeDirection;
import buildcraft.api.gates.ITileTrigger; import buildcraft.api.gates.ITileTrigger;
import buildcraft.api.gates.ITrigger;
import buildcraft.api.gates.ITriggerParameter; import buildcraft.api.gates.ITriggerParameter;
import buildcraft.api.inventory.ISpecialInventory; import buildcraft.api.inventory.ISpecialInventory;
import buildcraft.core.inventory.InventoryIterator; import buildcraft.core.inventory.InventoryIterator;
import buildcraft.core.inventory.InventoryIterator.IInvSlot; import buildcraft.core.inventory.InventoryIterator.IInvSlot;
import buildcraft.core.inventory.StackHelper; import buildcraft.core.inventory.StackHelper;
import buildcraft.core.utils.StringUtils; import buildcraft.core.utils.StringUtils;
import java.util.Locale;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.util.ForgeDirection;
public class TriggerInventory extends BCTrigger implements ITileTrigger { public class TriggerInventory extends BCTrigger implements ITileTrigger {
@ -37,10 +39,11 @@ public class TriggerInventory extends BCTrigger implements ITileTrigger {
@Override @Override
public boolean hasParameter() { public boolean hasParameter() {
if (state == State.Contains || state == State.Space) if (state == State.Contains || state == State.Space) {
return true; return true;
else } else {
return false; return false;
}
} }
@Override @Override
@ -69,8 +72,9 @@ public class TriggerInventory extends BCTrigger implements ITileTrigger {
case Full: case Full:
break; break;
case Space: case Space:
if (searchedStack == null) if (searchedStack == null) {
break; break;
}
int added = specialInventory.addItem(searchedStack, false, side); int added = specialInventory.addItem(searchedStack, false, side);
return added > 0; return added > 0;
} }
@ -90,8 +94,9 @@ public class TriggerInventory extends BCTrigger implements ITileTrigger {
&& (searchedStack == null || slot.canPutStackInSlot(searchedStack)); && (searchedStack == null || slot.canPutStackInSlot(searchedStack));
} }
if (!hasSlots) if (!hasSlots) {
return false; return false;
}
switch (state) { switch (state) {
case Empty: case Empty:
@ -121,4 +126,9 @@ public class TriggerInventory extends BCTrigger implements ITileTrigger {
return ActionTriggerIconProvider.Trigger_Inventory_Full; return ActionTriggerIconProvider.Trigger_Inventory_Full;
} }
} }
@Override
public ITrigger rotateLeft() {
return this;
}
} }

View file

@ -8,17 +8,19 @@
*/ */
package buildcraft.core.triggers; package buildcraft.core.triggers;
import java.util.Locale;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.util.ForgeDirection;
import buildcraft.api.gates.ITileTrigger; import buildcraft.api.gates.ITileTrigger;
import buildcraft.api.gates.ITrigger;
import buildcraft.api.gates.ITriggerParameter; import buildcraft.api.gates.ITriggerParameter;
import buildcraft.core.inventory.InventoryIterator; import buildcraft.core.inventory.InventoryIterator;
import buildcraft.core.inventory.InventoryIterator.IInvSlot; import buildcraft.core.inventory.InventoryIterator.IInvSlot;
import buildcraft.core.inventory.StackHelper; import buildcraft.core.inventory.StackHelper;
import buildcraft.core.utils.StringUtils; import buildcraft.core.utils.StringUtils;
import java.util.Locale;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.util.ForgeDirection;
public class TriggerInventoryLevel extends BCTrigger implements ITileTrigger { public class TriggerInventoryLevel extends BCTrigger implements ITileTrigger {
@ -58,8 +60,9 @@ public class TriggerInventoryLevel extends BCTrigger implements ITileTrigger {
@Override @Override
public boolean isTriggerActive(ForgeDirection side, TileEntity tile, ITriggerParameter parameter) { public boolean isTriggerActive(ForgeDirection side, TileEntity tile, ITriggerParameter parameter) {
// A parameter is required // A parameter is required
if (parameter == null) if (parameter == null) {
return false; return false;
}
if (tile instanceof IInventory) { if (tile instanceof IInventory) {
ItemStack searchStack = parameter.getItemStack(); ItemStack searchStack = parameter.getItemStack();
@ -77,7 +80,7 @@ public class TriggerInventoryLevel extends BCTrigger implements ITileTrigger {
} }
if (stackSpace > 0) { if (stackSpace > 0) {
float percentage = (float) foundItems / ((float) stackSpace * (float) searchStack.getMaxStackSize()); float percentage = foundItems / ((float) stackSpace * (float) searchStack.getMaxStackSize());
return percentage < type.level; return percentage < type.level;
} }
@ -97,4 +100,9 @@ public class TriggerInventoryLevel extends BCTrigger implements ITileTrigger {
return ActionTriggerIconProvider.Trigger_Inventory_Below75; return ActionTriggerIconProvider.Trigger_Inventory_Below75;
} }
} }
@Override
public ITrigger rotateLeft() {
return this;
}
} }

View file

@ -8,12 +8,13 @@
*/ */
package buildcraft.core.triggers; package buildcraft.core.triggers;
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.util.ForgeDirection;
import buildcraft.api.gates.ITileTrigger; import buildcraft.api.gates.ITileTrigger;
import buildcraft.api.gates.ITrigger;
import buildcraft.api.gates.ITriggerParameter; import buildcraft.api.gates.ITriggerParameter;
import buildcraft.core.IMachine; import buildcraft.core.IMachine;
import buildcraft.core.utils.StringUtils; import buildcraft.core.utils.StringUtils;
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.util.ForgeDirection;
public class TriggerMachine extends BCTrigger implements ITileTrigger { public class TriggerMachine extends BCTrigger implements ITileTrigger {
@ -35,10 +36,11 @@ public class TriggerMachine extends BCTrigger implements ITileTrigger {
if (tile instanceof IMachine) { if (tile instanceof IMachine) {
IMachine machine = (IMachine) tile; IMachine machine = (IMachine) tile;
if (active) if (active) {
return machine.isActive(); return machine.isActive();
else } else {
return !machine.isActive(); return !machine.isActive();
}
} }
return false; return false;
@ -46,9 +48,15 @@ public class TriggerMachine extends BCTrigger implements ITileTrigger {
@Override @Override
public int getIconIndex() { public int getIconIndex() {
if (active) if (active) {
return ActionTriggerIconProvider.Trigger_Machine_Active; return ActionTriggerIconProvider.Trigger_Machine_Active;
else } else {
return ActionTriggerIconProvider.Trigger_Machine_Inactive; return ActionTriggerIconProvider.Trigger_Machine_Inactive;
}
}
@Override
public ITrigger rotateLeft() {
return this;
} }
} }

View file

@ -8,6 +8,7 @@
*/ */
package buildcraft.core.triggers; package buildcraft.core.triggers;
import buildcraft.api.gates.ITrigger;
import buildcraft.api.gates.ITriggerParameter; import buildcraft.api.gates.ITriggerParameter;
import buildcraft.core.utils.StringUtils; import buildcraft.core.utils.StringUtils;
import buildcraft.transport.IPipeTrigger; import buildcraft.transport.IPipeTrigger;
@ -29,8 +30,9 @@ public class TriggerRedstoneInput extends BCTrigger implements IPipeTrigger {
@Override @Override
public boolean isTriggerActive(Pipe pipe, ITriggerParameter parameter) { public boolean isTriggerActive(Pipe pipe, ITriggerParameter parameter) {
if (active) if (active) {
return isBeingPowered(pipe); return isBeingPowered(pipe);
}
return !isBeingPowered(pipe); return !isBeingPowered(pipe);
} }
@ -42,4 +44,9 @@ public class TriggerRedstoneInput extends BCTrigger implements IPipeTrigger {
public int getIconIndex() { public int getIconIndex() {
return active ? ActionTriggerIconProvider.Trigger_RedstoneInput_Active : ActionTriggerIconProvider.Trigger_RedstoneInput_Inactive; return active ? ActionTriggerIconProvider.Trigger_RedstoneInput_Active : ActionTriggerIconProvider.Trigger_RedstoneInput_Inactive;
} }
@Override
public ITrigger rotateLeft() {
return this;
}
} }

View file

@ -8,7 +8,14 @@
*/ */
package buildcraft.energy.triggers; package buildcraft.energy.triggers;
import java.util.Locale;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.IIcon;
import net.minecraftforge.common.util.ForgeDirection;
import buildcraft.api.gates.ITileTrigger; import buildcraft.api.gates.ITileTrigger;
import buildcraft.api.gates.ITrigger;
import buildcraft.api.gates.ITriggerParameter; import buildcraft.api.gates.ITriggerParameter;
import buildcraft.core.triggers.BCTrigger; import buildcraft.core.triggers.BCTrigger;
import buildcraft.core.utils.StringUtils; import buildcraft.core.utils.StringUtils;
@ -16,11 +23,6 @@ import buildcraft.energy.TileEngine;
import buildcraft.energy.TileEngine.EnergyStage; import buildcraft.energy.TileEngine.EnergyStage;
import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly; import cpw.mods.fml.relauncher.SideOnly;
import java.util.Locale;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.IIcon;
import net.minecraftforge.common.util.ForgeDirection;
public class TriggerEngineHeat extends BCTrigger implements ITileTrigger { public class TriggerEngineHeat extends BCTrigger implements ITileTrigger {
@ -61,4 +63,9 @@ public class TriggerEngineHeat extends BCTrigger implements ITileTrigger {
public void registerIcons(IIconRegister iconRegister) { public void registerIcons(IIconRegister iconRegister) {
icon = iconRegister.registerIcon("buildcraft:triggers/trigger_engineheat_" + stage.name().toLowerCase(Locale.ENGLISH)); icon = iconRegister.registerIcon("buildcraft:triggers/trigger_engineheat_" + stage.name().toLowerCase(Locale.ENGLISH));
} }
@Override
public ITrigger rotateLeft() {
return this;
}
} }

View file

@ -12,9 +12,13 @@ import java.util.ArrayList;
import net.minecraft.item.Item; import net.minecraft.item.Item;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntity;
import buildcraft.api.blueprints.IBuilderContext; import buildcraft.api.blueprints.IBuilderContext;
import buildcraft.api.blueprints.SchematicTile; import buildcraft.api.blueprints.SchematicTile;
import buildcraft.api.gates.ActionManager;
import buildcraft.api.gates.IAction;
import buildcraft.api.gates.ITrigger;
import buildcraft.transport.BlockGenericPipe; import buildcraft.transport.BlockGenericPipe;
import buildcraft.transport.Pipe; import buildcraft.transport.Pipe;
import buildcraft.transport.TileGenericPipe.SideProperties; import buildcraft.transport.TileGenericPipe.SideProperties;
@ -46,6 +50,22 @@ public class SchematicPipe extends SchematicTile {
if (BptPipeExtension.contains(pipeItem)) { if (BptPipeExtension.contains(pipeItem)) {
BptPipeExtension.get(pipeItem).rotateLeft(this, context); BptPipeExtension.get(pipeItem).rotateLeft(this, context);
} }
NBTTagCompound gateNBT = cpt.getCompoundTag("Gate");
for (int i = 0; i < 8; ++i) {
if (gateNBT.hasKey("trigger[" + i + "]")) {
ITrigger t = ActionManager.triggers.get(gateNBT.getString("trigger[" + i + "]"));
t = t.rotateLeft ();
gateNBT.setString("trigger[" + i + "]", t.getUniqueTag());
}
if (gateNBT.hasKey("action[" + i + "]")) {
IAction a = ActionManager.actions.get(gateNBT.getString("action[" + i + "]"));
a = a.rotateLeft ();
gateNBT.setString("action[" + i + "]", a.getUniqueTag());
}
}
} }
@Override @Override

View file

@ -10,14 +10,14 @@ package buildcraft.transport.triggers;
import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.util.IIcon; import net.minecraft.util.IIcon;
import buildcraft.core.triggers.ActionTriggerIconProvider; import buildcraft.api.gates.IAction;
import buildcraft.core.triggers.BCAction; import buildcraft.core.triggers.BCAction;
import buildcraft.core.utils.StringUtils; import buildcraft.core.utils.StringUtils;
public class ActionEnergyPulsar extends BCAction { public class ActionEnergyPulsar extends BCAction {
private IIcon icon; private IIcon icon;
public ActionEnergyPulsar() { public ActionEnergyPulsar() {
super("buildcraft:pulsar.constant", "buildcraft.pulser.constant"); super("buildcraft:pulsar.constant", "buildcraft.pulser.constant");
} }
@ -26,15 +26,20 @@ public class ActionEnergyPulsar extends BCAction {
public IIcon getIcon() { public IIcon getIcon() {
return icon; return icon;
} }
@Override @Override
public String getDescription() { public String getDescription() {
return StringUtils.localize("gate.action.pulsar.constant"); return StringUtils.localize("gate.action.pulsar.constant");
} }
@Override @Override
public void registerIcons(IIconRegister iconRegister) { public void registerIcons(IIconRegister iconRegister) {
icon = iconRegister.registerIcon("buildcraft:triggers/action_pulsar"); icon = iconRegister.registerIcon("buildcraft:triggers/action_pulsar");
} }
@Override
public IAction rotateLeft() {
return this;
}
} }

View file

@ -8,12 +8,14 @@
*/ */
package buildcraft.transport.triggers; package buildcraft.transport.triggers;
import java.util.Locale;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.util.IIcon;
import buildcraft.api.gates.IAction;
import buildcraft.core.triggers.BCAction; import buildcraft.core.triggers.BCAction;
import buildcraft.core.utils.EnumColor; import buildcraft.core.utils.EnumColor;
import buildcraft.core.utils.StringUtils; import buildcraft.core.utils.StringUtils;
import java.util.Locale;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.util.IIcon;
public class ActionExtractionPreset extends BCAction { public class ActionExtractionPreset extends BCAction {
@ -40,4 +42,9 @@ public class ActionExtractionPreset extends BCAction {
public void registerIcons(IIconRegister iconRegister) { public void registerIcons(IIconRegister iconRegister) {
icon = iconRegister.registerIcon("buildcraft:triggers/extraction_preset_" + color.name().toLowerCase(Locale.ENGLISH)); icon = iconRegister.registerIcon("buildcraft:triggers/extraction_preset_" + color.name().toLowerCase(Locale.ENGLISH));
} }
@Override
public IAction rotateLeft() {
return this;
}
} }

View file

@ -8,12 +8,14 @@
*/ */
package buildcraft.transport.triggers; package buildcraft.transport.triggers;
import java.util.Locale;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.util.IIcon;
import buildcraft.api.gates.IAction;
import buildcraft.core.triggers.BCAction; import buildcraft.core.triggers.BCAction;
import buildcraft.core.utils.EnumColor; import buildcraft.core.utils.EnumColor;
import buildcraft.core.utils.StringUtils; import buildcraft.core.utils.StringUtils;
import java.util.Locale;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.util.IIcon;
public class ActionPipeColor extends BCAction { public class ActionPipeColor extends BCAction {
@ -40,4 +42,9 @@ public class ActionPipeColor extends BCAction {
public void registerIcons(IIconRegister iconRegister) { public void registerIcons(IIconRegister iconRegister) {
icon = iconRegister.registerIcon("buildcraft:triggers/color_" + color.name().toLowerCase(Locale.ENGLISH)); icon = iconRegister.registerIcon("buildcraft:triggers/color_" + color.name().toLowerCase(Locale.ENGLISH));
} }
@Override
public IAction rotateLeft() {
return this;
}
} }

View file

@ -8,11 +8,13 @@
*/ */
package buildcraft.transport.triggers; package buildcraft.transport.triggers;
import buildcraft.core.triggers.BCAction;
import java.util.Locale; import java.util.Locale;
import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.util.IIcon; import net.minecraft.util.IIcon;
import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.common.util.ForgeDirection;
import buildcraft.api.gates.IAction;
import buildcraft.core.triggers.BCAction;
public class ActionPipeDirection extends BCAction { public class ActionPipeDirection extends BCAction {
@ -39,4 +41,9 @@ public class ActionPipeDirection extends BCAction {
public void registerIcons(IIconRegister iconRegister) { public void registerIcons(IIconRegister iconRegister) {
icon = iconRegister.registerIcon("buildcraft:triggers/trigger_dir_" + direction.name().toLowerCase(Locale.ENGLISH)); icon = iconRegister.registerIcon("buildcraft:triggers/trigger_dir_" + direction.name().toLowerCase(Locale.ENGLISH));
} }
@Override
public IAction rotateLeft() {
return new ActionPipeDirection(direction.getRotation(ForgeDirection.UP));
}
} }

View file

@ -8,11 +8,13 @@
*/ */
package buildcraft.transport.triggers; package buildcraft.transport.triggers;
import buildcraft.core.triggers.BCAction;
import buildcraft.transport.pipes.PipePowerIron.PowerMode;
import java.util.Locale; import java.util.Locale;
import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.util.IIcon; import net.minecraft.util.IIcon;
import buildcraft.api.gates.IAction;
import buildcraft.core.triggers.BCAction;
import buildcraft.transport.pipes.PipePowerIron.PowerMode;
public class ActionPowerLimiter extends BCAction { public class ActionPowerLimiter extends BCAction {
@ -39,4 +41,9 @@ public class ActionPowerLimiter extends BCAction {
public void registerIcons(IIconRegister iconRegister) { public void registerIcons(IIconRegister iconRegister) {
icon = iconRegister.registerIcon("buildcraft:triggers/trigger_limiter_" + limit.name().toLowerCase(Locale.ENGLISH)); icon = iconRegister.registerIcon("buildcraft:triggers/trigger_limiter_" + limit.name().toLowerCase(Locale.ENGLISH));
} }
@Override
public IAction rotateLeft() {
return this;
}
} }

View file

@ -8,12 +8,13 @@
*/ */
package buildcraft.transport.triggers; package buildcraft.transport.triggers;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.util.IIcon;
import buildcraft.api.gates.IAction;
import buildcraft.core.triggers.BCAction; import buildcraft.core.triggers.BCAction;
import buildcraft.core.utils.StringUtils; import buildcraft.core.utils.StringUtils;
import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly; import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.util.IIcon;
public class ActionRedstoneFaderOutput extends BCAction { public class ActionRedstoneFaderOutput extends BCAction {
@ -43,4 +44,9 @@ public class ActionRedstoneFaderOutput extends BCAction {
public void registerIcons(IIconRegister iconRegister) { public void registerIcons(IIconRegister iconRegister) {
icon = iconRegister.registerIcon(String.format("buildcraft:triggers/redstone_%02d", level)); icon = iconRegister.registerIcon(String.format("buildcraft:triggers/redstone_%02d", level));
} }
@Override
public IAction rotateLeft() {
return this;
}
} }

View file

@ -8,11 +8,13 @@
*/ */
package buildcraft.transport.triggers; package buildcraft.transport.triggers;
import java.util.Locale;
import buildcraft.api.gates.IAction;
import buildcraft.api.transport.PipeWire;
import buildcraft.core.triggers.ActionTriggerIconProvider; import buildcraft.core.triggers.ActionTriggerIconProvider;
import buildcraft.core.triggers.BCAction; import buildcraft.core.triggers.BCAction;
import buildcraft.api.transport.PipeWire;
import buildcraft.core.utils.StringUtils; import buildcraft.core.utils.StringUtils;
import java.util.Locale;
public class ActionSignalOutput extends BCAction { public class ActionSignalOutput extends BCAction {
@ -43,4 +45,9 @@ public class ActionSignalOutput extends BCAction {
return ActionTriggerIconProvider.Trigger_PipeSignal_Yellow_Active; return ActionTriggerIconProvider.Trigger_PipeSignal_Yellow_Active;
} }
} }
@Override
public IAction rotateLeft() {
return this;
}
} }

View file

@ -10,12 +10,12 @@ package buildcraft.transport.triggers;
import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.util.IIcon; import net.minecraft.util.IIcon;
import buildcraft.core.triggers.ActionTriggerIconProvider; import buildcraft.api.gates.IAction;
import buildcraft.core.triggers.BCAction; import buildcraft.core.triggers.BCAction;
import buildcraft.core.utils.StringUtils; import buildcraft.core.utils.StringUtils;
public class ActionSingleEnergyPulse extends BCAction { public class ActionSingleEnergyPulse extends BCAction {
private IIcon icon; private IIcon icon;
public ActionSingleEnergyPulse() { public ActionSingleEnergyPulse() {
@ -31,10 +31,14 @@ public class ActionSingleEnergyPulse extends BCAction {
public String getDescription() { public String getDescription() {
return StringUtils.localize("gate.action.pulsar.single"); return StringUtils.localize("gate.action.pulsar.single");
} }
@Override @Override
public void registerIcons(IIconRegister iconRegister) { public void registerIcons(IIconRegister iconRegister) {
icon = iconRegister.registerIcon("buildcraft:triggers/action_single_pulsar"); icon = iconRegister.registerIcon("buildcraft:triggers/action_single_pulsar");
} }
@Override
public IAction rotateLeft() {
return this;
}
} }

View file

@ -10,10 +10,11 @@ package buildcraft.transport.triggers;
import java.util.Locale; import java.util.Locale;
import buildcraft.core.triggers.BCTrigger;
import buildcraft.core.utils.StringUtils;
import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.util.IIcon; import net.minecraft.util.IIcon;
import buildcraft.api.gates.ITrigger;
import buildcraft.core.triggers.BCTrigger;
import buildcraft.core.utils.StringUtils;
public class TriggerClockTimer extends BCTrigger { public class TriggerClockTimer extends BCTrigger {
@ -50,4 +51,9 @@ public class TriggerClockTimer extends BCTrigger {
public void registerIcons(IIconRegister iconRegister) { public void registerIcons(IIconRegister iconRegister) {
icon = iconRegister.registerIcon("buildcraft:triggers/trigger_timer_" + time.name().toLowerCase(Locale.ENGLISH)); icon = iconRegister.registerIcon("buildcraft:triggers/trigger_timer_" + time.name().toLowerCase(Locale.ENGLISH));
} }
@Override
public ITrigger rotateLeft() {
return this;
}
} }

View file

@ -8,6 +8,15 @@
*/ */
package buildcraft.transport.triggers; package buildcraft.transport.triggers;
import java.util.Locale;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.util.IIcon;
import net.minecraftforge.common.util.ForgeDirection;
import net.minecraftforge.fluids.FluidContainerRegistry;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.FluidTankInfo;
import buildcraft.api.gates.ITrigger;
import buildcraft.api.gates.ITriggerParameter; import buildcraft.api.gates.ITriggerParameter;
import buildcraft.core.triggers.BCTrigger; import buildcraft.core.triggers.BCTrigger;
import buildcraft.core.utils.StringUtils; import buildcraft.core.utils.StringUtils;
@ -20,13 +29,6 @@ import buildcraft.transport.TravelingItem;
import buildcraft.transport.pipes.PipePowerWood; import buildcraft.transport.pipes.PipePowerWood;
import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly; import cpw.mods.fml.relauncher.SideOnly;
import java.util.Locale;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.util.IIcon;
import net.minecraftforge.common.util.ForgeDirection;
import net.minecraftforge.fluids.FluidContainerRegistry;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.FluidTankInfo;
public class TriggerPipeContents extends BCTrigger implements IPipeTrigger { public class TriggerPipeContents extends BCTrigger implements IPipeTrigger {
@ -70,17 +72,20 @@ public class TriggerPipeContents extends BCTrigger implements IPipeTrigger {
if (pipe.transport instanceof PipeTransportItems) { if (pipe.transport instanceof PipeTransportItems) {
PipeTransportItems transportItems = (PipeTransportItems) pipe.transport; PipeTransportItems transportItems = (PipeTransportItems) pipe.transport;
if (kind == PipeContents.empty) if (kind == PipeContents.empty) {
return transportItems.items.isEmpty(); return transportItems.items.isEmpty();
else if (kind == PipeContents.containsItems) } else if (kind == PipeContents.containsItems) {
if (parameter != null && parameter.getItemStack() != null) { if (parameter != null && parameter.getItemStack() != null) {
for (TravelingItem item : transportItems.items) { for (TravelingItem item : transportItems.items) {
if (item.getItemStack().getItem() == parameter.getItemStack().getItem() if (item.getItemStack().getItem() == parameter.getItemStack().getItem()
&& item.getItemStack().getItemDamage() == parameter.getItemStack().getItemDamage()) && item.getItemStack().getItemDamage() == parameter.getItemStack().getItemDamage()) {
return true; return true;
}
} }
} else } else {
return !transportItems.items.isEmpty(); return !transportItems.items.isEmpty();
}
}
} else if (pipe.transport instanceof PipeTransportFluids) { } else if (pipe.transport instanceof PipeTransportFluids) {
PipeTransportFluids transportFluids = (PipeTransportFluids) pipe.transport; PipeTransportFluids transportFluids = (PipeTransportFluids) pipe.transport;
@ -92,16 +97,19 @@ public class TriggerPipeContents extends BCTrigger implements IPipeTrigger {
if (kind == PipeContents.empty) { if (kind == PipeContents.empty) {
for (FluidTankInfo b : transportFluids.getTankInfo(ForgeDirection.UNKNOWN)) { for (FluidTankInfo b : transportFluids.getTankInfo(ForgeDirection.UNKNOWN)) {
if (b.fluid != null && b.fluid.amount != 0) if (b.fluid != null && b.fluid.amount != 0) {
return false; return false;
}
} }
return true; return true;
} else { } else {
for (FluidTankInfo b : transportFluids.getTankInfo(ForgeDirection.UNKNOWN)) { for (FluidTankInfo b : transportFluids.getTankInfo(ForgeDirection.UNKNOWN)) {
if (b.fluid != null && b.fluid.amount != 0) if (b.fluid != null && b.fluid.amount != 0) {
if (searchedFluid == null || searchedFluid.isFluidEqual(b.fluid)) if (searchedFluid == null || searchedFluid.isFluidEqual(b.fluid)) {
return true; return true;
}
}
} }
return false; return false;
@ -112,15 +120,17 @@ public class TriggerPipeContents extends BCTrigger implements IPipeTrigger {
switch (kind) { switch (kind) {
case empty: case empty:
for (double s : transportPower.displayPower) { for (double s : transportPower.displayPower) {
if (s > 1e-4) if (s > 1e-4) {
return false; return false;
}
} }
return true; return true;
case containsEnergy: case containsEnergy:
for (double s : transportPower.displayPower) { for (double s : transportPower.displayPower) {
if (s > 1e-4) if (s > 1e-4) {
return true; return true;
}
} }
return false; return false;
@ -146,4 +156,9 @@ public class TriggerPipeContents extends BCTrigger implements IPipeTrigger {
public void registerIcons(IIconRegister iconRegister) { public void registerIcons(IIconRegister iconRegister) {
icon = iconRegister.registerIcon("buildcraft:triggers/trigger_pipecontents_" + kind.name().toLowerCase(Locale.ENGLISH)); icon = iconRegister.registerIcon("buildcraft:triggers/trigger_pipecontents_" + kind.name().toLowerCase(Locale.ENGLISH));
} }
@Override
public ITrigger rotateLeft() {
return this;
}
} }

View file

@ -8,14 +8,16 @@
*/ */
package buildcraft.transport.triggers; package buildcraft.transport.triggers;
import java.util.Locale;
import buildcraft.api.gates.ITrigger;
import buildcraft.api.gates.ITriggerParameter; import buildcraft.api.gates.ITriggerParameter;
import buildcraft.api.transport.PipeWire;
import buildcraft.core.triggers.ActionTriggerIconProvider; import buildcraft.core.triggers.ActionTriggerIconProvider;
import buildcraft.core.triggers.BCTrigger; import buildcraft.core.triggers.BCTrigger;
import buildcraft.core.utils.StringUtils;
import buildcraft.transport.IPipeTrigger; import buildcraft.transport.IPipeTrigger;
import buildcraft.transport.Pipe; import buildcraft.transport.Pipe;
import buildcraft.api.transport.PipeWire;
import buildcraft.core.utils.StringUtils;
import java.util.Locale;
public class TriggerPipeSignal extends BCTrigger implements IPipeTrigger { public class TriggerPipeSignal extends BCTrigger implements IPipeTrigger {
@ -42,10 +44,11 @@ public class TriggerPipeSignal extends BCTrigger implements IPipeTrigger {
@Override @Override
public boolean isTriggerActive(Pipe pipe, ITriggerParameter parameter) { public boolean isTriggerActive(Pipe pipe, ITriggerParameter parameter) {
if (active) if (active) {
return pipe.signalStrength[color.ordinal()] > 0; return pipe.signalStrength[color.ordinal()] > 0;
else } else {
return pipe.signalStrength[color.ordinal()] == 0; return pipe.signalStrength[color.ordinal()] == 0;
}
} }
@Override @Override
@ -75,4 +78,9 @@ public class TriggerPipeSignal extends BCTrigger implements IPipeTrigger {
} }
return -1; return -1;
} }
@Override
public ITrigger rotateLeft() {
return this;
}
} }

View file

@ -8,6 +8,9 @@
*/ */
package buildcraft.transport.triggers; package buildcraft.transport.triggers;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.util.IIcon;
import buildcraft.api.gates.ITrigger;
import buildcraft.api.gates.ITriggerParameter; import buildcraft.api.gates.ITriggerParameter;
import buildcraft.core.triggers.BCTrigger; import buildcraft.core.triggers.BCTrigger;
import buildcraft.core.utils.StringUtils; import buildcraft.core.utils.StringUtils;
@ -15,8 +18,6 @@ import buildcraft.transport.IPipeTrigger;
import buildcraft.transport.Pipe; import buildcraft.transport.Pipe;
import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly; import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.util.IIcon;
public class TriggerRedstoneFaderInput extends BCTrigger implements IPipeTrigger { public class TriggerRedstoneFaderInput extends BCTrigger implements IPipeTrigger {
@ -51,4 +52,9 @@ public class TriggerRedstoneFaderInput extends BCTrigger implements IPipeTrigger
public void registerIcons(IIconRegister iconRegister) { public void registerIcons(IIconRegister iconRegister) {
icon = iconRegister.registerIcon(String.format("buildcraft:triggers/redstone_%02d", level)); icon = iconRegister.registerIcon(String.format("buildcraft:triggers/redstone_%02d", level));
} }
@Override
public ITrigger rotateLeft() {
return this;
}
} }