Search in sources :

Example 1 with TelepadTarget

use of crazypants.enderio.base.item.coordselector.TelepadTarget in project EnderIO by SleepyTrousers.

the class TileTelePad method setTarget.

public void setTarget(@Nullable TelepadTarget newTarget) {
    if (inNetwork() && !isMaster()) {
        getMaster().setTarget(newTarget);
        return;
    }
    if (newTarget == null) {
        newTarget = new TelepadTarget();
    }
    target = new TelepadTarget(newTarget);
    coordsChanged = true;
    markDirty();
}
Also used : TelepadTarget(crazypants.enderio.base.item.coordselector.TelepadTarget)

Example 2 with TelepadTarget

use of crazypants.enderio.base.item.coordselector.TelepadTarget in project EnderIO by SleepyTrousers.

the class GuiTargetList method elementClicked.

@Override
protected boolean elementClicked(int elementIndex, boolean doubleClick, int elX, int elY) {
    TelepadTarget target = getSelectedElement();
    Rectangle iconBounds = getIconBounds(0);
    if (iconBounds.contains(elX, elY)) {
        PacketHandler.INSTANCE.sendToServer(new PacketTargetList(te, target, false));
        if (selectedIndex >= getNumElements()) {
            setSelection(getNumElements() - 1);
        }
        return false;
    }
    return true;
}
Also used : PacketTargetList(crazypants.enderio.machines.machine.teleport.telepad.packet.PacketTargetList) TelepadTarget(crazypants.enderio.base.item.coordselector.TelepadTarget) Rectangle(java.awt.Rectangle)

Example 3 with TelepadTarget

use of crazypants.enderio.base.item.coordselector.TelepadTarget in project EnderIO by SleepyTrousers.

the class GuiTargetList method drawElement.

@Override
protected void drawElement(int elementIndex, int x, int y, int heightIn, @Nonnull BufferBuilder renderer) {
    TelepadTarget targ = getElementAt(elementIndex);
    String name = targ.getName();
    if (name.trim().length() == 0) {
        name = Lang.GUI_TELEPAD_UNNAMED_LOCATION.get();
    }
    FontRenderer fr = Minecraft.getMinecraft().fontRenderer;
    fr.drawString(name, x + 4, y + 2, 0xffffff, true);
    if (getSelectedElement() == targ) {
        Rectangle iconBounds = getIconBounds(y);
        EnderWidget icon = EnderWidget.X_BUT;
        // TODO no access to these vars anymore
        // if(iconBounds.contains(mouseX, mouseY)) {
        // icon = EnderWidget.X_BUT_HOVER;
        // }
        EnderWidget.map.render(icon, iconBounds.x, iconBounds.y, iconBounds.width, iconBounds.height, 0, true);
    }
}
Also used : TelepadTarget(crazypants.enderio.base.item.coordselector.TelepadTarget) Rectangle(java.awt.Rectangle) FontRenderer(net.minecraft.client.gui.FontRenderer) EnderWidget(com.enderio.core.client.render.EnderWidget)

Example 4 with TelepadTarget

use of crazypants.enderio.base.item.coordselector.TelepadTarget in project EnderIO by SleepyTrousers.

the class ItemRodOfReturn method onItemUseFinish.

@Override
@Nonnull
public ItemStack onItemUseFinish(@Nonnull ItemStack stack, @Nonnull World worldIn, @Nonnull EntityLivingBase entityLiving) {
    boolean hasPower = true;
    boolean hasFluid = true;
    if (!(entityLiving instanceof EntityPlayer) || !((EntityPlayer) entityLiving).capabilities.isCreativeMode) {
        hasPower = updateStackNBT(stack, worldIn, 0);
        // don't use fluid if we didn't have enough power
        hasFluid = hasPower ? useFluid(stack) : true;
    }
    if (hasPower && hasFluid) {
        TelepadTarget target = TelepadTarget.readFromNBT(stack);
        if (target == null) {
            if (worldIn.isRemote) {
                stopPlayingSound();
                entityLiving.sendMessage(Lang.RETURN_ROD_NO_TARGET.toChat(TextFormatting.RED));
            }
            return stack;
        }
        TeleportUtil.doTeleport(entityLiving, target.getLocation(), target.getDimension(), false, TravelSource.TELEPAD);
    } else if (worldIn.isRemote) {
        if (!hasPower) {
            entityLiving.sendMessage(Lang.RETURN_ROD_NO_POWER.toChat(TextFormatting.RED));
        } else {
            entityLiving.sendMessage(Lang.RETURN_ROD_NO_FLUID.toChat(TextFormatting.RED));
        }
    }
    if (worldIn.isRemote) {
        stopPlayingSound();
    }
    return stack;
}
Also used : TelepadTarget(crazypants.enderio.base.item.coordselector.TelepadTarget) EntityPlayer(net.minecraft.entity.player.EntityPlayer) Nonnull(javax.annotation.Nonnull)

Example 5 with TelepadTarget

use of crazypants.enderio.base.item.coordselector.TelepadTarget in project EnderIO by SleepyTrousers.

the class TileDialingDevice method processTasks.

@Override
public boolean processTasks(boolean redstoneCheck) {
    getEnergy().useEnergy();
    if (!getInventory().getSlot("INPUT").isEmpty() && getInventory().getSlot("OUTPUT").isEmpty() && getEnergy().useEnergy(CapacitorKey.DIALING_DEVICE_POWER_USE_PAPER)) {
        ItemStack stack = getInventory().getSlot("INPUT").get();
        TelepadTarget newTarg = TelepadTarget.readFromNBT(stack);
        if (newTarg != null && !targets.contains(newTarg)) {
            addTarget(newTarg);
            PacketHandler.sendToAllAround(new PacketTargetList(this, newTarg, true), this);
        }
        getInventory().getSlot("INPUT").clear();
        getInventory().getSlot("OUTPUT").set(stack);
    }
    return false;
}
Also used : PacketTargetList(crazypants.enderio.machines.machine.teleport.telepad.packet.PacketTargetList) TelepadTarget(crazypants.enderio.base.item.coordselector.TelepadTarget) ItemStack(net.minecraft.item.ItemStack)

Aggregations

TelepadTarget (crazypants.enderio.base.item.coordselector.TelepadTarget)6 PacketTargetList (crazypants.enderio.machines.machine.teleport.telepad.packet.PacketTargetList)2 Rectangle (java.awt.Rectangle)2 EnderWidget (com.enderio.core.client.render.EnderWidget)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 Nonnull (javax.annotation.Nonnull)1 FontRenderer (net.minecraft.client.gui.FontRenderer)1 EntityPlayer (net.minecraft.entity.player.EntityPlayer)1 ItemStack (net.minecraft.item.ItemStack)1