From ae112cf5d0cb78240ee140a6558c25e256e428e4 Mon Sep 17 00:00:00 2001 From: SpaceToad Date: Sat, 28 Jun 2014 00:02:18 +0200 Subject: [PATCH] Fixed file casing. --- .../statements/ActionRobotGotoStation.java | 99 +++++++++++++++++++ 1 file changed, 99 insertions(+) create mode 100755 common/buildcraft/silicon/statements/ActionRobotGotoStation.java diff --git a/common/buildcraft/silicon/statements/ActionRobotGotoStation.java b/common/buildcraft/silicon/statements/ActionRobotGotoStation.java new file mode 100755 index 00000000..74a15f5d --- /dev/null +++ b/common/buildcraft/silicon/statements/ActionRobotGotoStation.java @@ -0,0 +1,99 @@ +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * 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 + */ +package buildcraft.silicon.statements; + +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.item.ItemStack; + +import net.minecraftforge.common.util.ForgeDirection; + +import buildcraft.api.core.BlockIndex; +import buildcraft.api.gates.ActionParameterItemStack; +import buildcraft.api.gates.IActionParameter; +import buildcraft.api.gates.IGate; +import buildcraft.api.robots.AIRobot; +import buildcraft.api.robots.DockingStationRegistry; +import buildcraft.core.ItemMapLocation; +import buildcraft.core.robots.AIRobotGoAndLinkToDock; +import buildcraft.core.robots.DockingStation; +import buildcraft.core.robots.EntityRobot; +import buildcraft.core.triggers.BCActionActive; +import buildcraft.core.utils.StringUtils; +import buildcraft.transport.Pipe; +import buildcraft.transport.TileGenericPipe; + +public class ActionRobotGotoStation extends BCActionActive { + + public ActionRobotGotoStation() { + super("buildcraft:robot.goto_station"); + } + + @Override + public String getDescription() { + return StringUtils.localize("gate.action.robot.goto_station"); + } + + @Override + public void registerIcons(IIconRegister iconRegister) { + icon = iconRegister.registerIcon("buildcraft:triggers/action_robot_goto_station"); + } + + @Override + public void actionActivate(IGate gate, IActionParameter[] parameters) { + Pipe pipe = (Pipe) gate.getPipe(); + TileGenericPipe tile = pipe.container; + + for (ForgeDirection d : ForgeDirection.VALID_DIRECTIONS) { + DockingStation station = tile.getStation(d); + + if (station != null && station.linked() != null) { + EntityRobot robot = (EntityRobot) station.linked(); + AIRobot ai = robot.getOverridingAI(); + + if (ai != null) { + continue; + } + + DockingStation newStation = station; + + if (parameters[0] != null) { + ActionParameterItemStack stackParam = (ActionParameterItemStack) parameters[0]; + ItemStack item = stackParam.getItemStackToDraw(); + + if (item.getItem() instanceof ItemMapLocation) { + BlockIndex index = ItemMapLocation.getBlockIndex(item); + + if (index != null) { + ForgeDirection side = ItemMapLocation.getSide(item); + DockingStation paramStation = (DockingStation) DockingStationRegistry.getStation(index.x, + index.y, index.z, side); + + if (paramStation != null) { + newStation = paramStation; + } + } + } + } + + robot.overrideAI(new AIRobotGoAndLinkToDock(robot, newStation)); + } + } + } + + @Override + public int maxParameters() { + return 1; + } + + @Override + public IActionParameter createParameter(int index) { + return new ActionParameterItemStack(); + } + +}