Search in sources :

Example 21 with EntityDrone

use of me.desht.pneumaticcraft.common.entity.living.EntityDrone in project pnc-repressurized by TeamPneumatic.

the class BlockDroneRedstoneEmitter method getWeakPower.

@Override
public int getWeakPower(IBlockState state, IBlockAccess blockAccess, BlockPos pos, EnumFacing side) {
    if (blockAccess instanceof World) {
        World world = (World) blockAccess;
        List<EntityDrone> drones = world.getEntitiesWithinAABB(EntityDrone.class, new AxisAlignedBB(pos, pos.add(1, 1, 1)));
        int signal = 0;
        for (EntityDrone drone : drones) {
            signal = Math.max(signal, drone.getEmittingRedstone(side.getOpposite()));
        }
        return signal;
    } else {
        return 0;
    }
}
Also used : AxisAlignedBB(net.minecraft.util.math.AxisAlignedBB) EntityDrone(me.desht.pneumaticcraft.common.entity.living.EntityDrone) World(net.minecraft.world.World)

Example 22 with EntityDrone

use of me.desht.pneumaticcraft.common.entity.living.EntityDrone in project pnc-repressurized by TeamPneumatic.

the class PacketSendDroneDebugEntry method handleClientSide.

@Override
public void handleClientSide(PacketSendDroneDebugEntry message, EntityPlayer player) {
    Entity entity = player.world.getEntityByID(message.entityId);
    if (entity instanceof EntityDrone) {
        EntityDrone drone = (EntityDrone) entity;
        drone.addDebugEntry(message.entry);
    }
}
Also used : Entity(net.minecraft.entity.Entity) EntityDrone(me.desht.pneumaticcraft.common.entity.living.EntityDrone)

Example 23 with EntityDrone

use of me.desht.pneumaticcraft.common.entity.living.EntityDrone in project pnc-repressurized by TeamPneumatic.

the class EventHandlerPneumaticCraft method onDroneSuicide.

@SubscribeEvent
public void onDroneSuicide(DroneSuicideEvent event) {
    if (event.drone instanceof EntityDrone) {
        EntityDrone drone = (EntityDrone) event.drone;
        AmadronOffer offer = drone.getHandlingOffer();
        if (offer != null) {
            int times = drone.getOfferTimes();
            if (offer.getInput() instanceof ItemStack) {
                int requiredCount = ((ItemStack) offer.getInput()).getCount() * times;
                for (int i = 0; i < drone.getInv().getSlots(); i++) {
                    requiredCount -= drone.getInv().getStackInSlot(i).getCount();
                }
                if (requiredCount <= 0) {
                    for (int i = 0; i < drone.getInv().getSlots(); i++) {
                        drone.getInv().setStackInSlot(i, ItemStack.EMPTY);
                    }
                    MinecraftForge.EVENT_BUS.post(new AmadronRetrievalEvent(event.drone));
                }
            } else {
                int requiredCount = ((FluidStack) offer.getInput()).amount * times;
                if (drone.getTank().getFluidAmount() >= requiredCount) {
                    MinecraftForge.EVENT_BUS.post(new AmadronRetrievalEvent(event.drone));
                }
            }
        }
    }
}
Also used : EntityDrone(me.desht.pneumaticcraft.common.entity.living.EntityDrone) AmadronRetrievalEvent(me.desht.pneumaticcraft.api.drone.AmadronRetrievalEvent) AmadronOffer(me.desht.pneumaticcraft.common.recipes.AmadronOffer) ItemStack(net.minecraft.item.ItemStack) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent)

Example 24 with EntityDrone

use of me.desht.pneumaticcraft.common.entity.living.EntityDrone 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 25 with EntityDrone

use of me.desht.pneumaticcraft.common.entity.living.EntityDrone in project pnc-repressurized by TeamPneumatic.

the class GuiDroneDebuggerOptions method initGui.

@Override
public void initGui(IGuiScreen gui) {
    GuiScreen guiScreen = (GuiScreen) gui;
    screenWidth = guiScreen.width;
    screenHeight = guiScreen.height;
    if (PneumaticCraftRepressurized.proxy.getPlayer() != null) {
        ItemStack helmet = PneumaticCraftRepressurized.proxy.getPlayer().getItemStackFromSlot(EntityEquipmentSlot.HEAD);
        if (helmet != null) {
            int entityId = NBTUtil.getInteger(helmet, NBTKeys.PNEUMATIC_HELMET_DEBUGGING_DRONE);
            Entity entity = PneumaticCraftRepressurized.proxy.getClientWorld().getEntityByID(entityId);
            if (entity instanceof EntityDrone) {
                selectedDrone = (EntityDrone) entity;
            }
        }
    }
    int spacing = 20;
    programmingStartX = spacing;
    programmingWidth = guiScreen.width - spacing * 2;
    programmingHeight = guiScreen.height - spacing - PROGRAMMING_START_Y;
    programmerUnit = new DebugInfoProgrammerUnit(selectedDrone != null ? selectedDrone.getProgWidgets() : new ArrayList<IProgWidget>(), gui.getFontRenderer(), 0, 0, guiScreen.width, guiScreen.height, 100, programmingStartX, PROGRAMMING_START_Y, programmingWidth, programmingHeight, 0, 0, 0);
    if (selectedDrone != null) {
        for (IProgWidget widget : selectedDrone.getProgWidgets()) {
            if (widget instanceof ProgWidgetStart) {
                programmerUnit.gotoPiece(widget);
                break;
            }
        }
    }
}
Also used : Entity(net.minecraft.entity.Entity) IProgWidget(me.desht.pneumaticcraft.common.progwidgets.IProgWidget) EntityDrone(me.desht.pneumaticcraft.common.entity.living.EntityDrone) GuiScreen(net.minecraft.client.gui.GuiScreen) IGuiScreen(me.desht.pneumaticcraft.api.client.pneumaticHelmet.IGuiScreen) ItemStack(net.minecraft.item.ItemStack) ProgWidgetStart(me.desht.pneumaticcraft.common.progwidgets.ProgWidgetStart)

Aggregations

EntityDrone (me.desht.pneumaticcraft.common.entity.living.EntityDrone)26 ItemStack (net.minecraft.item.ItemStack)10 Entity (net.minecraft.entity.Entity)6 BlockPos (net.minecraft.util.math.BlockPos)4 World (net.minecraft.world.World)4 AmadronOffer (me.desht.pneumaticcraft.common.recipes.AmadronOffer)3 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)3 SubscribeEvent (net.minecraftforge.fml.common.eventhandler.SubscribeEvent)3 IProgWidget (me.desht.pneumaticcraft.common.progwidgets.IProgWidget)2 Block (net.minecraft.block.Block)2 ItemBlock (net.minecraft.item.ItemBlock)2 TileEntity (net.minecraft.tileentity.TileEntity)2 EnumFacing (net.minecraft.util.EnumFacing)2 AxisAlignedBB (net.minecraft.util.math.AxisAlignedBB)2 FluidStack (net.minecraftforge.fluids.FluidStack)2 ArrayList (java.util.ArrayList)1 IEntityTrackEntry (me.desht.pneumaticcraft.api.client.pneumaticHelmet.IEntityTrackEntry)1 IGuiScreen (me.desht.pneumaticcraft.api.client.pneumaticHelmet.IGuiScreen)1 AmadronRetrievalEvent (me.desht.pneumaticcraft.api.drone.AmadronRetrievalEvent)1 EntityPathNavigateDrone (me.desht.pneumaticcraft.common.ai.EntityPathNavigateDrone)1