2017-11-28 05:02:38 +01:00
|
|
|
package com.legacy.aether.items.weapons;
|
2016-12-17 16:28:16 +01:00
|
|
|
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
import net.minecraft.entity.Entity;
|
|
|
|
import net.minecraft.entity.EntityLivingBase;
|
|
|
|
import net.minecraft.entity.player.EntityPlayer;
|
2018-12-07 05:33:43 +01:00
|
|
|
import net.minecraft.item.EnumAction;
|
2017-07-07 03:07:09 +02:00
|
|
|
import net.minecraft.item.EnumRarity;
|
2016-12-17 16:28:16 +01:00
|
|
|
import net.minecraft.item.ItemStack;
|
|
|
|
import net.minecraft.item.ItemSword;
|
2018-12-07 05:33:43 +01:00
|
|
|
import net.minecraft.util.AxisAlignedBB;
|
|
|
|
import net.minecraft.util.Vec3;
|
2016-12-17 16:28:16 +01:00
|
|
|
|
2017-11-28 05:02:38 +01:00
|
|
|
import com.legacy.aether.items.ItemsAether;
|
|
|
|
import com.legacy.aether.registry.creative_tabs.AetherCreativeTabs;
|
2016-12-17 16:28:16 +01:00
|
|
|
|
|
|
|
public class ItemValkyrieLance extends ItemSword
|
|
|
|
{
|
|
|
|
|
|
|
|
public ItemValkyrieLance()
|
|
|
|
{
|
2018-12-07 05:33:43 +01:00
|
|
|
super(ToolMaterial.EMERALD);
|
2016-12-17 16:28:16 +01:00
|
|
|
|
|
|
|
this.setCreativeTab(AetherCreativeTabs.weapons);
|
|
|
|
}
|
|
|
|
|
2018-12-07 05:33:43 +01:00
|
|
|
@Override
|
|
|
|
public EnumAction getItemUseAction(ItemStack stack)
|
|
|
|
{
|
|
|
|
return EnumAction.none;
|
|
|
|
}
|
|
|
|
|
2017-07-07 03:07:09 +02:00
|
|
|
@Override
|
|
|
|
public EnumRarity getRarity(ItemStack stack)
|
|
|
|
{
|
|
|
|
return ItemsAether.aether_loot;
|
|
|
|
}
|
|
|
|
|
2016-12-17 16:28:16 +01:00
|
|
|
@Override
|
2018-12-07 05:33:43 +01:00
|
|
|
@SuppressWarnings("unchecked")
|
2016-12-17 16:28:16 +01:00
|
|
|
public boolean onEntitySwing(EntityLivingBase entityLiving, ItemStack stack)
|
|
|
|
{
|
|
|
|
if (!(entityLiving instanceof EntityPlayer))
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
EntityPlayer player = (EntityPlayer) entityLiving;
|
|
|
|
|
2018-12-07 05:33:43 +01:00
|
|
|
Vec3 playerVision = player.getLookVec();
|
|
|
|
AxisAlignedBB reachDistance = player.boundingBox.expand(10.0D, 10.0D, 10.0D);
|
2016-12-17 16:28:16 +01:00
|
|
|
|
|
|
|
List<Entity> locatedEntities = player.worldObj.getEntitiesWithinAABB(Entity.class, reachDistance);
|
|
|
|
|
|
|
|
Entity found = null;
|
|
|
|
double foundLen = 0.0D;
|
|
|
|
|
|
|
|
for (Object o : locatedEntities)
|
|
|
|
{
|
|
|
|
if (o == player)
|
|
|
|
{
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
Entity ent = (Entity) o;
|
|
|
|
|
|
|
|
if (!ent.canBeCollidedWith())
|
|
|
|
{
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2018-12-07 05:33:43 +01:00
|
|
|
Vec3 vec = Vec3.createVectorHelper(ent.posX - player.posX, ent.boundingBox.minY + ent.height / 2f - player.posY - player.getEyeHeight(), ent.posZ - player.posZ);
|
2016-12-17 16:28:16 +01:00
|
|
|
double len = vec.lengthVector();
|
|
|
|
|
|
|
|
if (len > 10.0F)
|
|
|
|
{
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
vec = vec.normalize();
|
|
|
|
double dot = playerVision.dotProduct(vec);
|
|
|
|
|
|
|
|
if (dot < 1.0 - 0.125 / len || !player.canEntityBeSeen(ent))
|
|
|
|
{
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (foundLen == 0.0 || len < foundLen)
|
|
|
|
{
|
|
|
|
found = ent;
|
|
|
|
foundLen = len;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-12-07 05:33:43 +01:00
|
|
|
if (found != null && player.ridingEntity != found)
|
2016-12-17 16:28:16 +01:00
|
|
|
{
|
|
|
|
stack.damageItem(1, player);
|
|
|
|
|
|
|
|
player.attackTargetEntityWithCurrentItem(found);
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean getIsRepairable(ItemStack repairingItem, ItemStack material)
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|