Search in sources :

Example 66 with Coordinate

use of mcjty.lib.varia.Coordinate in project RFTools by McJty.

the class MatterReceiverTileEntity method getOrCalculateID.

public int getOrCalculateID() {
    if (id == -1) {
        TeleportDestinations destinations = TeleportDestinations.getDestinations(worldObj);
        GlobalCoordinate gc = new GlobalCoordinate(new Coordinate(xCoord, yCoord, zCoord), worldObj.provider.dimensionId);
        id = destinations.getNewId(gc);
        destinations.save(worldObj);
        setId(id);
    }
    return id;
}
Also used : GlobalCoordinate(mcjty.lib.varia.GlobalCoordinate) Coordinate(mcjty.lib.varia.Coordinate) GlobalCoordinate(mcjty.lib.varia.GlobalCoordinate)

Example 67 with Coordinate

use of mcjty.lib.varia.Coordinate in project RFTools by McJty.

the class MatterReceiverTileEntity method updateDestination.

/**
 * This method is called after putting down a receiver that was earlier wrenched. We need to fix the data in
 * the destination.
 */
public void updateDestination() {
    TeleportDestinations destinations = TeleportDestinations.getDestinations(worldObj);
    GlobalCoordinate gc = new GlobalCoordinate(new Coordinate(xCoord, yCoord, zCoord), worldObj.provider.dimensionId);
    TeleportDestination destination = destinations.getDestination(gc.getCoordinate(), gc.getDimension());
    if (destination != null) {
        destination.setName(name);
        if (id == -1) {
            id = destinations.getNewId(gc);
            markDirty();
        } else {
            destinations.assignId(gc, id);
        }
        destinations.save(worldObj);
    }
    worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
}
Also used : GlobalCoordinate(mcjty.lib.varia.GlobalCoordinate) Coordinate(mcjty.lib.varia.Coordinate) GlobalCoordinate(mcjty.lib.varia.GlobalCoordinate)

Example 68 with Coordinate

use of mcjty.lib.varia.Coordinate in project RFTools by McJty.

the class MatterTransmitterTileEntity method readRestorableFromNBT.

@Override
public void readRestorableFromNBT(NBTTagCompound tagCompound) {
    super.readRestorableFromNBT(tagCompound);
    name = tagCompound.getString("tpName");
    Coordinate c = Coordinate.readFromNBT(tagCompound, "dest");
    if (c == null) {
        teleportDestination = null;
    } else {
        int dim = tagCompound.getInteger("dim");
        teleportDestination = new TeleportDestination(c, dim);
    }
    if (tagCompound.hasKey("destId")) {
        teleportId = tagCompound.getInteger("destId");
    } else {
        teleportId = null;
    }
    privateAccess = tagCompound.getBoolean("private");
    beamHidden = tagCompound.getBoolean("hideBeam");
    once = tagCompound.getBoolean("once");
    allowedPlayers.clear();
    NBTTagList playerList = tagCompound.getTagList("players", Constants.NBT.TAG_STRING);
    if (playerList != null) {
        for (int i = 0; i < playerList.tagCount(); i++) {
            String player = playerList.getStringTagAt(i);
            allowedPlayers.add(player);
        }
    }
}
Also used : NBTTagList(net.minecraft.nbt.NBTTagList) GlobalCoordinate(mcjty.lib.varia.GlobalCoordinate) Coordinate(mcjty.lib.varia.Coordinate) NBTTagString(net.minecraft.nbt.NBTTagString)

Example 69 with Coordinate

use of mcjty.lib.varia.Coordinate in project RFTools by McJty.

the class MatterTransmitterTileEntity method startTeleportation.

