Java Code Examples for net.minecraft.entity.player.EntityPlayer.getAir()

The following are Jave code examples for showing how to use getAir() of the net.minecraft.entity.player.EntityPlayer class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: CompositeGear   File: ItemCGArmor.java   View Source Code Vote up 6 votes
@Optional.Method(modid = Compats.IC2)
@Override
public void onArmorTick(World world, EntityPlayer player, ItemStack stack)
{
	boolean shouldUpdate = false;
	
	// If we wear some air mask on head.
	if (this.isAirMask && this.armorType == EntityEquipmentSlot.HEAD)
	{
		// Default max value is 300
		
		if ((player.getAir() <= minAirToStartRefil) && (player.inventory.hasItemStack(ItemsCG.ic2AirCell)))
		{
			consumeItemFromInventory(player, ItemsCG.ic2AirCell);
	        player.inventory.addItemStackToInventory(new ItemStack(ItemsCG.ic2EmptyCell.getItem()));
	        player.setAir(300);
	        shouldUpdate = true;
		}
	}
	
	// If we have changed inventory contents then we should sync it on client.
	if (shouldUpdate) {
		player.inventoryContainer.detectAndSendChanges();
	}
}
 
Example 2
Project: CustomWorldGen   File: GuiIngameForge.java   View Source Code Vote up 6 votes
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.ceiling_double_int((double)(air - 2) * 10.0D / 300.0D);
        int partial = MathHelper.ceiling_double_int((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);
}
 
Example 3
Project: pnc-repressurized   File: TileEntityAerialInterface.java   View Source Code Vote up 5 votes
@Override
public void update() {
    if (!getWorld().isRemote && updateNeighbours) {
        updateNeighbours = false;
        updateNeighbours();
    }
    if (!getWorld().isRemote) {
        if (getPressure() > PneumaticValues.MIN_PRESSURE_AERIAL_INTERFACE && isConnectedToPlayer) {
            if (energyRF != null) tickRF();
            addAir(-PneumaticValues.USAGE_AERIAL_INTERFACE);
            // bitwise check much faster than mod (%)
            if ((getWorld().getTotalWorldTime() & 0xf) == 0) {
                EntityPlayer player = getPlayer();
                if (player != null && player.getAir() <= 280) {
                    player.setAir(player.getAir() + 16);
                    addAir(-3200);
                }
            }
        }
        if ((getWorld().getTotalWorldTime() & 0xf) == 0 && !getWorld().isRemote && !playerUUID.isEmpty()) {
            setPlayer(PneumaticCraftUtils.getPlayerFromId(playerUUID));
        }
    }

    if (oldRedstoneStatus != shouldEmitRedstone()) {
        oldRedstoneStatus = shouldEmitRedstone();
        updateNeighbours = true;
    }

    super.update();
}