Search in sources :

Example 11 with Pos

use of icbm.classic.lib.transform.vector.Pos in project ICBM-Classic by BuiltBrokenModding.

the class GuiCruiseLauncher method keyTyped.

@Override
public void keyTyped(char par1, int par2) throws IOException {
    super.keyTyped(par1, par2);
    this.textFieldX.textboxKeyTyped(par1, par2);
    this.textFieldZ.textboxKeyTyped(par1, par2);
    this.textFieldY.textboxKeyTyped(par1, par2);
    this.textFieldFreq.textboxKeyTyped(par1, par2);
    try {
        Pos newTarget = new Pos(parseInt(this.textFieldX.getText()), parseInt(this.textFieldY.getText()), parseInt(this.textFieldZ.getText()));
        this.tileEntity.setTarget(newTarget);
        ICBMClassic.packetHandler.sendToServer(new PacketTile("target_C>S", TileCruiseLauncher.SET_TARGET_PACKET_ID, tileEntity).addData(tileEntity.getTarget().xi(), this.tileEntity.getTarget().yi(), this.tileEntity.getTarget().zi()));
    } catch (NumberFormatException e) {
    }
    try {
        short newFrequency = (short) Math.max(Short.parseShort(this.textFieldFreq.getText()), 0);
        this.tileEntity.setFrequency(newFrequency);
        ICBMClassic.packetHandler.sendToServer(new PacketTile("frequency_C>S", TileCruiseLauncher.SET_FREQUENCY_PACKET_ID, tileEntity).addData(tileEntity.getFrequency()));
    } catch (NumberFormatException e) {
    }
}
Also used : PacketTile(icbm.classic.lib.network.packet.PacketTile) Pos(icbm.classic.lib.transform.vector.Pos)

Example 12 with Pos

use of icbm.classic.lib.transform.vector.Pos in project ICBM-Classic by BuiltBrokenModding.

the class TileCruiseLauncher method receiveRadioWave.

@Override
public // TODO pack as message object
void receiveRadioWave(// TODO pack as message object
float hz, // TODO pack as message object
IRadioWaveSender sender, // TODO pack as message object
String messageHeader, // TODO pack as message object
Object[] data) {
    // Floor frequency as we do not care about sub ranges
    final int frequency = (int) Math.floor(hz);
    if (isServer() && frequency == this.getFrequency()) {
        // Laser detonator signal
        if (// TODO cache headers somewhere like API references
        messageHeader.equals("activateLauncherWithTarget")) {
            final Pos pos = (Pos) data[0];
            if (!isTooClose(pos)) {
                setTarget(pos);
                ((FakeRadioSender) sender).player.sendMessage(new TextComponentString("Aiming missile at " + pos));
            }
        } else // Remote detonator signal
        if (messageHeader.equals("activateLauncher")) {
            ((FakeRadioSender) sender).player.sendMessage(new TextComponentString("Firing missile at " + getTarget()));
            launch();
        }
    }
}
Also used : Pos(icbm.classic.lib.transform.vector.Pos) BlockPos(net.minecraft.util.math.BlockPos) FakeRadioSender(icbm.classic.prefab.FakeRadioSender) TextComponentString(net.minecraft.util.text.TextComponentString)

Example 13 with Pos

use of icbm.classic.lib.transform.vector.Pos in project ICBM-Classic by BuiltBrokenModding.

the class TileCruiseLauncher method readDescPacket.

@Override
public void readDescPacket(ByteBuf buf) {
    super.readDescPacket(buf);
    if (buf.readBoolean()) {
        cachedMissileStack = ByteBufUtils.readItemStack(buf);
    } else {
        cachedMissileStack = ItemStack.EMPTY;
    }
    setTarget(new Pos(buf.readInt(), buf.readInt(), buf.readInt()));
    currentAim.setYaw(buf.readDouble());
    currentAim.setPitch(buf.readDouble());
}
Also used : Pos(icbm.classic.lib.transform.vector.Pos) BlockPos(net.minecraft.util.math.BlockPos)

Example 14 with Pos

use of icbm.classic.lib.transform.vector.Pos in project ICBM-Classic by BuiltBrokenModding.

the class GuiRadarStation method drawGuiContainerBackgroundLayer.

/**
 * Draw the background layer for the GuiContainer (everything behind the items)
 */
