From c50847c19605c2a808549c04cdb4b66e42e3d7e8 Mon Sep 17 00:00:00 2001 From: CovertJaguar Date: Mon, 24 Jun 2013 18:06:01 -0700 Subject: [PATCH] Added two new Power Pipe Triggers Requests Energy: Activated when the pipe has an active power request. Use to allow your network to respond to demand dynamically. Energy Overloaded: Activated when the pipe turns red, in case anyone wants to know when that happens. --- .../lang/buildcraft/en_US.properties | 6 ++ .../trigger_pipecontents_requestsenergy.png | Bin 0 -> 250 bytes .../trigger_pipecontents_toomuchenergy.png | Bin 0 -> 249 bytes common/buildcraft/BuildCraftTransport.java | 4 +- common/buildcraft/core/DefaultProps.java | 4 +- .../triggers/ActionTriggerIconProvider.java | 6 +- .../transport/PipeTransportPower.java | 6 +- .../transport/PipeTriggerProvider.java | 4 +- .../triggers/TriggerPipeContents.java | 92 +++++++++++------- 9 files changed, 82 insertions(+), 40 deletions(-) create mode 100644 buildcraft_resources/mods/buildcraft/textures/items/triggers/trigger_pipecontents_requestsenergy.png create mode 100644 buildcraft_resources/mods/buildcraft/textures/items/triggers/trigger_pipecontents_toomuchenergy.png diff --git a/buildcraft_resources/lang/buildcraft/en_US.properties b/buildcraft_resources/lang/buildcraft/en_US.properties index 425d32c0..50f77da3 100644 --- a/buildcraft_resources/lang/buildcraft/en_US.properties +++ b/buildcraft_resources/lang/buildcraft/en_US.properties @@ -1,5 +1,11 @@ # Master language file +gate.pipe.empty=Pipe Empty +gate.pipe.containsItems=Items Traversing +gate.pipe.containsLiquids=Liquid Traversing +gate.pipe.containsEnergy=Power Traversing +gate.pipe.requestsEnergy=Power Requested +gate.pipe.tooMuchEnergy=Power Overloaded gui.building.resources=Building Resources gui.del=Del gui.filling.resources=Filling Resources diff --git a/buildcraft_resources/mods/buildcraft/textures/items/triggers/trigger_pipecontents_requestsenergy.png b/buildcraft_resources/mods/buildcraft/textures/items/triggers/trigger_pipecontents_requestsenergy.png new file mode 100644 index 0000000000000000000000000000000000000000..11beb7d9b6b0ad0b325db38ae8bdb2d6cf2e1ef6 GIT binary patch literal 250 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61SBU+%rFB|Ea{HEjtmSN`?>!lvI6-E$sR$z z3=CCj3=9n|3=F@3LJcn%7)lKo7+xhXFj&oCU=S~uvn$XBD8X6a5n0T@z%2;EjP)t; z6M=$KC9V-A!TD(=<%vb93;~Imc_n&&t|1C##(JiDh6V;-iWUM@d3m}xhFJI~zfco2 zn6P4BwMuqCbK`#=o&vK8jb~b0)V(wur!cwx-=ADj+0A;Qp+He(7hB3s`SX$uRSI4c lLzQzBE_)t1@~faDlfiO+U4nTfZz#}I22WQ%mvv4FO#o34M^yj- literal 0 HcmV?d00001 diff --git a/buildcraft_resources/mods/buildcraft/textures/items/triggers/trigger_pipecontents_toomuchenergy.png b/buildcraft_resources/mods/buildcraft/textures/items/triggers/trigger_pipecontents_toomuchenergy.png new file mode 100644 index 0000000000000000000000000000000000000000..5627dd5f9d0596c43d61c853fa36c6d8a2e389d5 GIT binary patch literal 249 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61SBU+%rFB|Ea{HEjtmSN`?>!lvI6-E$sR$z z3=CCj3=9n|3=F@3LJcn%7)lKo7+xhXFj&oCU=S~uvn$XBD8X6a5n0T@z%2yAjF;}# z{Q(L}mAFQf1m~xflqVLYG6W=M=9TFAxrQi|8S9zq85$UTDOw0r<>~3-7-Hd{{6bC8 zV8V)h)hgKm&5i$gcnZuWG@fZ~QTNhtoWkVV_$qGG1_nt1y%v}24LaYO8yQ!yFA|9~ lJ;Y`-*TrWIfBOtJhKxH^$IX^}t^*p%;OXk;vd$@?2>_R5NBjT) literal 0 HcmV?d00001 diff --git a/common/buildcraft/BuildCraftTransport.java b/common/buildcraft/BuildCraftTransport.java index 759ad381..2b0196d0 100644 --- a/common/buildcraft/BuildCraftTransport.java +++ b/common/buildcraft/BuildCraftTransport.java @@ -148,7 +148,9 @@ public class BuildCraftTransport { public static BCTrigger triggerPipeEmpty = new TriggerPipeContents(DefaultProps.TRIGGER_PIPE_EMPTY, Kind.Empty); public static BCTrigger triggerPipeItems = new TriggerPipeContents(DefaultProps.TRIGGER_PIPE_ITEMS, Kind.ContainsItems); public static BCTrigger triggerPipeLiquids = new TriggerPipeContents(DefaultProps.TRIGGER_PIPE_LIQUIDS, Kind.ContainsLiquids); - public static BCTrigger triggerPipeEnergy = new TriggerPipeContents(DefaultProps.TRIGGER_PIPE_ENERGY, Kind.ContainsEnergy); + public static BCTrigger triggerPipeContainsEnergy = new TriggerPipeContents(DefaultProps.TRIGGER_PIPE_CONTAINS_ENERGY, Kind.ContainsEnergy); + public static BCTrigger triggerPipeRequestsEnergy = new TriggerPipeContents(DefaultProps.TRIGGER_PIPE_REQUESTS_ENERGY, Kind.RequestsEnergy); + public static BCTrigger triggerPipeTooMuchEnergy = new TriggerPipeContents(DefaultProps.TRIGGER_PIPE_TOO_MUCH_ENERGY, Kind.TooMuchEnergy); public static BCTrigger triggerRedSignalActive = new TriggerPipeSignal(DefaultProps.TRIGGER_RED_SIGNAL_ACTIVE, true, IPipe.WireColor.Red); public static BCTrigger triggerRedSignalInactive = new TriggerPipeSignal(DefaultProps.TRIGGER_RED_SIGNAL_INACTIVE, false, IPipe.WireColor.Red); public static BCTrigger triggerBlueSignalActive = new TriggerPipeSignal(DefaultProps.TRIGGER_BLUE_SIGNAL_ACTIVE, true, IPipe.WireColor.Blue); diff --git a/common/buildcraft/core/DefaultProps.java b/common/buildcraft/core/DefaultProps.java index b99efcea..726b9264 100644 --- a/common/buildcraft/core/DefaultProps.java +++ b/common/buildcraft/core/DefaultProps.java @@ -139,7 +139,7 @@ public class DefaultProps { public static int TRIGGER_PIPE_EMPTY = 13; public static int TRIGGER_PIPE_ITEMS = 14; public static int TRIGGER_PIPE_LIQUIDS = 15; - public static int TRIGGER_PIPE_ENERGY = 16; + public static int TRIGGER_PIPE_CONTAINS_ENERGY = 16; public static int TRIGGER_RED_SIGNAL_ACTIVE = 17; public static int TRIGGER_RED_SIGNAL_INACTIVE = 18; public static int TRIGGER_BLUE_SIGNAL_ACTIVE = 19; @@ -152,6 +152,8 @@ public class DefaultProps { public static int TRIGGER_GREEN_ENGINE_HEAT = 26; public static int TRIGGER_YELLOW_ENGINE_HEAT = 27; public static int TRIGGER_RED_ENGINE_HEAT = 28; + public static int TRIGGER_PIPE_REQUESTS_ENERGY = 29; + public static int TRIGGER_PIPE_TOO_MUCH_ENERGY = 30; public static int ACTION_REDSTONE = 1; public static int ACTION_RED_SIGNAL = 2; diff --git a/common/buildcraft/core/triggers/ActionTriggerIconProvider.java b/common/buildcraft/core/triggers/ActionTriggerIconProvider.java index f3d242f1..ab8e4703 100644 --- a/common/buildcraft/core/triggers/ActionTriggerIconProvider.java +++ b/common/buildcraft/core/triggers/ActionTriggerIconProvider.java @@ -40,8 +40,10 @@ public class ActionTriggerIconProvider implements IIconProvider { public static final int Trigger_PipeSignal_Yellow_Inactive = 28; public static final int Trigger_RedstoneInput_Active = 29; public static final int Trigger_RedstoneInput_Inactive = 30; + public static final int Trigger_PipeContents_RequestsEnergy = 31; + public static final int Trigger_PipeContents_TooMuchEnergy = 32; - public static final int MAX = 31; + public static final int MAX = 33; @SideOnly(Side.CLIENT) @@ -80,6 +82,8 @@ public class ActionTriggerIconProvider implements IIconProvider { icons[ActionTriggerIconProvider.Trigger_PipeContents_ContainsItems] = iconRegister.registerIcon("buildcraft:triggers/trigger_pipecontents_containsitems"); icons[ActionTriggerIconProvider.Trigger_PipeContents_ContainsLiquid] = iconRegister.registerIcon("buildcraft:triggers/trigger_pipecontents_containsliquid"); icons[ActionTriggerIconProvider.Trigger_PipeContents_ContainsEnergy] = iconRegister.registerIcon("buildcraft:triggers/trigger_pipecontents_containsenergy"); + icons[ActionTriggerIconProvider.Trigger_PipeContents_RequestsEnergy] = iconRegister.registerIcon("buildcraft:triggers/trigger_pipecontents_requestsenergy"); + icons[ActionTriggerIconProvider.Trigger_PipeContents_TooMuchEnergy] = iconRegister.registerIcon("buildcraft:triggers/trigger_pipecontents_toomuchenergy"); icons[ActionTriggerIconProvider.Trigger_PipeSignal_Red_Active] = iconRegister.registerIcon("buildcraft:triggers/trigger_pipesignal_red_active"); icons[ActionTriggerIconProvider.Trigger_PipeSignal_Red_Inactive] = iconRegister.registerIcon("buildcraft:triggers/trigger_pipesignal_red_inactive"); icons[ActionTriggerIconProvider.Trigger_PipeSignal_Blue_Active] = iconRegister.registerIcon("buildcraft:triggers/trigger_pipesignal_blue_active"); diff --git a/common/buildcraft/transport/PipeTransportPower.java b/common/buildcraft/transport/PipeTransportPower.java index b64e4074..db2e600b 100644 --- a/common/buildcraft/transport/PipeTransportPower.java +++ b/common/buildcraft/transport/PipeTransportPower.java @@ -233,12 +233,16 @@ public class PipeTransportPower extends PipeTransport { } packet.displayPower = clientDisplayPower; - packet.overload = overload >= OVERLOAD_TICKS; + packet.overload = isOverloaded(); CoreProxy.proxy.sendToPlayers(packet.getPacket(), worldObj, xCoord, yCoord, zCoord, DefaultProps.PIPE_CONTENTS_RENDER_DIST); } } + public boolean isOverloaded() { + return overload >= OVERLOAD_TICKS; + } + public void step() { if (currentDate != worldObj.getWorldTime()) { currentDate = worldObj.getWorldTime(); diff --git a/common/buildcraft/transport/PipeTriggerProvider.java b/common/buildcraft/transport/PipeTriggerProvider.java index 2ad57515..9bf8021f 100644 --- a/common/buildcraft/transport/PipeTriggerProvider.java +++ b/common/buildcraft/transport/PipeTriggerProvider.java @@ -30,7 +30,9 @@ public class PipeTriggerProvider implements ITriggerProvider { result.add(BuildCraftTransport.triggerPipeItems); } else if (pipe.transport instanceof PipeTransportPower) { result.add(BuildCraftTransport.triggerPipeEmpty); - result.add(BuildCraftTransport.triggerPipeEnergy); + result.add(BuildCraftTransport.triggerPipeContainsEnergy); + result.add(BuildCraftTransport.triggerPipeRequestsEnergy); + result.add(BuildCraftTransport.triggerPipeTooMuchEnergy); } else if (pipe.transport instanceof PipeTransportLiquids) { result.add(BuildCraftTransport.triggerPipeEmpty); result.add(BuildCraftTransport.triggerPipeLiquids); diff --git a/common/buildcraft/transport/triggers/TriggerPipeContents.java b/common/buildcraft/transport/triggers/TriggerPipeContents.java index 092a25fd..26503f4f 100644 --- a/common/buildcraft/transport/triggers/TriggerPipeContents.java +++ b/common/buildcraft/transport/triggers/TriggerPipeContents.java @@ -1,12 +1,10 @@ /** - * Copyright (c) SpaceToad, 2011 - * http://www.mod-buildcraft.com + * 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 + * 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.transport.triggers; import net.minecraftforge.common.ForgeDirection; @@ -16,6 +14,7 @@ import net.minecraftforge.liquids.LiquidStack; import buildcraft.api.gates.ITriggerParameter; import buildcraft.core.triggers.ActionTriggerIconProvider; import buildcraft.core.triggers.BCTrigger; +import buildcraft.core.utils.StringUtils; import buildcraft.transport.EntityData; import buildcraft.transport.ITriggerPipe; import buildcraft.transport.Pipe; @@ -26,9 +25,9 @@ import buildcraft.transport.PipeTransportPower; public class TriggerPipeContents extends BCTrigger implements ITriggerPipe { public enum Kind { - Empty, ContainsItems, ContainsLiquids, ContainsEnergy - }; + Empty, ContainsItems, ContainsLiquids, ContainsEnergy, RequestsEnergy, TooMuchEnergy + }; Kind kind; public TriggerPipeContents(int id, Kind kind) { @@ -39,11 +38,11 @@ public class TriggerPipeContents extends BCTrigger implements ITriggerPipe { @Override public boolean hasParameter() { switch (kind) { - case ContainsItems: - case ContainsLiquids: - return true; - default: - return false; + case ContainsItems: + case ContainsLiquids: + return true; + default: + return false; } } @@ -51,14 +50,18 @@ public class TriggerPipeContents extends BCTrigger implements ITriggerPipe { public String getDescription() { switch (kind) { - case Empty: - return "Pipe Empty"; - case ContainsItems: - return "Items Traversing"; - case ContainsLiquids: - return "Liquid Traversing"; - case ContainsEnergy: - return "Power Traversing"; + case Empty: + return StringUtils.localize("gate.pipe.empty"); + case ContainsItems: + return StringUtils.localize("gate.pipe.containsItems"); + case ContainsLiquids: + return StringUtils.localize("gate.pipe.containsLiquids"); + case ContainsEnergy: + return StringUtils.localize("gate.pipe.containsEnergy"); + case RequestsEnergy: + return StringUtils.localize("gate.pipe.requestsEnergy"); + case TooMuchEnergy: + return StringUtils.localize("gate.pipe.tooMuchEnergy"); } return ""; @@ -73,10 +76,11 @@ public class TriggerPipeContents extends BCTrigger implements ITriggerPipe { return transportItems.travelingEntities.isEmpty(); else if (kind == Kind.ContainsItems) if (parameter != null && parameter.getItem() != null) { - for (EntityData data : transportItems.travelingEntities.values()) + for (EntityData data : transportItems.travelingEntities.values()) { if (data.item.getItemStack().itemID == parameter.getItem().itemID && data.item.getItemStack().getItemDamage() == parameter.getItem().getItemDamage()) return true; + } } else return !transportItems.travelingEntities.isEmpty(); } else if (pipe.transport instanceof PipeTransportLiquids) { @@ -89,34 +93,48 @@ public class TriggerPipeContents extends BCTrigger implements ITriggerPipe { } if (kind == Kind.Empty) { - for (ILiquidTank b : transportLiquids.getTanks(ForgeDirection.UNKNOWN)) + for (ILiquidTank b : transportLiquids.getTanks(ForgeDirection.UNKNOWN)) { if (b.getLiquid() != null && b.getLiquid().amount != 0) return false; + } return true; } else { - for (ILiquidTank b : transportLiquids.getTanks(ForgeDirection.UNKNOWN)) + for (ILiquidTank b : transportLiquids.getTanks(ForgeDirection.UNKNOWN)) { if (b.getLiquid() != null && b.getLiquid().amount != 0) if (searchedLiquid == null || searchedLiquid.isLiquidEqual(b.getLiquid())) return true; + } return false; } } else if (pipe.transport instanceof PipeTransportPower) { PipeTransportPower transportPower = (PipeTransportPower) pipe.transport; - if (kind == Kind.Empty) { - for (double s : transportPower.displayPower) - if (s > 0) - return false; + switch (kind) { + case Empty: + for (double s : transportPower.displayPower) { + if (s > 0) + return false; + } - return true; - } else { - for (double s : transportPower.displayPower) - if (s > 0) - return true; + return true; + case ContainsEnergy: + for (double s : transportPower.displayPower) { + if (s > 0) + return true; + } - return false; + return false; + case RequestsEnergy: + for (double s : transportPower.powerQuery) { + if (s > 0) + return true; + } + + return false; + case TooMuchEnergy: + return transportPower.isOverloaded(); } } @@ -133,9 +151,13 @@ public class TriggerPipeContents extends BCTrigger implements ITriggerPipe { case ContainsLiquids: return ActionTriggerIconProvider.Trigger_PipeContents_ContainsLiquid; case ContainsEnergy: - default: return ActionTriggerIconProvider.Trigger_PipeContents_ContainsEnergy; - + case RequestsEnergy: + return ActionTriggerIconProvider.Trigger_PipeContents_RequestsEnergy; + case TooMuchEnergy: + default: + return ActionTriggerIconProvider.Trigger_PipeContents_TooMuchEnergy; + } } }