Search in sources :

Example 31 with EntityPlayer

use of net.minecraft.entity.player.EntityPlayer in project PneumaticCraft by MineMaarten.

the class TileEntityPressureChamberValve method giveOutput.

private void giveOutput(ItemStack[] output, double[] outputPosition) {
    for (ItemStack iStack : output) {
        if (iStack.getItem() == etchingAcid) {
            for (EntityPlayer player : (List<EntityPlayer>) worldObj.getEntitiesWithinAABB(EntityPlayer.class, AxisAlignedBB.getBoundingBox(xCoord - 32, yCoord - 32, zCoord - 32, xCoord + 32, yCoord + 32, zCoord + 32))) {
                AchievementHandler.giveAchievement(player, new ItemStack(etchingAcid));
            }
        }
        EntityItem item = new EntityItem(worldObj, outputPosition[0], outputPosition[1], outputPosition[2], iStack.copy());
        worldObj.spawnEntityInWorld(item);
    }
}
Also used : EntityPlayer(net.minecraft.entity.player.EntityPlayer) ArrayList(java.util.ArrayList) NBTTagList(net.minecraft.nbt.NBTTagList) List(java.util.List) ItemStack(net.minecraft.item.ItemStack) EntityItem(net.minecraft.entity.item.EntityItem)

Example 32 with EntityPlayer

use of net.minecraft.entity.player.EntityPlayer in project PneumaticCraft by MineMaarten.

the class TileEntityPneumaticDoorBase method shouldOpen.

private boolean shouldOpen() {
    switch(redstoneMode) {
        case 0:
        case 1:
            int range = TileEntityConstants.RANGE_PNEUMATIC_DOOR_BASE + this.getUpgrades(ItemMachineUpgrade.UPGRADE_RANGE);
            AxisAlignedBB aabb = AxisAlignedBB.getBoundingBox(xCoord - range, yCoord - range, zCoord - range, xCoord + range + 1, yCoord + range + 1, zCoord + range + 1);
            List<EntityPlayer> players = worldObj.getEntitiesWithinAABB(EntityPlayer.class, aabb);
            for (EntityPlayer player : players) {
                if (PneumaticCraftUtils.getProtectingSecurityStations(worldObj, xCoord, yCoord, zCoord, player, false, false) == 0) {
                    if (redstoneMode == 0) {
                        return true;
                    } else {
                        ((BlockPneumaticDoor) Blockss.pneumaticDoor).isTrackingPlayerEye = true;
                        //max range = range * sqrt(2).
                        ChunkPosition lookedPosition = PneumaticCraftUtils.getEntityLookedBlock(player, range * 1.41F);
                        ((BlockPneumaticDoor) Blockss.pneumaticDoor).isTrackingPlayerEye = false;
                        if (lookedPosition != null) {
                            if (lookedPosition.equals(new ChunkPosition(xCoord, yCoord, zCoord))) {
                                return true;
                            } else {
                                if (door != null) {
                                    if (lookedPosition.equals(new ChunkPosition(door.xCoord, door.yCoord, door.zCoord)))
                                        return true;
                                    if (lookedPosition.equals(new ChunkPosition(door.xCoord, door.yCoord + (door.getBlockMetadata() < 6 ? 1 : -1), door.zCoord)))
                                        return true;
                                }
                            }
                        }
                    }
                }
            }
            return false;
        case 2:
            return opening;
    }
    return false;
}
Also used : AxisAlignedBB(net.minecraft.util.AxisAlignedBB) ChunkPosition(net.minecraft.world.ChunkPosition) EntityPlayer(net.minecraft.entity.player.EntityPlayer)

Example 33 with EntityPlayer

use of net.minecraft.entity.player.EntityPlayer in project MinecraftForge by MinecraftForge.

the class GuiIngameForge method renderHealth.

