mirror of
https://github.com/GTNewHorizons/BloodArsenal.git
synced 2026-11-19 11:59:18 +00:00
Baubles issue
This commit is contained in:
1 parent
047c72ac44
commit
d675aad914
7 files changed
+261
-101
No files matched your search
@@ -73,11 +73,6 @@ public class BloodArsenalEventHooks
|
||||
}
|
||||
}
|
||||
|
||||
if (BloodArsenalConfig.baublesIntegration && Loader.isModLoaded("Baubles"))
|
||||
{
|
||||
selfSacrificeHandler(event);
|
||||
}
|
||||
|
||||
EntityPlayerMP player = (EntityPlayerMP) entityAttacked;
|
||||
|
||||
if (player.inventory.armorInventory != null)
|
||||
@@ -99,17 +94,6 @@ public class BloodArsenalEventHooks
|
||||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onLivingDeath(LivingDeathEvent event)
|
||||
{
|
||||
Entity killer = event.source.getEntity();
|
||||
|
||||
if (killer != null && killer instanceof EntityPlayer && BloodArsenalConfig.baublesIntegration && Loader.isModLoaded("Baubles"))
|
||||
{
|
||||
sacrificeHandler(event);
|
||||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onEntityUpdate(LivingEvent.LivingUpdateEvent event)
|
||||
{
|
||||
@@ -121,13 +105,13 @@ public class BloodArsenalEventHooks
|
||||
{
|
||||
int amplifier = entityLiving.getActivePotionEffect(BloodArsenal.bleeding).getAmplifier();
|
||||
int duration = entityLiving.getActivePotionEffect(BloodArsenal.bleeding).getDuration();
|
||||
int damage = (rand.nextInt(2) * (amplifier + 1) + rand.nextInt(3));
|
||||
int damage = (rand.nextInt(2) * (amplifier + 1) + rand.nextInt(2));
|
||||
|
||||
if (entityLiving.worldObj.getWorldTime() % (20 / (amplifier + 1)) == 0)
|
||||
if (entityLiving.worldObj.getWorldTime() % (60 / (amplifier + 1)) == 0)
|
||||
{
|
||||
entityLiving.attackEntityFrom(BloodArsenal.deathFromBlood, damage);
|
||||
entityLiving.addPotionEffect(new PotionEffect(Potion.blindness.id, duration, 1));
|
||||
entityLiving.hurtResistantTime = Math.min(entityLiving.hurtResistantTime, 20 / (amplifier + 1));
|
||||
// entityLiving.hurtResistantTime = Math.min(entityLiving.hurtResistantTime, 60 / (amplifier + 1));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -155,7 +139,6 @@ public class BloodArsenalEventHooks
|
||||
SoulNetworkHandler.syphonAndDamageFromNetwork(owner, (EntityPlayer) entityLiving, lpToMinus);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (entityLiving instanceof EntityPlayer)
|
||||
@@ -257,57 +240,7 @@ public class BloodArsenalEventHooks
|
||||
}
|
||||
|
||||
@Optional.Method(modid = "Baubles")
|
||||
private void sacrificeHandler(LivingDeathEvent event)
|
||||
{
|
||||
Entity killer = event.source.getEntity();
|
||||
EntityLivingBase victim = event.entityLiving;
|
||||
|
||||
EntityPlayer player = (EntityPlayer) killer;
|
||||
InventoryBaubles inv = PlayerHandler.getPlayerBaubles(player);
|
||||
|
||||
for (int i = 0; i < inv.getSizeInventory(); i++)
|
||||
{
|
||||
ItemStack stack = inv.getStackInSlot(i);
|
||||
|
||||
if (stack != null)
|
||||
{
|
||||
if (stack.getItem() == ModItems.sacrifice_amulet)
|
||||
{
|
||||
SacrificeAmulet sacrificeAmulet = (SacrificeAmulet) ModItems.sacrifice_amulet;
|
||||
float victimHealth = victim.getMaxHealth();
|
||||
boolean healthGood = victimHealth > 4.0F;
|
||||
int lpReceived = healthGood ? 200 : 50;
|
||||
boolean shouldExecute = sacrificeAmulet.getStoredLP(stack) < 10000;
|
||||
|
||||
if (shouldExecute)
|
||||
{
|
||||
sacrificeAmulet.setStoredLP(stack, Math.min(sacrificeAmulet.getStoredLP(stack) + (lpReceived * 2), 10000));
|
||||
}
|
||||
}
|
||||
|
||||
if (stack.getItem() == ModItems.empowered_sacrifice_amulet)
|
||||
{
|
||||
EmpoweredSacrificeAmulet sacrificeAmulet = (EmpoweredSacrificeAmulet) ModItems.empowered_sacrifice_amulet;
|
||||
float victimHealth = victim.getMaxHealth();
|
||||
boolean healthGood = victimHealth > 4.0F;
|
||||
int lpReceived = healthGood ? 200 : 50;
|
||||
boolean shouldExecute = sacrificeAmulet.getStoredLP(stack) < 50000;
|
||||
|
||||
if (shouldExecute)
|
||||
{
|
||||
sacrificeAmulet.setStoredLP(stack, Math.min(sacrificeAmulet.getStoredLP(stack) + (lpReceived * 5), 50000));
|
||||
}
|
||||
}
|
||||
|
||||
if (player instanceof EntityPlayerMP)
|
||||
{
|
||||
PacketHandler.INSTANCE.sendTo(new PacketSyncBauble(player, i), (EntityPlayerMP) player);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Optional.Method(modid = "Baubles")
|
||||
@SubscribeEvent
|
||||
private void selfSacrificeHandler(LivingAttackEvent event)
|
||||
{
|
||||
EntityLivingBase entityAttacked = event.entityLiving;
|
||||
@@ -341,6 +274,11 @@ public class BloodArsenalEventHooks
|
||||
selfSacrificeAmulet.setStoredLP(stack, Math.min(selfSacrificeAmulet.getStoredLP(stack) + (lpReceived * 2), 10000));
|
||||
}
|
||||
}
|
||||
|
||||
// if (player instanceof EntityPlayerMP)
|
||||
{
|
||||
PacketHandler.INSTANCE.sendTo(new PacketSyncBauble(player, i), (EntityPlayerMP) player);
|
||||
}
|
||||
}
|
||||
|
||||
if (stack.getItem() == ModItems.empowered_self_sacrifice_amulet)
|
||||
@@ -362,11 +300,11 @@ public class BloodArsenalEventHooks
|
||||
selfSacrificeAmulet.setStoredLP(stack, Math.min(selfSacrificeAmulet.getStoredLP(stack) + (lpReceived * 5), 50000));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (player instanceof EntityPlayerMP)
|
||||
{
|
||||
PacketHandler.INSTANCE.sendTo(new PacketSyncBauble(player, i), (EntityPlayerMP) player);
|
||||
// if (player instanceof EntityPlayerMP)
|
||||
{
|
||||
PacketHandler.INSTANCE.sendTo(new PacketSyncBauble(player, i), (EntityPlayerMP) player);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+58
-3
@@ -7,17 +7,30 @@ import WayofTime.alchemicalWizardry.common.spell.complex.effect.SpellHelper;
|
||||
import WayofTime.alchemicalWizardry.common.tileEntity.TEAltar;
|
||||
import baubles.api.BaubleType;
|
||||
import baubles.api.IBauble;
|
||||
import baubles.common.container.InventoryBaubles;
|
||||
import baubles.common.lib.PlayerHandler;
|
||||
import baubles.common.network.PacketHandler;
|
||||
import baubles.common.network.PacketSyncBauble;
|
||||
import com.arc.bloodarsenal.common.BloodArsenalConfig;
|
||||
import com.arc.bloodarsenal.common.items.ModItems;
|
||||
import cpw.mods.fml.common.Optional;
|
||||
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.item.EnumRarity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.EnumChatFormatting;
|
||||
import net.minecraft.util.MovingObjectPosition;
|
||||
import net.minecraft.util.StatCollector;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.event.entity.living.LivingDeathEvent;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -26,8 +39,50 @@ public class EmpoweredSacrificeAmulet extends SacrificeAmulet implements IBauble
|
||||
public EmpoweredSacrificeAmulet()
|
||||
{
|
||||
super();
|
||||
setMaxDamage(0);
|
||||
setUnlocalizedName("empowered_sacrifice_amulet");
|
||||
setHasSubtypes(true);
|
||||
MinecraftForge.EVENT_BUS.register(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SubscribeEvent
|
||||
public void sacrificeHandler(LivingDeathEvent event)
|
||||
{
|
||||
Entity killer = event.source.getEntity();
|
||||
|
||||
if (killer != null && killer instanceof EntityPlayer && BloodArsenalConfig.baublesIntegration)
|
||||
{
|
||||
EntityLivingBase victim = event.entityLiving;
|
||||
|
||||
EntityPlayer player = (EntityPlayer) killer;
|
||||
InventoryBaubles inv = PlayerHandler.getPlayerBaubles(player);
|
||||
|
||||
for (int i = 0; i < inv.getSizeInventory(); i++)
|
||||
{
|
||||
ItemStack stack = inv.getStackInSlot(i);
|
||||
|
||||
if (stack != null)
|
||||
{
|
||||
if (stack.getItem() == ModItems.empowered_sacrifice_amulet)
|
||||
{
|
||||
EmpoweredSacrificeAmulet sacrificeAmulet = (EmpoweredSacrificeAmulet) ModItems.empowered_sacrifice_amulet;
|
||||
float victimHealth = victim.getMaxHealth();
|
||||
boolean healthGood = victimHealth > 4.0F;
|
||||
int lpReceived = healthGood ? 200 : 50;
|
||||
boolean shouldExecute = sacrificeAmulet.getStoredLP(stack) < 50000;
|
||||
|
||||
if (shouldExecute)
|
||||
{
|
||||
sacrificeAmulet.setStoredLP(stack, Math.min(sacrificeAmulet.getStoredLP(stack) + (lpReceived * 5), 50000));
|
||||
}
|
||||
|
||||
if (player instanceof EntityPlayerMP)
|
||||
{
|
||||
PacketHandler.INSTANCE.sendTo(new PacketSyncBauble(player, i), (EntityPlayerMP) player);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -37,7 +92,7 @@ public class EmpoweredSacrificeAmulet extends SacrificeAmulet implements IBauble
|
||||
|
||||
if (!(par1ItemStack.stackTagCompound == null))
|
||||
{
|
||||
par3List.add("Stored LP: " + this.getStoredLP(par1ItemStack));
|
||||
par3List.add("Stored LP: " + EnumChatFormatting.RED + this.getStoredLP(par1ItemStack));
|
||||
|
||||
if (!par1ItemStack.stackTagCompound.getString("ownerName").equals(""))
|
||||
{
|
||||
|
||||
+67
-3
@@ -7,17 +7,31 @@ import WayofTime.alchemicalWizardry.common.spell.complex.effect.SpellHelper;
|
||||
import WayofTime.alchemicalWizardry.common.tileEntity.TEAltar;
|
||||
import baubles.api.BaubleType;
|
||||
import baubles.api.IBauble;
|
||||
import baubles.common.container.InventoryBaubles;
|
||||
import baubles.common.lib.PlayerHandler;
|
||||
import baubles.common.network.PacketHandler;
|
||||
import baubles.common.network.PacketSyncBauble;
|
||||
import com.arc.bloodarsenal.common.BloodArsenalConfig;
|
||||
import com.arc.bloodarsenal.common.items.ModItems;
|
||||
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.item.EnumRarity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.potion.Potion;
|
||||
import net.minecraft.potion.PotionEffect;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.EnumChatFormatting;
|
||||
import net.minecraft.util.MovingObjectPosition;
|
||||
import net.minecraft.util.StatCollector;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.event.entity.living.LivingAttackEvent;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -26,8 +40,58 @@ public class EmpoweredSelfSacrificeAmulet extends SelfSacrificeAmulet implements
|
||||
public EmpoweredSelfSacrificeAmulet()
|
||||
{
|
||||
super();
|
||||
setMaxDamage(0);
|
||||
setUnlocalizedName("empowered_self_sacrifice_amulet");
|
||||
setHasSubtypes(true);
|
||||
MinecraftForge.EVENT_BUS.register(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SubscribeEvent
|
||||
public void selfSacrificeHandler(LivingAttackEvent event)
|
||||
{
|
||||
EntityLivingBase entityAttacked = event.entityLiving;
|
||||
Entity entityAttacking = event.source.getSourceOfDamage();
|
||||
|
||||
if (entityAttacking != null && entityAttacked != null && entityAttacked instanceof EntityPlayer && BloodArsenalConfig.baublesIntegration)
|
||||
{
|
||||
float damageDone = event.ammount;
|
||||
|
||||
EntityPlayer player = (EntityPlayer) entityAttacked;
|
||||
InventoryBaubles inv = PlayerHandler.getPlayerBaubles(player);
|
||||
|
||||
for (int i = 0; i < inv.getSizeInventory(); i++)
|
||||
{
|
||||
ItemStack stack = inv.getStackInSlot(i);
|
||||
|
||||
if (stack != null)
|
||||
{
|
||||
if (stack.getItem() == ModItems.empowered_self_sacrifice_amulet)
|
||||
{
|
||||
EmpoweredSelfSacrificeAmulet selfSacrificeAmulet = (EmpoweredSelfSacrificeAmulet) ModItems.empowered_self_sacrifice_amulet;
|
||||
int lpReceived = (int) damageDone;
|
||||
boolean shouldExecute = selfSacrificeAmulet.getStoredLP(stack) < 50000;
|
||||
|
||||
if (shouldExecute)
|
||||
{
|
||||
PotionEffect regenEffect = player.getActivePotionEffect(Potion.regeneration);
|
||||
|
||||
if (regenEffect != null && regenEffect.getAmplifier() >= 2)
|
||||
{
|
||||
selfSacrificeAmulet.setStoredLP(stack, Math.min(selfSacrificeAmulet.getStoredLP(stack) + (lpReceived * 5) / (regenEffect.getAmplifier() + 1), 50000));
|
||||
}
|
||||
else
|
||||
{
|
||||
selfSacrificeAmulet.setStoredLP(stack, Math.min(selfSacrificeAmulet.getStoredLP(stack) + (lpReceived * 5), 50000));
|
||||
}
|
||||
}
|
||||
|
||||
if (player instanceof EntityPlayerMP)
|
||||
{
|
||||
PacketHandler.INSTANCE.sendTo(new PacketSyncBauble(player, i), (EntityPlayerMP) player);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -37,7 +101,7 @@ public class EmpoweredSelfSacrificeAmulet extends SelfSacrificeAmulet implements
|
||||
|
||||
if (!(par1ItemStack.stackTagCompound == null))
|
||||
{
|
||||
par3List.add("Stored LP: " + this.getStoredLP(par1ItemStack));
|
||||
par3List.add("Stored LP: " + EnumChatFormatting.RED + this.getStoredLP(par1ItemStack));
|
||||
|
||||
if (!par1ItemStack.stackTagCompound.getString("ownerName").equals(""))
|
||||
{
|
||||
|
||||
@@ -3,7 +3,6 @@ package com.arc.bloodarsenal.common.items.bauble;
|
||||
import baubles.api.IBauble;
|
||||
import baubles.common.container.InventoryBaubles;
|
||||
import baubles.common.lib.PlayerHandler;
|
||||
import com.arc.bloodarsenal.common.BloodArsenal;
|
||||
import cpw.mods.fml.common.Optional;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
@@ -19,8 +18,6 @@ public abstract class ItemBauble extends Item implements IBauble
|
||||
super();
|
||||
setMaxStackSize(1);
|
||||
setMaxDamage(0);
|
||||
setHasSubtypes(true);
|
||||
setCreativeTab(BloodArsenal.BA_TAB);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -48,7 +45,7 @@ public abstract class ItemBauble extends Item implements IBauble
|
||||
|
||||
onEquipped(par1ItemStack, par3EntityPlayer);
|
||||
|
||||
if(stackInSlot != null)
|
||||
if (stackInSlot != null)
|
||||
{
|
||||
((IBauble) stackInSlot.getItem()).onUnequipped(stackInSlot, par3EntityPlayer);
|
||||
return stackInSlot.copy();
|
||||
@@ -74,14 +71,7 @@ public abstract class ItemBauble extends Item implements IBauble
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onWornTick(ItemStack stack, EntityLivingBase player)
|
||||
{
|
||||
if (player.ticksExisted == 1)
|
||||
{
|
||||
onEquippedOrLoadedIntoWorld(stack, player);
|
||||
}
|
||||
}
|
||||
|
||||
public void onWornTick(ItemStack stack, EntityLivingBase player) {}
|
||||
@Override
|
||||
public void onEquipped(ItemStack stack, EntityLivingBase player)
|
||||
{
|
||||
@@ -93,9 +83,7 @@ public abstract class ItemBauble extends Item implements IBauble
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUnequipped(ItemStack stack, EntityLivingBase player)
|
||||
{
|
||||
}
|
||||
public void onUnequipped(ItemStack stack, EntityLivingBase player) {}
|
||||
|
||||
@Override
|
||||
public boolean hasContainerItem(ItemStack stack)
|
||||
|
||||
@@ -4,17 +4,30 @@ import WayofTime.alchemicalWizardry.api.items.IAltarManipulator;
|
||||
import WayofTime.alchemicalWizardry.common.tileEntity.TEAltar;
|
||||
import baubles.api.BaubleType;
|
||||
import baubles.api.IBauble;
|
||||
import baubles.common.container.InventoryBaubles;
|
||||
import baubles.common.lib.PlayerHandler;
|
||||
import baubles.common.network.PacketHandler;
|
||||
import baubles.common.network.PacketSyncBauble;
|
||||
import com.arc.bloodarsenal.common.BloodArsenalConfig;
|
||||
import com.arc.bloodarsenal.common.items.ModItems;
|
||||
import cpw.mods.fml.common.Optional;
|
||||
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.EnumChatFormatting;
|
||||
import net.minecraft.util.MovingObjectPosition;
|
||||
import net.minecraft.util.StatCollector;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.event.entity.living.LivingDeathEvent;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -23,7 +36,48 @@ public class SacrificeAmulet extends ItemBauble implements IAltarManipulator, IB
|
||||
public SacrificeAmulet()
|
||||
{
|
||||
super();
|
||||
setUnlocalizedName("sacrifice_amulet");
|
||||
MinecraftForge.EVENT_BUS.register(this);
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void sacrificeHandler(LivingDeathEvent event)
|
||||
{
|
||||
Entity killer = event.source.getEntity();
|
||||
|
||||
if (killer != null && killer instanceof EntityPlayer && BloodArsenalConfig.baublesIntegration)
|
||||
{
|
||||
EntityLivingBase victim = event.entityLiving;
|
||||
|
||||
EntityPlayer player = (EntityPlayer) killer;
|
||||
InventoryBaubles inv = PlayerHandler.getPlayerBaubles(player);
|
||||
|
||||
for (int i = 0; i < inv.getSizeInventory(); i++)
|
||||
{
|
||||
ItemStack stack = inv.getStackInSlot(i);
|
||||
|
||||
if (stack != null)
|
||||
{
|
||||
if (stack.getItem() == ModItems.sacrifice_amulet)
|
||||
{
|
||||
SacrificeAmulet sacrificeAmulet = (SacrificeAmulet) ModItems.sacrifice_amulet;
|
||||
float victimHealth = victim.getMaxHealth();
|
||||
boolean healthGood = victimHealth > 4.0F;
|
||||
int lpReceived = healthGood ? 200 : 50;
|
||||
boolean shouldExecute = sacrificeAmulet.getStoredLP(stack) < 10000;
|
||||
|
||||
if (shouldExecute)
|
||||
{
|
||||
sacrificeAmulet.setStoredLP(stack, Math.min(sacrificeAmulet.getStoredLP(stack) + (lpReceived * 2), 10000));
|
||||
}
|
||||
|
||||
if (player instanceof EntityPlayerMP)
|
||||
{
|
||||
PacketHandler.INSTANCE.sendTo(new PacketSyncBauble(player, i), (EntityPlayerMP) player);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -33,7 +87,7 @@ public class SacrificeAmulet extends ItemBauble implements IAltarManipulator, IB
|
||||
|
||||
if (!(par1ItemStack.stackTagCompound == null))
|
||||
{
|
||||
par3List.add("Stored LP: " + this.getStoredLP(par1ItemStack));
|
||||
par3List.add("Stored LP: " + EnumChatFormatting.RED + this.getStoredLP(par1ItemStack));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -4,17 +4,31 @@ import WayofTime.alchemicalWizardry.api.items.IAltarManipulator;
|
||||
import WayofTime.alchemicalWizardry.common.tileEntity.TEAltar;
|
||||
import baubles.api.BaubleType;
|
||||
import baubles.api.IBauble;
|
||||
import baubles.common.container.InventoryBaubles;
|
||||
import baubles.common.lib.PlayerHandler;
|
||||
import baubles.common.network.PacketHandler;
|
||||
import baubles.common.network.PacketSyncBauble;
|
||||
import com.arc.bloodarsenal.common.BloodArsenalConfig;
|
||||
import com.arc.bloodarsenal.common.items.ModItems;
|
||||
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.potion.Potion;
|
||||
import net.minecraft.potion.PotionEffect;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.EnumChatFormatting;
|
||||
import net.minecraft.util.MovingObjectPosition;
|
||||
import net.minecraft.util.StatCollector;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.event.entity.living.LivingAttackEvent;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -23,7 +37,55 @@ public class SelfSacrificeAmulet extends ItemBauble implements IAltarManipulator
|
||||
public SelfSacrificeAmulet()
|
||||
{
|
||||
super();
|
||||
setUnlocalizedName("self_sacrifice_amulet");
|
||||
MinecraftForge.EVENT_BUS.register(this);
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void selfSacrificeHandler(LivingAttackEvent event)
|
||||
{
|
||||
EntityLivingBase entityAttacked = event.entityLiving;
|
||||
|
||||
if (entityAttacked != null && entityAttacked instanceof EntityPlayer && BloodArsenalConfig.baublesIntegration)
|
||||
{
|
||||
float damageDone = event.ammount;
|
||||
|
||||
EntityPlayer player = (EntityPlayer) entityAttacked;
|
||||
InventoryBaubles inv = PlayerHandler.getPlayerBaubles(player);
|
||||
|
||||
for (int i = 0; i < inv.getSizeInventory(); i++)
|
||||
{
|
||||
ItemStack stack = inv.getStackInSlot(i);
|
||||
|
||||
if (stack != null)
|
||||
{
|
||||
if (stack.getItem() == ModItems.self_sacrifice_amulet)
|
||||
{
|
||||
SelfSacrificeAmulet selfSacrificeAmulet = (SelfSacrificeAmulet) ModItems.self_sacrifice_amulet;
|
||||
int lpReceived = (int) damageDone;
|
||||
boolean shouldExecute = selfSacrificeAmulet.getStoredLP(stack) < 10000;
|
||||
|
||||
if (shouldExecute)
|
||||
{
|
||||
PotionEffect regenEffect = player.getActivePotionEffect(Potion.regeneration);
|
||||
|
||||
if (regenEffect != null && regenEffect.getAmplifier() >= 2)
|
||||
{
|
||||
selfSacrificeAmulet.setStoredLP(stack, Math.min(selfSacrificeAmulet.getStoredLP(stack) + (lpReceived * 2) / (regenEffect.getAmplifier() + 1), 10000));
|
||||
}
|
||||
else
|
||||
{
|
||||
selfSacrificeAmulet.setStoredLP(stack, Math.min(selfSacrificeAmulet.getStoredLP(stack) + (lpReceived * 2), 10000));
|
||||
}
|
||||
}
|
||||
|
||||
if (player instanceof EntityPlayerMP)
|
||||
{
|
||||
PacketHandler.INSTANCE.sendTo(new PacketSyncBauble(player, i), (EntityPlayerMP) player);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -33,7 +95,7 @@ public class SelfSacrificeAmulet extends ItemBauble implements IAltarManipulator
|
||||
|
||||
if (!(par1ItemStack.stackTagCompound == null))
|
||||
{
|
||||
par3List.add("Stored LP: " + this.getStoredLP(par1ItemStack));
|
||||
par3List.add("Stored LP: " + EnumChatFormatting.RED + this.getStoredLP(par1ItemStack));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -19,7 +19,6 @@ public class VampireRing extends ItemBauble implements IBauble
|
||||
super();
|
||||
setMaxStackSize(1);
|
||||
setHasSubtypes(true);
|
||||
setUnlocalizedName("vampire_ring");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in new issue
Block a user