本文整理了Java中net.minecraft.entity.Entity.getPositionVector()
方法的一些代码示例,展示了Entity.getPositionVector()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Entity.getPositionVector()
方法的具体详情如下:
包路径:net.minecraft.entity.Entity
类名称:Entity
方法名:getPositionVector
暂无
代码示例来源:origin: SquidDev-CC/plethora
@Nonnull
@Override
public Vec3d getPositionVector() {
return entity.getPositionVector();
}
代码示例来源:origin: Darkhax-Minecraft/Bookshelf
/**
* Calculates the distance between two entities.
*
* @param firstEntity The first entity to use.
* @param secondEntity The second entity to use.
* @return double The distance between the two entities passed.
*/
public static double getDistanceFromEntity (Entity firstEntity, Entity secondEntity) {
return MathsUtils.getDistanceBetweenPoints(firstEntity.getPositionVector(), secondEntity.getPositionVector());
}
代码示例来源:origin: SquidDev-CC/plethora
@Nonnull
@Override
public Vec3d getLoc() {
return pocket.getEntity().getPositionVector();
}
代码示例来源:origin: OpenMods/OpenModsLib
public static Vec3d getPredictedPosition(Entity entity) {
return entity.getPositionVector().addVector(
entity.motionX,
entity.motionY,
entity.motionZ);
}
代码示例来源:origin: SquidDev-CC/plethora
@Override
public void update(@Nonnull IVehicleAccess vehicle, @Nonnull IPeripheral peripheral) {
Entity entity = vehicle.getVehicle();
update(entity.getEntityWorld(), entity.getPositionVector());
}
代码示例来源:origin: TeamWizardry/Wizardry
@Override
@SideOnly(Side.CLIENT)
public void runIfClient() {
LibParticles.AIR_THROTTLE(world, entity.getPositionVector(), normal, color1, color2, 0.5);
}
});
代码示例来源:origin: TeamWizardry/Wizardry
@Override
@SideOnly(Side.CLIENT)
public void runIfClient() {
LibParticles.FIZZING_EXPLOSION(entityIn.world, entityIn.getPositionVector());
}
});
代码示例来源:origin: OpenMods/OpenModsLib
public static RayTraceResult raytraceEntity(Entity entity) {
if (entity == null || entity.world == null) { return null; }
return entity.world.rayTraceBlocks(
entity.getPositionVector(),
getPredictedPosition(entity),
false,
true,
false);
}
代码示例来源:origin: Darkhax-Minecraft/Bookshelf
/**
* Calculates the distance between an entity and a BlockPos.
*
* @param entity The Entity to use for the first position.
* @param pos The BlockPos to use for the second position.
* @return double The distance between the Entity and the BlockPos.
*/
public static double getDistaceFromPos (Entity entity, BlockPos pos) {
return MathsUtils.getDistanceBetweenPoints(entity.getPositionVector(), new Vec3d(pos));
}
代码示例来源:origin: TeamWizardry/Wizardry
@Nullable
public Vec3d getOrigin() {
Vec3d origin = getData(DefaultKeys.ORIGIN);
if (origin == null) {
Entity caster = getData(DefaultKeys.CASTER);
if (caster == null) {
return null;
} else return caster.getPositionVector().add(0, caster.height / 2.0, 0);
} else return origin;
}
代码示例来源:origin: TeamWizardry/Wizardry
public void addEntity(Vec3d origin, Entity target, Entity caster, double potency, double duration) {
double dist = target.getPositionVector().subtract(origin).length();
int numPoints = (int) (dist * LightningGenerator.POINTS_PER_DIST);
newEntries.add(new TrackingEntry(numPoints, potency, duration, caster, target));
}
代码示例来源:origin: SquidDev-CC/plethora
@Override
public void update(@Nonnull IVehicleAccess vehicle, @Nonnull IPeripheral peripheral) {
Entity entity = vehicle.getVehicle();
update(entity.getEntityWorld(), entity.getPositionVector());
if (peripheral instanceof ModemPeripheral) {
ModemPeripheral modem = (ModemPeripheral) peripheral;
if (modem.pollChanged()) {
vehicle.getData().setBoolean("active", modem.isActive());
vehicle.markDataDirty();
}
}
}
代码示例来源:origin: TeamWizardry/Wizardry
@Nullable
public Vec3d getTarget() {
Vec3d target = getData(DefaultKeys.TARGET_HIT);
if (target == null) {
BlockPos pos = getData(BLOCK_HIT);
if (pos == null) {
Entity victim = getData(DefaultKeys.ENTITY_HIT);
if (victim == null) {
return null;
} else return victim.getPositionVector().add(0, victim.height / 2.0, 0);
} else return new Vec3d(pos).add(0.5, 0.5, 0.5);
}
return target;
}
代码示例来源:origin: SquidDev-CC/plethora
@Nonnull
@Override
public T get() throws LuaException {
T entity = super.get();
if (entity.getEntityWorld() != location.getWorld()) throw new LuaException("The entity has gone");
Vec3d pos = entity.getPositionVector().subtract(location.getLoc());
if (
pos.x < -radius || pos.x > radius ||
pos.y < -radius || pos.y > radius ||
pos.z < -radius || pos.z > radius
) {
valid = false;
throw new LuaException("The entity is out of range");
}
valid = true;
return entity;
}
代码示例来源:origin: TeamWizardry/Wizardry
public void processEntity(@Nonnull Entity entity, boolean asCaster) {
if (asCaster) {
addData(DefaultKeys.ORIGIN, entity.getPositionVector().add(0, entity.getEyeHeight(), 0));
addData(DefaultKeys.CASTER, entity);
addData(DefaultKeys.YAW, entity.rotationYaw);
addData(DefaultKeys.PITCH, entity.rotationPitch);
addData(DefaultKeys.LOOK, entity.getLook(0));
addData(DefaultKeys.CAPABILITY, WizardryCapabilityProvider.getCap(entity));
} else {
addData(DefaultKeys.TARGET_HIT, entity.getPositionVector().add(0, entity.height / 2.0, 0));
addData(DefaultKeys.BLOCK_HIT, entity.getPosition());
addData(DefaultKeys.ENTITY_HIT, entity);
}
}
代码示例来源:origin: TeamWizardry/Wizardry
@Override
@SideOnly(Side.CLIENT)
public void renderSpell(ModuleInstanceEffect instance, @Nonnull SpellData spell, @Nonnull SpellRing spellRing) {
World world = spell.world;
Entity target = spell.getVictim();
if (!(target instanceof EntityLivingBase)) return;
if (!((EntityLivingBase) target).isPotionActive(ModPotions.GRACE)) return;
ParticleBuilder glitter = new ParticleBuilder(30);
glitter.setColorFunction(new InterpColorHSV(instance.getPrimaryColor(), instance.getSecondaryColor()));
glitter.setRender(new ResourceLocation(Wizardry.MODID, Constants.MISC.SPARKLE_BLURRED));
glitter.disableRandom();
ParticleSpawner.spawn(glitter, world, new InterpCircle(target.getPositionVector().add(0, target.height / 2.0, 0), new Vec3d(Math.cos(world.getTotalWorldTime() / 10.0), 1, Math.cos(world.getTotalWorldTime() / 10.0)), 2), 15, 0, (aFloat, particleBuilder) -> {
particleBuilder.setLifetime(RandUtil.nextInt(20, 25));
particleBuilder.setScaleFunction(new InterpScale(RandUtil.nextFloat(1f, 1.5f), 0f));
particleBuilder.setAlphaFunction(new InterpFloatInOut(aFloat, aFloat));
});
}
代码示例来源:origin: TeamWizardry/Wizardry
public static void boom(World world, Vec3d pos, @Nullable Entity excluded, double scale, boolean reverseDirection) {
List<Entity> entityList = world.getEntitiesWithinAABBExcludingEntity(excluded, new AxisAlignedBB(new BlockPos(pos)).grow(32, 32, 32));
for (Entity entity1 : entityList) {
double x = entity1.getDistance(pos.x, pos.y, pos.z) / 32.0;
double magY;
if (reverseDirection) magY = x;
else magY = -x + 1;
Vec3d dir = entity1.getPositionVector().subtract(pos).normalize().scale(reverseDirection ? -1 : 1).scale(magY).scale(scale);
entity1.motionX += (dir.x);
entity1.motionY += (dir.y);
entity1.motionZ += (dir.z);
entity1.fallDistance = 0;
entity1.velocityChanged = true;
if (entity1 instanceof EntityPlayerMP)
((EntityPlayerMP) entity1).connection.sendPacket(new SPacketEntityVelocity(entity1));
}
}
}
代码示例来源:origin: cabaletta/baritone
private Goal towards(Entity following) {
BlockPos pos;
if (Baritone.settings().followOffsetDistance.get() == 0) {
pos = new BlockPos(following);
} else {
GoalXZ g = GoalXZ.fromDirection(following.getPositionVector(), Baritone.settings().followOffsetDirection.get(), Baritone.settings().followOffsetDistance.get());
pos = new BlockPos(g.getX(), following.posY, g.getZ());
}
return new GoalNear(pos, Baritone.settings().followRadius.get());
}
代码示例来源:origin: ForestryMC/ForestryMC
private static void addSmoke(ItemStack stack, World world, Entity entity, int distance) {
if (distance <= 0) {
return;
}
Vec3d look = entity.getLookVec();
EnumHandSide handSide = getHandSide(stack, entity);
Vec3d handOffset;
if (handSide == EnumHandSide.RIGHT) {
handOffset = look.crossProduct(new Vec3d(0, 1, 0));
} else {
handOffset = look.crossProduct(new Vec3d(0, -1, 0));
}
Vec3d lookDistance = new Vec3d(look.x * distance, look.y * distance, look.z * distance);
Vec3d scaledOffset = handOffset.scale(1.0 / distance);
Vec3d smokePos = lookDistance.add(entity.getPositionVector()).add(scaledOffset);
if (world.isRemote) {
ParticleRender.addEntitySmokeFX(world, smokePos.x, smokePos.y + 1, smokePos.z);
}
BlockPos blockPos = new BlockPos(smokePos.x, smokePos.y + 1, smokePos.z);
TileUtil.actOnTile(world, blockPos, IHiveTile.class, IHiveTile::calmBees);
}
代码示例来源:origin: MatterOverdrive/MatterOverdrive-Legacy-Edition
@Override
public void onAndroidUpdate(AndroidPlayer android, int level) {
if (isActive(android, level)) {
if (!android.getPlayer().world.isRemote && !android.getPlayer().isDead) {
for (Entity entityitem : android.getPlayer().world.getEntitiesWithinAABBExcludingEntity(android.getPlayer(), android.getPlayer().getEntityBoundingBox().grow(10.0D, 5.0D, 10.0D))) {
if (entityitem instanceof EntityItem) {
if (!((EntityItem) entityitem).cannotPickup()) {
Vec3d dir = android.getPlayer().getPositionVector().addVector(0, android.getPlayer().getEyeHeight(), 0).subtract(entityitem.getPositionVector()).normalize();
entityitem.addVelocity(dir.x * ITEM_SPEED, dir.y * ITEM_SPEED, dir.z * ITEM_SPEED);
android.extractEnergyScaled(ENERGY_PULL_PER_ITEM);
}
} else if (entityitem instanceof EntityXPOrb && ((EntityXPOrb) entityitem).delayBeforeCanPickup <= 0 && android.getPlayer().xpCooldown == 0) {
Vec3d dir = android.getPlayer().getPositionVector().addVector(0, android.getPlayer().getEyeHeight(), 0).subtract(entityitem.getPositionVector()).normalize();
entityitem.addVelocity(dir.x * ITEM_SPEED, dir.y * ITEM_SPEED, dir.z * ITEM_SPEED);
android.extractEnergyScaled(ENERGY_PULL_PER_ITEM);
}
}
}
}
}
内容来源于网络,如有侵权,请联系作者删除!