From 43f0c5cf5c7d4d63174b6398c61122a221a70301 Mon Sep 17 00:00:00 2001 From: SpaceToad Date: Wed, 19 Mar 2014 11:59:40 +0100 Subject: [PATCH] added support for rotating actions and triggers, close #1515 --- common/buildcraft/api/gates/IAction.java | 6 ++- common/buildcraft/api/gates/ITrigger.java | 10 +++- .../builders/triggers/ActionFiller.java | 10 +++- .../core/triggers/ActionMachineControl.java | 9 +++- .../core/triggers/ActionRedstoneOutput.java | 7 +++ .../core/triggers/TriggerFluidContainer.java | 33 +++++++++---- .../triggers/TriggerFluidContainerLevel.java | 25 ++++++---- .../core/triggers/TriggerInventory.java | 28 +++++++---- .../core/triggers/TriggerInventoryLevel.java | 22 ++++++--- .../core/triggers/TriggerMachine.java | 20 +++++--- .../core/triggers/TriggerRedstoneInput.java | 9 +++- .../energy/triggers/TriggerEngineHeat.java | 17 +++++-- .../transport/blueprints/SchematicPipe.java | 20 ++++++++ .../triggers/ActionEnergyPulsar.java | 13 +++-- .../triggers/ActionExtractionPreset.java | 13 +++-- .../transport/triggers/ActionPipeColor.java | 13 +++-- .../triggers/ActionPipeDirection.java | 9 +++- .../triggers/ActionPowerLimiter.java | 11 ++++- .../triggers/ActionRedstoneFaderOutput.java | 10 +++- .../triggers/ActionSignalOutput.java | 11 ++++- .../triggers/ActionSingleEnergyPulse.java | 10 ++-- .../transport/triggers/TriggerClockTimer.java | 10 +++- .../triggers/TriggerPipeContents.java | 47 ++++++++++++------- .../transport/triggers/TriggerPipeSignal.java | 18 +++++-- .../triggers/TriggerRedstoneFaderInput.java | 10 +++- 25 files changed, 292 insertions(+), 99 deletions(-) diff --git a/common/buildcraft/api/gates/IAction.java b/common/buildcraft/api/gates/IAction.java index 38f134eb..503c645f 100644 --- a/common/buildcraft/api/gates/IAction.java +++ b/common/buildcraft/api/gates/IAction.java @@ -8,10 +8,10 @@ */ 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.util.IIcon; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; public interface IAction { @@ -26,4 +26,6 @@ public interface IAction { boolean hasParameter(); String getDescription(); + + IAction rotateLeft(); } diff --git a/common/buildcraft/api/gates/ITrigger.java b/common/buildcraft/api/gates/ITrigger.java index affc418b..ea2c3ab0 100644 --- a/common/buildcraft/api/gates/ITrigger.java +++ b/common/buildcraft/api/gates/ITrigger.java @@ -8,10 +8,10 @@ */ 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.util.IIcon; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; public interface ITrigger { @@ -49,4 +49,10 @@ public interface ITrigger { * trigger parameter available so this subprogram is final. */ ITriggerParameter createParameter(); + + /** + * This returns the trigger after a left rotation. Used in particular in + * blueprints orientation. + */ + ITrigger rotateLeft(); } diff --git a/common/buildcraft/builders/triggers/ActionFiller.java b/common/buildcraft/builders/triggers/ActionFiller.java index 0c991df1..2fb9600b 100644 --- a/common/buildcraft/builders/triggers/ActionFiller.java +++ b/common/buildcraft/builders/triggers/ActionFiller.java @@ -8,9 +8,10 @@ */ package buildcraft.builders.triggers; -import buildcraft.api.filler.IFillerPattern; -import buildcraft.core.triggers.*; 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 { @@ -35,4 +36,9 @@ public class ActionFiller extends BCAction { public int getTextureMap() { return 0; } + + @Override + public IAction rotateLeft() { + return this; + } } diff --git a/common/buildcraft/core/triggers/ActionMachineControl.java b/common/buildcraft/core/triggers/ActionMachineControl.java index c06378f2..f590af40 100644 --- a/common/buildcraft/core/triggers/ActionMachineControl.java +++ b/common/buildcraft/core/triggers/ActionMachineControl.java @@ -8,9 +8,11 @@ */ package buildcraft.core.triggers; -import buildcraft.core.utils.StringUtils; import java.util.Locale; +import buildcraft.api.gates.IAction; +import buildcraft.core.utils.StringUtils; + public class ActionMachineControl extends BCAction { public enum Mode { @@ -42,4 +44,9 @@ public class ActionMachineControl extends BCAction { return ActionTriggerIconProvider.Action_MachineControl_Loop; } } + + @Override + public IAction rotateLeft() { + return this; + } } diff --git a/common/buildcraft/core/triggers/ActionRedstoneOutput.java b/common/buildcraft/core/triggers/ActionRedstoneOutput.java index 122c0dc9..c6f13f94 100644 --- a/common/buildcraft/core/triggers/ActionRedstoneOutput.java +++ b/common/buildcraft/core/triggers/ActionRedstoneOutput.java @@ -8,6 +8,8 @@ */ package buildcraft.core.triggers; +import buildcraft.api.gates.IAction; + public class ActionRedstoneOutput extends BCAction { public ActionRedstoneOutput() { @@ -23,4 +25,9 @@ public class ActionRedstoneOutput extends BCAction { public int getIconIndex() { return ActionTriggerIconProvider.Trigger_RedstoneInput_Active; } + + @Override + public IAction rotateLeft() { + return this; + } } diff --git a/common/buildcraft/core/triggers/TriggerFluidContainer.java b/common/buildcraft/core/triggers/TriggerFluidContainer.java index 83aac0fa..8a3b07e0 100644 --- a/common/buildcraft/core/triggers/TriggerFluidContainer.java +++ b/common/buildcraft/core/triggers/TriggerFluidContainer.java @@ -8,16 +8,18 @@ */ package buildcraft.core.triggers; -import buildcraft.api.gates.ITileTrigger; -import buildcraft.api.gates.ITriggerParameter; -import buildcraft.core.utils.StringUtils; import java.util.Locale; + import net.minecraft.tileentity.TileEntity; import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.fluids.FluidContainerRegistry; import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.FluidTankInfo; 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 { @@ -34,10 +36,11 @@ public class TriggerFluidContainer extends BCTrigger implements ITileTrigger { @Override public boolean hasParameter() { - if (state == State.Contains || state == State.Space) + if (state == State.Contains || state == State.Space) { return true; - else + } else { return false; + } } @Override @@ -61,27 +64,31 @@ public class TriggerFluidContainer extends BCTrigger implements ITileTrigger { } FluidTankInfo[] liquids = container.getTankInfo(side); - if (liquids == null || liquids.length == 0) + if (liquids == null || liquids.length == 0) { return false; + } switch (state) { case Empty: 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 true; case Contains: 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 false; case Space: if (searchedFluid == null) { 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 false; } @@ -89,8 +96,9 @@ public class TriggerFluidContainer extends BCTrigger implements ITileTrigger { case Full: if (searchedFluid == null) { 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 true; } @@ -114,4 +122,9 @@ public class TriggerFluidContainer extends BCTrigger implements ITileTrigger { return ActionTriggerIconProvider.Trigger_FluidContainer_Full; } } + + @Override + public ITrigger rotateLeft() { + return this; + } } diff --git a/common/buildcraft/core/triggers/TriggerFluidContainerLevel.java b/common/buildcraft/core/triggers/TriggerFluidContainerLevel.java index 3e8fbec6..3b2b345d 100644 --- a/common/buildcraft/core/triggers/TriggerFluidContainerLevel.java +++ b/common/buildcraft/core/triggers/TriggerFluidContainerLevel.java @@ -8,31 +8,32 @@ */ 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.util.ForgeDirection; import net.minecraftforge.fluids.FluidContainerRegistry; import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.FluidTankInfo; 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 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) { @@ -66,8 +67,9 @@ public class TriggerFluidContainerLevel extends BCTrigger implements ITileTrigge } FluidTankInfo[] liquids = container.getTankInfo(side); - if (liquids == null || liquids.length == 0) + if (liquids == null || liquids.length == 0) { return false; + } for (FluidTankInfo c : liquids) { if (c.fluid == null) { @@ -76,7 +78,7 @@ public class TriggerFluidContainerLevel extends BCTrigger implements ITileTrigge } 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; @@ -99,4 +101,9 @@ public class TriggerFluidContainerLevel extends BCTrigger implements ITileTrigge return ActionTriggerIconProvider.Trigger_FluidContainer_Below75; } } + + @Override + public ITrigger rotateLeft() { + return this; + } } diff --git a/common/buildcraft/core/triggers/TriggerInventory.java b/common/buildcraft/core/triggers/TriggerInventory.java index 70ae3cc1..0d9c513f 100644 --- a/common/buildcraft/core/triggers/TriggerInventory.java +++ b/common/buildcraft/core/triggers/TriggerInventory.java @@ -8,18 +8,20 @@ */ 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.ITrigger; import buildcraft.api.gates.ITriggerParameter; import buildcraft.api.inventory.ISpecialInventory; import buildcraft.core.inventory.InventoryIterator; import buildcraft.core.inventory.InventoryIterator.IInvSlot; import buildcraft.core.inventory.StackHelper; 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 { @@ -37,10 +39,11 @@ public class TriggerInventory extends BCTrigger implements ITileTrigger { @Override public boolean hasParameter() { - if (state == State.Contains || state == State.Space) + if (state == State.Contains || state == State.Space) { return true; - else + } else { return false; + } } @Override @@ -69,8 +72,9 @@ public class TriggerInventory extends BCTrigger implements ITileTrigger { case Full: break; case Space: - if (searchedStack == null) + if (searchedStack == null) { break; + } int added = specialInventory.addItem(searchedStack, false, side); return added > 0; } @@ -90,8 +94,9 @@ public class TriggerInventory extends BCTrigger implements ITileTrigger { && (searchedStack == null || slot.canPutStackInSlot(searchedStack)); } - if (!hasSlots) + if (!hasSlots) { return false; + } switch (state) { case Empty: @@ -121,4 +126,9 @@ public class TriggerInventory extends BCTrigger implements ITileTrigger { return ActionTriggerIconProvider.Trigger_Inventory_Full; } } + + @Override + public ITrigger rotateLeft() { + return this; + } } diff --git a/common/buildcraft/core/triggers/TriggerInventoryLevel.java b/common/buildcraft/core/triggers/TriggerInventoryLevel.java index 28302948..9595897e 100644 --- a/common/buildcraft/core/triggers/TriggerInventoryLevel.java +++ b/common/buildcraft/core/triggers/TriggerInventoryLevel.java @@ -8,17 +8,19 @@ */ 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.ITrigger; import buildcraft.api.gates.ITriggerParameter; import buildcraft.core.inventory.InventoryIterator; import buildcraft.core.inventory.InventoryIterator.IInvSlot; import buildcraft.core.inventory.StackHelper; 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 { @@ -58,8 +60,9 @@ public class TriggerInventoryLevel extends BCTrigger implements ITileTrigger { @Override public boolean isTriggerActive(ForgeDirection side, TileEntity tile, ITriggerParameter parameter) { // A parameter is required - if (parameter == null) + if (parameter == null) { return false; + } if (tile instanceof IInventory) { ItemStack searchStack = parameter.getItemStack(); @@ -77,7 +80,7 @@ public class TriggerInventoryLevel extends BCTrigger implements ITileTrigger { } if (stackSpace > 0) { - float percentage = (float) foundItems / ((float) stackSpace * (float) searchStack.getMaxStackSize()); + float percentage = foundItems / ((float) stackSpace * (float) searchStack.getMaxStackSize()); return percentage < type.level; } @@ -97,4 +100,9 @@ public class TriggerInventoryLevel extends BCTrigger implements ITileTrigger { return ActionTriggerIconProvider.Trigger_Inventory_Below75; } } + + @Override + public ITrigger rotateLeft() { + return this; + } } diff --git a/common/buildcraft/core/triggers/TriggerMachine.java b/common/buildcraft/core/triggers/TriggerMachine.java index 7d816caa..c3c8aa94 100644 --- a/common/buildcraft/core/triggers/TriggerMachine.java +++ b/common/buildcraft/core/triggers/TriggerMachine.java @@ -8,12 +8,13 @@ */ package buildcraft.core.triggers; +import net.minecraft.tileentity.TileEntity; +import net.minecraftforge.common.util.ForgeDirection; import buildcraft.api.gates.ITileTrigger; +import buildcraft.api.gates.ITrigger; import buildcraft.api.gates.ITriggerParameter; import buildcraft.core.IMachine; import buildcraft.core.utils.StringUtils; -import net.minecraft.tileentity.TileEntity; -import net.minecraftforge.common.util.ForgeDirection; public class TriggerMachine extends BCTrigger implements ITileTrigger { @@ -35,10 +36,11 @@ public class TriggerMachine extends BCTrigger implements ITileTrigger { if (tile instanceof IMachine) { IMachine machine = (IMachine) tile; - if (active) + if (active) { return machine.isActive(); - else + } else { return !machine.isActive(); + } } return false; @@ -46,9 +48,15 @@ public class TriggerMachine extends BCTrigger implements ITileTrigger { @Override public int getIconIndex() { - if (active) + if (active) { return ActionTriggerIconProvider.Trigger_Machine_Active; - else + } else { return ActionTriggerIconProvider.Trigger_Machine_Inactive; + } + } + + @Override + public ITrigger rotateLeft() { + return this; } } diff --git a/common/buildcraft/core/triggers/TriggerRedstoneInput.java b/common/buildcraft/core/triggers/TriggerRedstoneInput.java index 15154136..06a0d6c6 100644 --- a/common/buildcraft/core/triggers/TriggerRedstoneInput.java +++ b/common/buildcraft/core/triggers/TriggerRedstoneInput.java @@ -8,6 +8,7 @@ */ package buildcraft.core.triggers; +import buildcraft.api.gates.ITrigger; import buildcraft.api.gates.ITriggerParameter; import buildcraft.core.utils.StringUtils; import buildcraft.transport.IPipeTrigger; @@ -29,8 +30,9 @@ public class TriggerRedstoneInput extends BCTrigger implements IPipeTrigger { @Override public boolean isTriggerActive(Pipe pipe, ITriggerParameter parameter) { - if (active) + if (active) { return isBeingPowered(pipe); + } return !isBeingPowered(pipe); } @@ -42,4 +44,9 @@ public class TriggerRedstoneInput extends BCTrigger implements IPipeTrigger { public int getIconIndex() { return active ? ActionTriggerIconProvider.Trigger_RedstoneInput_Active : ActionTriggerIconProvider.Trigger_RedstoneInput_Inactive; } + + @Override + public ITrigger rotateLeft() { + return this; + } } diff --git a/common/buildcraft/energy/triggers/TriggerEngineHeat.java b/common/buildcraft/energy/triggers/TriggerEngineHeat.java index c1b76131..67a6b088 100644 --- a/common/buildcraft/energy/triggers/TriggerEngineHeat.java +++ b/common/buildcraft/energy/triggers/TriggerEngineHeat.java @@ -8,7 +8,14 @@ */ 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.ITrigger; import buildcraft.api.gates.ITriggerParameter; import buildcraft.core.triggers.BCTrigger; import buildcraft.core.utils.StringUtils; @@ -16,11 +23,6 @@ import buildcraft.energy.TileEngine; import buildcraft.energy.TileEngine.EnergyStage; import cpw.mods.fml.relauncher.Side; 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 { @@ -61,4 +63,9 @@ public class TriggerEngineHeat extends BCTrigger implements ITileTrigger { public void registerIcons(IIconRegister iconRegister) { icon = iconRegister.registerIcon("buildcraft:triggers/trigger_engineheat_" + stage.name().toLowerCase(Locale.ENGLISH)); } + + @Override + public ITrigger rotateLeft() { + return this; + } } diff --git a/common/buildcraft/transport/blueprints/SchematicPipe.java b/common/buildcraft/transport/blueprints/SchematicPipe.java index 99276888..9ad2e688 100644 --- a/common/buildcraft/transport/blueprints/SchematicPipe.java +++ b/common/buildcraft/transport/blueprints/SchematicPipe.java @@ -12,9 +12,13 @@ import java.util.ArrayList; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; import buildcraft.api.blueprints.IBuilderContext; 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.Pipe; import buildcraft.transport.TileGenericPipe.SideProperties; @@ -46,6 +50,22 @@ public class SchematicPipe extends SchematicTile { if (BptPipeExtension.contains(pipeItem)) { 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 diff --git a/common/buildcraft/transport/triggers/ActionEnergyPulsar.java b/common/buildcraft/transport/triggers/ActionEnergyPulsar.java index 4245b08d..26755e42 100644 --- a/common/buildcraft/transport/triggers/ActionEnergyPulsar.java +++ b/common/buildcraft/transport/triggers/ActionEnergyPulsar.java @@ -10,14 +10,14 @@ package buildcraft.transport.triggers; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.util.IIcon; -import buildcraft.core.triggers.ActionTriggerIconProvider; +import buildcraft.api.gates.IAction; import buildcraft.core.triggers.BCAction; import buildcraft.core.utils.StringUtils; public class ActionEnergyPulsar extends BCAction { private IIcon icon; - + public ActionEnergyPulsar() { super("buildcraft:pulsar.constant", "buildcraft.pulser.constant"); } @@ -26,15 +26,20 @@ public class ActionEnergyPulsar extends BCAction { public IIcon getIcon() { return icon; } - + @Override public String getDescription() { return StringUtils.localize("gate.action.pulsar.constant"); } - + @Override public void registerIcons(IIconRegister iconRegister) { icon = iconRegister.registerIcon("buildcraft:triggers/action_pulsar"); } + @Override + public IAction rotateLeft() { + return this; + } + } diff --git a/common/buildcraft/transport/triggers/ActionExtractionPreset.java b/common/buildcraft/transport/triggers/ActionExtractionPreset.java index d201c1e2..08191c31 100644 --- a/common/buildcraft/transport/triggers/ActionExtractionPreset.java +++ b/common/buildcraft/transport/triggers/ActionExtractionPreset.java @@ -8,12 +8,14 @@ */ 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.utils.EnumColor; 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 { @@ -40,4 +42,9 @@ public class ActionExtractionPreset extends BCAction { public void registerIcons(IIconRegister iconRegister) { icon = iconRegister.registerIcon("buildcraft:triggers/extraction_preset_" + color.name().toLowerCase(Locale.ENGLISH)); } + + @Override + public IAction rotateLeft() { + return this; + } } diff --git a/common/buildcraft/transport/triggers/ActionPipeColor.java b/common/buildcraft/transport/triggers/ActionPipeColor.java index f7ec1741..b1282926 100644 --- a/common/buildcraft/transport/triggers/ActionPipeColor.java +++ b/common/buildcraft/transport/triggers/ActionPipeColor.java @@ -8,12 +8,14 @@ */ 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.utils.EnumColor; 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 { @@ -40,4 +42,9 @@ public class ActionPipeColor extends BCAction { public void registerIcons(IIconRegister iconRegister) { icon = iconRegister.registerIcon("buildcraft:triggers/color_" + color.name().toLowerCase(Locale.ENGLISH)); } + + @Override + public IAction rotateLeft() { + return this; + } } diff --git a/common/buildcraft/transport/triggers/ActionPipeDirection.java b/common/buildcraft/transport/triggers/ActionPipeDirection.java index 602a0f1a..d495571c 100644 --- a/common/buildcraft/transport/triggers/ActionPipeDirection.java +++ b/common/buildcraft/transport/triggers/ActionPipeDirection.java @@ -8,11 +8,13 @@ */ package buildcraft.transport.triggers; -import buildcraft.core.triggers.BCAction; import java.util.Locale; + import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.util.IIcon; import net.minecraftforge.common.util.ForgeDirection; +import buildcraft.api.gates.IAction; +import buildcraft.core.triggers.BCAction; public class ActionPipeDirection extends BCAction { @@ -39,4 +41,9 @@ public class ActionPipeDirection extends BCAction { public void registerIcons(IIconRegister iconRegister) { icon = iconRegister.registerIcon("buildcraft:triggers/trigger_dir_" + direction.name().toLowerCase(Locale.ENGLISH)); } + + @Override + public IAction rotateLeft() { + return new ActionPipeDirection(direction.getRotation(ForgeDirection.UP)); + } } diff --git a/common/buildcraft/transport/triggers/ActionPowerLimiter.java b/common/buildcraft/transport/triggers/ActionPowerLimiter.java index 63887870..16f96443 100644 --- a/common/buildcraft/transport/triggers/ActionPowerLimiter.java +++ b/common/buildcraft/transport/triggers/ActionPowerLimiter.java @@ -8,11 +8,13 @@ */ package buildcraft.transport.triggers; -import buildcraft.core.triggers.BCAction; -import buildcraft.transport.pipes.PipePowerIron.PowerMode; 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.transport.pipes.PipePowerIron.PowerMode; public class ActionPowerLimiter extends BCAction { @@ -39,4 +41,9 @@ public class ActionPowerLimiter extends BCAction { public void registerIcons(IIconRegister iconRegister) { icon = iconRegister.registerIcon("buildcraft:triggers/trigger_limiter_" + limit.name().toLowerCase(Locale.ENGLISH)); } + + @Override + public IAction rotateLeft() { + return this; + } } diff --git a/common/buildcraft/transport/triggers/ActionRedstoneFaderOutput.java b/common/buildcraft/transport/triggers/ActionRedstoneFaderOutput.java index 291422db..aaabc16a 100644 --- a/common/buildcraft/transport/triggers/ActionRedstoneFaderOutput.java +++ b/common/buildcraft/transport/triggers/ActionRedstoneFaderOutput.java @@ -8,12 +8,13 @@ */ 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.utils.StringUtils; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; -import net.minecraft.client.renderer.texture.IIconRegister; -import net.minecraft.util.IIcon; public class ActionRedstoneFaderOutput extends BCAction { @@ -43,4 +44,9 @@ public class ActionRedstoneFaderOutput extends BCAction { public void registerIcons(IIconRegister iconRegister) { icon = iconRegister.registerIcon(String.format("buildcraft:triggers/redstone_%02d", level)); } + + @Override + public IAction rotateLeft() { + return this; + } } diff --git a/common/buildcraft/transport/triggers/ActionSignalOutput.java b/common/buildcraft/transport/triggers/ActionSignalOutput.java index 45c093e5..e4d329d5 100644 --- a/common/buildcraft/transport/triggers/ActionSignalOutput.java +++ b/common/buildcraft/transport/triggers/ActionSignalOutput.java @@ -8,11 +8,13 @@ */ 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.BCAction; -import buildcraft.api.transport.PipeWire; import buildcraft.core.utils.StringUtils; -import java.util.Locale; public class ActionSignalOutput extends BCAction { @@ -43,4 +45,9 @@ public class ActionSignalOutput extends BCAction { return ActionTriggerIconProvider.Trigger_PipeSignal_Yellow_Active; } } + + @Override + public IAction rotateLeft() { + return this; + } } diff --git a/common/buildcraft/transport/triggers/ActionSingleEnergyPulse.java b/common/buildcraft/transport/triggers/ActionSingleEnergyPulse.java index 673ce0b5..d43ef0b0 100644 --- a/common/buildcraft/transport/triggers/ActionSingleEnergyPulse.java +++ b/common/buildcraft/transport/triggers/ActionSingleEnergyPulse.java @@ -10,12 +10,12 @@ package buildcraft.transport.triggers; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.util.IIcon; -import buildcraft.core.triggers.ActionTriggerIconProvider; +import buildcraft.api.gates.IAction; import buildcraft.core.triggers.BCAction; import buildcraft.core.utils.StringUtils; public class ActionSingleEnergyPulse extends BCAction { - + private IIcon icon; public ActionSingleEnergyPulse() { @@ -31,10 +31,14 @@ public class ActionSingleEnergyPulse extends BCAction { public String getDescription() { return StringUtils.localize("gate.action.pulsar.single"); } - + @Override public void registerIcons(IIconRegister iconRegister) { icon = iconRegister.registerIcon("buildcraft:triggers/action_single_pulsar"); } + @Override + public IAction rotateLeft() { + return this; + } } diff --git a/common/buildcraft/transport/triggers/TriggerClockTimer.java b/common/buildcraft/transport/triggers/TriggerClockTimer.java index 88b35f03..98e8c287 100644 --- a/common/buildcraft/transport/triggers/TriggerClockTimer.java +++ b/common/buildcraft/transport/triggers/TriggerClockTimer.java @@ -10,10 +10,11 @@ package buildcraft.transport.triggers; import java.util.Locale; -import buildcraft.core.triggers.BCTrigger; -import buildcraft.core.utils.StringUtils; import net.minecraft.client.renderer.texture.IIconRegister; 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 { @@ -50,4 +51,9 @@ public class TriggerClockTimer extends BCTrigger { public void registerIcons(IIconRegister iconRegister) { icon = iconRegister.registerIcon("buildcraft:triggers/trigger_timer_" + time.name().toLowerCase(Locale.ENGLISH)); } + + @Override + public ITrigger rotateLeft() { + return this; + } } diff --git a/common/buildcraft/transport/triggers/TriggerPipeContents.java b/common/buildcraft/transport/triggers/TriggerPipeContents.java index af0d66d8..632b4d1a 100644 --- a/common/buildcraft/transport/triggers/TriggerPipeContents.java +++ b/common/buildcraft/transport/triggers/TriggerPipeContents.java @@ -8,6 +8,15 @@ */ 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.core.triggers.BCTrigger; import buildcraft.core.utils.StringUtils; @@ -20,13 +29,6 @@ import buildcraft.transport.TravelingItem; import buildcraft.transport.pipes.PipePowerWood; import cpw.mods.fml.relauncher.Side; 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 { @@ -70,17 +72,20 @@ public class TriggerPipeContents extends BCTrigger implements IPipeTrigger { if (pipe.transport instanceof PipeTransportItems) { PipeTransportItems transportItems = (PipeTransportItems) pipe.transport; - if (kind == PipeContents.empty) + if (kind == PipeContents.empty) { return transportItems.items.isEmpty(); - else if (kind == PipeContents.containsItems) + } else if (kind == PipeContents.containsItems) { if (parameter != null && parameter.getItemStack() != null) { for (TravelingItem item : transportItems.items) { if (item.getItemStack().getItem() == parameter.getItemStack().getItem() - && item.getItemStack().getItemDamage() == parameter.getItemStack().getItemDamage()) + && item.getItemStack().getItemDamage() == parameter.getItemStack().getItemDamage()) { return true; + } } - } else + } else { return !transportItems.items.isEmpty(); + } + } } else if (pipe.transport instanceof PipeTransportFluids) { PipeTransportFluids transportFluids = (PipeTransportFluids) pipe.transport; @@ -92,16 +97,19 @@ public class TriggerPipeContents extends BCTrigger implements IPipeTrigger { if (kind == PipeContents.empty) { 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 true; } else { for (FluidTankInfo b : transportFluids.getTankInfo(ForgeDirection.UNKNOWN)) { - if (b.fluid != null && b.fluid.amount != 0) - if (searchedFluid == null || searchedFluid.isFluidEqual(b.fluid)) + if (b.fluid != null && b.fluid.amount != 0) { + if (searchedFluid == null || searchedFluid.isFluidEqual(b.fluid)) { return true; + } + } } return false; @@ -112,15 +120,17 @@ public class TriggerPipeContents extends BCTrigger implements IPipeTrigger { switch (kind) { case empty: for (double s : transportPower.displayPower) { - if (s > 1e-4) + if (s > 1e-4) { return false; + } } return true; case containsEnergy: for (double s : transportPower.displayPower) { - if (s > 1e-4) + if (s > 1e-4) { return true; + } } return false; @@ -146,4 +156,9 @@ public class TriggerPipeContents extends BCTrigger implements IPipeTrigger { public void registerIcons(IIconRegister iconRegister) { icon = iconRegister.registerIcon("buildcraft:triggers/trigger_pipecontents_" + kind.name().toLowerCase(Locale.ENGLISH)); } + + @Override + public ITrigger rotateLeft() { + return this; + } } diff --git a/common/buildcraft/transport/triggers/TriggerPipeSignal.java b/common/buildcraft/transport/triggers/TriggerPipeSignal.java index 01744b82..690b8531 100644 --- a/common/buildcraft/transport/triggers/TriggerPipeSignal.java +++ b/common/buildcraft/transport/triggers/TriggerPipeSignal.java @@ -8,14 +8,16 @@ */ package buildcraft.transport.triggers; +import java.util.Locale; + +import buildcraft.api.gates.ITrigger; import buildcraft.api.gates.ITriggerParameter; +import buildcraft.api.transport.PipeWire; import buildcraft.core.triggers.ActionTriggerIconProvider; import buildcraft.core.triggers.BCTrigger; +import buildcraft.core.utils.StringUtils; import buildcraft.transport.IPipeTrigger; 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 { @@ -42,10 +44,11 @@ public class TriggerPipeSignal extends BCTrigger implements IPipeTrigger { @Override public boolean isTriggerActive(Pipe pipe, ITriggerParameter parameter) { - if (active) + if (active) { return pipe.signalStrength[color.ordinal()] > 0; - else + } else { return pipe.signalStrength[color.ordinal()] == 0; + } } @Override @@ -75,4 +78,9 @@ public class TriggerPipeSignal extends BCTrigger implements IPipeTrigger { } return -1; } + + @Override + public ITrigger rotateLeft() { + return this; + } } diff --git a/common/buildcraft/transport/triggers/TriggerRedstoneFaderInput.java b/common/buildcraft/transport/triggers/TriggerRedstoneFaderInput.java index 580c1b94..8b2b36cc 100644 --- a/common/buildcraft/transport/triggers/TriggerRedstoneFaderInput.java +++ b/common/buildcraft/transport/triggers/TriggerRedstoneFaderInput.java @@ -8,6 +8,9 @@ */ 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.core.triggers.BCTrigger; import buildcraft.core.utils.StringUtils; @@ -15,8 +18,6 @@ import buildcraft.transport.IPipeTrigger; import buildcraft.transport.Pipe; import cpw.mods.fml.relauncher.Side; 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 { @@ -51,4 +52,9 @@ public class TriggerRedstoneFaderInput extends BCTrigger implements IPipeTrigger public void registerIcons(IIconRegister iconRegister) { icon = iconRegister.registerIcon(String.format("buildcraft:triggers/redstone_%02d", level)); } + + @Override + public ITrigger rotateLeft() { + return this; + } }