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

The following examples show how to use net.minecraft.entity.player.EntityPlayer#setAir() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ArmorLogicRebreather.java    From GregTech with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
public void onArmorTick(World world, EntityPlayer player, ItemStack itemStack) {
    IElectricItem electricItem = itemStack.getCapability(GregtechCapabilities.CAPABILITY_ELECTRIC_ITEM, null);
    if (electricItem.getCharge() >= energyUsagePerTick) {
        if (player.isInsideOfMaterial(Material.WATER) && world.isRemote && world.getTotalWorldTime() % 20 == 0L) {
            Vec3d pos = player.getPositionVector().add(new Vec3d(0.0, player.getEyeHeight(), 0.0));
            Particle particle = new ParticleBubble.Factory().createParticle(0, world, pos.x, pos.y, pos.z, 0.0, 0.0, 0.0);
            particle.setMaxAge(Integer.MAX_VALUE);
            Minecraft.getMinecraft().effectRenderer.addEffect(particle);
        }
        if (player.isInsideOfMaterial(Material.WATER) && !player.isPotionActive(MobEffects.WATER_BREATHING)) {
            if (player.getAir() < 300 && drainActivationEnergy(electricItem)) {
                player.setAir(Math.min(player.getAir() + 1, 300));
            }
        }
    }
}
 
Example 2
Source File: TileEntityAerialInterface.java    From PneumaticCraft with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void updateEntity(){
    if(!worldObj.isRemote && updateNeighbours) {
        updateNeighbours = false;
        updateNeighbours();
    }
    if(!worldObj.isRemote) {
        if(getPressure(ForgeDirection.UNKNOWN) > PneumaticValues.MIN_PRESSURE_AERIAL_INTERFACE && isConnectedToPlayer) {
            if(energyRF != null) tickRF();
            addAir(-PneumaticValues.USAGE_AERIAL_INTERFACE, ForgeDirection.UNKNOWN);
            if(worldObj.getTotalWorldTime() % 40 == 0) dispenserUpgradeInserted = getUpgrades(ItemMachineUpgrade.UPGRADE_DISPENSER_DAMAGE) > 0;
            if(worldObj.getTotalWorldTime() % 20 == 0) {
                EntityPlayer player = getPlayer();
                if(player != null && player.getAir() <= 280) {
                    player.setAir(player.getAir() + 20);
                    addAir(-4000, null);
                }
            }
        }
        if(worldObj.getTotalWorldTime() % 20 == 0) getPlayerInventory();
    }

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

    super.updateEntity();

}
 
Example 3
Source File: ItemQuantumGoggles.java    From Electro-Magic-Tools with GNU General Public License v3.0 4 votes vote down vote up
@SuppressWarnings({"rawtypes", "unchecked"})
@Override
public void onArmorTick(World world, EntityPlayer player, ItemStack itemStack) {
    int refill = player.getAir();
    if (ElectricItem.manager.canUse(itemStack, 1000) && refill < 100) {
        player.setAir(refill + 200);
        ElectricItem.manager.use(itemStack, 1000, null);
    }

    Iterator i$ = (new LinkedList(player.getActivePotionEffects())).iterator();
    do {
        if (!i$.hasNext()) {
            break;
        }
        {
            PotionEffect effect = (PotionEffect) i$.next();
            int id = effect.getPotionID();
            Integer cost = (Integer) potionCost.get(Integer.valueOf(id));
            if (cost != null) {
                cost = Integer.valueOf(cost.intValue() * (effect.getAmplifier() + 1));
                if (ElectricItem.manager.canUse(itemStack, cost.intValue())) {
                    ElectricItem.manager.use(itemStack, cost.intValue(), null);
                    ItemStack milk = (new ItemStack(Items.milk_bucket));
                    player.curePotionEffects(milk);
                }
            }
        }
    } while (true);

    if (ConfigHandler.nightVisionOff == false) {
        if (ElectricItem.manager.canUse(itemStack, 1 / 1000)) {
            int x = MathHelper.floor_double(player.posX);
            int z = MathHelper.floor_double(player.posZ);
            int y = MathHelper.floor_double(player.posY);
            int lightlevel = player.worldObj.getBlockLightValue(x, y, z);
            if (lightlevel >= 0)
                player.addPotionEffect(new PotionEffect(Potion.nightVision.id, 300, -3));
            ElectricItem.manager.use(itemStack, 1 / 1000, player);
        } else {
            player.addPotionEffect(new PotionEffect(Potion.blindness.id, 300, 0, true));
        }
    }
}