2016-01-08 22:20:31 -05:00
|
|
|
package WayofTime.bloodmagic.entity.projectile;
|
|
|
|
|
2018-03-29 16:05:56 -04:00
|
|
|
import java.util.Locale;
|
|
|
|
|
2016-01-08 22:20:31 -05:00
|
|
|
import net.minecraft.entity.EntityLivingBase;
|
2016-06-12 12:42:32 -04:00
|
|
|
import net.minecraft.entity.monster.IMob;
|
2016-01-08 22:20:31 -05:00
|
|
|
import net.minecraft.entity.player.EntityPlayer;
|
2016-04-09 17:57:30 -04:00
|
|
|
import net.minecraft.entity.projectile.EntityTippedArrow;
|
2016-03-18 16:57:57 -04:00
|
|
|
import net.minecraft.init.Items;
|
2018-03-29 16:05:56 -04:00
|
|
|
import net.minecraft.init.MobEffects;
|
2016-03-18 16:57:57 -04:00
|
|
|
import net.minecraft.item.ItemStack;
|
2016-01-08 22:20:31 -05:00
|
|
|
import net.minecraft.nbt.NBTTagCompound;
|
2018-03-29 16:05:56 -04:00
|
|
|
import net.minecraft.potion.PotionEffect;
|
2016-06-12 12:42:32 -04:00
|
|
|
import net.minecraft.world.EnumDifficulty;
|
2016-01-08 22:20:31 -05:00
|
|
|
import net.minecraft.world.World;
|
2018-03-29 16:05:56 -04:00
|
|
|
import WayofTime.bloodmagic.soul.EnumDemonWillType;
|
|
|
|
import WayofTime.bloodmagic.soul.PlayerDemonWillHandler;
|
|
|
|
import WayofTime.bloodmagic.util.Constants;
|
2016-01-08 22:20:31 -05:00
|
|
|
|
2018-03-29 16:05:56 -04:00
|
|
|
public class EntitySentientArrow extends EntityTippedArrow
|
|
|
|
{
|
2016-01-08 22:20:31 -05:00
|
|
|
public double reimbursedAmountOnHit = 0;
|
2016-04-09 15:35:02 -04:00
|
|
|
public EnumDemonWillType type = EnumDemonWillType.DEFAULT;
|
2018-03-29 16:05:56 -04:00
|
|
|
public int currentLevel = 0;
|
|
|
|
public float[] destructiveExplosionRadius = { 0.5f, 1, 1.5f, 2, 2.5f, 3, 3.5f };
|
|
|
|
public int[] poisonDuration = { 50, 100, 150, 80, 120, 160, 200 };
|
|
|
|
public int[] poisonLevel = { 0, 0, 0, 1, 1, 1, 1 };
|
|
|
|
public int[] levitationDuration = { 20, 40, 60, 80, 100, 120, 160 };
|
|
|
|
public int[] levitationLevel = { 0, 0, 0, 1, 1, 1, 2 };
|
|
|
|
public int[] slownessDuration = { 40, 60, 100, 150, 200, 250, 300 };
|
|
|
|
public int[] slownessLevel = { 0, 0, 0, 1, 1, 1, 2 };
|
2016-01-08 22:20:31 -05:00
|
|
|
|
2018-03-29 16:05:56 -04:00
|
|
|
public EntitySentientArrow(World worldIn)
|
|
|
|
{
|
2016-01-08 22:20:31 -05:00
|
|
|
super(worldIn);
|
|
|
|
}
|
|
|
|
|
2018-03-29 16:05:56 -04:00
|
|
|
public EntitySentientArrow(World worldIn, double x, double y, double z)
|
|
|
|
{
|
2016-01-08 22:20:31 -05:00
|
|
|
super(worldIn, x, y, z);
|
|
|
|
}
|
|
|
|
|
2018-03-29 16:05:56 -04:00
|
|
|
public EntitySentientArrow(World worldIn, EntityLivingBase shooter, EnumDemonWillType type, double reinburseAmount, int currentLevel)
|
|
|
|
{
|
2016-04-09 15:35:02 -04:00
|
|
|
super(worldIn, shooter);
|
2016-06-12 12:42:32 -04:00
|
|
|
this.reimbursedAmountOnHit = reinburseAmount;
|
2016-04-09 15:35:02 -04:00
|
|
|
this.type = type;
|
2018-03-29 16:05:56 -04:00
|
|
|
this.currentLevel = currentLevel;
|
2016-01-08 22:20:31 -05:00
|
|
|
}
|
|
|
|
|
2018-03-29 16:05:56 -04:00
|
|
|
public void reimbursePlayer(EntityLivingBase hitEntity, float damage)
|
|
|
|
{
|
|
|
|
if (this.shootingEntity instanceof EntityPlayer)
|
|
|
|
{
|
|
|
|
if (hitEntity.getEntityWorld().getDifficulty() != EnumDifficulty.PEACEFUL && !(hitEntity instanceof IMob))
|
|
|
|
{
|
2016-06-12 12:42:32 -04:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
PlayerDemonWillHandler.addDemonWill(type, (EntityPlayer) this.shootingEntity, reimbursedAmountOnHit * damage / 20f);
|
2016-01-08 22:20:31 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2018-03-29 16:05:56 -04:00
|
|
|
protected void arrowHit(EntityLivingBase living)
|
|
|
|
{
|
|
|
|
super.arrowHit(living);
|
|
|
|
|
|
|
|
switch (type)
|
|
|
|
{
|
|
|
|
case CORROSIVE:
|
|
|
|
living.addPotionEffect(new PotionEffect(MobEffects.POISON, currentLevel >= 0 ? poisonDuration[currentLevel] : 0, currentLevel >= 0 ? poisonLevel[currentLevel] : 0));
|
|
|
|
break;
|
|
|
|
case DEFAULT:
|
|
|
|
break;
|
|
|
|
case DESTRUCTIVE:
|
|
|
|
this.world.createExplosion(this, this.posX, this.posY, this.posZ, currentLevel >= 0 ? destructiveExplosionRadius[currentLevel] : 0, false);
|
|
|
|
break;
|
|
|
|
case STEADFAST:
|
|
|
|
living.addPotionEffect(new PotionEffect(MobEffects.LEVITATION, currentLevel >= 0 ? levitationDuration[currentLevel] : 0, currentLevel >= 0 ? levitationLevel[currentLevel] : 0));
|
|
|
|
break;
|
|
|
|
case VENGEFUL:
|
|
|
|
living.addPotionEffect(new PotionEffect(MobEffects.SLOWNESS, currentLevel >= 0 ? slownessDuration[currentLevel] : 0, currentLevel >= 0 ? slownessLevel[currentLevel] : 0));
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onUpdate()
|
|
|
|
{
|
|
|
|
super.onUpdate();
|
|
|
|
|
|
|
|
if (!this.world.isRemote && this.inGround && this.timeInGround > 0)
|
|
|
|
{
|
|
|
|
switch (type)
|
|
|
|
{
|
|
|
|
case DESTRUCTIVE:
|
|
|
|
this.world.createExplosion(this, this.posX, this.posY, this.posZ, currentLevel >= 0 ? destructiveExplosionRadius[currentLevel] : 0, false);
|
|
|
|
this.setDead();
|
|
|
|
break;
|
|
|
|
case CORROSIVE:
|
|
|
|
break;
|
|
|
|
case DEFAULT:
|
|
|
|
break;
|
|
|
|
case STEADFAST:
|
|
|
|
break;
|
|
|
|
case VENGEFUL:
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// else if (this.inGround && this.timeInGround != 0 && !this.customPotionEffects.isEmpty() && this.timeInGround >= 600)
|
|
|
|
// {
|
|
|
|
// this.world.setEntityState(this, (byte)0);
|
|
|
|
// this.potion = PotionTypes.EMPTY;
|
|
|
|
// this.customPotionEffects.clear();
|
|
|
|
// this.dataManager.set(COLOR, Integer.valueOf(-1));
|
|
|
|
// }
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void writeEntityToNBT(NBTTagCompound tag)
|
|
|
|
{
|
2016-01-08 22:20:31 -05:00
|
|
|
super.writeEntityToNBT(tag);
|
|
|
|
|
|
|
|
tag.setDouble("reimbursement", reimbursedAmountOnHit);
|
2018-03-29 16:05:56 -04:00
|
|
|
tag.setInteger("currentLevel", currentLevel);
|
2016-04-09 15:35:02 -04:00
|
|
|
tag.setString(Constants.NBT.WILL_TYPE, type.toString());
|
2016-01-08 22:20:31 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2018-03-29 16:05:56 -04:00
|
|
|
public void readEntityFromNBT(NBTTagCompound tag)
|
|
|
|
{
|
2016-01-08 22:20:31 -05:00
|
|
|
super.readEntityFromNBT(tag);
|
|
|
|
|
|
|
|
reimbursedAmountOnHit = tag.getDouble("reimbursement");
|
2016-10-18 16:59:50 -07:00
|
|
|
type = EnumDemonWillType.valueOf(tag.getString(Constants.NBT.WILL_TYPE).toUpperCase(Locale.ENGLISH));
|
2018-03-29 16:05:56 -04:00
|
|
|
currentLevel = tag.getInteger("currentLevel");
|
2016-01-08 22:20:31 -05:00
|
|
|
}
|
2016-03-18 16:57:57 -04:00
|
|
|
|
|
|
|
@Override
|
2018-03-29 16:05:56 -04:00
|
|
|
protected ItemStack getArrowStack()
|
|
|
|
{
|
2016-04-24 10:06:28 -07:00
|
|
|
return new ItemStack(Items.ARROW);
|
2016-03-18 16:57:57 -04:00
|
|
|
}
|
2016-01-08 22:20:31 -05:00
|
|
|
}
|