Search in sources :

Example 1 with IEntityTrackEntry

use of me.desht.pneumaticcraft.api.client.pneumaticHelmet.IEntityTrackEntry in project pnc-repressurized by TeamPneumatic.

the class RenderTarget method update.

public void update() {
    stat.update();
    stat.setTitle(entity.getName());
    EntityPlayer player = FMLClientHandler.instance().getClient().player;
    if (ticksExisted >= 30 && !didMakeLockSound) {
        didMakeLockSound = true;
        player.world.playSound(player.posX, player.posY, player.posZ, Sounds.HUD_ENTITY_LOCK, SoundCategory.PLAYERS, 0.1F, 1.0F, true);
    }
    boolean tagged = NBTUtil.getInteger(player.getItemStackFromSlot(EntityEquipmentSlot.HEAD), NBTKeys.PNEUMATIC_HELMET_DEBUGGING_DRONE) == entity.getEntityId();
    circle1.setRenderingAsTagged(tagged);
    circle2.setRenderingAsTagged(tagged);
    circle1.update();
    circle2.update();
    for (IEntityTrackEntry tracker : trackEntries) {
        tracker.update(entity);
    }
    isLookingAtTarget = isPlayerLookingAtTarget();
    if (hackTime > 0) {
        IHackableEntity hackableEntity = HackableHandler.getHackableForEntity(entity, PneumaticCraftRepressurized.proxy.getPlayer());
        if (hackableEntity != null) {
            // = Math.min(hackTime + 1, hackableEntity.getHackTime(entity, PneumaticCraft.proxy.getPlayer()));
            hackTime++;
        } else {
            hackTime = 0;
        }
    }
}
Also used : IEntityTrackEntry(me.desht.pneumaticcraft.api.client.pneumaticHelmet.IEntityTrackEntry) EntityPlayer(net.minecraft.entity.player.EntityPlayer) IHackableEntity(me.desht.pneumaticcraft.api.client.pneumaticHelmet.IHackableEntity)

Example 2 with IEntityTrackEntry

use of me.desht.pneumaticcraft.api.client.pneumaticHelmet.IEntityTrackEntry in project pnc-repressurized by TeamPneumatic.

the class RenderTarget method render.

