use of WayofTime.bloodmagic.livingArmour.LivingArmour in project BloodMagic by WayofTime.
the class ItemLivingArmour method damageArmor.
@Override
public void damageArmor(EntityLivingBase entity, ItemStack stack, DamageSource source, int damage, int slot) {
if (this == RegistrarBloodMagicItems.LIVING_ARMOUR_CHEST) {
int preDamage = stack.getItemDamage();
if (source.isUnblockable()) {
return;
}
if (damage > this.getMaxDamage(stack) - this.getDamage(stack)) {
// TODO: Syphon a load of LP.
if (entity.getEntityWorld().isRemote && entity instanceof EntityPlayer) {
EntityPlayer player = (EntityPlayer) entity;
SoulNetwork network = NetworkHelper.getSoulNetwork(player);
network.syphonAndDamage(player, damage * 100);
}
return;
}
stack.damageItem(damage, entity);
int receivedDamage = stack.getItemDamage() - preDamage;
if (entity instanceof EntityPlayer) {
EntityPlayer player = (EntityPlayer) entity;
if (LivingArmour.hasFullSet(player)) {
LivingArmour armour = ItemLivingArmour.getLivingArmour(stack);
if (armour != null) {
StatTrackerRepairing.incrementCounter(armour, receivedDamage);
}
}
}
} else {
stack.damageItem(damage, entity);
}
// TODO Armour shouldn't get damaged... for now
return;
}
use of WayofTime.bloodmagic.livingArmour.LivingArmour in project BloodMagic by WayofTime.
the class LivingArmourHandler method onPlayerClick.
@SubscribeEvent
public static void onPlayerClick(PlayerInteractEvent event) {
if (event.isCancelable()) {
EntityPlayer player = event.getEntityPlayer();
if (LivingArmour.hasFullSet(player)) {
ItemStack chestStack = player.getItemStackFromSlot(EntityEquipmentSlot.CHEST);
LivingArmour armour = ItemLivingArmour.getLivingArmour(chestStack);
if (armour != null) {
if (event.getHand() == EnumHand.OFF_HAND) {
LivingArmourUpgrade upgrade = ItemLivingArmour.getUpgrade(BloodMagic.MODID + ".upgrade.crippledArm", chestStack);
if (upgrade instanceof LivingArmourUpgradeCrippledArm) {
event.setCanceled(true);
}
}
if (event.getItemStack().getItemUseAction() == EnumAction.DRINK) {
ItemStack drinkStack = event.getItemStack();
// TODO: See if the item is a splash potion? Those should be usable.
LivingArmourUpgrade upgrade = ItemLivingArmour.getUpgrade(BloodMagic.MODID + ".upgrade.quenched", chestStack);
if (upgrade instanceof LivingArmourUpgradeQuenched) {
event.setCanceled(true);
}
}
}
}
}
}
use of WayofTime.bloodmagic.livingArmour.LivingArmour in project BloodMagic by WayofTime.
the class LivingArmourHandler method onEntityHealed.
@SubscribeEvent
public static void onEntityHealed(LivingHealEvent event) {
if (event.getEntityLiving() instanceof EntityPlayer) {
EntityPlayer player = (EntityPlayer) event.getEntity();
if (LivingArmour.hasFullSet(player)) {
ItemStack chestStack = player.getItemStackFromSlot(EntityEquipmentSlot.CHEST);
LivingArmour armour = ItemLivingArmour.getLivingArmour(chestStack);
if (armour != null) {
double modifier = 1;
LivingArmourUpgrade upgrade = ItemLivingArmour.getUpgrade(BloodMagic.MODID + ".upgrade.slowHeal", chestStack);
if (upgrade instanceof LivingArmourUpgradeSlowHeal) {
modifier *= ((LivingArmourUpgradeSlowHeal) upgrade).getHealingModifier();
}
if (modifier != 1) {
event.setAmount((float) (event.getAmount() * modifier));
}
}
}
}
}
use of WayofTime.bloodmagic.livingArmour.LivingArmour in project BloodMagic by WayofTime.
the class LivingArmourHandler method onEntityDeath.
// Applies: Grim Reaper
@SubscribeEvent(priority = EventPriority.HIGHEST)
public static void onEntityDeath(LivingDeathEvent event) {
if (event.getEntityLiving() instanceof EntityPlayer) {
EntityPlayer player = (EntityPlayer) event.getEntityLiving();
if (LivingArmour.hasFullSet(player)) {
ItemStack chestStack = player.getItemStackFromSlot(EntityEquipmentSlot.CHEST);
LivingArmour armour = ItemLivingArmour.getLivingArmour(chestStack);
if (armour != null) {
StatTrackerGrimReaperSprint.incrementCounter(armour);
LivingArmourUpgrade upgrade = ItemLivingArmour.getUpgrade(BloodMagic.MODID + ".upgrade.grimReaper", chestStack);
if (upgrade instanceof LivingArmourUpgradeGrimReaperSprint && ((LivingArmourUpgradeGrimReaperSprint) upgrade).canSavePlayer(player)) {
((LivingArmourUpgradeGrimReaperSprint) upgrade).applyEffectOnRebirth(player);
event.setCanceled(true);
event.setResult(Event.Result.DENY);
}
armour.writeDirtyToNBT(ItemLivingArmour.getArmourTag(chestStack));
}
}
}
}
use of WayofTime.bloodmagic.livingArmour.LivingArmour in project BloodMagic by WayofTime.
the class StatTrackerHandler method blockBreakEvent.
// Tracks: Digging, DigSlowdown
@SubscribeEvent
public static void blockBreakEvent(BlockEvent.BreakEvent event) {
EntityPlayer player = event.getPlayer();
if (player != null) {
if (LivingArmour.hasFullSet(player)) {
ItemStack chestStack = player.getItemStackFromSlot(EntityEquipmentSlot.CHEST);
if (chestStack.getItem() instanceof ItemLivingArmour) {
LivingArmour armour = ItemLivingArmour.getLivingArmour(chestStack);
if (armour != null) {
StatTrackerDigging.incrementCounter(armour);
LivingArmourUpgradeDigging.hasDug(armour);
}
}
}
}
}
Aggregations