本文整理了Java中net.minecraft.entity.Entity.getDistance()
方法的一些代码示例,展示了Entity.getDistance()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Entity.getDistance()
方法的具体详情如下:
包路径:net.minecraft.entity.Entity
类名称:Entity
方法名:getDistance
暂无
代码示例来源:origin: Vazkii/Botania
public FXWisp(World world, double d, double d1, double d2, float size, float red, float green, float blue, boolean distanceLimit, boolean depthTest, float maxAgeMul) {
super(world, d, d1, d2, 0.0D, 0.0D, 0.0D);
particleRed = red;
particleGreen = green;
particleBlue = blue;
particleAlpha = 0.5F; // So MC renders us on the alpha layer, value not actually used
particleGravity = 0;
motionX = motionY = motionZ = 0;
particleScale *= size;
moteParticleScale = particleScale;
particleMaxAge = (int)(28D / (Math.random() * 0.3D + 0.7D) * maxAgeMul);
this.depthTest = depthTest;
moteHalfLife = particleMaxAge / 2;
setSize(0.01F, 0.01F);
Entity renderentity = FMLClientHandler.instance().getClient().getRenderViewEntity();
if(distanceLimit) {
int visibleDistance = 50;
if (!FMLClientHandler.instance().getClient().gameSettings.fancyGraphics)
visibleDistance = 25;
if (renderentity == null || renderentity.getDistance(posX, posY, posZ) > visibleDistance)
particleMaxAge = 0;
}
prevPosX = posX;
prevPosY = posY;
prevPosZ = posZ;
}
代码示例来源:origin: Silentine/GrimoireOfGaia
/**
* Helper functions
*/
void updateDistanceMovedTotal(Entity parEntity) {
distanceMovedTotal += parEntity.getDistance(parEntity.prevPosX, parEntity.prevPosY, parEntity.prevPosZ);
}
代码示例来源:origin: P3pp3rF1y/AncientWarfare2
private float getEntityDistance(Node n) {
return entity == null ? 0.f : n == null ? 0.f : (float) entity.getDistance(n.x + 0.5d, n.y, n.z + 0.5d);
}
代码示例来源:origin: Vazkii/Psi
public FXWisp(World world, double d, double d1, double d2, float size, float red, float green, float blue, boolean distanceLimit, boolean depthTest, float maxAgeMul) {
super(world, d, d1, d2, size, red, green, blue, (int) (28 / (Math.random() * 0.3D + 0.7D) * maxAgeMul));
moteParticleScale = particleScale;
this.depthTest = depthTest;
moteHalfLife = particleMaxAge / 2;
Entity viewEntity = Minecraft.getMinecraft().getRenderViewEntity();
if (distanceLimit) {
int visibleDistance = 50;
if (!Minecraft.getMinecraft().gameSettings.fancyGraphics)
visibleDistance = 25;
if (viewEntity == null || viewEntity.getDistance(posX, posY, posZ) > visibleDistance)
particleMaxAge = 0;
}
}
代码示例来源:origin: P3pp3rF1y/AncientWarfare2
private void detectStuck() {
if (this.stuckCheckTicks <= 0) {
this.stuckCheckTicks = this.stuckCheckTicksMax;
if (this.currentTarget != null && entity.getDistance(stuckCheckPosition.x, stuckCheckPosition.y, stuckCheckPosition.z) < 1.5d) {
this.owner.onStuckDetected();
this.clearPath();
this.currentTarget = null;
}
stuckCheckPosition = new Vec3d(entity.posX, entity.posY, entity.posZ);
} else {
this.stuckCheckTicks--;
}
}
代码示例来源:origin: P3pp3rF1y/AncientWarfare2
private boolean isAtTarget(BlockPos pos) {
return entity.getDistance(pos.getX() + 0.5d, pos.getY(), pos.getZ() + 0.5d) < entity.width;
}
代码示例来源:origin: P3pp3rF1y/AncientWarfare2
private boolean isNewTargetClose(BlockPos target) {
float dist = (float) entity.getDistance(finalTarget.x, finalTarget.y, finalTarget.z);
float tDist = Trig.getDistance(finalTarget.x, finalTarget.y, finalTarget.z, target.getX(), target.getY(), target.getZ());
return tDist < dist * 0.1f;
}
代码示例来源:origin: CyclopsMC/IntegratedDynamics
protected boolean shouldRender(BlockPos pos) {
if (!NetworkHelpers.shouldWork()) {
return false;
}
Entity renderEntity = FMLClientHandler.instance().getClient().player;
return renderEntity.getDistance(pos.getX(), pos.getY(), pos.getZ()) < getMaxRenderDistance();
}
代码示例来源:origin: RS485/LogisticsPipes
public PipeFXLaserPowerBall(World par1World, DoubleCoordinates pos, int color, TileEntity tile) {
super(par1World, pos.getXCoord() + 0.5D, pos.getYCoord() + 0.5D, pos.getZCoord() + 0.5D, 0.0D, 0.0D, 0.0D);
this.tile = tile;
setSize(0.02F, 0.02F);
particleRed = ((float) ((color & 0xff0000) >> 16)) / 0xff;
particleGreen = ((float) ((color & 0x00ff00) >> 8)) / 0xff;
particleBlue = ((float) ((color & 0x0000ff) >> 0)) / 0xff;
canCollide = false;
motionX = 0.0D;
motionY = 0.0D;
motionZ = 0.0D;
prevPosX = posX;
prevPosY = posY;
prevPosZ = posZ;
particleMaxAge = 0;
random = PipeFXLaserPowerBall.RAND.nextFloat() * PipeFXLaserPowerBall.RAND.nextInt(360 / PipeFXLaserPowerBall.ROTATIONSPEED);
Entity renderentity = FMLClientHandler.instance().getClient().getRenderViewEntity();
int visibleDistance = 50;
if (!FMLClientHandler.instance().getClient().gameSettings.fancyGraphics) {
visibleDistance = 25;
}
if (renderentity.getDistance(posX, posY, posZ) > visibleDistance) {
setExpired();
}
}
代码示例来源:origin: Darkhax-Minecraft/Bookshelf
final double distance = entity.getDistance(this.x, this.y, this.z) / totalSize;
this.affectEntity(entity, explosionPosition, distance, totalSize);
代码示例来源: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: CyclopsMC/EvilCraft
double inverseStrength = entity.getDistance(x, y, z) / (itemUsedCount + 1);
double knock = power + itemUsedCount / 200 + 1.0D;
代码示例来源:origin: ValkyrienWarfare/Valkyrien-Warfare-Revamped
double d12 = entity.getDistance(this.x, this.y, this.z) / f3;
代码示例来源:origin: PrinceOfAmber/Cyclic
Entity entity = (Entity) list.get(k2);
if (!entity.isImmuneToExplosions()) {
double d12 = entity.getDistance(this.explosionX, this.explosionY, this.explosionZ) / (double) f3;
if (d12 <= 1.0D) {
double d5 = entity.posX - this.explosionX;
代码示例来源:origin: RS485/LogisticsPipes
public PipeFXLaserPowerBeam(World par1World, DoubleCoordinates pos, float length, EnumFacing dir, int color, TileEntity tile) {
super(par1World, pos.getXCoord() + 0.5D, pos.getYCoord() + 0.5D, pos.getZCoord() + 0.5D, 0.0D, 0.0D, 0.0D);
setSize(0.02F, 0.02F);
this.tile = tile;
particleRed = ((float) ((color & 0xff0000) >> 16)) / 0xff;
particleGreen = ((float) ((color & 0x00ff00) >> 8)) / 0xff;
particleBlue = ((float) ((color & 0x0000ff) >> 0)) / 0xff;
canCollide = false;
motionX = 0.0D;
motionY = 0.0D;
motionZ = 0.0D;
prevPosX = posX;
prevPosY = posY;
prevPosZ = posZ;
this.length = length;
random = PipeFXLaserPowerBeam.RAND.nextFloat() * PipeFXLaserPowerBeam.RAND.nextInt(10);
dir = dir.getOpposite();
yaw = ((float) (Math.atan2(dir.getDirectionVec().getX(), dir.getDirectionVec().getZ()) * 180.0D / Math.PI));
pitch = ((float) (Math.atan2(dir.getDirectionVec().getY(), MathHelper.sqrt(dir.getDirectionVec().getX() * dir.getDirectionVec().getX() + dir.getDirectionVec().getZ() * dir.getDirectionVec().getZ())) * 180.0D / Math.PI));
particleMaxAge = 0;
Entity renderentity = FMLClientHandler.instance().getClient().getRenderViewEntity();
int visibleDistance = 50;
if (!FMLClientHandler.instance().getClient().gameSettings.fancyGraphics) {
visibleDistance = 25;
}
if (renderentity.getDistance(posX, posY, posZ) > visibleDistance) {
setExpired();
}
}
代码示例来源:origin: MatterOverdrive/MatterOverdrive-Legacy-Edition
public void consume(Entity entity) {
if (!entity.isDead && onEntityConsume(entity, true)) {
boolean consumedFlag = false;
if (entity instanceof EntityItem) {
consumedFlag |= consumeEntityItem((EntityItem) entity);
} else if (entity instanceof EntityFallingBlock) {
consumedFlag |= consumeFallingBlock((EntityFallingBlock) entity);
} else if (entity instanceof EntityLivingBase) {
consumedFlag |= consumeLivingEntity((EntityLivingBase) entity, getBreakStrength((float) entity.getDistance(getPos().getX(), getPos().getY(), getPos().getZ()), (float) getMaxRange()));
}
if (consumedFlag) {
onEntityConsume(entity, false);
}
}
}
代码示例来源:origin: Alex-the-666/Ice_and_Fire
double d12 = entity.getDistance(this.explosionX, this.explosionY, this.explosionZ) / f3;
代码示例来源:origin: Alex-the-666/Ice_and_Fire
if (!(entity instanceof EntityDragonFire)) {
if (!entity.isImmuneToExplosions() && !entity.isEntityEqual(exploder)) {
double d12 = entity.getDistance(this.explosionX, this.explosionY, this.explosionZ) / f3;
代码示例来源:origin: TeamLapen/Vampirism
if (e.getDistance(player) <= player.getEntityAttribute(EntityPlayer.REACH_DISTANCE).getAttributeValue() + 1) {
feed_victim_bite_type = determineBiteType((EntityLivingBase) e);
if (feed_victim_bite_type == BITE_TYPE.ATTACK || feed_victim_bite_type == BITE_TYPE.ATTACK_HUNTER) {
代码示例来源:origin: CyclopsMC/IntegratedDynamics
float distanceFactor = (float) ((getMaxRenderDistance() - renderEntity.getDistance(pos.getX(), pos.getY(), pos.getZ())) / 5);
float distanceAlpha = Math.min(1.0F, distanceFactor);
if(distanceAlpha < 0.05F) distanceAlpha = 0.05F; // Can't be 0 because the MC font renderer doesn't handle 0 alpha's properly.
内容来源于网络,如有侵权,请联系作者删除!