2015-11-02 20:39:44 +00:00
|
|
|
package WayofTime.bloodmagic.util.handler;
|
2015-10-30 05:22:08 +00:00
|
|
|
|
2016-01-07 16:01:38 +00:00
|
|
|
import java.util.List;
|
2016-01-07 03:07:17 +00:00
|
|
|
import java.util.Random;
|
|
|
|
|
2016-02-04 04:31:09 +00:00
|
|
|
import WayofTime.bloodmagic.api.util.helper.NBTHelper;
|
2016-01-03 20:39:59 +00:00
|
|
|
import net.minecraft.block.Block;
|
2016-01-07 03:07:17 +00:00
|
|
|
import net.minecraft.enchantment.Enchantment;
|
|
|
|
import net.minecraft.enchantment.EnchantmentHelper;
|
2016-01-05 23:27:51 +00:00
|
|
|
import net.minecraft.entity.Entity;
|
|
|
|
import net.minecraft.entity.EntityLivingBase;
|
2016-01-07 16:01:38 +00:00
|
|
|
import net.minecraft.entity.item.EntityItem;
|
2016-01-31 03:22:46 +00:00
|
|
|
import net.minecraft.entity.passive.EntityAnimal;
|
2016-01-03 20:39:59 +00:00
|
|
|
import net.minecraft.entity.player.EntityPlayer;
|
|
|
|
import net.minecraft.entity.player.EntityPlayerMP;
|
2016-01-07 03:07:17 +00:00
|
|
|
import net.minecraft.entity.projectile.EntityArrow;
|
2016-01-03 20:39:59 +00:00
|
|
|
import net.minecraft.init.Items;
|
|
|
|
import net.minecraft.item.ItemStack;
|
2016-01-08 19:56:36 +00:00
|
|
|
import net.minecraft.potion.PotionEffect;
|
2016-01-07 00:34:10 +00:00
|
|
|
import net.minecraft.util.DamageSource;
|
2016-01-07 03:07:17 +00:00
|
|
|
import net.minecraft.world.World;
|
2016-02-04 04:31:09 +00:00
|
|
|
import net.minecraftforge.event.AnvilUpdateEvent;
|
2016-01-05 23:27:51 +00:00
|
|
|
import net.minecraftforge.event.entity.living.LivingAttackEvent;
|
2016-01-07 16:01:38 +00:00
|
|
|
import net.minecraftforge.event.entity.living.LivingDropsEvent;
|
2016-01-07 00:55:51 +00:00
|
|
|
import net.minecraftforge.event.entity.living.LivingHealEvent;
|
2016-01-03 20:39:59 +00:00
|
|
|
import net.minecraftforge.event.entity.living.LivingHurtEvent;
|
2016-02-04 04:31:09 +00:00
|
|
|
import net.minecraftforge.event.entity.player.*;
|
2016-01-03 20:39:59 +00:00
|
|
|
import net.minecraftforge.event.world.BlockEvent;
|
|
|
|
import net.minecraftforge.fml.client.event.ConfigChangedEvent;
|
|
|
|
import net.minecraftforge.fml.common.eventhandler.Event;
|
2016-01-07 17:59:46 +00:00
|
|
|
import net.minecraftforge.fml.common.eventhandler.Event.Result;
|
2016-01-08 19:56:36 +00:00
|
|
|
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
2016-01-01 17:29:35 +00:00
|
|
|
import WayofTime.bloodmagic.ConfigHandler;
|
2016-01-01 20:33:42 +00:00
|
|
|
import WayofTime.bloodmagic.api.BloodMagicAPI;
|
2016-01-01 20:33:26 +00:00
|
|
|
import WayofTime.bloodmagic.api.Constants;
|
2016-01-05 17:17:05 +00:00
|
|
|
import WayofTime.bloodmagic.api.event.SacrificeKnifeUsedEvent;
|
2016-01-01 17:29:35 +00:00
|
|
|
import WayofTime.bloodmagic.api.event.TeleposeEvent;
|
2016-01-05 17:17:05 +00:00
|
|
|
import WayofTime.bloodmagic.api.livingArmour.LivingArmourUpgrade;
|
2016-01-09 15:47:36 +00:00
|
|
|
import WayofTime.bloodmagic.api.soul.IDemonWill;
|
|
|
|
import WayofTime.bloodmagic.api.soul.IDemonWillWeapon;
|
|
|
|
import WayofTime.bloodmagic.api.soul.PlayerDemonWillHandler;
|
2015-11-11 18:45:46 +00:00
|
|
|
import WayofTime.bloodmagic.api.util.helper.PlayerHelper;
|
2015-11-30 00:04:50 +00:00
|
|
|
import WayofTime.bloodmagic.block.BlockAltar;
|
2016-01-09 15:47:36 +00:00
|
|
|
import WayofTime.bloodmagic.entity.projectile.EntitySentientArrow;
|
2015-11-30 00:04:50 +00:00
|
|
|
import WayofTime.bloodmagic.item.ItemAltarMaker;
|
2016-01-03 20:39:59 +00:00
|
|
|
import WayofTime.bloodmagic.item.armour.ItemLivingArmour;
|
2015-11-11 18:45:46 +00:00
|
|
|
import WayofTime.bloodmagic.item.gear.ItemPackSacrifice;
|
2016-01-03 20:39:59 +00:00
|
|
|
import WayofTime.bloodmagic.livingArmour.LivingArmour;
|
2016-01-28 22:56:49 +00:00
|
|
|
import WayofTime.bloodmagic.livingArmour.tracker.StatTrackerArrowShot;
|
|
|
|
import WayofTime.bloodmagic.livingArmour.tracker.StatTrackerDigging;
|
|
|
|
import WayofTime.bloodmagic.livingArmour.tracker.StatTrackerHealthboost;
|
|
|
|
import WayofTime.bloodmagic.livingArmour.tracker.StatTrackerMeleeDamage;
|
|
|
|
import WayofTime.bloodmagic.livingArmour.tracker.StatTrackerPhysicalProtect;
|
|
|
|
import WayofTime.bloodmagic.livingArmour.tracker.StatTrackerSelfSacrifice;
|
2016-01-31 03:22:46 +00:00
|
|
|
import WayofTime.bloodmagic.livingArmour.upgrade.LivingArmourUpgradeArrowShot;
|
|
|
|
import WayofTime.bloodmagic.livingArmour.upgrade.LivingArmourUpgradeDigging;
|
|
|
|
import WayofTime.bloodmagic.livingArmour.upgrade.LivingArmourUpgradeSelfSacrifice;
|
2015-11-02 20:39:44 +00:00
|
|
|
import WayofTime.bloodmagic.registry.ModBlocks;
|
|
|
|
import WayofTime.bloodmagic.registry.ModItems;
|
2016-01-08 19:56:36 +00:00
|
|
|
import WayofTime.bloodmagic.registry.ModPotions;
|
2015-11-30 01:12:44 +00:00
|
|
|
import WayofTime.bloodmagic.util.ChatUtil;
|
2016-01-06 12:13:56 +00:00
|
|
|
import WayofTime.bloodmagic.util.Utils;
|
2015-11-30 01:12:44 +00:00
|
|
|
import WayofTime.bloodmagic.util.helper.TextHelper;
|
2015-10-30 05:22:08 +00:00
|
|
|
|
2015-12-30 20:34:40 +00:00
|
|
|
public class EventHandler
|
|
|
|
{
|
2016-01-07 03:07:17 +00:00
|
|
|
Random random = new Random();
|
|
|
|
|
2015-11-11 18:45:46 +00:00
|
|
|
@SubscribeEvent
|
2016-01-23 00:06:48 +00:00
|
|
|
public void onEntityHurt(LivingHurtEvent event)
|
2015-12-30 20:34:40 +00:00
|
|
|
{
|
2015-11-11 18:45:46 +00:00
|
|
|
int chestIndex = 2;
|
|
|
|
|
2016-01-23 00:06:48 +00:00
|
|
|
if (event.entity.worldObj.isRemote)
|
|
|
|
return;
|
|
|
|
|
2015-12-30 20:34:40 +00:00
|
|
|
if (event.source.getEntity() instanceof EntityPlayer && !PlayerHelper.isFakePlayer((EntityPlayer) event.source.getEntity()))
|
|
|
|
{
|
2015-11-11 18:45:46 +00:00
|
|
|
EntityPlayer player = (EntityPlayer) event.source.getEntity();
|
|
|
|
|
2015-12-30 20:34:40 +00:00
|
|
|
if (player.getCurrentArmor(chestIndex) != null && player.getCurrentArmor(chestIndex).getItem() instanceof ItemPackSacrifice)
|
|
|
|
{
|
2015-11-11 18:45:46 +00:00
|
|
|
ItemPackSacrifice pack = (ItemPackSacrifice) player.getCurrentArmor(chestIndex).getItem();
|
|
|
|
|
|
|
|
boolean shouldSyphon = pack.getStoredLP(player.getCurrentArmor(chestIndex)) < pack.CAPACITY;
|
2016-01-08 02:15:23 +00:00
|
|
|
float damageDone = event.entityLiving.getHealth() < event.ammount ? event.ammount - event.entityLiving.getHealth() : event.ammount;
|
2016-01-21 20:54:46 +00:00
|
|
|
int totalLP = Math.round(damageDone * ConfigHandler.sacrificialPackConversion);
|
2015-11-11 18:45:46 +00:00
|
|
|
|
|
|
|
if (shouldSyphon)
|
|
|
|
pack.addLP(player.getCurrentArmor(chestIndex), totalLP);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-02-04 04:31:09 +00:00
|
|
|
@SubscribeEvent
|
|
|
|
public void onAnvil(AnvilUpdateEvent event)
|
|
|
|
{
|
|
|
|
if (event.left.getItem() == ModItems.livingArmourHelmet && event.right.getItem() == Constants.Compat.THAUMCRAFT_GOGGLES && !event.right.isItemDamaged())
|
|
|
|
{
|
|
|
|
ItemStack output = event.left.copy();
|
|
|
|
output = NBTHelper.checkNBT(output);
|
|
|
|
output.getTagCompound().setBoolean(Constants.Compat.THAUMCRAFT_HAS_GOGGLES, true);
|
|
|
|
event.cost = 1;
|
|
|
|
|
|
|
|
event.output = output;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-10-30 05:22:08 +00:00
|
|
|
@SubscribeEvent
|
2015-12-30 20:34:40 +00:00
|
|
|
public void onBucketFill(FillBucketEvent event)
|
|
|
|
{
|
2015-10-30 05:22:08 +00:00
|
|
|
if (event.current.getItem() != Items.bucket)
|
|
|
|
return;
|
|
|
|
|
|
|
|
ItemStack result = null;
|
|
|
|
|
|
|
|
Block block = event.world.getBlockState(event.target.getBlockPos()).getBlock();
|
|
|
|
|
2015-12-30 20:34:40 +00:00
|
|
|
if (block != null && (block.equals(ModBlocks.lifeEssence)) && block.getMetaFromState(event.world.getBlockState(event.target.getBlockPos())) == 0)
|
|
|
|
{
|
2015-10-30 05:22:08 +00:00
|
|
|
event.world.setBlockToAir(event.target.getBlockPos());
|
|
|
|
result = new ItemStack(ModItems.bucketEssence);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (result == null)
|
|
|
|
return;
|
|
|
|
|
|
|
|
event.result = result;
|
|
|
|
event.setResult(Event.Result.ALLOW);
|
|
|
|
}
|
2015-11-30 00:04:50 +00:00
|
|
|
|
|
|
|
@SubscribeEvent
|
2015-12-30 20:34:40 +00:00
|
|
|
public void harvestEvent(PlayerEvent.HarvestCheck event)
|
|
|
|
{
|
|
|
|
if (event.block != null && event.block instanceof BlockAltar && event.entityPlayer != null && event.entityPlayer instanceof EntityPlayerMP && event.entityPlayer.getCurrentEquippedItem() != null && event.entityPlayer.getCurrentEquippedItem().getItem() instanceof ItemAltarMaker)
|
|
|
|
{
|
2015-11-30 00:04:50 +00:00
|
|
|
ItemAltarMaker altarMaker = (ItemAltarMaker) event.entityPlayer.getCurrentEquippedItem().getItem();
|
2015-12-28 22:27:59 +00:00
|
|
|
ChatUtil.sendNoSpam(event.entityPlayer, TextHelper.localizeEffect("chat.BloodMagic.altarMaker.destroy", altarMaker.destroyAltar(event.entityPlayer)));
|
2015-11-30 00:04:50 +00:00
|
|
|
}
|
|
|
|
}
|
2016-01-01 17:29:35 +00:00
|
|
|
|
|
|
|
@SubscribeEvent
|
2016-01-01 20:33:26 +00:00
|
|
|
public void onTelepose(TeleposeEvent event)
|
|
|
|
{
|
2016-01-05 23:26:24 +00:00
|
|
|
if (ConfigHandler.teleposerBlacklist.contains(event.initialStack) || ConfigHandler.teleposerBlacklist.contains(event.finalStack))
|
2016-01-01 17:29:35 +00:00
|
|
|
event.setCanceled(true);
|
2016-01-01 20:33:42 +00:00
|
|
|
|
2016-01-05 23:26:24 +00:00
|
|
|
if (BloodMagicAPI.getTeleposerBlacklist().contains(event.initialStack) || BloodMagicAPI.getTeleposerBlacklist().contains(event.finalStack))
|
2016-01-01 20:33:42 +00:00
|
|
|
event.setCanceled(true);
|
2016-01-01 17:29:35 +00:00
|
|
|
}
|
2016-01-01 20:33:26 +00:00
|
|
|
|
|
|
|
@SubscribeEvent
|
2016-01-02 22:56:37 +00:00
|
|
|
public void onConfigChanged(ConfigChangedEvent event)
|
|
|
|
{
|
2016-01-01 20:33:26 +00:00
|
|
|
if (event.modID.equals(Constants.Mod.MODID))
|
|
|
|
ConfigHandler.syncConfig();
|
|
|
|
}
|
2016-01-03 20:39:59 +00:00
|
|
|
|
|
|
|
@SubscribeEvent
|
|
|
|
public void blockBreakEvent(BlockEvent.BreakEvent event)
|
|
|
|
{
|
|
|
|
EntityPlayer player = event.getPlayer();
|
|
|
|
if (player != null)
|
|
|
|
{
|
2016-01-29 06:37:19 +00:00
|
|
|
if (LivingArmour.hasFullSet(player))
|
2016-01-05 17:17:05 +00:00
|
|
|
{
|
2016-01-29 06:37:19 +00:00
|
|
|
ItemStack chestStack = player.getCurrentArmor(2);
|
|
|
|
if (chestStack != null && chestStack.getItem() instanceof ItemLivingArmour)
|
2016-01-05 17:17:05 +00:00
|
|
|
{
|
2016-01-29 06:37:19 +00:00
|
|
|
LivingArmour armour = ItemLivingArmour.armourMap.get(chestStack);
|
2016-01-03 20:39:59 +00:00
|
|
|
|
2016-01-29 06:37:19 +00:00
|
|
|
if (armour != null)
|
|
|
|
{
|
|
|
|
StatTrackerDigging.incrementCounter(armour);
|
|
|
|
LivingArmourUpgradeDigging.hasDug(armour);
|
|
|
|
}
|
2016-01-03 20:39:59 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2016-01-05 17:17:05 +00:00
|
|
|
|
|
|
|
@SubscribeEvent
|
|
|
|
public void selfSacrificeEvent(SacrificeKnifeUsedEvent event)
|
|
|
|
{
|
|
|
|
EntityPlayer player = event.player;
|
|
|
|
|
2016-01-29 06:37:19 +00:00
|
|
|
if (LivingArmour.hasFullSet(player))
|
2016-01-05 17:17:05 +00:00
|
|
|
{
|
2016-01-29 06:37:19 +00:00
|
|
|
ItemStack chestStack = player.getCurrentArmor(2);
|
|
|
|
LivingArmour armour = ItemLivingArmour.armourMap.get(chestStack);
|
|
|
|
if (armour != null)
|
2016-01-05 17:17:05 +00:00
|
|
|
{
|
2016-01-29 06:37:19 +00:00
|
|
|
StatTrackerSelfSacrifice.incrementCounter(armour);
|
|
|
|
LivingArmourUpgrade upgrade = ItemLivingArmour.getUpgrade(Constants.Mod.MODID + ".upgrade.selfSacrifice", chestStack);
|
2016-01-05 17:17:05 +00:00
|
|
|
|
2016-01-29 06:37:19 +00:00
|
|
|
if (upgrade instanceof LivingArmourUpgradeSelfSacrifice)
|
|
|
|
{
|
|
|
|
double modifier = ((LivingArmourUpgradeSelfSacrifice) upgrade).getSacrificeModifier();
|
2016-01-05 17:17:05 +00:00
|
|
|
|
2016-01-29 06:37:19 +00:00
|
|
|
event.lpAdded = (int) (event.lpAdded * (1 + modifier));
|
|
|
|
}
|
2016-01-05 17:17:05 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2016-01-05 23:27:51 +00:00
|
|
|
|
2016-01-07 00:55:51 +00:00
|
|
|
@SubscribeEvent
|
|
|
|
public void onEntityHealed(LivingHealEvent event)
|
|
|
|
{
|
|
|
|
EntityLivingBase healedEntity = event.entityLiving;
|
|
|
|
if (!(healedEntity instanceof EntityPlayer))
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
EntityPlayer player = (EntityPlayer) healedEntity;
|
|
|
|
|
2016-01-29 06:37:19 +00:00
|
|
|
if (LivingArmour.hasFullSet(player))
|
2016-01-07 00:55:51 +00:00
|
|
|
{
|
2016-01-29 06:37:19 +00:00
|
|
|
ItemStack chestStack = player.getCurrentArmor(2);
|
|
|
|
LivingArmour armour = ItemLivingArmour.armourMap.get(chestStack);
|
|
|
|
if (armour != null)
|
|
|
|
StatTrackerHealthboost.incrementCounter(armour, event.amount);
|
2016-01-07 00:55:51 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-01-05 23:27:51 +00:00
|
|
|
@SubscribeEvent
|
|
|
|
public void onEntityAttacked(LivingAttackEvent event)
|
|
|
|
{
|
2016-01-07 00:34:10 +00:00
|
|
|
DamageSource source = event.source;
|
2016-01-05 23:27:51 +00:00
|
|
|
Entity sourceEntity = event.source.getEntity();
|
|
|
|
EntityLivingBase attackedEntity = event.entityLiving;
|
|
|
|
|
2016-01-06 12:13:56 +00:00
|
|
|
if (attackedEntity.hurtResistantTime > 0)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2016-01-07 00:34:10 +00:00
|
|
|
if (attackedEntity instanceof EntityPlayer)
|
2016-01-05 23:27:51 +00:00
|
|
|
{
|
|
|
|
EntityPlayer attackedPlayer = (EntityPlayer) attackedEntity;
|
|
|
|
|
2016-01-29 06:37:19 +00:00
|
|
|
// Living Armor Handling
|
|
|
|
if (LivingArmour.hasFullSet(attackedPlayer))
|
2016-01-05 23:27:51 +00:00
|
|
|
{
|
2016-01-15 11:24:10 +00:00
|
|
|
float amount = Math.min(Utils.getModifiedDamage(attackedPlayer, event.source, event.ammount), attackedPlayer.getHealth());
|
2016-01-07 00:34:10 +00:00
|
|
|
ItemStack chestStack = attackedPlayer.getCurrentArmor(2);
|
|
|
|
LivingArmour armour = ItemLivingArmour.getLivingArmour(chestStack);
|
|
|
|
if (armour != null)
|
|
|
|
{
|
|
|
|
if (sourceEntity != null && !source.isMagicDamage())
|
|
|
|
{
|
|
|
|
// Add resistance to the upgrade that protects against non-magic damage
|
|
|
|
StatTrackerPhysicalProtect.incrementCounter(armour, amount);
|
|
|
|
}
|
|
|
|
}
|
2016-01-05 23:27:51 +00:00
|
|
|
}
|
|
|
|
}
|
2016-01-07 02:26:51 +00:00
|
|
|
|
2016-01-09 15:47:36 +00:00
|
|
|
if (sourceEntity instanceof EntitySentientArrow)
|
2016-01-09 03:20:31 +00:00
|
|
|
{
|
|
|
|
// Soul Weapon handling
|
2016-01-09 15:47:36 +00:00
|
|
|
((EntitySentientArrow) sourceEntity).reimbursePlayer();
|
2016-01-09 03:20:31 +00:00
|
|
|
}
|
|
|
|
|
2016-01-07 02:26:51 +00:00
|
|
|
if (sourceEntity instanceof EntityPlayer)
|
|
|
|
{
|
|
|
|
EntityPlayer player = (EntityPlayer) sourceEntity;
|
|
|
|
|
2016-01-29 06:37:19 +00:00
|
|
|
// Living Armor Handling
|
|
|
|
if (LivingArmour.hasFullSet(player))
|
2016-01-07 02:26:51 +00:00
|
|
|
{
|
2016-01-15 11:24:10 +00:00
|
|
|
float amount = Math.min(Utils.getModifiedDamage(attackedEntity, event.source, event.ammount), attackedEntity.getHealth());
|
2016-01-07 02:26:51 +00:00
|
|
|
ItemStack chestStack = player.getCurrentArmor(2);
|
|
|
|
LivingArmour armour = ItemLivingArmour.getLivingArmour(chestStack);
|
|
|
|
if (armour != null)
|
|
|
|
{
|
2016-01-29 06:37:19 +00:00
|
|
|
if (!source.isProjectile())
|
2016-01-07 02:26:51 +00:00
|
|
|
{
|
|
|
|
StatTrackerMeleeDamage.incrementCounter(armour, amount);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2016-01-05 23:27:51 +00:00
|
|
|
}
|
2016-01-07 03:07:17 +00:00
|
|
|
|
|
|
|
@SubscribeEvent
|
|
|
|
public void onArrowFire(ArrowLooseEvent event)
|
|
|
|
{
|
|
|
|
World world = event.entityPlayer.worldObj;
|
|
|
|
ItemStack stack = event.bow;
|
|
|
|
EntityPlayer player = event.entityPlayer;
|
|
|
|
|
2016-01-29 06:37:19 +00:00
|
|
|
if (LivingArmour.hasFullSet(player))
|
2016-01-07 03:07:17 +00:00
|
|
|
{
|
|
|
|
ItemStack chestStack = player.getCurrentArmor(2);
|
|
|
|
LivingArmour armour = ItemLivingArmour.getLivingArmour(chestStack);
|
|
|
|
if (armour != null)
|
|
|
|
{
|
|
|
|
StatTrackerArrowShot.incrementCounter(armour);
|
|
|
|
|
|
|
|
LivingArmourUpgrade upgrade = ItemLivingArmour.getUpgrade(Constants.Mod.MODID + ".upgrade.arrowShot", chestStack);
|
|
|
|
if (upgrade instanceof LivingArmourUpgradeArrowShot)
|
|
|
|
{
|
|
|
|
int i = event.charge;
|
|
|
|
float f = (float) i / 20.0F;
|
|
|
|
f = (f * f + f * 2.0F) / 3.0F;
|
|
|
|
|
|
|
|
if ((double) f < 0.1D)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (f > 1.0F)
|
|
|
|
{
|
|
|
|
f = 1.0F;
|
|
|
|
}
|
|
|
|
|
|
|
|
int numberExtra = ((LivingArmourUpgradeArrowShot) upgrade).getExtraArrows();
|
|
|
|
for (int n = 0; n < numberExtra; n++)
|
|
|
|
{
|
|
|
|
EntityArrow entityarrow = new EntityArrow(world, player, f * 2.0F);
|
|
|
|
|
|
|
|
double velocityModifier = 0.6 * f;
|
|
|
|
entityarrow.motionX += (random.nextDouble() - 0.5) * velocityModifier;
|
|
|
|
entityarrow.motionY += (random.nextDouble() - 0.5) * velocityModifier;
|
|
|
|
entityarrow.motionZ += (random.nextDouble() - 0.5) * velocityModifier;
|
|
|
|
|
|
|
|
if (f == 1.0F)
|
|
|
|
{
|
|
|
|
entityarrow.setIsCritical(true);
|
|
|
|
}
|
|
|
|
|
|
|
|
int j = EnchantmentHelper.getEnchantmentLevel(Enchantment.power.effectId, stack);
|
|
|
|
|
|
|
|
if (j > 0)
|
|
|
|
{
|
|
|
|
entityarrow.setDamage(entityarrow.getDamage() + (double) j * 0.5D + 0.5D);
|
|
|
|
}
|
|
|
|
|
|
|
|
int k = EnchantmentHelper.getEnchantmentLevel(Enchantment.punch.effectId, stack);
|
|
|
|
|
|
|
|
if (k > 0)
|
|
|
|
{
|
|
|
|
entityarrow.setKnockbackStrength(k);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (EnchantmentHelper.getEnchantmentLevel(Enchantment.flame.effectId, stack) > 0)
|
|
|
|
{
|
|
|
|
entityarrow.setFire(100);
|
|
|
|
}
|
|
|
|
|
|
|
|
entityarrow.canBePickedUp = 2;
|
|
|
|
|
|
|
|
if (!world.isRemote)
|
|
|
|
{
|
|
|
|
world.spawnEntityInWorld(entityarrow);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2016-01-07 16:01:38 +00:00
|
|
|
|
|
|
|
@SubscribeEvent
|
|
|
|
public void onLivingDrops(LivingDropsEvent event)
|
|
|
|
{
|
|
|
|
EntityLivingBase attackedEntity = event.entityLiving;
|
|
|
|
DamageSource source = event.source;
|
|
|
|
Entity entity = source.getEntity();
|
|
|
|
|
2016-01-08 19:56:36 +00:00
|
|
|
if (attackedEntity.isPotionActive(ModPotions.soulSnare))
|
|
|
|
{
|
|
|
|
PotionEffect eff = attackedEntity.getActivePotionEffect(ModPotions.soulSnare);
|
|
|
|
int lvl = eff.getAmplifier();
|
|
|
|
|
|
|
|
double amountOfSouls = random.nextDouble() * (lvl + 1) * (lvl + 1) * 5;
|
2016-01-09 15:47:36 +00:00
|
|
|
ItemStack soulStack = ((IDemonWill) ModItems.monsterSoul).createWill(0, amountOfSouls);
|
2016-01-08 19:56:36 +00:00
|
|
|
event.drops.add(new EntityItem(attackedEntity.worldObj, attackedEntity.posX, attackedEntity.posY, attackedEntity.posZ, soulStack));
|
|
|
|
}
|
|
|
|
|
2016-01-07 16:01:38 +00:00
|
|
|
if (entity != null && entity instanceof EntityLivingBase)
|
|
|
|
{
|
|
|
|
EntityLivingBase attackingEntity = (EntityLivingBase) entity;
|
|
|
|
ItemStack heldStack = attackingEntity.getHeldItem();
|
2016-01-09 15:47:36 +00:00
|
|
|
if (heldStack != null && heldStack.getItem() instanceof IDemonWillWeapon)
|
2016-01-07 16:01:38 +00:00
|
|
|
{
|
2016-01-09 15:47:36 +00:00
|
|
|
List<ItemStack> droppedSouls = ((IDemonWillWeapon) heldStack.getItem()).getRandomDemonWillDrop(attackedEntity, attackingEntity, heldStack, event.lootingLevel);
|
2016-01-07 16:01:38 +00:00
|
|
|
if (!droppedSouls.isEmpty())
|
|
|
|
{
|
|
|
|
for (ItemStack soulStack : droppedSouls)
|
|
|
|
{
|
|
|
|
event.drops.add(new EntityItem(attackedEntity.worldObj, attackedEntity.posX, attackedEntity.posY, attackedEntity.posZ, soulStack));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2016-01-31 03:22:46 +00:00
|
|
|
|
|
|
|
if (heldStack != null && heldStack.getItem() == ModItems.boundSword && !(attackedEntity instanceof EntityAnimal))
|
|
|
|
{
|
|
|
|
for (int i = 0; i <= EnchantmentHelper.getLootingModifier(attackingEntity); i++)
|
|
|
|
{
|
|
|
|
if (this.random.nextDouble() < 0.2)
|
|
|
|
{
|
|
|
|
event.drops.add(new EntityItem(attackedEntity.worldObj, attackedEntity.posX, attackedEntity.posY, attackedEntity.posZ, new ItemStack(ModItems.bloodShard, 1, 0)));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2016-01-07 16:01:38 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@SubscribeEvent
|
|
|
|
public void onItemPickup(EntityItemPickupEvent event)
|
|
|
|
{
|
2016-01-07 17:59:46 +00:00
|
|
|
ItemStack stack = event.item.getEntityItem();
|
2016-01-09 15:47:36 +00:00
|
|
|
if (stack != null && stack.getItem() instanceof IDemonWill)
|
2016-01-07 17:59:46 +00:00
|
|
|
{
|
|
|
|
EntityPlayer player = event.entityPlayer;
|
|
|
|
|
2016-01-09 15:47:36 +00:00
|
|
|
ItemStack remainder = PlayerDemonWillHandler.addDemonWill(player, stack);
|
2016-01-07 17:59:46 +00:00
|
|
|
|
2016-01-30 02:19:59 +00:00
|
|
|
if (remainder == null || ((IDemonWill) stack.getItem()).getWill(stack) < 0.0001 || PlayerDemonWillHandler.isDemonWillFull(player))
|
2016-01-07 17:59:46 +00:00
|
|
|
{
|
|
|
|
stack.stackSize = 0;
|
|
|
|
event.setResult(Result.ALLOW);
|
|
|
|
}
|
|
|
|
}
|
2016-01-07 16:01:38 +00:00
|
|
|
}
|
2015-10-30 05:22:08 +00:00
|
|
|
}
|