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.
This commit is contained in:
CovertJaguar 2013-06-24 18:06:01 -07:00
parent 318eb5c4a7
commit c50847c196
9 changed files with 82 additions and 40 deletions

View file

@ -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

Binary file not shown.

After

Width:  |  Height:  |  Size: 250 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 249 B

View file

@ -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);

View file

@ -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;

View file

@ -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");

View file

@ -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();

View file

@ -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);

View file

@ -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;
}
}
}