public void renderHealth(int width, int height) {
    bind(ICONS);
    if (pre(HEALTH))
        return;
    mc.mcProfiler.startSection("health");
    GlStateManager.enableBlend();
    EntityPlayer player = (EntityPlayer) this.mc.getRenderViewEntity();
    int health = MathHelper.ceil(player.getHealth());
    boolean highlight = healthUpdateCounter > (long) updateCounter && (healthUpdateCounter - (long) updateCounter) / 3L % 2L == 1L;
    if (health < this.playerHealth && player.hurtResistantTime > 0) {
        this.lastSystemTime = Minecraft.getSystemTime();
        this.healthUpdateCounter = (long) (this.updateCounter + 20);
    } else if (health > this.playerHealth && player.hurtResistantTime > 0) {
        this.lastSystemTime = Minecraft.getSystemTime();
        this.healthUpdateCounter = (long) (this.updateCounter + 10);
    }
    if (Minecraft.getSystemTime() - this.lastSystemTime > 1000L) {
        this.playerHealth = health;
        this.lastPlayerHealth = health;
        this.lastSystemTime = Minecraft.getSystemTime();
    }
    this.playerHealth = health;
    int healthLast = this.lastPlayerHealth;
    IAttributeInstance attrMaxHealth = player.getEntityAttribute(SharedMonsterAttributes.MAX_HEALTH);
    float healthMax = (float) attrMaxHealth.getAttributeValue();
    float absorb = MathHelper.ceil(player.getAbsorptionAmount());
    int healthRows = MathHelper.ceil((healthMax + absorb) / 2.0F / 10.0F);
    int rowHeight = Math.max(10 - (healthRows - 2), 3);
    this.rand.setSeed((long) (updateCounter * 312871));
    int left = width / 2 - 91;
    int top = height - left_height;
    left_height += (healthRows * rowHeight);
    if (rowHeight != 10)
        left_height += 10 - rowHeight;
    int regen = -1;
    if (player.isPotionActive(MobEffects.REGENERATION)) {
        regen = updateCounter % 25;
    }
    final int TOP = 9 * (mc.world.getWorldInfo().isHardcoreModeEnabled() ? 5 : 0);
    final int BACKGROUND = (highlight ? 25 : 16);
    int MARGIN = 16;
    if (player.isPotionActive(MobEffects.POISON))
        MARGIN += 36;
    else if (player.isPotionActive(MobEffects.WITHER))
        MARGIN += 72;
    float absorbRemaining = absorb;
    for (int i = MathHelper.ceil((healthMax + absorb) / 2.0F) - 1; i >= 0; --i) {
        //int b0 = (highlight ? 1 : 0);
        int row = MathHelper.ceil((float) (i + 1) / 10.0F) - 1;
        int x = left + i % 10 * 8;
        int y = top - row * rowHeight;
        if (health <= 4)
            y += rand.nextInt(2);
        if (i == regen)
            y -= 2;
        drawTexturedModalRect(x, y, BACKGROUND, TOP, 9, 9);
        if (highlight) {
            if (i * 2 + 1 < healthLast)
                //6
                drawTexturedModalRect(x, y, MARGIN + 54, TOP, 9, 9);
            else if (i * 2 + 1 == healthLast)
                //7
                drawTexturedModalRect(x, y, MARGIN + 63, TOP, 9, 9);
        }
        if (absorbRemaining > 0.0F) {
            if (absorbRemaining == absorb && absorb % 2.0F == 1.0F) {
                //17
                drawTexturedModalRect(x, y, MARGIN + 153, TOP, 9, 9);
                absorbRemaining -= 1.0F;
            } else {
                //16
                drawTexturedModalRect(x, y, MARGIN + 144, TOP, 9, 9);
                absorbRemaining -= 2.0F;
            }
        } else {
            if (i * 2 + 1 < health)
                //4
                drawTexturedModalRect(x, y, MARGIN + 36, TOP, 9, 9);
            else if (i * 2 + 1 == health)
                //5
                drawTexturedModalRect(x, y, MARGIN + 45, TOP, 9, 9);
        }
    }
    GlStateManager.disableBlend();
    mc.mcProfiler.endSection();
    post(HEALTH);
}
Also used : IAttributeInstance(net.minecraft.entity.ai.attributes.IAttributeInstance) EntityPlayer(net.minecraft.entity.player.EntityPlayer)

