buildcraft/common/buildcraft/transport/PipeTriggerProvider.java

72 lines
2.2 KiB
Java
Raw Normal View History

2014-02-15 09:21:40 +01:00
/**
* Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team
2014-02-15 09:21:40 +01:00
* http://www.mod-buildcraft.com
*
* BuildCraft is distributed under the terms of the Minecraft Mod Public
* License 1.0, or MMPL. Please check the contents of the license located in
* http://www.mod-buildcraft.com/MMPL-1.0.txt
*/
2012-07-25 12:45:15 +02:00
package buildcraft.transport;
2012-05-09 22:43:05 +02:00
import java.util.LinkedList;
import net.minecraft.tileentity.TileEntity;
2014-09-03 19:22:15 +02:00
import net.minecraftforge.common.util.ForgeDirection;
import buildcraft.api.statements.IStatementContainer;
import buildcraft.api.statements.ITriggerExternal;
import buildcraft.api.statements.ITriggerInternal;
import buildcraft.api.statements.ITriggerProvider;
2014-10-26 13:20:08 +01:00
import buildcraft.transport.statements.TriggerPipeContents;
2012-07-25 12:45:15 +02:00
2012-05-09 22:43:05 +02:00
public class PipeTriggerProvider implements ITriggerProvider {
@Override
public LinkedList<ITriggerInternal> getInternalTriggers(IStatementContainer container) {
LinkedList<ITriggerInternal> result = new LinkedList<ITriggerInternal>();
2014-06-15 19:27:17 +02:00
Pipe<?> pipe = null;
TileEntity tile = container.getTile();
2015-03-22 14:06:05 +01:00
if (tile instanceof TileGenericPipe) {
2013-12-21 01:55:47 +01:00
pipe = ((TileGenericPipe) tile).pipe;
}
if (pipe == null) {
2013-12-21 01:55:47 +01:00
return result;
}
2014-10-19 21:04:02 +02:00
boolean containsGate = false;
2013-12-21 01:55:47 +01:00
2014-06-14 13:42:13 +02:00
for (Gate gate : pipe.gates) {
if (gate != null) {
2014-10-19 21:04:02 +02:00
containsGate = true;
gate.addTriggers(result);
2014-06-14 13:42:13 +02:00
}
}
2012-05-09 22:43:05 +02:00
switch (((TileGenericPipe) tile).getPipeType()) {
2013-12-21 01:55:47 +01:00
case ITEM:
2013-12-27 17:40:44 +01:00
result.add(TriggerPipeContents.PipeContents.empty.trigger);
result.add(TriggerPipeContents.PipeContents.containsItems.trigger);
2013-12-21 01:55:47 +01:00
break;
case FLUID:
2013-12-27 17:40:44 +01:00
result.add(TriggerPipeContents.PipeContents.empty.trigger);
result.add(TriggerPipeContents.PipeContents.containsFluids.trigger);
2013-12-21 01:55:47 +01:00
break;
case POWER:
2013-12-27 17:40:44 +01:00
result.add(TriggerPipeContents.PipeContents.empty.trigger);
result.add(TriggerPipeContents.PipeContents.containsEnergy.trigger);
result.add(TriggerPipeContents.PipeContents.tooMuchEnergy.trigger);
2014-10-19 21:04:02 +02:00
result.add(TriggerPipeContents.PipeContents.requestsEnergy.trigger);
break;
case STRUCTURE:
2013-12-21 01:55:47 +01:00
break;
2012-05-09 22:43:05 +02:00
}
return result;
}
@Override
public LinkedList<ITriggerExternal> getExternalTriggers(ForgeDirection side, TileEntity tile) {
LinkedList<ITriggerExternal> result = new LinkedList<ITriggerExternal>();
return result;
2012-05-09 22:43:05 +02:00
}
}