
The new one is now built for the api jar and the old one is now internal. It will slowly be moved around to sane places within the internal code. Most of the features provided in the old "api" are addon specific features which will generally rely on the main jar anyways. The new API will be specific to compatibility features, such as blacklists, recipes, and value modification.
66 lines
2.3 KiB
Java
66 lines
2.3 KiB
Java
package WayofTime.bloodmagic.entity.projectile;
|
|
|
|
import WayofTime.bloodmagic.apibutnotreally.Constants;
|
|
import WayofTime.bloodmagic.apibutnotreally.soul.EnumDemonWillType;
|
|
import WayofTime.bloodmagic.apibutnotreally.soul.PlayerDemonWillHandler;
|
|
import net.minecraft.entity.EntityLivingBase;
|
|
import net.minecraft.entity.monster.IMob;
|
|
import net.minecraft.entity.player.EntityPlayer;
|
|
import net.minecraft.entity.projectile.EntityTippedArrow;
|
|
import net.minecraft.init.Items;
|
|
import net.minecraft.item.ItemStack;
|
|
import net.minecraft.nbt.NBTTagCompound;
|
|
import net.minecraft.world.EnumDifficulty;
|
|
import net.minecraft.world.World;
|
|
|
|
import java.util.Locale;
|
|
|
|
public class EntitySentientArrow extends EntityTippedArrow {
|
|
public double reimbursedAmountOnHit = 0;
|
|
public EnumDemonWillType type = EnumDemonWillType.DEFAULT;
|
|
|
|
public EntitySentientArrow(World worldIn) {
|
|
super(worldIn);
|
|
}
|
|
|
|
public EntitySentientArrow(World worldIn, double x, double y, double z) {
|
|
super(worldIn, x, y, z);
|
|
}
|
|
|
|
public EntitySentientArrow(World worldIn, EntityLivingBase shooter, EnumDemonWillType type, double reinburseAmount) {
|
|
super(worldIn, shooter);
|
|
this.reimbursedAmountOnHit = reinburseAmount;
|
|
this.type = type;
|
|
}
|
|
|
|
public void reimbursePlayer(EntityLivingBase hitEntity, float damage) {
|
|
if (this.shootingEntity instanceof EntityPlayer) {
|
|
if (hitEntity.getEntityWorld().getDifficulty() != EnumDifficulty.PEACEFUL && !(hitEntity instanceof IMob)) {
|
|
return;
|
|
}
|
|
|
|
PlayerDemonWillHandler.addDemonWill(type, (EntityPlayer) this.shootingEntity, reimbursedAmountOnHit * damage / 20f);
|
|
}
|
|
}
|
|
|
|
@Override
|
|
public void writeEntityToNBT(NBTTagCompound tag) {
|
|
super.writeEntityToNBT(tag);
|
|
|
|
tag.setDouble("reimbursement", reimbursedAmountOnHit);
|
|
tag.setString(Constants.NBT.WILL_TYPE, type.toString());
|
|
}
|
|
|
|
@Override
|
|
public void readEntityFromNBT(NBTTagCompound tag) {
|
|
super.readEntityFromNBT(tag);
|
|
|
|
reimbursedAmountOnHit = tag.getDouble("reimbursement");
|
|
type = EnumDemonWillType.valueOf(tag.getString(Constants.NBT.WILL_TYPE).toUpperCase(Locale.ENGLISH));
|
|
}
|
|
|
|
@Override
|
|
protected ItemStack getArrowStack() {
|
|
return new ItemStack(Items.ARROW);
|
|
}
|
|
}
|