public void render(float partialTicks, boolean justRenderWhenHovering) {
    for (IEntityTrackEntry tracker : trackEntries) {
        tracker.render(entity, partialTicks);
    }
    double x = entity.prevPosX + (entity.posX - entity.prevPosX) * partialTicks;
    double y = entity.prevPosY + (entity.posY - entity.prevPosY) * partialTicks + entity.height / 2D;
    double z = entity.prevPosZ + (entity.posZ - entity.prevPosZ) * partialTicks;
    GL11.glDepthMask(false);
    GL11.glDisable(GL11.GL_DEPTH_TEST);
    GL11.glDisable(GL11.GL_CULL_FACE);
    GL11.glDisable(GL11.GL_TEXTURE_2D);
    GL11.glEnable(GL11.GL_BLEND);
    GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
    GL11.glPushMatrix();
    GL11.glClear(GL11.GL_DEPTH_BUFFER_BIT);
    float red;
    float green;
    float blue;
    float alpha = 0.5F;
    if (entity instanceof EntityDrone) {
        red = 1;
        green = 1;
        blue = 0;
    } else if (entity instanceof EntityMob || entity instanceof EntitySlime) {
        red = 1;
        green = 0;
        blue = 0;
    } else {
        red = 0;
        green = 1;
        blue = 0;
    }
    float size = entity.height * 0.5F;
    if (ticksExisted < 60) {
        size += 5 - Math.abs(ticksExisted) * 0.083F;
        alpha = Math.abs(ticksExisted) * 0.005F;
    }
    GL11.glTranslated(x, y, z);
    GL11.glRotatef(180.0F - Minecraft.getMinecraft().getRenderManager().playerViewY, 0.0F, 1.0F, 0.0F);
    GL11.glRotatef(180.0F - Minecraft.getMinecraft().getRenderManager().playerViewX, 1.0F, 0.0F, 0.0F);
    GL11.glColor4d(red, green, blue, alpha);
    float renderSize = oldSize + (size - oldSize) * partialTicks;
    circle1.render(renderSize, partialTicks);
    circle2.render(renderSize + 0.2D, partialTicks);
    int targetAcquireProgress = (int) ((ticksExisted - 50) / 0.7F);
    if (ticksExisted <= 120 && ticksExisted > 50) {
        GL11.glColor4d(0, 1, 0, 0.8D);
        RenderProgressBar.render(0D, 0.4D, 1.8D, 0.9D, 0, targetAcquireProgress);
    }
    GL11.glEnable(GL11.GL_TEXTURE_2D);
    FontRenderer fontRenderer = Minecraft.getMinecraft().getRenderManager().getFontRenderer();
    GL11.glScaled(0.02D, 0.02D, 0.02D);
    GL11.glColor4d(red, green, blue, alpha);
    if (ticksExisted > 120) {
        if (justRenderWhenHovering && !isLookingAtTarget) {
            stat.closeWindow();
        } else {
            stat.openWindow();
        }
        textList = new ArrayList<String>();
        for (IEntityTrackEntry tracker : trackEntries) {
            tracker.addInfo(entity, textList);
        }
        stat.setText(textList);
        stat.render(-1, -1, partialTicks);
    } else if (ticksExisted > 50) {
        fontRenderer.drawString("Acquiring Target...", 0, 0, 0x7F7F7F);
        fontRenderer.drawString(targetAcquireProgress + "%", 37, 28, 0x002F00);
    } else if (ticksExisted < -30) {
        stat.closeWindow();
        // if(stat.getWidth() > stat.getMinWidth() || stat.getHeight() > stat.getMinHeight()) {
        // stat.setText(new ArrayList<String>());
        stat.render(-1, -1, partialTicks);
        // }
        fontRenderer.drawString("Lost Target!", 0, 0, 0xFF0000);
    }
    GL11.glPopMatrix();
    GL11.glEnable(GL11.GL_CULL_FACE);
    GL11.glEnable(GL11.GL_DEPTH_TEST);
    GL11.glDisable(GL11.GL_BLEND);
    GL11.glDepthMask(true);
    oldSize = size;
}
Also used : EntityMob(net.minecraft.entity.monster.EntityMob) IEntityTrackEntry(me.desht.pneumaticcraft.api.client.pneumaticHelmet.IEntityTrackEntry) EntityDrone(me.desht.pneumaticcraft.common.entity.living.EntityDrone) EntitySlime(net.minecraft.entity.monster.EntitySlime) FontRenderer(net.minecraft.client.gui.FontRenderer)

Example 3 with IEntityTrackEntry

use of me.desht.pneumaticcraft.api.client.pneumaticHelmet.IEntityTrackEntry in project pnc-repressurized by TeamPneumatic.

the class EntityTrackHandler method getTrackersForEntity.

public static List<IEntityTrackEntry> getTrackersForEntity(Entity entity) {
    List<IEntityTrackEntry> trackers = new ArrayList<>();
    for (IEntityTrackEntry tracker : trackEntries) {
        if (tracker.isApplicable(entity)) {
            try {
                IEntityTrackEntry newTracker = tracker.getClass().newInstance();
                // just as an initializer.
                newTracker.isApplicable(entity);
                trackers.add(newTracker);
            } catch (Exception e) {
                // Shouldn't happen, as we tried it in the init().
                e.printStackTrace();
            }
        }
    }
    return trackers;
}
Also used : IEntityTrackEntry(me.desht.pneumaticcraft.api.client.pneumaticHelmet.IEntityTrackEntry) ArrayList(java.util.ArrayList)

Aggregations

IEntityTrackEntry (me.desht.pneumaticcraft.api.client.pneumaticHelmet.IEntityTrackEntry)3 ArrayList (java.util.ArrayList)1 IHackableEntity (me.desht.pneumaticcraft.api.client.pneumaticHelmet.IHackableEntity)1 EntityDrone (me.desht.pneumaticcraft.common.entity.living.EntityDrone)1 FontRenderer (net.minecraft.client.gui.FontRenderer)1 EntityMob (net.minecraft.entity.monster.EntityMob)1 EntitySlime (net.minecraft.entity.monster.EntitySlime)1 EntityPlayer (net.minecraft.entity.player.EntityPlayer)1