Search in sources :

Example 1 with TileDialingDevice

use of crazypants.enderio.machines.machine.teleport.telepad.TileDialingDevice in project EnderIO by SleepyTrousers.

the class ContainerDialingDevice method doTeleport.

@Override
public IMessage doTeleport(@Nonnull BlockPos telepad, int targetID, boolean initiateTeleport) {
    final TileDialingDevice dialer = getTileEntity();
    if (dialer != null && dialer.getEnergy().canUseEnergy(CapacitorKey.DIALING_DEVICE_POWER_USE_TELEPORT)) {
        TileTelePad tp = BlockEnder.getAnyTileEntitySafe(dialer.getWorld(), telepad, TileTelePad.class);
        if (tp != null) {
            ArrayList<TelepadTarget> targets = dialer.getTargets();
            if (targetID >= 0 && targetID < targets.size()) {
                tp.setTarget(targets.get(targetID));
                if (initiateTeleport) {
                    tp.teleportAll();
                    dialer.getEnergy().useEnergy(CapacitorKey.DIALING_DEVICE_POWER_USE_TELEPORT);
                }
            }
            return new PacketSetTarget(tp, tp.getTarget());
        }
    }
    return null;
}
Also used : TelepadTarget(crazypants.enderio.base.item.coordselector.TelepadTarget) TileDialingDevice(crazypants.enderio.machines.machine.teleport.telepad.TileDialingDevice) TileTelePad(crazypants.enderio.machines.machine.teleport.telepad.TileTelePad) PacketSetTarget(crazypants.enderio.machines.machine.teleport.telepad.packet.PacketSetTarget)

Aggregations

TelepadTarget (crazypants.enderio.base.item.coordselector.TelepadTarget)1 TileDialingDevice (crazypants.enderio.machines.machine.teleport.telepad.TileDialingDevice)1 TileTelePad (crazypants.enderio.machines.machine.teleport.telepad.TileTelePad)1 PacketSetTarget (crazypants.enderio.machines.machine.teleport.telepad.packet.PacketSetTarget)1