BloodMagic/src/main/java/WayofTime/bloodmagic/item/sigil/ItemSigilAir.java

68 lines
2.5 KiB
Java
Raw Normal View History

2015-11-02 19:57:48 -08:00
package WayofTime.bloodmagic.item.sigil;
import net.minecraft.entity.EntityLivingBase;
2015-11-02 19:57:48 -08:00
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.MobEffects;
2016-03-18 14:54:31 -04:00
import net.minecraft.init.SoundEvents;
2015-11-02 19:57:48 -08:00
import net.minecraft.item.ItemStack;
import net.minecraft.potion.PotionEffect;
2016-03-18 14:54:31 -04:00
import net.minecraft.util.ActionResult;
import net.minecraft.util.EnumHand;
import net.minecraft.util.SoundCategory;
import net.minecraft.util.math.Vec3d;
2015-11-02 19:57:48 -08:00
import net.minecraft.world.World;
import WayofTime.bloodmagic.api.iface.ISentientSwordEffectProvider;
import WayofTime.bloodmagic.api.soul.EnumDemonWillType;
import WayofTime.bloodmagic.api.util.helper.NetworkHelper;
2015-11-02 19:57:48 -08:00
public class ItemSigilAir extends ItemSigilBase implements ISentientSwordEffectProvider
{
public ItemSigilAir()
{
2015-11-02 19:57:48 -08:00
super("air", 50);
}
@Override
2016-03-18 14:54:31 -04:00
public ActionResult<ItemStack> onItemRightClick(ItemStack stack, World world, EntityPlayer player, EnumHand hand)
{
if (!world.isRemote && !isUnusable(stack))
{
2016-03-18 14:54:31 -04:00
Vec3d vec = player.getLookVec();
2015-11-02 19:57:48 -08:00
double wantedVelocity = 1.7;
// TODO - Revisit after potions
// if (player.isPotionActive(ModPotions.customPotionBoost)) {
// int amplifier =
// player.getActivePotionEffect(ModPotions.customPotionBoost).getAmplifier();
// wantedVelocity += (1 + amplifier) * (0.35);
// }
2015-11-02 19:57:48 -08:00
player.motionX = vec.xCoord * wantedVelocity;
player.motionY = vec.yCoord * wantedVelocity;
player.motionZ = vec.zCoord * wantedVelocity;
player.velocityChanged = true;
2016-04-24 10:06:28 -07:00
world.playSound(null, player.posX, player.posY, player.posZ, SoundEvents.BLOCK_FIRE_EXTINGUISH, SoundCategory.BLOCKS, 0.5F, 2.6F + (world.rand.nextFloat() - world.rand.nextFloat()) * 0.8F);
2016-03-18 14:54:31 -04:00
2015-11-02 19:57:48 -08:00
player.fallDistance = 0;
if (!player.capabilities.isCreativeMode)
this.setUnusable(stack, !NetworkHelper.getSoulNetwork(player).syphonAndDamage(player, getLpUsed()));
2015-11-02 19:57:48 -08:00
}
2016-03-18 14:54:31 -04:00
return super.onItemRightClick(stack, world, player, hand);
2015-11-02 19:57:48 -08:00
}
@Override
public boolean applyOnHitEffect(EnumDemonWillType type, ItemStack swordStack, ItemStack providerStack, EntityLivingBase attacker, EntityLivingBase target)
{
2016-04-24 10:06:28 -07:00
target.addPotionEffect(new PotionEffect(MobEffects.LEVITATION, 200, 0));
return true;
}
@Override
public boolean providesEffectForWill(EnumDemonWillType type)
{
2016-03-31 21:11:58 -04:00
return false;
}
2015-11-02 19:57:48 -08:00
}