public void startTeleportation(Entity entity) {
    if (cooldownTimer > 0) {
        // In cooldown. We can't do teleport right now.
        return;
    }
    if (teleportingPlayer != null) {
        // Already teleporting
        return;
    }
    if (!(entity instanceof EntityPlayer)) {
        return;
    }
    EntityPlayer player = (EntityPlayer) entity;
    TeleportDestination dest = teleportDestination;
    if (teleportId != null) {
        dest = getTeleportDestination();
    }
    if (dest != null && dest.isValid()) {
        Coordinate cthis = new Coordinate(xCoord, yCoord, zCoord);
        int cost = TeleportationTools.calculateRFCost(worldObj, cthis, dest);
        cost = (int) (cost * (4.0f - getInfusedFactor()) / 4.0f);
        if (getEnergyStored(ForgeDirection.DOWN) < cost) {
            Logging.warn(player, "Not enough power to start the teleport!");
            cooldownTimer = 80;
            return;
        }
        int srcId = worldObj.provider.dimensionId;
        int dstId = dest.getDimension();
        if (!TeleportationTools.checkValidTeleport(player, srcId, dstId)) {
            cooldownTimer = 80;
            return;
        }
        Logging.message(player, "Start teleportation...");
        teleportingPlayer = player;
        teleportTimer = TeleportationTools.calculateTime(worldObj, cthis, dest);
        teleportTimer = (int) (teleportTimer * (1.2f - getInfusedFactor()) / 1.2f);
        int rf = TeleportConfiguration.rfTeleportPerTick;
        rf = (int) (rf * (4.0f - getInfusedFactor()) / 4.0f);
        int totalRfUsed = cost + rf * (teleportTimer + 1);
        rfPerTick = totalRfUsed / (teleportTimer + 1);
        totalTicks = teleportTimer;
        goodTicks = 0;
        badTicks = 0;
    } else {
        Logging.warn(player, "Something is wrong with the destination!");
    }
}
Also used : GlobalCoordinate(mcjty.lib.varia.GlobalCoordinate) Coordinate(mcjty.lib.varia.Coordinate) EntityPlayer(net.minecraft.entity.player.EntityPlayer)

Example 70 with Coordinate

use of mcjty.lib.varia.Coordinate in project RFTools by McJty.

the class GuiDialingDevice method checkStatus.

private void checkStatus() {
    int receiverSelected = receiverList.getSelected();
    TeleportDestination destination = getSelectedReceiver(receiverSelected);
    if (destination == null) {
        return;
    }
    Coordinate c = destination.getCoordinate();
    RFToolsMessages.INSTANCE.sendToServer(new PacketRequestIntegerFromServer(tileEntity.xCoord, tileEntity.yCoord, tileEntity.zCoord, DialingDeviceTileEntity.CMD_CHECKSTATUS, DialingDeviceTileEntity.CLIENTCMD_STATUS, new Argument("c", c), new Argument("dim", destination.getDimension())));
    lastCheckedReceiver = true;
    listDirty = 0;
}
Also used : Argument(mcjty.lib.network.Argument) Coordinate(mcjty.lib.varia.Coordinate) PacketRequestIntegerFromServer(mcjty.lib.network.PacketRequestIntegerFromServer)

Aggregations

Coordinate (mcjty.lib.varia.Coordinate)181 GlobalCoordinate (mcjty.lib.varia.GlobalCoordinate)63 TileEntity (net.minecraft.tileentity.TileEntity)30 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)19 Block (net.minecraft.block.Block)14 HashMap (java.util.HashMap)13 Map (java.util.Map)13 GenericEnergyReceiverTileEntity (mcjty.lib.entity.GenericEnergyReceiverTileEntity)13 World (net.minecraft.world.World)12 NBTTagList (net.minecraft.nbt.NBTTagList)11 Callback (li.cil.oc.api.machine.Callback)10 HorizontalLayout (mcjty.lib.gui.layout.HorizontalLayout)10 Panel (mcjty.lib.gui.widgets.Panel)10 ItemStack (net.minecraft.item.ItemStack)10 ArrayList (java.util.ArrayList)9 Label (mcjty.lib.gui.widgets.Label)8 BlockInfo (mcjty.rftools.BlockInfo)7 SyncedCoordinate (mcjty.lib.entity.SyncedCoordinate)5 ChoiceEvent (mcjty.lib.gui.events.ChoiceEvent)4 TeleportDestinationClientInfo (mcjty.rftools.blocks.teleporter.TeleportDestinationClientInfo)4