Tweaks to damage. It now uses the DamageSource correctly
This commit is contained in:
parent
305b5e165f
commit
437dc1b96e
|
@ -1,6 +1,10 @@
|
|||
package WayofTime.bloodmagic.api;
|
||||
|
||||
import WayofTime.bloodmagic.util.helper.TextHelper;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.util.ChatComponentText;
|
||||
import net.minecraft.util.DamageSource;
|
||||
import net.minecraft.util.IChatComponent;
|
||||
|
||||
public class DamageSourceBloodMagic extends DamageSource {
|
||||
|
||||
|
@ -8,5 +12,11 @@ public class DamageSourceBloodMagic extends DamageSource {
|
|||
super("bloodMagic");
|
||||
|
||||
setDamageBypassesArmor();
|
||||
setDamageIsAbsolute();
|
||||
}
|
||||
|
||||
@Override
|
||||
public IChatComponent getDeathMessage(EntityLivingBase livingBase) {
|
||||
return new ChatComponentText(TextHelper.localizeEffect("chat.BloodMagic.damageSource", livingBase.getName()));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -100,46 +100,47 @@ public class SoulNetwork extends WorldSavedData {
|
|||
* @return - Whether the action should be performed.
|
||||
*/
|
||||
public boolean syphonAndDamage(int toSyphon) {
|
||||
if (getPlayer().worldObj.isRemote)
|
||||
return false;
|
||||
|
||||
if (!Strings.isNullOrEmpty(mapName)) {
|
||||
SoulNetworkEvent.ItemDrainNetworkEvent event = new SoulNetworkEvent.ItemDrainNetworkEvent(player, mapName, getPlayer().getHeldItem(), toSyphon);
|
||||
|
||||
if (MinecraftForge.EVENT_BUS.post(event))
|
||||
if (getPlayer() != null) {
|
||||
if (getPlayer().worldObj.isRemote)
|
||||
return false;
|
||||
|
||||
int drainAmount = syphon(event.syphon);
|
||||
if (!Strings.isNullOrEmpty(mapName)) {
|
||||
SoulNetworkEvent.ItemDrainNetworkEvent event = new SoulNetworkEvent.ItemDrainNetworkEvent(player, mapName, getPlayer().getHeldItem(), toSyphon);
|
||||
|
||||
if (drainAmount == 0 || event.shouldDamage)
|
||||
hurtPlayer(event.syphon);
|
||||
if (MinecraftForge.EVENT_BUS.post(event))
|
||||
return false;
|
||||
|
||||
return event.getResult() != Event.Result.DENY;
|
||||
int drainAmount = syphon(event.syphon);
|
||||
|
||||
if (drainAmount == 0 || event.shouldDamage)
|
||||
hurtPlayer(event.syphon);
|
||||
|
||||
return event.getResult() != Event.Result.DENY;
|
||||
}
|
||||
|
||||
int amount = syphon(toSyphon);
|
||||
hurtPlayer(toSyphon - amount);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
int amount = syphon(toSyphon);
|
||||
hurtPlayer(toSyphon - amount);
|
||||
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
public void hurtPlayer(int syphon) {
|
||||
getPlayer().addPotionEffect(new PotionEffect(Potion.confusion.getId(), 20));
|
||||
if (syphon < 100 && syphon > 0) {
|
||||
if (!getPlayer().capabilities.isCreativeMode) {
|
||||
getPlayer().setHealth((getPlayer().getHealth() - 1));
|
||||
public void hurtPlayer(float syphon) {
|
||||
if (getPlayer() != null) {
|
||||
getPlayer().addPotionEffect(new PotionEffect(Potion.confusion.getId(), 20));
|
||||
if (syphon < 100 && syphon > 0) {
|
||||
if (!getPlayer().capabilities.isCreativeMode) {
|
||||
getPlayer().hurtResistantTime = 0;
|
||||
getPlayer().attackEntityFrom(BloodMagicAPI.getDamageSource(), 1.0F);
|
||||
}
|
||||
|
||||
if (getPlayer().getHealth() <= 0.0005f)
|
||||
getPlayer().onDeath(BloodMagicAPI.getDamageSource());
|
||||
}
|
||||
} else if (syphon >= 100) {
|
||||
if (!getPlayer().capabilities.isCreativeMode) {
|
||||
for (int i = 0; i < ((syphon + 99) / 100); i++) {
|
||||
getPlayer().setHealth((getPlayer().getHealth() - 1));
|
||||
|
||||
if (getPlayer().getHealth() <= 0.0005f) {
|
||||
getPlayer().onDeath(BloodMagicAPI.getDamageSource());
|
||||
break;
|
||||
} else if (syphon >= 100) {
|
||||
if (!getPlayer().capabilities.isCreativeMode) {
|
||||
for (int i = 0; i < ((syphon + 99) / 100); i++) {
|
||||
getPlayer().hurtResistantTime = 0;
|
||||
getPlayer().attackEntityFrom(BloodMagicAPI.getDamageSource(), 1.0F);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,12 +1,15 @@
|
|||
package WayofTime.bloodmagic.item;
|
||||
|
||||
import WayofTime.bloodmagic.BloodMagic;
|
||||
import WayofTime.bloodmagic.api.BloodMagicAPI;
|
||||
import WayofTime.bloodmagic.api.Constants;
|
||||
import WayofTime.bloodmagic.api.DamageSourceBloodMagic;
|
||||
import WayofTime.bloodmagic.api.altar.IBloodAltar;
|
||||
import WayofTime.bloodmagic.api.event.SacrificeKnifeUsedEvent;
|
||||
import WayofTime.bloodmagic.api.util.helper.NBTHelper;
|
||||
import WayofTime.bloodmagic.api.util.helper.PlayerHelper;
|
||||
import WayofTime.bloodmagic.api.util.helper.PlayerSacrificeHelper;
|
||||
import WayofTime.bloodmagic.util.helper.TextHelper;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
|
@ -23,6 +26,7 @@ import net.minecraftforge.common.MinecraftForge;
|
|||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public class ItemSacrificialDagger extends Item {
|
||||
|
@ -52,28 +56,12 @@ public class ItemSacrificialDagger extends Item {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void addInformation(ItemStack stack, EntityPlayer par2EntityPlayer, List par3List, boolean par4) {
|
||||
// if (AlchemicalWizardry.wimpySettings)
|
||||
{
|
||||
// par3List.add(StatCollector.translateToLocal("tooltip.sacrificialdagger.desc1"));
|
||||
}
|
||||
// else
|
||||
{
|
||||
par3List.add(StatCollector.translateToLocal("tooltip.sacrificialdagger.desc2"));
|
||||
par3List.add(StatCollector.translateToLocal("tooltip.sacrificialdagger.desc3"));
|
||||
}
|
||||
public void addInformation(ItemStack stack, EntityPlayer player, List<String> list, boolean advanced) {
|
||||
list.addAll(Arrays.asList(TextHelper.cutLongString(TextHelper.localizeEffect("tooltip.BloodMagic.sacrificialDagger.desc"))));
|
||||
}
|
||||
|
||||
/**
|
||||
* called when the player releases the use item button. Args: itemstack, world, entityplayer, itemInUseCount
|
||||
*/
|
||||
@Override
|
||||
public void onPlayerStoppedUsing(ItemStack stack, World world, EntityPlayer player, int itemInUseCount) {
|
||||
// if(itemInUseCount < 32)
|
||||
// {
|
||||
// return;
|
||||
// }
|
||||
|
||||
PlayerSacrificeHelper.sacrificePlayerHealth(player);
|
||||
}
|
||||
|
||||
|
@ -82,9 +70,6 @@ public class ItemSacrificialDagger extends Item {
|
|||
return 72000;
|
||||
}
|
||||
|
||||
/**
|
||||
* returns the action that specifies what animation to play when the items is being used
|
||||
*/
|
||||
@Override
|
||||
public EnumAction getItemUseAction(ItemStack stack) {
|
||||
return EnumAction.BOW;
|
||||
|
@ -92,6 +77,10 @@ public class ItemSacrificialDagger extends Item {
|
|||
|
||||
@Override
|
||||
public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) {
|
||||
|
||||
if (PlayerHelper.isFakePlayer(player))
|
||||
return stack;
|
||||
|
||||
if (this.canUseForSacrifice(stack)) {
|
||||
player.setItemInUse(stack, this.getMaxItemUseDuration(stack));
|
||||
return stack;
|
||||
|
@ -99,21 +88,16 @@ public class ItemSacrificialDagger extends Item {
|
|||
|
||||
if (!player.capabilities.isCreativeMode) {
|
||||
SacrificeKnifeUsedEvent evt = new SacrificeKnifeUsedEvent(player, true, true, 2);
|
||||
if (MinecraftForge.EVENT_BUS.post(evt)) {
|
||||
if (MinecraftForge.EVENT_BUS.post(evt))
|
||||
return stack;
|
||||
}
|
||||
|
||||
if (evt.shouldDrainHealth) {
|
||||
player.setHealth(player.getHealth() - 2);
|
||||
player.hurtResistantTime = 0;
|
||||
player.attackEntityFrom(BloodMagicAPI.getDamageSource(), 2.0F);
|
||||
}
|
||||
|
||||
if (!evt.shouldFillAltar) {
|
||||
if (!evt.shouldFillAltar)
|
||||
return stack;
|
||||
}
|
||||
}
|
||||
|
||||
if (PlayerHelper.isFakePlayer(player)) {
|
||||
return stack;
|
||||
}
|
||||
|
||||
double posX = player.posX;
|
||||
|
@ -125,37 +109,24 @@ public class ItemSacrificialDagger extends Item {
|
|||
float f2 = f * f * 0.7F - 0.5F;
|
||||
float f3 = f * f * 0.6F - 0.7F;
|
||||
|
||||
for (int l = 0; l < 8; ++l) {
|
||||
for (int l = 0; l < 8; ++l)
|
||||
world.spawnParticle(EnumParticleTypes.REDSTONE, posX + Math.random() - Math.random(), posY + Math.random() - Math.random(), posZ + Math.random() - Math.random(), f1, f2, f3);
|
||||
}
|
||||
|
||||
if (!world.isRemote && PlayerHelper.isFakePlayer(player)) {
|
||||
if (!world.isRemote && PlayerHelper.isFakePlayer(player))
|
||||
return stack;
|
||||
}
|
||||
|
||||
// if (player.isPotionActive(AlchemicalWizardry.customPotionSoulFray))
|
||||
{
|
||||
// findAndFillAltar(world, player, 20);
|
||||
}
|
||||
// else
|
||||
{
|
||||
findAndFillAltar(world, player, 200);
|
||||
}
|
||||
|
||||
if (player.getHealth() <= 0.001f) {
|
||||
player.onDeath(new DamageSourceBloodMagic());
|
||||
}
|
||||
// TODO - Check if SoulFray is active
|
||||
findAndFillAltar(world, player, 200);
|
||||
|
||||
return stack;
|
||||
}
|
||||
|
||||
public void findAndFillAltar(World world, EntityPlayer player, int amount) {
|
||||
private void findAndFillAltar(World world, EntityPlayer player, int amount) {
|
||||
BlockPos pos = player.getPosition();
|
||||
IBloodAltar altarEntity = getAltar(world, pos);
|
||||
|
||||
if (altarEntity == null) {
|
||||
if (altarEntity == null)
|
||||
return;
|
||||
}
|
||||
|
||||
altarEntity.sacrificialDaggerCall(amount, false);
|
||||
altarEntity.startCycle();
|
||||
|
@ -182,18 +153,8 @@ public class ItemSacrificialDagger extends Item {
|
|||
|
||||
@Override
|
||||
public void onUpdate(ItemStack stack, World world, Entity entity, int par4, boolean par5) {
|
||||
if (!world.isRemote && entity instanceof EntityPlayer) {
|
||||
if (!world.isRemote && entity instanceof EntityPlayer)
|
||||
this.setUseForSacrifice(stack, this.isPlayerPreparedForSacrifice(world, (EntityPlayer) entity));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getItemStackDisplayName(ItemStack stack) {
|
||||
// if (AlchemicalWizardry.wimpySettings)
|
||||
{
|
||||
// return "Sacrificial Orb";
|
||||
}
|
||||
return super.getItemStackDisplayName(stack);
|
||||
}
|
||||
|
||||
public boolean isPlayerPreparedForSacrifice(World world, EntityPlayer player) {
|
||||
|
@ -201,19 +162,13 @@ public class ItemSacrificialDagger extends Item {
|
|||
}
|
||||
|
||||
public boolean canUseForSacrifice(ItemStack stack) {
|
||||
NBTTagCompound tag = stack.getTagCompound();
|
||||
|
||||
return tag != null && tag.getBoolean("sacrifice");
|
||||
stack = NBTHelper.checkNBT(stack);
|
||||
return stack.getTagCompound().getBoolean(Constants.NBT.SACRIFICE);
|
||||
}
|
||||
|
||||
public void setUseForSacrifice(ItemStack stack, boolean sacrifice) {
|
||||
NBTTagCompound tag = stack.getTagCompound();
|
||||
if (tag == null) {
|
||||
tag = new NBTTagCompound();
|
||||
stack.setTagCompound(tag);
|
||||
}
|
||||
|
||||
tag.setBoolean("sacrifice", sacrifice);
|
||||
stack = NBTHelper.checkNBT(stack);
|
||||
stack.getTagCompound().setBoolean(Constants.NBT.SACRIFICE, sacrifice);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -117,6 +117,8 @@ tooltip.BloodMagic.sigil.water.desc=&oInfinite water, anyone?
|
|||
tooltip.BloodMagic.sigil.lava.desc=&oHOT! DO NOT EAT
|
||||
tooltip.BloodMagic.sigil.void.desc=&oBetter than a Swiffer®!
|
||||
|
||||
tooltip.BloodMagic.sacrificialDagger.desc=Just a prick of the finger will suffice...
|
||||
|
||||
tooltip.BloodMagic.pack.selfSacrifice.desc=This pack really chafes...
|
||||
tooltip.BloodMagic.pack.sacrifice.desc=Description
|
||||
tooltip.BloodMagic.pack.stored=Stored: %d LP
|
||||
|
@ -129,6 +131,7 @@ tooltip.BloodMagic.activationCrystal.creative=Creative Only - Activates any ritu
|
|||
chat.BloodMagic.altarMaker.setTier=Set Tier to: %d
|
||||
chat.BloodMagic.altarMaker.building=Building a Tier %d Altar
|
||||
chat.BloodMagic.altarMaker.destroy=Destroyed a Tier %d Altar
|
||||
chat.BloodMagic.damageSource=%s's soul became too weak
|
||||
|
||||
# JustEnoughItems
|
||||
jei.BloodMagic.recipe.altar=Blood Altar
|
||||
|
|
Loading…
Reference in a new issue