本文整理汇总了Java中net.minecraft.entity.EntityLivingBase.getLookVec方法的典型用法代码示例。如果您正苦于以下问题:Java EntityLivingBase.getLookVec方法的具体用法?Java EntityLivingBase.getLookVec怎么用?Java EntityLivingBase.getLookVec使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.minecraft.entity.EntityLivingBase
的用法示例。
在下文中一共展示了EntityLivingBase.getLookVec方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onItemUseFinish
import net.minecraft.entity.EntityLivingBase; //导入方法依赖的package包/类
@Override
public ItemStack onItemUseFinish(ItemStack stack, World worldIn, EntityLivingBase entityLiving) {
Spell spell = getSpellFromItemStack(stack);
if (spell != null && !worldIn.isRemote) {
if (entityLiving instanceof EntityPlayer) {
int spellCost = spell.getCost() * 80;
Optional<IEnergy> eng = EnergyHandler.getEnergy((EntityPlayer) entityLiving);
if (eng.isPresent() && eng.get().get() < spellCost)
return stack;
EnergyHandler.addEnergy((EntityPlayer) entityLiving, -spellCost);
}
if (spell.getType() == EnumSpellType.INSTANT)
spell.performEffect(new RayTraceResult(Type.MISS, entityLiving.getLookVec(), EnumFacing.UP, entityLiving.getPosition()), entityLiving, worldIn);
else {
EntitySpellCarrier car = new EntitySpellCarrier(worldIn, entityLiving.posX + entityLiving.getLookVec().x, entityLiving.posY + entityLiving.getEyeHeight() + entityLiving.getLookVec().y, entityLiving.posZ + entityLiving.getLookVec().z);
car.setSpell(spell);
car.setCaster(entityLiving);
car.shoot(entityLiving, entityLiving.rotationPitch, entityLiving.rotationYaw, 0, 2f, 0);
worldIn.spawnEntity(car);
}
}
if (entityLiving instanceof EntityPlayer && ((EntityPlayer) entityLiving).isCreative()) return stack;
return ItemStack.EMPTY;
}
示例2: updateNoteLocation
import net.minecraft.entity.EntityLivingBase; //导入方法依赖的package包/类
public void updateNoteLocation()
{
if(noteLocationObject instanceof EntityLivingBase)
{
EntityLivingBase living = (EntityLivingBase)noteLocationObject;
Vec3d view = living.getLookVec();
this.xPosF = (float)(living.posX + view.x * 0.3D) + (float)living.motionX;
this.yPosF = (float)(living.posY + living.getEyeHeight() + view.y * 0.3D) + (float)living.motionY;
this.zPosF = (float)(living.posZ + view.z * 0.3D) + (float)living.motionZ;
}
else if(noteLocationObject instanceof BlockPos)
{
BlockPos pos = (BlockPos)noteLocationObject;
this.xPosF = pos.getX() + 0.5F;
this.yPosF = pos.getY() + 0.5F;
this.zPosF = pos.getZ() + 0.5F;
}
}
示例3: performEffect
import net.minecraft.entity.EntityLivingBase; //导入方法依赖的package包/类
@Override
public void performEffect(EntityLivingBase entityLivingBaseIn, int p_76394_2_){
if (!entityLivingBaseIn.world.isRemote){
EntityItem item = new EntityItem(entityLivingBaseIn.world, entityLivingBaseIn.posX + (entityLivingBaseIn.getLookVec().xCoord * 0.2F), entityLivingBaseIn.posY + entityLivingBaseIn.getEyeHeight() - 0.7F, entityLivingBaseIn.posZ + (entityLivingBaseIn.getLookVec().zCoord), new ItemStack(loot_table[(int) (Math.random() * loot_table.length)], 1));
item.setPickupDelay(15);
entityLivingBaseIn.world.spawnEntity(item);
}
}
示例4: acquireAllLookTargets
import net.minecraft.entity.EntityLivingBase; //导入方法依赖的package包/类
private List<EntityLivingBase> acquireAllLookTargets(EntityLivingBase seeker, int distance, double radius) {
if (distance < 0 || distance > MAX_DISTANCE) {
distance = MAX_DISTANCE;
}
List<EntityLivingBase> targets = new ArrayList<EntityLivingBase>();
Vec3d vec3 = seeker.getLookVec();
double targetX = seeker.posX;
double targetY = seeker.posY + seeker.getEyeHeight() - 0.10000000149011612D;
double targetZ = seeker.posZ;
double distanceTraveled = 0;
while ((int) distanceTraveled < distance) {
targetX += vec3.xCoord;
targetY += vec3.yCoord;
targetZ += vec3.zCoord;
distanceTraveled += vec3.lengthVector();
AxisAlignedBB bb = new AxisAlignedBB(targetX-radius, targetY-radius, targetZ-radius, targetX+radius, targetY+radius, targetZ+radius);
List<EntityLivingBase> list = seeker.worldObj.getEntitiesWithinAABB(EntityLivingBase.class, bb);
for (EntityLivingBase target : list) {
if (target != seeker && target.canBeCollidedWith() && isTargetInSight(vec3, seeker, target)) {
if (!targets.contains(target)) {
targets.add(target);
}
}
}
}
return targets;
}
示例5: getMouseOverServer
import net.minecraft.entity.EntityLivingBase; //导入方法依赖的package包/类
public static RayTraceResult getMouseOverServer(EntityLivingBase lookingEntity, double range) {
RayTraceResult mop = raytraceEntityBlocks(lookingEntity, range);
double d1 = range;
Pair<Vec3d, Vec3d> startAndEnd = getStartAndEndLookVec(lookingEntity, (float) range);
Vec3d vec3 = startAndEnd.getLeft();
if (mop != null) {
d1 = mop.hitVec.distanceTo(vec3);
}
Vec3d vec31 = lookingEntity.getLookVec();
Vec3d vec32 = startAndEnd.getRight();
Entity pointedEntity = null;
Vec3d vec33 = null;
float f1 = 1.0F;
List<Entity> list = lookingEntity.world.getEntitiesWithinAABBExcludingEntity(lookingEntity, lookingEntity.getEntityBoundingBox()
.grow(vec31.x * range, vec31.y * range, vec31.z * range).grow(f1, f1, f1));
double d2 = d1;
for (Entity entity : list) {
if (entity.canBeCollidedWith()) {
float f2 = entity.getCollisionBorderSize();
AxisAlignedBB axisalignedbb = entity.getEntityBoundingBox().grow(f2, f2, f2);
RayTraceResult movingobjectposition = axisalignedbb.calculateIntercept(vec3, vec32);
if (axisalignedbb.contains(vec3)) {
if (0.0D < d2 || d2 == 0.0D) {
pointedEntity = entity;
vec33 = movingobjectposition == null ? vec3 : movingobjectposition.hitVec;
d2 = 0.0D;
}
} else if (movingobjectposition != null) {
double d3 = vec3.distanceTo(movingobjectposition.hitVec);
if (d3 < d2 || d2 == 0.0D) {
if (entity == entity.getRidingEntity() && !entity.canRiderInteract()) {
if (d2 == 0.0D) {
pointedEntity = entity;
vec33 = movingobjectposition.hitVec;
}
} else {
pointedEntity = entity;
vec33 = movingobjectposition.hitVec;
d2 = d3;
}
}
}
}
}
if (pointedEntity != null && (d2 < d1 || mop == null)) {
mop = new RayTraceResult(pointedEntity, vec33);
}
return mop;
}