net.minecraftforge.common.ISpecialArmor Java Examples

The following examples show how to use net.minecraftforge.common.ISpecialArmor. 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: NotificationDisplay.java    From Cyberware with MIT License 6 votes vote down vote up
@SideOnly(Side.CLIENT)
private boolean updateLightArmor()
{
	for (ItemStack stack : inv)
	{
		if (stack != null && stack.getItem() instanceof ItemArmor)
		{
			if (((ItemArmor) stack.getItem()).getArmorMaterial().getDamageReductionAmount(EntityEquipmentSlot.CHEST) > 4)
			{
				return false;
			}
		}
		else if (stack != null && stack.getItem() instanceof ISpecialArmor)
		{
			if (((ISpecialArmor) stack.getItem()).getProperties(Minecraft.getMinecraft().thePlayer, stack, DamageSource.cactus, 1, 1).AbsorbRatio * 25D > 4)
			{
				return false;
			}
		}
	}
	return true;
}
 
Example #2
Source File: ItemSkinUpgrade.java    From Cyberware with MIT License 5 votes vote down vote up
@SubscribeEvent
public void handleHurt(LivingHurtEvent event)
{
	EntityLivingBase e = event.getEntityLiving();

	if (CyberwareAPI.isCyberwareInstalled(e, new ItemStack(this, 1, 1)))
	{
		if (event.getSource() instanceof EntityDamageSource && !(event.getSource() instanceof EntityDamageSourceIndirect))
		{
			for (ItemStack stack : e.getArmorInventoryList())
			{
				if (stack != null && stack.getItem() instanceof ItemArmor)
				{
					if (((ItemArmor) stack.getItem()).getArmorMaterial().getDamageReductionAmount(EntityEquipmentSlot.CHEST) > 4)
					{
						return;
					}
				}
				else if (stack != null && stack.getItem() instanceof ISpecialArmor)
				{
					if (((ISpecialArmor) stack.getItem()).getProperties(e, stack, event.getSource(), event.getAmount(), 1).AbsorbRatio * 25D > 4)
					{
						return;
					}
				}
			}
			
			Random random = e.getRNG();
			Entity attacker = ((EntityDamageSource) event.getSource()).getSourceOfDamage();
			int level = 2;
			if (EnchantmentThorns.shouldHit(3, random))
			{
				if (attacker != null)
				{
					attacker.attackEntityFrom(DamageSource.causeThornsDamage(e), (float) EnchantmentThorns.getDamage(2, random));
				}
			}
		}
	}
}
 
Example #3
Source File: ItemElectricGoggles.java    From Electro-Magic-Tools with GNU General Public License v3.0 5 votes vote down vote up
@Override
public ArmorProperties getProperties(EntityLivingBase player, ItemStack armor, DamageSource source, double damage, int slot) {
    if (source.isUnblockable()) {
        return new net.minecraftforge.common.ISpecialArmor.ArmorProperties(0, 0.0D, 0);
    } else {
        double absorptionRatio = getBaseAbsorptionRatio() * getDamageAbsorptionRatio();
        int energyPerDamage = getEnergyPerDamage();
        double damageLimit = energyPerDamage <= 0 ? 0 : (25 * ElectricItem.manager.getCharge(armor)) / energyPerDamage;
        return new net.minecraftforge.common.ISpecialArmor.ArmorProperties(0, absorptionRatio, (int) damageLimit);
    }
}
 
Example #4
Source File: ItemNanoWing.java    From Electro-Magic-Tools with GNU General Public License v3.0 5 votes vote down vote up
@Override
public ArmorProperties getProperties(EntityLivingBase player, ItemStack armor, DamageSource source, double damage, int slot) {
    if (source.isUnblockable()) {
        return new net.minecraftforge.common.ISpecialArmor.ArmorProperties(0, 0.0D, 3);
    } else {
        double absorptionRatio = getBaseAbsorptionRatio() * getDamageAbsorptionRatio();
        int energyPerDamage = getEnergyPerDamage();
        double damageLimit = energyPerDamage <= 0 ? 0 : (25 * ElectricItem.manager.getCharge(armor)) / energyPerDamage;
        return new net.minecraftforge.common.ISpecialArmor.ArmorProperties(3, absorptionRatio, (int) damageLimit);
    }
}
 
Example #5
Source File: ItemElectricBootsTraveller.java    From Electro-Magic-Tools with GNU General Public License v3.0 5 votes vote down vote up
@Override
public ArmorProperties getProperties(EntityLivingBase player, ItemStack armor, DamageSource source, double damage, int slot) {
    if (source.isUnblockable()) {
        return new net.minecraftforge.common.ISpecialArmor.ArmorProperties(0, 0.0D, 3);
    } else {
        double absorptionRatio = getBaseAbsorptionRatio() * getDamageAbsorptionRatio();
        int energyPerDamage = getEnergyPerDamage();
        double damageLimit = energyPerDamage <= 0 ? 0 : (25 * ElectricItem.manager.getCharge(armor)) / energyPerDamage;
        return new net.minecraftforge.common.ISpecialArmor.ArmorProperties(3, absorptionRatio, (int) damageLimit);
    }
}
 
Example #6
Source File: ItemBrainUpgrade.java    From Cyberware with MIT License 4 votes vote down vote up
@SubscribeEvent(priority=EventPriority.HIGHEST)
public void handleHurt(LivingAttackEvent event)
{
	EntityLivingBase e = event.getEntityLiving();
	
	if (CyberwareAPI.isCyberwareInstalled(e, new ItemStack(this, 1, 4)) && isMatrixWorking(e))
	{

		if (!e.worldObj.isRemote && event.getSource() instanceof EntityDamageSource)
		{
			Entity attacker = ((EntityDamageSource) event.getSource()).getSourceOfDamage();
			if (e instanceof EntityPlayer)
			{
				String str = e.getEntityId() + " " + e.ticksExisted + " " + attacker.getEntityId();
				if (lastHits.contains(str))
				{
					return;
				}
				else
				{
					lastHits.add(str);
				}
			}
			
			boolean armor = false;
			for (ItemStack stack : e.getArmorInventoryList())
			{
				if (stack != null && stack.getItem() instanceof ItemArmor)
				{
					if (((ItemArmor) stack.getItem()).getArmorMaterial().getDamageReductionAmount(EntityEquipmentSlot.CHEST) > 4)
					{
						return;
					}
				}
				else if (stack != null && stack.getItem() instanceof ISpecialArmor)
				{
					if (((ISpecialArmor) stack.getItem()).getProperties(e, stack, event.getSource(), event.getAmount(), 1).AbsorbRatio * 25D > 4)
					{
						return;
					}
				}
				
				if (stack != null)
				{
					armor = true;
				}
				
			}
			

			if (!((float) e.hurtResistantTime > (float) e.maxHurtResistantTime / 2.0F))
               {
				Random random = e.getRNG();
				if (random.nextFloat() < (armor ? LibConstants.DODGE_ARMOR : LibConstants.DODGE_NO_ARMOR))
				{
					event.setCanceled(true);
					e.hurtResistantTime = e.maxHurtResistantTime;
					e.hurtTime = e.maxHurtTime = 10;
					ReflectionHelper.setPrivateValue(EntityLivingBase.class, e, 9999F, 46);
					
					CyberwarePacketHandler.INSTANCE.sendToAllAround(new DodgePacket(e.getEntityId()), new TargetPoint(e.worldObj.provider.getDimension(), e.posX, e.posY, e.posZ, 50));
				}
			}
		}
	}
}