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

The following examples show how to use net.minecraft.entity.EntityLivingBase#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: PotionSuffocate.java    From Wizardry with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Override
public void performEffect(EntityLivingBase entity, int amplifier)
{
	entity.setAir(0);
	entity.attackEntityFrom(DamageSource.DROWN, 2.0F);
}
 
Example 2
Source File: ItemLungsUpgrade.java    From Cyberware with MIT License 4 votes vote down vote up
@SubscribeEvent
public void handleLivingUpdate(CyberwareUpdateEvent event)
{
	EntityLivingBase e = event.getEntityLiving();
	if (CyberwareAPI.isCyberwareInstalled(e, new ItemStack(this, 1, 0)))
	{
		ItemStack stack = CyberwareAPI.getCyberware(e, new ItemStack(this, 1, 0));
		int air = getAir(stack);
		if (e.getAir() < 300 && air > 0)
		{
			int toAdd = Math.min(300 - e.getAir(), air);
			e.setAir(e.getAir() + toAdd);
			CyberwareAPI.getCyberwareNBT(stack).setInteger("air", air - toAdd);
		}
		else if (e.getAir() == 300 && air < 900)
		{
			CyberwareAPI.getCyberwareNBT(stack).setInteger("air", air + 1);
		}
	}
	


	ItemStack test = new ItemStack(this, 1, 1);
	if (CyberwareAPI.isCyberwareInstalled(e, new ItemStack(this, 1, 1)))
	{
		if ((e.isSprinting() || e instanceof EntityMob) && !e.isInWater() && e.onGround)
		{
			boolean last = getLastOxygen(e);

			int ranks = CyberwareAPI.getCyberwareRank(e, test);
			test.stackSize = ranks;
			boolean powerUsed = e.ticksExisted % 20 == 0 ? CyberwareAPI.getCapability(e).usePower(test, getPowerConsumption(test)) : last;
			
			if (powerUsed)
			{
				e.moveRelative(0F, .2F * ranks, 0.075F);
			}
			
			lastOxygen.put(e.getEntityId(), powerUsed);
		}
	}
}