BloodMagic/src/main/java/WayofTime/bloodmagic/entity/projectile/EntitySentientArrow.java

63 lines
1.7 KiB
Java
Raw Normal View History

package WayofTime.bloodmagic.entity.projectile;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.projectile.EntityArrow;
2016-03-18 16:57:57 -04:00
import net.minecraft.init.Items;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.world.World;
2016-03-18 16:57:57 -04:00
import WayofTime.bloodmagic.api.soul.EnumDemonWillType;
import WayofTime.bloodmagic.api.soul.PlayerDemonWillHandler;
public class EntitySentientArrow extends EntityArrow
{
public double reimbursedAmountOnHit = 0;
public EntitySentientArrow(World worldIn)
{
super(worldIn);
}
public EntitySentientArrow(World worldIn, double x, double y, double z)
{
super(worldIn, x, y, z);
}
2016-03-18 16:57:57 -04:00
public EntitySentientArrow(World worldIn, EntityLivingBase shooter, double reimbursement)
{
2016-03-18 16:57:57 -04:00
this(worldIn, shooter.posX, shooter.posY, shooter.posZ);
this.reimbursedAmountOnHit = reimbursement;
}
public void reimbursePlayer()
{
if (this.shootingEntity instanceof EntityPlayer)
{
PlayerDemonWillHandler.addDemonWill(EnumDemonWillType.DEFAULT, (EntityPlayer) this.shootingEntity, reimbursedAmountOnHit);
}
}
@Override
public void writeEntityToNBT(NBTTagCompound tag)
{
super.writeEntityToNBT(tag);
tag.setDouble("reimbursement", reimbursedAmountOnHit);
}
@Override
public void readEntityFromNBT(NBTTagCompound tag)
{
super.readEntityFromNBT(tag);
reimbursedAmountOnHit = tag.getDouble("reimbursement");
}
2016-03-18 16:57:57 -04:00
@Override
protected ItemStack getArrowStack()
{
return new ItemStack(Items.arrow);
}
}