use of WayofTime.bloodmagic.livingArmour.LivingArmourUpgrade 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.LivingArmourUpgrade 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.LivingArmourUpgrade 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.LivingArmourUpgrade in project BloodMagic by WayofTime.
the class StatTrackerHandler method onExperiencePickup.
// Tracks: Experienced
@SubscribeEvent(priority = EventPriority.LOW)
public static void onExperiencePickup(PlayerPickupXpEvent event) {
EntityPlayer player = event.getEntityPlayer();
if (LivingArmour.hasFullSet(player)) {
ItemStack chestStack = player.getItemStackFromSlot(EntityEquipmentSlot.CHEST);
LivingArmour armour = ItemLivingArmour.getLivingArmour(chestStack);
if (armour != null) {
LivingArmourUpgrade upgrade = ItemLivingArmour.getUpgrade(BloodMagic.MODID + ".upgrade.experienced", chestStack);
if (upgrade instanceof LivingArmourUpgradeExperience) {
double modifier = ((LivingArmourUpgradeExperience) upgrade).getExperienceModifier();
double exp = event.getOrb().xpValue * (1 + modifier);
event.getOrb().xpValue = (int) Math.floor(exp) + (Math.random() < exp % 1 ? 1 : 0);
}
StatTrackerExperience.incrementCounter(armour, event.getOrb().xpValue);
}
}
}
use of WayofTime.bloodmagic.livingArmour.LivingArmourUpgrade in project BloodMagic by WayofTime.
the class RitualFeatheredKnife method performRitual.
@Override
public void performRitual(IMasterRitualStone masterRitualStone) {
World world = masterRitualStone.getWorldObj();
int currentEssence = masterRitualStone.getOwnerNetwork().getCurrentEssence();
if (currentEssence < getRefreshCost()) {
masterRitualStone.getOwnerNetwork().causeNausea();
return;
}
BlockPos pos = masterRitualStone.getBlockPos();
List<EnumDemonWillType> willConfig = masterRitualStone.getActiveWillConfig();
double corrosiveWill = this.getWillRespectingConfig(world, pos, EnumDemonWillType.CORROSIVE, willConfig);
double destructiveWill = this.getWillRespectingConfig(world, pos, EnumDemonWillType.DESTRUCTIVE, willConfig);
double rawWill = this.getWillRespectingConfig(world, pos, EnumDemonWillType.DEFAULT, willConfig);
double steadfastWill = this.getWillRespectingConfig(world, pos, EnumDemonWillType.STEADFAST, willConfig);
double vengefulWill = this.getWillRespectingConfig(world, pos, EnumDemonWillType.VENGEFUL, willConfig);
refreshTime = getRefreshTimeForRawWill(rawWill);
boolean consumeRawWill = rawWill >= rawWillDrain && refreshTime != defaultRefreshTime;
int maxEffects = currentEssence / getRefreshCost();
int totalEffects = 0;
BlockPos altarPos = pos.add(altarOffsetPos);
TileEntity tile = world.getTileEntity(altarPos);
AreaDescriptor altarRange = getBlockRange(ALTAR_RANGE);
if (!altarRange.isWithinArea(altarOffsetPos) || !(tile instanceof IBloodAltar)) {
for (BlockPos newPos : altarRange.getContainedPositions(pos)) {
TileEntity nextTile = world.getTileEntity(newPos);
if (nextTile instanceof IBloodAltar) {
tile = nextTile;
altarOffsetPos = newPos.subtract(pos);
altarRange.resetCache();
break;
}
}
}
boolean useIncense = corrosiveWill >= corrosiveWillThreshold;
if (tile instanceof IBloodAltar) {
IBloodAltar tileAltar = (IBloodAltar) tile;
AreaDescriptor damageRange = getBlockRange(DAMAGE_RANGE);
AxisAlignedBB range = damageRange.getAABB(pos);
double destructiveDrain = 0;
List<EntityPlayer> entities = world.getEntitiesWithinAABB(EntityPlayer.class, range);
for (EntityPlayer player : entities) {
float healthThreshold = steadfastWill >= steadfastWillThreshold ? 0.7f : 0.3f;
if (vengefulWill >= vengefulWillThreshold && !player.getGameProfile().getId().equals(masterRitualStone.getOwner())) {
healthThreshold = 0.1f;
}
float health = player.getHealth();
float maxHealth = player.getMaxHealth();
float sacrificedHealth = 1;
double lpModifier = 1;
if ((health / player.getMaxHealth() > healthThreshold) && (!useIncense || !player.isPotionActive(RegistrarBloodMagic.SOUL_FRAY))) {
if (useIncense) {
double incenseAmount = PlayerSacrificeHelper.getPlayerIncense(player);
sacrificedHealth = health - maxHealth * healthThreshold;
lpModifier *= PlayerSacrificeHelper.getModifier(incenseAmount);
PlayerSacrificeHelper.setPlayerIncense(player, 0);
player.addPotionEffect(new PotionEffect(RegistrarBloodMagic.SOUL_FRAY, PlayerSacrificeHelper.soulFrayDuration));
}
if (destructiveWill >= destructiveWillDrain * sacrificedHealth) {
lpModifier *= getLPModifierForWill(destructiveWill);
destructiveWill -= destructiveWillDrain * sacrificedHealth;
destructiveDrain += destructiveWillDrain * sacrificedHealth;
}
if (LivingArmour.hasFullSet(player)) {
ItemStack chestStack = player.getItemStackFromSlot(EntityEquipmentSlot.CHEST);
LivingArmour armour = ItemLivingArmour.getLivingArmour(chestStack);
if (armour != null) {
LivingArmourUpgrade upgrade = ItemLivingArmour.getUpgrade(BloodMagic.MODID + ".upgrade.selfSacrifice", chestStack);
if (upgrade instanceof LivingArmourUpgradeSelfSacrifice) {
double modifier = ((LivingArmourUpgradeSelfSacrifice) upgrade).getSacrificeModifier();
lpModifier *= (1 + modifier);
}
}
}
player.setHealth(health - sacrificedHealth);
tileAltar.sacrificialDaggerCall((int) (ConfigHandler.values.sacrificialDaggerConversion * lpModifier * sacrificedHealth), false);
totalEffects++;
if (totalEffects >= maxEffects) {
break;
}
}
}
if (destructiveDrain > 0) {
WorldDemonWillHandler.drainWill(world, pos, EnumDemonWillType.STEADFAST, destructiveDrain, true);
}
}
masterRitualStone.getOwnerNetwork().syphon(getRefreshCost() * totalEffects);
if (totalEffects > 0 && consumeRawWill) {
WorldDemonWillHandler.drainWill(world, pos, EnumDemonWillType.DEFAULT, rawWillDrain, true);
}
}
Aggregations