Example 34 with EntityPlayer

use of net.minecraft.entity.player.EntityPlayer in project MinecraftForge by MinecraftForge.

the class GuiIngameForge method renderAir.

protected void renderAir(int width, int height) {
    if (pre(AIR))
        return;
    mc.mcProfiler.startSection("air");
    EntityPlayer player = (EntityPlayer) this.mc.getRenderViewEntity();
    GlStateManager.enableBlend();
    int left = width / 2 + 91;
    int top = height - right_height;
    if (player.isInsideOfMaterial(Material.WATER)) {
        int air = player.getAir();
        int full = MathHelper.ceil((double) (air - 2) * 10.0D / 300.0D);
        int partial = MathHelper.ceil((double) air * 10.0D / 300.0D) - full;
        for (int i = 0; i < full + partial; ++i) {
            drawTexturedModalRect(left - i * 8 - 9, top, (i < full ? 16 : 25), 18, 9, 9);
        }
        right_height += 10;
    }
    GlStateManager.disableBlend();
    mc.mcProfiler.endSection();
    post(AIR);
}
Also used : EntityPlayer(net.minecraft.entity.player.EntityPlayer)

Example 35 with EntityPlayer

use of net.minecraft.entity.player.EntityPlayer in project SimplyJetpacks by Tonius.

the class RenderUtils method getArmorModel.

public static ModelBiped getArmorModel(PackBase pack, EntityLivingBase entity) {
    ModelBiped model = null;
    switch(pack.armorModel) {
        case JETPACK:
            model = ModelJetpack.INSTANCE;
            break;
        case FLUX_PACK:
            model = ModelFluxPack.INSTANCE;
        default:
    }
    if (model == null) {
        return null;
    }
    model.isSneak = entity.isSneaking();
    model.isRiding = entity.isRiding();
    model.isChild = entity.isChild();
    model.heldItemRight = entity.getEquipmentInSlot(0) != null ? 1 : 0;
    if (entity instanceof EntityPlayer) {
        model.aimedBow = ((EntityPlayer) entity).getItemInUseDuration() > 2;
    }
    return model;
}
Also used : ModelBiped(net.minecraft.client.model.ModelBiped) EntityPlayer(net.minecraft.entity.player.EntityPlayer)

Aggregations

EntityPlayer (net.minecraft.entity.player.EntityPlayer)625 ItemStack (net.minecraft.item.ItemStack)169 EntityLivingBase (net.minecraft.entity.EntityLivingBase)104 SubscribeEvent (net.minecraftforge.fml.common.eventhandler.SubscribeEvent)81 Entity (net.minecraft.entity.Entity)77 World (net.minecraft.world.World)73 BlockPos (net.minecraft.util.math.BlockPos)61 AxisAlignedBB (net.minecraft.util.math.AxisAlignedBB)49 SubscribeEvent (cpw.mods.fml.common.eventhandler.SubscribeEvent)44 TileEntity (net.minecraft.tileentity.TileEntity)43 PotionEffect (net.minecraft.potion.PotionEffect)41 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)38 EntityItem (net.minecraft.entity.item.EntityItem)37 Block (net.minecraft.block.Block)36 EntityPlayerMP (net.minecraft.entity.player.EntityPlayerMP)35 ArrayList (java.util.ArrayList)33 IBlockState (net.minecraft.block.state.IBlockState)33 List (java.util.List)28 TextComponentString (net.minecraft.util.text.TextComponentString)27 AxisAlignedBB (net.minecraft.util.AxisAlignedBB)23