use of WayofTime.bloodmagic.livingArmour.LivingArmour in project BloodMagic by WayofTime.
the class GenericHandler method onEntityHurt.
@SubscribeEvent
public static void onEntityHurt(LivingHurtEvent event) {
if (event.getEntity().getEntityWorld().isRemote)
return;
if (event.getSource().getTrueSource() instanceof EntityPlayer && !PlayerHelper.isFakePlayer((EntityPlayer) event.getSource().getTrueSource())) {
EntityPlayer player = (EntityPlayer) event.getSource().getTrueSource();
if (!player.getItemStackFromSlot(EntityEquipmentSlot.CHEST).isEmpty() && player.getItemStackFromSlot(EntityEquipmentSlot.CHEST).getItem() instanceof ItemPackSacrifice) {
ItemPackSacrifice pack = (ItemPackSacrifice) player.getItemStackFromSlot(EntityEquipmentSlot.CHEST).getItem();
boolean shouldSyphon = pack.getStoredLP(player.getItemStackFromSlot(EntityEquipmentSlot.CHEST)) < pack.CAPACITY;
float damageDone = event.getEntityLiving().getHealth() < event.getAmount() ? event.getAmount() - event.getEntityLiving().getHealth() : event.getAmount();
int totalLP = Math.round(damageDone * ConfigHandler.values.coatOfArmsConversion);
if (shouldSyphon)
ItemHelper.LPContainer.addLPToItem(player.getItemStackFromSlot(EntityEquipmentSlot.CHEST), totalLP, pack.CAPACITY);
}
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.battleHunger", chestStack);
if (upgrade instanceof LivingArmourUpgradeBattleHungry) {
((LivingArmourUpgradeBattleHungry) upgrade).resetTimer();
}
}
}
}
}
use of WayofTime.bloodmagic.livingArmour.LivingArmour in project BloodMagic by WayofTime.
the class LivingArmourHandler method onArrowFire.
// Applies: Arrow Shot
// Tracks: Arrow Shot
@SubscribeEvent
public static void onArrowFire(ArrowLooseEvent event) {
World world = event.getEntityPlayer().getEntityWorld();
ItemStack stack = event.getBow();
EntityPlayer player = event.getEntityPlayer();
if (world.isRemote)
return;
if (LivingArmour.hasFullSet(player)) {
ItemStack chestStack = player.getItemStackFromSlot(EntityEquipmentSlot.CHEST);
LivingArmour armour = ItemLivingArmour.getLivingArmour(chestStack);
if (armour != null) {
StatTrackerArrowShot.incrementCounter(armour);
LivingArmourUpgrade upgrade = ItemLivingArmour.getUpgrade(BloodMagic.MODID + ".upgrade.arrowShot", chestStack);
if (upgrade instanceof LivingArmourUpgradeArrowShot) {
int charge = event.getCharge();
float velocity = (float) charge / 20.0F;
velocity = (velocity * velocity + velocity * 2.0F) / 3.0F;
if ((double) velocity < 0.1D)
return;
if (velocity > 1.0F)
velocity = 1.0F;
int extraArrows = ((LivingArmourUpgradeArrowShot) upgrade).getExtraArrows();
for (int n = 0; n < extraArrows; n++) {
ItemStack arrowStack = new ItemStack(Items.ARROW);
ItemArrow itemarrow = (ItemArrow) ((stack.getItem() instanceof ItemArrow ? arrowStack.getItem() : Items.ARROW));
EntityArrow entityarrow = itemarrow.createArrow(world, arrowStack, player);
entityarrow.shoot(player, player.rotationPitch, player.rotationYaw, 0.0F, velocity * 3.0F, 1.0F);
float velocityModifier = 0.6f * velocity;
entityarrow.motionX += (event.getWorld().rand.nextDouble() - 0.5) * velocityModifier;
entityarrow.motionY += (event.getWorld().rand.nextDouble() - 0.5) * velocityModifier;
entityarrow.motionZ += (event.getWorld().rand.nextDouble() - 0.5) * velocityModifier;
if (velocity == 1.0F)
entityarrow.setIsCritical(true);
int powerLevel = EnchantmentHelper.getEnchantmentLevel(Enchantments.POWER, stack);
if (powerLevel > 0)
entityarrow.setDamage(entityarrow.getDamage() + (double) powerLevel * 0.5D + 0.5D);
int punchLevel = EnchantmentHelper.getEnchantmentLevel(Enchantments.PUNCH, stack);
if (punchLevel > 0)
entityarrow.setKnockbackStrength(punchLevel);
if (EnchantmentHelper.getEnchantmentLevel(Enchantments.FLAME, stack) > 0)
entityarrow.setFire(100);
entityarrow.pickupStatus = EntityArrow.PickupStatus.CREATIVE_ONLY;
world.spawnEntity(entityarrow);
}
}
}
}
}
use of WayofTime.bloodmagic.livingArmour.LivingArmour in project BloodMagic by WayofTime.
the class LivingArmourHandler method onMiningSpeedCheck.
@SubscribeEvent
public static void onMiningSpeedCheck(PlayerEvent.BreakSpeed event) {
EntityPlayer player = event.getEntityPlayer();
if (LivingArmour.hasFullSet(player)) {
ItemStack chestStack = player.getItemStackFromSlot(EntityEquipmentSlot.CHEST);
LivingArmour armour = ItemLivingArmour.getLivingArmour(chestStack);
if (armour != null) {
double modifier = 1;
for (LivingArmourUpgrade upgrade : armour.upgradeMap.values()) {
modifier *= upgrade.getMiningSpeedModifier(player);
}
if (modifier != 1) {
event.setNewSpeed((float) (event.getOriginalSpeed() * modifier));
}
}
}
}
use of WayofTime.bloodmagic.livingArmour.LivingArmour in project BloodMagic by WayofTime.
the class LivingArmourHandler method onEntityUpdate.
// Applies: Step Assist, Speed Boost
@SubscribeEvent(priority = EventPriority.HIGHEST)
public static void onEntityUpdate(LivingEvent.LivingUpdateEvent event) {
if (event.getEntityLiving() instanceof EntityPlayer) {
EntityPlayer player = (EntityPlayer) event.getEntityLiving();
boolean hasAssist = false;
if (event.getEntityLiving().isPotionActive(RegistrarBloodMagic.BOOST)) {
hasAssist = true;
player.stepHeight = Constants.Misc.ALTERED_STEP_HEIGHT;
} else {
if (LivingArmour.hasFullSet(player)) {
ItemStack chestStack = player.getItemStackFromSlot(EntityEquipmentSlot.CHEST);
LivingArmour armour = ItemLivingArmour.getLivingArmourFromStack(chestStack);
if (armour != null) {
LivingArmourUpgrade upgrade = ItemLivingArmour.getUpgrade(BloodMagic.MODID + ".upgrade.stepAssist", chestStack);
if (upgrade instanceof LivingArmourUpgradeStepAssist) {
player.stepHeight = ((LivingArmourUpgradeStepAssist) upgrade).getStepAssist();
hasAssist = true;
}
}
}
}
if (!hasAssist && player.stepHeight == Constants.Misc.ALTERED_STEP_HEIGHT)
player.stepHeight = 0.6f;
float percentIncrease = 0;
if (LivingArmour.hasFullSet(player)) {
ItemStack chestStack = player.getItemStackFromSlot(EntityEquipmentSlot.CHEST);
LivingArmour armour = ItemLivingArmour.getLivingArmourFromStack(chestStack);
if (armour != null) {
LivingArmourUpgrade upgrade = ItemLivingArmour.getUpgradeFromNBT(BloodMagic.MODID + ".upgrade.movement", chestStack);
if (upgrade instanceof LivingArmourUpgradeSpeed) {
percentIncrease += ((LivingArmourUpgradeSpeed) upgrade).getSpeedModifier();
}
}
}
if (event.getEntityLiving().isPotionActive(RegistrarBloodMagic.BOOST)) {
int i = event.getEntityLiving().getActivePotionEffect(RegistrarBloodMagic.BOOST).getAmplifier();
{
percentIncrease += (i + 1) * 0.5f;
}
}
if (percentIncrease > 0 && (player.onGround || player.capabilities.isFlying) && (Math.abs(player.moveForward) > 0 || Math.abs(player.moveStrafing) > 0)) {
player.travel(player.moveStrafing * percentIncrease, 0, player.moveForward * percentIncrease);
}
}
}
use of WayofTime.bloodmagic.livingArmour.LivingArmour in project BloodMagic by WayofTime.
the class StatTrackerHandler method onEntityHealed.
// Tracks: Health Boost
@SubscribeEvent
public static void onEntityHealed(LivingHealEvent event) {
EntityLivingBase healedEntity = event.getEntityLiving();
if (!(healedEntity instanceof EntityPlayer)) {
return;
}
EntityPlayer player = (EntityPlayer) healedEntity;
if (LivingArmour.hasFullSet(player)) {
ItemStack chestStack = player.getItemStackFromSlot(EntityEquipmentSlot.CHEST);
LivingArmour armour = ItemLivingArmour.getLivingArmour(chestStack);
if (armour != null) {
StatTrackerHealthboost.incrementCounter(armour, event.getAmount());
if (player.getEntityWorld().canSeeSky(player.getPosition()) && player.getEntityWorld().provider.isDaytime()) {
StatTrackerSolarPowered.incrementCounter(armour, event.getAmount());
}
}
}
}
Aggregations