@Override
protected void drawGuiContainerBackgroundLayer(float f, int mouseX, int mouseY) {
    drawDefaultBackground();
    FMLClientHandler.instance().getClient().renderEngine.bindTexture(TEXTURE);
    GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
    this.containerPosX = (this.width - this.xSize) / 2;
    this.containerPosY = (this.height - this.ySize) / 2;
    this.drawTexturedModalRect(containerPosX, containerPosY, 0, 0, this.xSize, this.ySize);
    this.radarCenter = new Point(this.containerPosX + this.xSize / 3 - 10, this.containerPosY + this.ySize / 2 + 4);
    this.radarMapRadius = TileRadarStation.MAX_DETECTION_RANGE / 71f;
    this.info = "";
    this.info2 = "";
    if (this.tileEntity.hasPower()) {
        int range = 4;
        for (Pos pos : tileEntity.guiDrawPoints) {
            final RadarObjectType type = RadarObjectType.get(pos.zi());
            final double x = pos.x();
            final double z = pos.y();
            Point position = new Point(radarCenter.x() + (x - this.tileEntity.getPos().getX()) / this.radarMapRadius, radarCenter.y() - (z - this.tileEntity.getPos().getZ()) / this.radarMapRadius);
            switch(type) {
                case MISSILE:
                    FMLClientHandler.instance().getClient().renderEngine.bindTexture(TEXTURE_YELLOW_DOT);
                    break;
                case MISSILE_IMPACT:
                    FMLClientHandler.instance().getClient().renderEngine.bindTexture(TEXTURE_RED_DOT);
                    break;
                case OTHER:
                default:
                    FMLClientHandler.instance().getClient().renderEngine.bindTexture(TEXTURE_WHITE_DOT);
                    break;
            }
            this.drawTexturedModalRect(position.xi(), position.yi(), 0, 0, 2, 2);
            // Hover Detection
            Point minPosition = position.add(-range);
            Point maxPosition = position.add(range);
            if (new Rectangle(minPosition, maxPosition).isWithin(this.mousePosition)) {
                if (type == RadarObjectType.OTHER) {
                    this.info = String.format(LanguageUtility.getLocal("gui.misc.object"), (int) x, (int) z);
                } else {
                    this.info = (type == RadarObjectType.MISSILE ? "\u00a76" : "\u00a74") + String.format(LanguageUtility.getLocal("gui.misc.missile"), (int) x, (int) z);
                }
            }
        }
    }
    // Draw energy bar
    if (tileEntity.getEnergy() > 0) {
        float energyScale = tileEntity.getEnergy() / (float) tileEntity.getEnergyBufferSize();
        final int textureWidth = 8;
        final int textureHeight = 142 / 2;
        final int height = (int) Math.min(textureHeight, Math.floor(textureHeight * energyScale));
        this.drawTexturedModalRect(containerPosX + 248, containerPosY + 65 + (textureHeight - height), 0, (332 / 2) + textureHeight - height, textureWidth, height);
    }
}
Also used : Pos(icbm.classic.lib.transform.vector.Pos) Rectangle(icbm.classic.lib.transform.region.Rectangle) Point(icbm.classic.lib.transform.vector.Point) Point(icbm.classic.lib.transform.vector.Point)

Example 15 with Pos

use of icbm.classic.lib.transform.vector.Pos in project ICBM-Classic by BuiltBrokenModding.

the class TileEntityExplosive method trigger.

public void trigger(boolean setFire) {
    if (!hasBeenTriggered) {
        hasBeenTriggered = true;
        EntityExplosive entityExplosive = new EntityExplosive(world, new Pos(pos).add(0.5), getDirection(), capabilityExplosive.toStack());
        if (setFire) {
            entityExplosive.setFire(100);
        }
        world.spawnEntity(entityExplosive);
        world.setBlockToAir(pos);
        ICBMClassic.logger().info("TileEntityExplosive: Triggered ITEM{" + capabilityExplosive.toStack() + "] " + capabilityExplosive.getExplosiveData().getRegistryName() + " at location " + getPos());
    }
}
Also used : Pos(icbm.classic.lib.transform.vector.Pos) EntityExplosive(icbm.classic.content.entity.EntityExplosive)

Aggregations

Pos (icbm.classic.lib.transform.vector.Pos)39 BlockPos (net.minecraft.util.math.BlockPos)22 TileEntity (net.minecraft.tileentity.TileEntity)8 Entity (net.minecraft.entity.Entity)6 ChunkPos (net.minecraft.util.math.ChunkPos)6 EnumFacing (net.minecraft.util.EnumFacing)5 TextComponentString (net.minecraft.util.text.TextComponentString)5 IPos3D (com.builtbroken.jlib.data.vector.IPos3D)4 ItemStack (net.minecraft.item.ItemStack)4 Location (icbm.classic.lib.transform.vector.Location)3 Point (icbm.classic.lib.transform.vector.Point)3 FakeRadioSender (icbm.classic.prefab.FakeRadioSender)3 EntityPlayer (net.minecraft.entity.player.EntityPlayer)3 AxisAlignedBB (net.minecraft.util.math.AxisAlignedBB)3 ICBMClassic (icbm.classic.ICBMClassic)2 IWorldPosition (icbm.classic.api.data.IWorldPosition)2 IWorldPosItem (icbm.classic.api.items.IWorldPosItem)2 IExplosiveData (icbm.classic.api.reg.IExplosiveData)2 ItemLaserDetonator (icbm.classic.content.items.ItemLaserDetonator)2 ItemRemoteDetonator (icbm.classic.content.items.ItemRemoteDetonator)2