2015-11-02 12:39:44 -08:00
|
|
|
package WayofTime.bloodmagic.util.handler;
|
2015-10-29 22:22:08 -07:00
|
|
|
|
2016-02-14 21:50:32 -05:00
|
|
|
import java.util.ArrayList;
|
2016-02-21 20:10:56 -05:00
|
|
|
import java.util.HashMap;
|
2016-01-07 11:01:38 -05:00
|
|
|
import java.util.List;
|
2016-01-06 22:07:17 -05:00
|
|
|
import java.util.Random;
|
2016-02-21 20:10:56 -05:00
|
|
|
import java.util.concurrent.CopyOnWriteArrayList;
|
2016-01-06 22:07:17 -05:00
|
|
|
|
2016-03-14 18:56:55 -07:00
|
|
|
import WayofTime.bloodmagic.api.network.SoulNetwork;
|
|
|
|
import WayofTime.bloodmagic.api.orb.IBloodOrb;
|
|
|
|
import WayofTime.bloodmagic.api.util.helper.NetworkHelper;
|
2016-01-03 15:39:59 -05:00
|
|
|
import net.minecraft.block.Block;
|
2016-01-06 22:07:17 -05:00
|
|
|
import net.minecraft.enchantment.Enchantment;
|
|
|
|
import net.minecraft.enchantment.EnchantmentHelper;
|
2016-01-05 18:27:51 -05:00
|
|
|
import net.minecraft.entity.Entity;
|
|
|
|
import net.minecraft.entity.EntityLivingBase;
|
2016-01-07 11:01:38 -05:00
|
|
|
import net.minecraft.entity.item.EntityItem;
|
2016-01-30 22:22:46 -05:00
|
|
|
import net.minecraft.entity.passive.EntityAnimal;
|
2016-01-03 15:39:59 -05:00
|
|
|
import net.minecraft.entity.player.EntityPlayer;
|
|
|
|
import net.minecraft.entity.player.EntityPlayerMP;
|
2016-01-06 22:07:17 -05:00
|
|
|
import net.minecraft.entity.projectile.EntityArrow;
|
2016-01-03 15:39:59 -05:00
|
|
|
import net.minecraft.init.Items;
|
|
|
|
import net.minecraft.item.ItemStack;
|
2016-02-21 20:10:56 -05:00
|
|
|
import net.minecraft.nbt.NBTTagCompound;
|
2016-01-08 14:56:36 -05:00
|
|
|
import net.minecraft.potion.PotionEffect;
|
2016-02-21 20:10:56 -05:00
|
|
|
import net.minecraft.util.BlockPos;
|
2016-01-06 19:34:10 -05:00
|
|
|
import net.minecraft.util.DamageSource;
|
2016-02-21 20:10:56 -05:00
|
|
|
import net.minecraft.world.ChunkCoordIntPair;
|
2016-01-06 22:07:17 -05:00
|
|
|
import net.minecraft.world.World;
|
2016-02-03 23:14:26 -08:00
|
|
|
import net.minecraftforge.common.MinecraftForge;
|
2016-02-03 20:31:09 -08:00
|
|
|
import net.minecraftforge.event.AnvilUpdateEvent;
|
2016-01-05 18:27:51 -05:00
|
|
|
import net.minecraftforge.event.entity.living.LivingAttackEvent;
|
2016-02-09 20:22:14 -05:00
|
|
|
import net.minecraftforge.event.entity.living.LivingDeathEvent;
|
2016-01-07 11:01:38 -05:00
|
|
|
import net.minecraftforge.event.entity.living.LivingDropsEvent;
|
2016-02-09 15:53:22 -05:00
|
|
|
import net.minecraftforge.event.entity.living.LivingEvent;
|
2016-01-06 19:55:51 -05:00
|
|
|
import net.minecraftforge.event.entity.living.LivingHealEvent;
|
2016-01-03 15:39:59 -05:00
|
|
|
import net.minecraftforge.event.entity.living.LivingHurtEvent;
|
2016-02-07 15:37:35 -05:00
|
|
|
import net.minecraftforge.event.entity.player.ArrowLooseEvent;
|
|
|
|
import net.minecraftforge.event.entity.player.EntityItemPickupEvent;
|
|
|
|
import net.minecraftforge.event.entity.player.FillBucketEvent;
|
|
|
|
import net.minecraftforge.event.entity.player.PlayerEvent;
|
|
|
|
import net.minecraftforge.event.entity.player.PlayerInteractEvent;
|
2016-01-03 15:39:59 -05:00
|
|
|
import net.minecraftforge.event.world.BlockEvent;
|
2016-02-21 20:10:56 -05:00
|
|
|
import net.minecraftforge.event.world.ChunkDataEvent;
|
2016-01-03 15:39:59 -05:00
|
|
|
import net.minecraftforge.fml.client.event.ConfigChangedEvent;
|
|
|
|
import net.minecraftforge.fml.common.eventhandler.Event;
|
2016-01-07 12:59:46 -05:00
|
|
|
import net.minecraftforge.fml.common.eventhandler.Event.Result;
|
2016-02-09 20:22:14 -05:00
|
|
|
import net.minecraftforge.fml.common.eventhandler.EventPriority;
|
2016-01-08 14:56:36 -05:00
|
|
|
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
2016-02-21 20:10:56 -05:00
|
|
|
import net.minecraftforge.fml.common.gameevent.TickEvent;
|
|
|
|
import net.minecraftforge.fml.relauncher.Side;
|
2016-01-01 09:29:35 -08:00
|
|
|
import WayofTime.bloodmagic.ConfigHandler;
|
2016-01-01 12:33:42 -08:00
|
|
|
import WayofTime.bloodmagic.api.BloodMagicAPI;
|
2016-01-01 12:33:26 -08:00
|
|
|
import WayofTime.bloodmagic.api.Constants;
|
2016-02-25 08:54:18 -05:00
|
|
|
import WayofTime.bloodmagic.api.event.AltarCraftedEvent;
|
2016-02-07 15:37:35 -05:00
|
|
|
import WayofTime.bloodmagic.api.event.ItemBindEvent;
|
2016-01-05 12:17:05 -05:00
|
|
|
import WayofTime.bloodmagic.api.event.SacrificeKnifeUsedEvent;
|
2016-01-01 09:29:35 -08:00
|
|
|
import WayofTime.bloodmagic.api.event.TeleposeEvent;
|
2016-02-07 15:37:35 -05:00
|
|
|
import WayofTime.bloodmagic.api.iface.IBindable;
|
2016-02-14 21:50:32 -05:00
|
|
|
import WayofTime.bloodmagic.api.iface.IUpgradeTrainer;
|
2016-01-05 12:17:05 -05:00
|
|
|
import WayofTime.bloodmagic.api.livingArmour.LivingArmourUpgrade;
|
2016-02-21 20:10:56 -05:00
|
|
|
import WayofTime.bloodmagic.api.soul.DemonWillHolder;
|
2016-02-18 18:00:02 -05:00
|
|
|
import WayofTime.bloodmagic.api.soul.EnumDemonWillType;
|
2016-01-09 10:47:36 -05:00
|
|
|
import WayofTime.bloodmagic.api.soul.IDemonWill;
|
|
|
|
import WayofTime.bloodmagic.api.soul.IDemonWillWeapon;
|
|
|
|
import WayofTime.bloodmagic.api.soul.PlayerDemonWillHandler;
|
2016-02-07 15:37:35 -05:00
|
|
|
import WayofTime.bloodmagic.api.util.helper.BindableHelper;
|
|
|
|
import WayofTime.bloodmagic.api.util.helper.NBTHelper;
|
2015-11-11 10:45:46 -08:00
|
|
|
import WayofTime.bloodmagic.api.util.helper.PlayerHelper;
|
2015-11-29 19:04:50 -05:00
|
|
|
import WayofTime.bloodmagic.block.BlockAltar;
|
2016-02-21 20:10:56 -05:00
|
|
|
import WayofTime.bloodmagic.demonAura.PosXY;
|
|
|
|
import WayofTime.bloodmagic.demonAura.WillChunk;
|
|
|
|
import WayofTime.bloodmagic.demonAura.WorldDemonWillHandler;
|
2016-01-09 10:47:36 -05:00
|
|
|
import WayofTime.bloodmagic.entity.projectile.EntitySentientArrow;
|
2015-11-29 19:04:50 -05:00
|
|
|
import WayofTime.bloodmagic.item.ItemAltarMaker;
|
2016-02-25 08:54:18 -05:00
|
|
|
import WayofTime.bloodmagic.item.ItemInscriptionTool;
|
2016-02-11 14:10:43 -05:00
|
|
|
import WayofTime.bloodmagic.item.ItemUpgradeTome;
|
2016-01-03 15:39:59 -05:00
|
|
|
import WayofTime.bloodmagic.item.armour.ItemLivingArmour;
|
2015-11-11 10:45:46 -08:00
|
|
|
import WayofTime.bloodmagic.item.gear.ItemPackSacrifice;
|
2016-01-03 15:39:59 -05:00
|
|
|
import WayofTime.bloodmagic.livingArmour.LivingArmour;
|
2016-01-28 14:56:49 -08:00
|
|
|
import WayofTime.bloodmagic.livingArmour.tracker.StatTrackerArrowShot;
|
|
|
|
import WayofTime.bloodmagic.livingArmour.tracker.StatTrackerDigging;
|
2016-02-09 20:22:14 -05:00
|
|
|
import WayofTime.bloodmagic.livingArmour.tracker.StatTrackerGrimReaperSprint;
|
2016-01-28 14:56:49 -08:00
|
|
|
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-02-11 14:10:43 -05:00
|
|
|
import WayofTime.bloodmagic.livingArmour.tracker.StatTrackerSolarPowered;
|
2016-01-30 22:22:46 -05:00
|
|
|
import WayofTime.bloodmagic.livingArmour.upgrade.LivingArmourUpgradeArrowShot;
|
|
|
|
import WayofTime.bloodmagic.livingArmour.upgrade.LivingArmourUpgradeDigging;
|
2016-02-09 20:22:14 -05:00
|
|
|
import WayofTime.bloodmagic.livingArmour.upgrade.LivingArmourUpgradeGrimReaperSprint;
|
2016-01-30 22:22:46 -05:00
|
|
|
import WayofTime.bloodmagic.livingArmour.upgrade.LivingArmourUpgradeSelfSacrifice;
|
2016-02-17 16:31:11 -05:00
|
|
|
import WayofTime.bloodmagic.livingArmour.upgrade.LivingArmourUpgradeSpeed;
|
2016-02-09 20:22:14 -05:00
|
|
|
import WayofTime.bloodmagic.livingArmour.upgrade.LivingArmourUpgradeStepAssist;
|
2015-11-02 12:39:44 -08:00
|
|
|
import WayofTime.bloodmagic.registry.ModBlocks;
|
|
|
|
import WayofTime.bloodmagic.registry.ModItems;
|
2016-01-08 14:56:36 -05:00
|
|
|
import WayofTime.bloodmagic.registry.ModPotions;
|
2015-11-29 17:12:44 -08:00
|
|
|
import WayofTime.bloodmagic.util.ChatUtil;
|
2016-01-06 07:13:56 -05:00
|
|
|
import WayofTime.bloodmagic.util.Utils;
|
2015-11-29 17:12:44 -08:00
|
|
|
import WayofTime.bloodmagic.util.helper.TextHelper;
|
2015-10-29 22:22:08 -07:00
|
|
|
|
2016-02-07 15:37:35 -05:00
|
|
|
import com.google.common.base.Strings;
|
|
|
|
|
2015-12-30 15:34:40 -05:00
|
|
|
public class EventHandler
|
|
|
|
{
|
2016-01-06 22:07:17 -05:00
|
|
|
Random random = new Random();
|
2016-02-21 20:10:56 -05:00
|
|
|
HashMap<Integer, Integer> serverTicks = new HashMap<Integer, Integer>();
|
2016-01-06 22:07:17 -05:00
|
|
|
|
2016-02-09 20:22:14 -05:00
|
|
|
@SubscribeEvent(priority = EventPriority.HIGHEST)
|
|
|
|
public void onEntityDeath(LivingDeathEvent event)
|
|
|
|
{
|
|
|
|
if (event.entityLiving instanceof EntityPlayer)
|
|
|
|
{
|
|
|
|
EntityPlayer player = (EntityPlayer) event.entityLiving;
|
|
|
|
|
|
|
|
if (LivingArmour.hasFullSet(player))
|
|
|
|
{
|
|
|
|
ItemStack chestStack = player.getCurrentArmor(2);
|
|
|
|
LivingArmour armour = ItemLivingArmour.armourMap.get(chestStack);
|
|
|
|
if (armour != null)
|
|
|
|
{
|
|
|
|
StatTrackerGrimReaperSprint.incrementCounter(armour);
|
|
|
|
|
|
|
|
LivingArmourUpgrade upgrade = ItemLivingArmour.getUpgrade(Constants.Mod.MODID + ".upgrade.grimReaper", chestStack);
|
|
|
|
|
|
|
|
if (upgrade instanceof LivingArmourUpgradeGrimReaperSprint && ((LivingArmourUpgradeGrimReaperSprint) upgrade).canSavePlayer(player))
|
|
|
|
{
|
|
|
|
((LivingArmourUpgradeGrimReaperSprint) upgrade).applyEffectOnRebirth(player);
|
|
|
|
event.setCanceled(true);
|
|
|
|
event.setResult(Result.DENY);
|
|
|
|
}
|
|
|
|
|
|
|
|
armour.writeDirtyToNBT(ItemLivingArmour.getArmourTag(chestStack));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-02-21 20:10:56 -05:00
|
|
|
@SubscribeEvent
|
|
|
|
public void onServerWorldTick(TickEvent.WorldTickEvent event)
|
|
|
|
{
|
|
|
|
if (event.side == Side.CLIENT)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
int dim = event.world.provider.getDimensionId();
|
|
|
|
if (event.phase == TickEvent.Phase.END)
|
|
|
|
{
|
|
|
|
if (!this.serverTicks.containsKey(Integer.valueOf(dim)))
|
|
|
|
{
|
|
|
|
this.serverTicks.put(Integer.valueOf(dim), Integer.valueOf(0));
|
|
|
|
}
|
|
|
|
|
|
|
|
int ticks = ((Integer) this.serverTicks.get(Integer.valueOf(dim))).intValue();
|
|
|
|
|
|
|
|
if (ticks % 20 == 0)
|
|
|
|
{
|
|
|
|
CopyOnWriteArrayList<PosXY> dirtyChunks = WorldDemonWillHandler.dirtyChunks.get(Integer.valueOf(dim));
|
|
|
|
if ((dirtyChunks != null) && (dirtyChunks.size() > 0))
|
|
|
|
{
|
|
|
|
for (PosXY pos : dirtyChunks)
|
|
|
|
{
|
|
|
|
event.world.markChunkDirty(new BlockPos(pos.x * 16, 5, pos.y * 16), null);
|
|
|
|
}
|
|
|
|
|
|
|
|
dirtyChunks.clear();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
this.serverTicks.put(Integer.valueOf(dim), Integer.valueOf(ticks + 1));
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
@SubscribeEvent
|
|
|
|
public void chunkSave(ChunkDataEvent.Save event)
|
|
|
|
{
|
|
|
|
int dim = event.world.provider.getDimensionId();
|
|
|
|
ChunkCoordIntPair loc = event.getChunk().getChunkCoordIntPair();
|
|
|
|
|
|
|
|
NBTTagCompound nbt = new NBTTagCompound();
|
|
|
|
event.getData().setTag("BloodMagic", nbt);
|
|
|
|
|
|
|
|
WillChunk ac = WorldDemonWillHandler.getWillChunk(dim, loc.chunkXPos, loc.chunkZPos);
|
|
|
|
if (ac != null)
|
|
|
|
{
|
|
|
|
nbt.setShort("base", ac.getBase());
|
|
|
|
ac.getCurrentWill().writeToNBT(nbt, "current");
|
|
|
|
if (!event.getChunk().isLoaded())
|
|
|
|
{
|
|
|
|
WorldDemonWillHandler.removeWillChunk(dim, loc.chunkXPos, loc.chunkZPos);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@SubscribeEvent
|
|
|
|
public void chunkLoad(ChunkDataEvent.Load event)
|
|
|
|
{
|
|
|
|
int dim = event.world.provider.getDimensionId();
|
|
|
|
if (event.getData().getCompoundTag("BloodMagic").hasKey("base"))
|
|
|
|
{
|
|
|
|
NBTTagCompound nbt = event.getData().getCompoundTag("BloodMagic");
|
|
|
|
short base = nbt.getShort("base");
|
|
|
|
DemonWillHolder current = new DemonWillHolder();
|
|
|
|
current.readFromNBT(nbt, "current");
|
|
|
|
WorldDemonWillHandler.addWillChunk(dim, event.getChunk(), base, current);
|
|
|
|
} else
|
|
|
|
{
|
|
|
|
WorldDemonWillHandler.generateWill(event.getChunk());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-02-09 15:53:22 -05:00
|
|
|
@SubscribeEvent(priority = EventPriority.HIGHEST)
|
|
|
|
public void onEntityUpdate(LivingEvent.LivingUpdateEvent event)
|
|
|
|
{
|
|
|
|
if (event.entityLiving instanceof EntityPlayer)
|
|
|
|
{
|
2016-02-09 20:22:14 -05:00
|
|
|
EntityPlayer player = (EntityPlayer) event.entityLiving;
|
2016-02-09 15:53:22 -05:00
|
|
|
if (event.entityLiving.isPotionActive(ModPotions.boost))
|
|
|
|
{
|
2016-02-09 20:22:14 -05:00
|
|
|
player.stepHeight = 1.0f;
|
2016-02-09 15:53:22 -05:00
|
|
|
} else
|
|
|
|
{
|
2016-02-09 20:22:14 -05:00
|
|
|
boolean hasAssist = false;
|
|
|
|
if (LivingArmour.hasFullSet(player))
|
|
|
|
{
|
|
|
|
ItemStack chestStack = player.getCurrentArmor(2);
|
|
|
|
LivingArmour armour = ItemLivingArmour.getLivingArmour(chestStack);
|
|
|
|
if (armour != null)
|
|
|
|
{
|
|
|
|
LivingArmourUpgrade upgrade = ItemLivingArmour.getUpgrade(Constants.Mod.MODID + ".upgrade.stepAssist", chestStack);
|
|
|
|
|
|
|
|
if (upgrade instanceof LivingArmourUpgradeStepAssist)
|
|
|
|
{
|
|
|
|
player.stepHeight = ((LivingArmourUpgradeStepAssist) upgrade).getStepAssist();
|
|
|
|
hasAssist = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!hasAssist)
|
2016-03-14 19:46:59 -07:00
|
|
|
player.stepHeight = 0.6f;
|
2016-02-09 15:53:22 -05:00
|
|
|
}
|
2016-02-17 16:31:11 -05:00
|
|
|
|
|
|
|
float percentIncrease = 0;
|
|
|
|
|
|
|
|
if (LivingArmour.hasFullSet(player))
|
|
|
|
{
|
|
|
|
ItemStack chestStack = player.getCurrentArmor(2);
|
|
|
|
LivingArmour armour = ItemLivingArmour.getLivingArmour(chestStack);
|
|
|
|
if (armour != null)
|
|
|
|
{
|
|
|
|
LivingArmourUpgrade upgrade = ItemLivingArmour.getUpgrade(Constants.Mod.MODID + ".upgrade.movement", chestStack);
|
|
|
|
|
|
|
|
if (upgrade instanceof LivingArmourUpgradeSpeed)
|
|
|
|
{
|
|
|
|
percentIncrease += 0.1f * ((LivingArmourUpgradeSpeed) upgrade).getSpeedModifier();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (event.entityLiving.isPotionActive(ModPotions.boost))
|
|
|
|
{
|
|
|
|
int i = event.entityLiving.getActivePotionEffect(ModPotions.boost).getAmplifier();
|
|
|
|
{
|
|
|
|
percentIncrease += (i + 1) * 0.05f;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (percentIncrease > 0 && (player.onGround || player.capabilities.isFlying) && player.moveForward > 0F)
|
|
|
|
{
|
|
|
|
player.moveFlying(0F, 1F, player.capabilities.isFlying ? (percentIncrease / 2.0f) : percentIncrease);
|
|
|
|
}
|
2016-02-09 15:53:22 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-02-23 22:48:34 -08:00
|
|
|
@SubscribeEvent
|
|
|
|
public void onAltarCrafted(AltarCraftedEvent event)
|
|
|
|
{
|
2016-03-07 06:30:58 -05:00
|
|
|
if (event.getOutput() == null)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (event.getOutput().getItem() instanceof ItemInscriptionTool)
|
|
|
|
{
|
2016-02-23 22:48:34 -08:00
|
|
|
NBTHelper.checkNBT(event.getOutput());
|
|
|
|
event.getOutput().getTagCompound().setInteger(Constants.NBT.USES, 10);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-11-11 10:45:46 -08:00
|
|
|
@SubscribeEvent
|
2016-01-22 16:06:48 -08:00
|
|
|
public void onEntityHurt(LivingHurtEvent event)
|
2015-12-30 15:34:40 -05:00
|
|
|
{
|
2015-11-11 10:45:46 -08:00
|
|
|
int chestIndex = 2;
|
|
|
|
|
2016-01-22 16:06:48 -08:00
|
|
|
if (event.entity.worldObj.isRemote)
|
|
|
|
return;
|
|
|
|
|
2015-12-30 15:34:40 -05:00
|
|
|
if (event.source.getEntity() instanceof EntityPlayer && !PlayerHelper.isFakePlayer((EntityPlayer) event.source.getEntity()))
|
|
|
|
{
|
2015-11-11 10:45:46 -08:00
|
|
|
EntityPlayer player = (EntityPlayer) event.source.getEntity();
|
|
|
|
|
2015-12-30 15:34:40 -05:00
|
|
|
if (player.getCurrentArmor(chestIndex) != null && player.getCurrentArmor(chestIndex).getItem() instanceof ItemPackSacrifice)
|
|
|
|
{
|
2015-11-11 10:45:46 -08:00
|
|
|
ItemPackSacrifice pack = (ItemPackSacrifice) player.getCurrentArmor(chestIndex).getItem();
|
|
|
|
|
|
|
|
boolean shouldSyphon = pack.getStoredLP(player.getCurrentArmor(chestIndex)) < pack.CAPACITY;
|
2016-01-07 18:15:23 -08:00
|
|
|
float damageDone = event.entityLiving.getHealth() < event.ammount ? event.ammount - event.entityLiving.getHealth() : event.ammount;
|
2016-01-21 12:54:46 -08:00
|
|
|
int totalLP = Math.round(damageDone * ConfigHandler.sacrificialPackConversion);
|
2015-11-11 10:45:46 -08:00
|
|
|
|
|
|
|
if (shouldSyphon)
|
|
|
|
pack.addLP(player.getCurrentArmor(chestIndex), totalLP);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-02-03 20:31:09 -08:00
|
|
|
@SubscribeEvent
|
|
|
|
public void onAnvil(AnvilUpdateEvent event)
|
|
|
|
{
|
2016-02-03 20:41:41 -08:00
|
|
|
if (ConfigHandler.thaumcraftGogglesUpgrade)
|
2016-02-03 20:31:09 -08:00
|
|
|
{
|
2016-02-03 20:41:41 -08:00
|
|
|
if (event.left.getItem() == ModItems.livingArmourHelmet && event.right.getItem() == Constants.Compat.THAUMCRAFT_GOGGLES && !event.right.isItemDamaged())
|
|
|
|
{
|
2016-02-09 18:49:38 -08:00
|
|
|
ItemStack output = new ItemStack(ModItems.upgradeTome);
|
2016-02-03 20:41:41 -08:00
|
|
|
output = NBTHelper.checkNBT(output);
|
2016-02-14 21:50:32 -05:00
|
|
|
ItemUpgradeTome.setKey(output, Constants.Mod.MODID + ".upgrade.revealing");
|
|
|
|
ItemUpgradeTome.setLevel(output, 1);
|
2016-02-03 20:41:41 -08:00
|
|
|
event.cost = 1;
|
2016-02-03 20:31:09 -08:00
|
|
|
|
2016-02-03 20:41:41 -08:00
|
|
|
event.output = output;
|
2016-02-14 21:50:32 -05:00
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (event.left.getItem() == ModItems.upgradeTome && event.right.getItem() == ModItems.upgradeTome)
|
|
|
|
{
|
|
|
|
LivingArmourUpgrade leftUpgrade = ItemUpgradeTome.getUpgrade(event.left);
|
|
|
|
if (leftUpgrade != null && ItemUpgradeTome.getKey(event.left).equals(ItemUpgradeTome.getKey(event.right)))
|
|
|
|
{
|
|
|
|
int leftLevel = ItemUpgradeTome.getLevel(event.left);
|
|
|
|
int rightLevel = ItemUpgradeTome.getLevel(event.right);
|
|
|
|
|
|
|
|
if (leftLevel == rightLevel && leftLevel < leftUpgrade.getMaxTier() - 1)
|
|
|
|
{
|
|
|
|
ItemStack outputStack = event.left.copy();
|
|
|
|
ItemUpgradeTome.setLevel(outputStack, leftLevel + 1);
|
|
|
|
event.cost = leftLevel + 2;
|
|
|
|
|
|
|
|
event.output = outputStack;
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (event.left.getItem() instanceof IUpgradeTrainer && event.right.getItem() == ModItems.upgradeTome)
|
|
|
|
{
|
|
|
|
LivingArmourUpgrade rightUpgrade = ItemUpgradeTome.getUpgrade(event.right);
|
|
|
|
if (rightUpgrade != null)
|
|
|
|
{
|
|
|
|
String key = ItemUpgradeTome.getKey(event.right);
|
|
|
|
ItemStack outputStack = event.left.copy();
|
|
|
|
List<String> keyList = new ArrayList<String>();
|
|
|
|
keyList.add(key);
|
|
|
|
if (((IUpgradeTrainer) event.left.getItem()).setTrainedUpgrades(outputStack, keyList))
|
|
|
|
{
|
|
|
|
event.cost = 1;
|
|
|
|
|
|
|
|
event.output = outputStack;
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
2016-02-03 20:41:41 -08:00
|
|
|
}
|
2016-02-03 20:31:09 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-10-29 22:22:08 -07:00
|
|
|
@SubscribeEvent
|
2015-12-30 15:34:40 -05:00
|
|
|
public void onBucketFill(FillBucketEvent event)
|
|
|
|
{
|
2015-10-29 22:22:08 -07:00
|
|
|
if (event.current.getItem() != Items.bucket)
|
|
|
|
return;
|
|
|
|
|
|
|
|
ItemStack result = null;
|
|
|
|
|
|
|
|
Block block = event.world.getBlockState(event.target.getBlockPos()).getBlock();
|
|
|
|
|
2015-12-30 15:34:40 -05:00
|
|
|
if (block != null && (block.equals(ModBlocks.lifeEssence)) && block.getMetaFromState(event.world.getBlockState(event.target.getBlockPos())) == 0)
|
|
|
|
{
|
2015-10-29 22:22:08 -07: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-29 19:04:50 -05:00
|
|
|
|
|
|
|
@SubscribeEvent
|
2015-12-30 15:34:40 -05: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-29 19:04:50 -05:00
|
|
|
ItemAltarMaker altarMaker = (ItemAltarMaker) event.entityPlayer.getCurrentEquippedItem().getItem();
|
2015-12-28 14:27:59 -08:00
|
|
|
ChatUtil.sendNoSpam(event.entityPlayer, TextHelper.localizeEffect("chat.BloodMagic.altarMaker.destroy", altarMaker.destroyAltar(event.entityPlayer)));
|
2015-11-29 19:04:50 -05:00
|
|
|
}
|
|
|
|
}
|
2016-01-01 09:29:35 -08:00
|
|
|
|
|
|
|
@SubscribeEvent
|
2016-01-01 12:33:26 -08:00
|
|
|
public void onTelepose(TeleposeEvent event)
|
|
|
|
{
|
2016-01-05 15:26:24 -08:00
|
|
|
if (ConfigHandler.teleposerBlacklist.contains(event.initialStack) || ConfigHandler.teleposerBlacklist.contains(event.finalStack))
|
2016-01-01 09:29:35 -08:00
|
|
|
event.setCanceled(true);
|
2016-01-01 12:33:42 -08:00
|
|
|
|
2016-01-05 15:26:24 -08:00
|
|
|
if (BloodMagicAPI.getTeleposerBlacklist().contains(event.initialStack) || BloodMagicAPI.getTeleposerBlacklist().contains(event.finalStack))
|
2016-01-01 12:33:42 -08:00
|
|
|
event.setCanceled(true);
|
2016-01-01 09:29:35 -08:00
|
|
|
}
|
2016-01-01 12:33:26 -08:00
|
|
|
|
|
|
|
@SubscribeEvent
|
2016-01-02 17:56:37 -05:00
|
|
|
public void onConfigChanged(ConfigChangedEvent event)
|
|
|
|
{
|
2016-01-01 12:33:26 -08:00
|
|
|
if (event.modID.equals(Constants.Mod.MODID))
|
|
|
|
ConfigHandler.syncConfig();
|
|
|
|
}
|
2016-01-03 15:39:59 -05:00
|
|
|
|
|
|
|
@SubscribeEvent
|
|
|
|
public void blockBreakEvent(BlockEvent.BreakEvent event)
|
|
|
|
{
|
|
|
|
EntityPlayer player = event.getPlayer();
|
|
|
|
if (player != null)
|
|
|
|
{
|
2016-01-28 22:37:19 -08:00
|
|
|
if (LivingArmour.hasFullSet(player))
|
2016-01-05 12:17:05 -05:00
|
|
|
{
|
2016-01-28 22:37:19 -08:00
|
|
|
ItemStack chestStack = player.getCurrentArmor(2);
|
|
|
|
if (chestStack != null && chestStack.getItem() instanceof ItemLivingArmour)
|
2016-01-05 12:17:05 -05:00
|
|
|
{
|
2016-01-28 22:37:19 -08:00
|
|
|
LivingArmour armour = ItemLivingArmour.armourMap.get(chestStack);
|
2016-01-03 15:39:59 -05:00
|
|
|
|
2016-01-28 22:37:19 -08:00
|
|
|
if (armour != null)
|
|
|
|
{
|
|
|
|
StatTrackerDigging.incrementCounter(armour);
|
|
|
|
LivingArmourUpgradeDigging.hasDug(armour);
|
|
|
|
}
|
2016-01-03 15:39:59 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2016-01-05 12:17:05 -05:00
|
|
|
|
2016-02-03 23:14:26 -08:00
|
|
|
@SubscribeEvent
|
|
|
|
public void interactEvent(PlayerInteractEvent event)
|
|
|
|
{
|
|
|
|
if (event.world.isRemote)
|
|
|
|
return;
|
|
|
|
|
|
|
|
EntityPlayer player = event.entityPlayer;
|
|
|
|
|
|
|
|
if (PlayerHelper.isFakePlayer(player))
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (event.useBlock == Result.DENY && event.useItem != Result.DENY)
|
|
|
|
{
|
|
|
|
ItemStack held = player.getHeldItem();
|
|
|
|
if (held != null && held.getItem() instanceof IBindable)
|
|
|
|
{
|
|
|
|
held = NBTHelper.checkNBT(held);
|
2016-02-04 00:25:37 -08:00
|
|
|
IBindable bindable = (IBindable) held.getItem();
|
|
|
|
if (Strings.isNullOrEmpty(bindable.getOwnerUUID(held)))
|
2016-02-03 23:14:26 -08:00
|
|
|
{
|
|
|
|
if (bindable.onBind(player, held))
|
|
|
|
{
|
|
|
|
String uuid = PlayerHelper.getUUIDFromPlayer(player).toString();
|
|
|
|
ItemBindEvent toPost = new ItemBindEvent(player, uuid, held);
|
|
|
|
if (MinecraftForge.EVENT_BUS.post(toPost) || toPost.getResult() == Result.DENY)
|
|
|
|
return;
|
|
|
|
|
|
|
|
BindableHelper.setItemOwnerUUID(held, uuid);
|
|
|
|
BindableHelper.setItemOwnerName(held, player.getDisplayNameString());
|
|
|
|
}
|
2016-02-04 00:25:37 -08:00
|
|
|
} else if (bindable.getOwnerUUID(held).equals(PlayerHelper.getUUIDFromPlayer(player).toString()) && !bindable.getOwnerName(held).equals(player.getDisplayNameString()))
|
2016-02-03 23:14:26 -08:00
|
|
|
BindableHelper.setItemOwnerName(held, player.getDisplayNameString());
|
|
|
|
}
|
2016-03-14 18:56:55 -07:00
|
|
|
|
2016-03-16 18:41:06 -04:00
|
|
|
if (held != null && held.getItem() instanceof IBloodOrb)
|
|
|
|
{
|
2016-03-14 18:56:55 -07:00
|
|
|
held = NBTHelper.checkNBT(held);
|
|
|
|
IBloodOrb bloodOrb = (IBloodOrb) held.getItem();
|
|
|
|
SoulNetwork network = NetworkHelper.getSoulNetwork(player);
|
|
|
|
|
|
|
|
if (bloodOrb.getOrbLevel(held.getItemDamage()) > network.getOrbTier())
|
|
|
|
network.setOrbTier(bloodOrb.getOrbLevel(held.getItemDamage()));
|
|
|
|
}
|
2016-02-03 23:14:26 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-01-05 12:17:05 -05:00
|
|
|
@SubscribeEvent
|
|
|
|
public void selfSacrificeEvent(SacrificeKnifeUsedEvent event)
|
|
|
|
{
|
|
|
|
EntityPlayer player = event.player;
|
|
|
|
|
2016-01-28 22:37:19 -08:00
|
|
|
if (LivingArmour.hasFullSet(player))
|
2016-01-05 12:17:05 -05:00
|
|
|
{
|
2016-01-28 22:37:19 -08:00
|
|
|
ItemStack chestStack = player.getCurrentArmor(2);
|
|
|
|
LivingArmour armour = ItemLivingArmour.armourMap.get(chestStack);
|
|
|
|
if (armour != null)
|
2016-01-05 12:17:05 -05:00
|
|
|
{
|
2016-01-28 22:37:19 -08:00
|
|
|
StatTrackerSelfSacrifice.incrementCounter(armour);
|
|
|
|
LivingArmourUpgrade upgrade = ItemLivingArmour.getUpgrade(Constants.Mod.MODID + ".upgrade.selfSacrifice", chestStack);
|
2016-01-05 12:17:05 -05:00
|
|
|
|
2016-01-28 22:37:19 -08:00
|
|
|
if (upgrade instanceof LivingArmourUpgradeSelfSacrifice)
|
|
|
|
{
|
|
|
|
double modifier = ((LivingArmourUpgradeSelfSacrifice) upgrade).getSacrificeModifier();
|
2016-01-05 12:17:05 -05:00
|
|
|
|
2016-01-28 22:37:19 -08:00
|
|
|
event.lpAdded = (int) (event.lpAdded * (1 + modifier));
|
|
|
|
}
|
2016-01-05 12:17:05 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2016-01-05 18:27:51 -05:00
|
|
|
|
2016-01-06 19:55:51 -05:00
|
|
|
@SubscribeEvent
|
|
|
|
public void onEntityHealed(LivingHealEvent event)
|
|
|
|
{
|
|
|
|
EntityLivingBase healedEntity = event.entityLiving;
|
|
|
|
if (!(healedEntity instanceof EntityPlayer))
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
EntityPlayer player = (EntityPlayer) healedEntity;
|
|
|
|
|
2016-01-28 22:37:19 -08:00
|
|
|
if (LivingArmour.hasFullSet(player))
|
2016-01-06 19:55:51 -05:00
|
|
|
{
|
2016-01-28 22:37:19 -08:00
|
|
|
ItemStack chestStack = player.getCurrentArmor(2);
|
|
|
|
LivingArmour armour = ItemLivingArmour.armourMap.get(chestStack);
|
|
|
|
if (armour != null)
|
2016-02-11 14:10:43 -05:00
|
|
|
{
|
2016-01-28 22:37:19 -08:00
|
|
|
StatTrackerHealthboost.incrementCounter(armour, event.amount);
|
2016-02-11 14:10:43 -05:00
|
|
|
if (player.worldObj.canSeeSky(player.getPosition()) && player.worldObj.provider.isDaytime())
|
|
|
|
{
|
|
|
|
StatTrackerSolarPowered.incrementCounter(armour, event.amount);
|
|
|
|
}
|
|
|
|
}
|
2016-01-06 19:55:51 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-01-05 18:27:51 -05:00
|
|
|
@SubscribeEvent
|
|
|
|
public void onEntityAttacked(LivingAttackEvent event)
|
|
|
|
{
|
2016-01-06 19:34:10 -05:00
|
|
|
DamageSource source = event.source;
|
2016-01-05 18:27:51 -05:00
|
|
|
Entity sourceEntity = event.source.getEntity();
|
|
|
|
EntityLivingBase attackedEntity = event.entityLiving;
|
|
|
|
|
2016-01-06 07:13:56 -05:00
|
|
|
if (attackedEntity.hurtResistantTime > 0)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2016-01-06 19:34:10 -05:00
|
|
|
if (attackedEntity instanceof EntityPlayer)
|
2016-01-05 18:27:51 -05:00
|
|
|
{
|
|
|
|
EntityPlayer attackedPlayer = (EntityPlayer) attackedEntity;
|
|
|
|
|
2016-01-28 22:37:19 -08:00
|
|
|
// Living Armor Handling
|
|
|
|
if (LivingArmour.hasFullSet(attackedPlayer))
|
2016-01-05 18:27:51 -05:00
|
|
|
{
|
2016-01-15 06:24:10 -05:00
|
|
|
float amount = Math.min(Utils.getModifiedDamage(attackedPlayer, event.source, event.ammount), attackedPlayer.getHealth());
|
2016-01-06 19:34:10 -05:00
|
|
|
ItemStack chestStack = attackedPlayer.getCurrentArmor(2);
|
2016-02-07 15:37:35 -05:00
|
|
|
LivingArmour armour = ItemLivingArmour.armourMap.get(chestStack);
|
2016-01-06 19:34:10 -05:00
|
|
|
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 18:27:51 -05:00
|
|
|
}
|
|
|
|
}
|
2016-01-06 21:26:51 -05:00
|
|
|
|
2016-01-09 10:47:36 -05:00
|
|
|
if (sourceEntity instanceof EntitySentientArrow)
|
2016-01-08 22:20:31 -05:00
|
|
|
{
|
|
|
|
// Soul Weapon handling
|
2016-01-09 10:47:36 -05:00
|
|
|
((EntitySentientArrow) sourceEntity).reimbursePlayer();
|
2016-01-08 22:20:31 -05:00
|
|
|
}
|
|
|
|
|
2016-01-06 21:26:51 -05:00
|
|
|
if (sourceEntity instanceof EntityPlayer)
|
|
|
|
{
|
|
|
|
EntityPlayer player = (EntityPlayer) sourceEntity;
|
|
|
|
|
2016-01-28 22:37:19 -08:00
|
|
|
// Living Armor Handling
|
|
|
|
if (LivingArmour.hasFullSet(player))
|
2016-01-06 21:26:51 -05:00
|
|
|
{
|
2016-01-15 06:24:10 -05:00
|
|
|
float amount = Math.min(Utils.getModifiedDamage(attackedEntity, event.source, event.ammount), attackedEntity.getHealth());
|
2016-01-06 21:26:51 -05:00
|
|
|
ItemStack chestStack = player.getCurrentArmor(2);
|
2016-02-07 15:37:35 -05:00
|
|
|
LivingArmour armour = ItemLivingArmour.armourMap.get(chestStack);
|
2016-01-06 21:26:51 -05:00
|
|
|
if (armour != null)
|
|
|
|
{
|
2016-01-28 22:37:19 -08:00
|
|
|
if (!source.isProjectile())
|
2016-01-06 21:26:51 -05:00
|
|
|
{
|
|
|
|
StatTrackerMeleeDamage.incrementCounter(armour, amount);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2016-01-05 18:27:51 -05:00
|
|
|
}
|
2016-01-06 22:07:17 -05:00
|
|
|
|
|
|
|
@SubscribeEvent
|
|
|
|
public void onArrowFire(ArrowLooseEvent event)
|
|
|
|
{
|
|
|
|
World world = event.entityPlayer.worldObj;
|
|
|
|
ItemStack stack = event.bow;
|
|
|
|
EntityPlayer player = event.entityPlayer;
|
|
|
|
|
2016-01-28 22:37:19 -08:00
|
|
|
if (LivingArmour.hasFullSet(player))
|
2016-01-06 22:07:17 -05:00
|
|
|
{
|
|
|
|
ItemStack chestStack = player.getCurrentArmor(2);
|
2016-02-07 15:37:35 -05:00
|
|
|
LivingArmour armour = ItemLivingArmour.armourMap.get(chestStack);
|
2016-01-06 22:07:17 -05:00
|
|
|
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 11:01:38 -05:00
|
|
|
|
|
|
|
@SubscribeEvent
|
|
|
|
public void onLivingDrops(LivingDropsEvent event)
|
|
|
|
{
|
|
|
|
EntityLivingBase attackedEntity = event.entityLiving;
|
|
|
|
DamageSource source = event.source;
|
|
|
|
Entity entity = source.getEntity();
|
|
|
|
|
2016-01-08 14:56:36 -05: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 10:47:36 -05:00
|
|
|
ItemStack soulStack = ((IDemonWill) ModItems.monsterSoul).createWill(0, amountOfSouls);
|
2016-01-08 14:56:36 -05:00
|
|
|
event.drops.add(new EntityItem(attackedEntity.worldObj, attackedEntity.posX, attackedEntity.posY, attackedEntity.posZ, soulStack));
|
|
|
|
}
|
|
|
|
|
2016-03-15 19:50:03 -07:00
|
|
|
if (entity != null && entity instanceof EntityPlayer)
|
2016-01-07 11:01:38 -05:00
|
|
|
{
|
2016-03-15 19:50:03 -07:00
|
|
|
EntityPlayer player = (EntityPlayer) entity;
|
|
|
|
ItemStack heldStack = player.getHeldItem();
|
|
|
|
if (heldStack != null && heldStack.getItem() instanceof IDemonWillWeapon && !player.worldObj.isRemote)
|
2016-01-07 11:01:38 -05:00
|
|
|
{
|
2016-03-15 19:50:03 -07:00
|
|
|
IDemonWillWeapon demonWillWeapon = (IDemonWillWeapon) heldStack.getItem();
|
|
|
|
List<ItemStack> droppedSouls = demonWillWeapon.getRandomDemonWillDrop(attackedEntity, player, heldStack, event.lootingLevel);
|
2016-01-07 11:01:38 -05:00
|
|
|
if (!droppedSouls.isEmpty())
|
|
|
|
{
|
2016-03-15 19:50:03 -07:00
|
|
|
ItemStack remainder;
|
|
|
|
for (ItemStack willStack : droppedSouls)
|
2016-01-07 11:01:38 -05:00
|
|
|
{
|
2016-03-15 19:50:03 -07:00
|
|
|
remainder = PlayerDemonWillHandler.addDemonWill(player, willStack);
|
|
|
|
if (remainder != null && ((IDemonWill) remainder.getItem()).getWill(remainder) >= 0.0001)
|
|
|
|
event.drops.add(new EntityItem(attackedEntity.worldObj, attackedEntity.posX, attackedEntity.posY, attackedEntity.posZ, remainder));
|
2016-01-07 11:01:38 -05:00
|
|
|
}
|
2016-03-15 19:50:03 -07:00
|
|
|
player.inventoryContainer.detectAndSendChanges();
|
2016-01-07 11:01:38 -05:00
|
|
|
}
|
|
|
|
}
|
2016-01-30 22:22:46 -05:00
|
|
|
|
|
|
|
if (heldStack != null && heldStack.getItem() == ModItems.boundSword && !(attackedEntity instanceof EntityAnimal))
|
2016-03-15 19:50:03 -07:00
|
|
|
for (int i = 0; i <= EnchantmentHelper.getLootingModifier(player); i++)
|
2016-01-30 22:22:46 -05:00
|
|
|
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 11:01:38 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@SubscribeEvent
|
|
|
|
public void onItemPickup(EntityItemPickupEvent event)
|
|
|
|
{
|
2016-01-07 12:59:46 -05:00
|
|
|
ItemStack stack = event.item.getEntityItem();
|
2016-01-09 10:47:36 -05:00
|
|
|
if (stack != null && stack.getItem() instanceof IDemonWill)
|
2016-01-07 12:59:46 -05:00
|
|
|
{
|
|
|
|
EntityPlayer player = event.entityPlayer;
|
|
|
|
|
2016-01-09 10:47:36 -05:00
|
|
|
ItemStack remainder = PlayerDemonWillHandler.addDemonWill(player, stack);
|
2016-01-07 12:59:46 -05:00
|
|
|
|
2016-02-18 18:00:02 -05:00
|
|
|
if (remainder == null || ((IDemonWill) stack.getItem()).getWill(stack) < 0.0001 || PlayerDemonWillHandler.isDemonWillFull(EnumDemonWillType.DEFAULT, player))
|
2016-01-07 12:59:46 -05:00
|
|
|
{
|
|
|
|
stack.stackSize = 0;
|
|
|
|
event.setResult(Result.ALLOW);
|
|
|
|
}
|
|
|
|
}
|
2016-01-07 11:01:38 -05:00
|
|
|
}
|
2015-10-29 22:22:08 -07:00
|
|
|
}
|