本文整理了Java中net.minecraft.entity.Entity.getDistanceSq()
方法的一些代码示例,展示了Entity.getDistanceSq()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Entity.getDistanceSq()
方法的具体详情如下:
包路径:net.minecraft.entity.Entity
类名称:Entity
方法名:getDistanceSq
暂无
代码示例来源:origin: Alex-the-666/Ice_and_Fire
public int compare(Entity p_compare_1_, Entity p_compare_2_) {
double d0 = this.theEntity.getDistanceSq(p_compare_1_);
double d1 = this.theEntity.getDistanceSq(p_compare_2_);
return d0 < d1 ? -1 : (d0 > d1 ? 1 : 0);
}
}
代码示例来源:origin: Alex-the-666/Ice_and_Fire
public int compare(Entity p_compare_1_, Entity p_compare_2_) {
double d0 = this.theEntity.getDistanceSq(p_compare_1_);
double d1 = this.theEntity.getDistanceSq(p_compare_2_);
return d0 < d1 ? -1 : (d0 > d1 ? 1 : 0);
}
}
代码示例来源:origin: Alex-the-666/Ice_and_Fire
public int compare(Entity p_compare_1_, Entity p_compare_2_) {
double d0 = this.theEntity.getDistanceSq(p_compare_1_);
double d1 = this.theEntity.getDistanceSq(p_compare_2_);
return d0 < d1 ? -1 : (d0 > d1 ? 1 : 0);
}
}
代码示例来源:origin: Alex-the-666/Ice_and_Fire
public int compare(Entity p_compare_1_, Entity p_compare_2_) {
double d0 = this.theEntity.getDistanceSq(p_compare_1_);
double d1 = this.theEntity.getDistanceSq(p_compare_2_);
return d0 < d1 ? -1 : (d0 > d1 ? 1 : 0);
}
}
代码示例来源:origin: Alex-the-666/Ice_and_Fire
public int compare(Entity p_compare_1_, Entity p_compare_2_) {
double d0 = this.theEntity.getDistanceSq(p_compare_1_);
double d1 = this.theEntity.getDistanceSq(p_compare_2_);
return d0 < d1 ? -1 : (d0 > d1 ? 1 : 0);
}
}
代码示例来源:origin: Alex-the-666/Ice_and_Fire
public int compare(Entity p_compare_1_, Entity p_compare_2_) {
double d0 = this.theEntity.getDistanceSq(p_compare_1_);
double d1 = this.theEntity.getDistanceSq(p_compare_2_);
return d0 < d1 ? -1 : (d0 > d1 ? 1 : 0);
}
}
代码示例来源:origin: SleepyTrousers/EnderIO
@Override
public int compare(Entity paramT1, Entity paramT2) {
double distanceSqToEntity1 = paramT1 == null ? 0 : refPoint.getDistanceSq(paramT1);
double distanceSqToEntity2 = paramT2 == null ? 0 : refPoint.getDistanceSq(paramT2);
if (distanceSqToEntity1 < distanceSqToEntity2) {
return -1;
}
if (distanceSqToEntity1 > distanceSqToEntity2) {
return 1;
}
// Double.compare() does something with bits now, but for distances it's clear:
// if it's neither farther nor nearer is same.
return 0;
}
代码示例来源:origin: Alex-the-666/Ice_and_Fire
public int compare(Entity p_compare_1_, Entity p_compare_2_) {
double d0 = this.theEntity.getDistanceSq(p_compare_1_);
double d1 = this.theEntity.getDistanceSq(p_compare_2_);
return d0 < d1 ? -1 : (d0 > d1 ? 1 : 0);
}
}
代码示例来源:origin: Alex-the-666/Ice_and_Fire
public int compare(Entity p_compare_1_, Entity p_compare_2_) {
double d0 = this.entity.getDistanceSq(p_compare_1_);
double d1 = this.entity.getDistanceSq(p_compare_2_);
if (d0 < d1) {
return -1;
} else {
return d0 > d1 ? 1 : 0;
}
}
}
代码示例来源:origin: Alex-the-666/Ice_and_Fire
public int compare(Entity p_compare_1_, Entity p_compare_2_) {
double d0 = this.theEntity.getDistanceSq(p_compare_1_);
double d1 = this.theEntity.getDistanceSq(p_compare_2_);
return d0 < d1 ? -1 : (d0 > d1 ? 1 : 0);
}
}
代码示例来源:origin: JurassiCraftTeam/JurassiCraft2
public int compare(Entity entity1, Entity entity2)
{
double d0 = this.entity.getDistanceSq(entity1);
double d1 = this.entity.getDistanceSq(entity2);
if (d0 < d1)
{
return -1;
}
else
{
return d0 > d1 ? 1 : 0;
}
}
}
代码示例来源:origin: CoFH/CoFHCore
@Override
public boolean apply(@Nullable Entity entity) {
// Out of range? Not applicable.
if (entity == null) {
return false;
}
if (entity.getDistanceSq(origX, origY, origZ) > distance * distance) {
return false;
}
// No specific types to check for? Applicable.
if (types == null) {
return true;
}
// Check types. Applicable if found and assignable...
for (Class<?> type : types) {
if (type.isAssignableFrom(entity.getClass())) {
return true;
}
}
// ...otherwise, not.
return false;
}
}
代码示例来源:origin: P3pp3rF1y/AncientWarfare2
@Override
public boolean shouldExecute() {
if (!npc.getIsAIEnabled())
return false;
// assume not fleeing, reduce fear level early
if (fearLevel > 0)
fearLevel--;
ticker++;
if (ticker != TICKER_MAX)
return false;
ticker = 0;
boolean flee = false;
findNearbyRelevantEntities();
if (!npc.nearbyHostiles.isEmpty()) {
Entity nearestHostile = npc.nearbyHostiles.iterator().next();
if (npc.getTownHallPosition().isPresent() || npc.hasHome())
flee = true;
else {
fleeVector = RandomPositionGenerator.findRandomTargetBlockAwayFrom(this.npc, MAX_FLEE_RANGE, HEIGHT_CHECK, new Vec3d(nearestHostile.posX, nearestHostile.posY, nearestHostile.posZ));
flee = fleeVector != null && nearestHostile.getDistanceSq(fleeVector.x, fleeVector.y, fleeVector.z) >= nearestHostile.getDistanceSq(this.npc);
}
if (flee) {
if (nearestHostile instanceof EntityLivingBase)
npc.setAttackTarget((EntityLivingBase) nearestHostile);
else
AncientWarfareNPC.LOG.error("Attempted to flee an entity that isn't EntityLiving: '" + EntityList.getEntityString(nearestHostile) + "', ignoring! Please report this error.");
}
}
return flee;
}
代码示例来源:origin: WayofTime/BloodMagic
/**
* Returns whether the EntityAIBase should begin execution.
*/
@Override
public boolean shouldExecute() {
if (!this.theEntity.shouldEmergencyHeal()) {
return false;
}
//This part almost doesn't matter
List<T> list = this.theEntity.getEntityWorld().getEntitiesWithinAABB(this.classToAvoid, this.theEntity.getEntityBoundingBox().expand((double) this.avoidDistance, 3.0D, (double) this.avoidDistance), Predicates.and(EntitySelectors.CAN_AI_TARGET, this.canBeSeenSelector, this.avoidTargetSelector));
if (list.isEmpty()) {
return true; //No entities nearby, so I can freely heal
} else {
this.closestLivingEntity = list.get(0);
Vec3d vec3d = RandomPositionGenerator.findRandomTargetBlockAwayFrom(this.theEntity, 16, 7, new Vec3d(this.closestLivingEntity.posX, this.closestLivingEntity.posY, this.closestLivingEntity.posZ));
if (vec3d == null) {
return false; //Nowhere to run, gotta fight!
} else if (this.closestLivingEntity.getDistanceSq(vec3d.x, vec3d.y, vec3d.z) < this.closestLivingEntity.getDistanceSq(this.theEntity)) {
return false; //I'll be headed off if I choose this direction.
} else {
this.entityPathEntity = this.entityPathNavigate.getPathToXYZ(vec3d.x, vec3d.y, vec3d.z);
return this.entityPathEntity != null;
}
}
}
代码示例来源:origin: Ellpeck/ActuallyAdditions
if(entity.isDead || entity.getDistanceSq(player.posX, player.posY, player.posZ) > range*range){
entity.setGlowing(false);
代码示例来源:origin: Vazkii/Psi
@SubscribeEvent
@SideOnly(Side.CLIENT)
public static void fireParticles(TickEvent.ClientTickEvent event) {
if (event.side.isClient() && event.phase == TickEvent.Phase.END) {
World world = Minecraft.getMinecraft().world;
Entity viewPoint = Minecraft.getMinecraft().getRenderViewEntity();
if (viewPoint == null)
viewPoint = Minecraft.getMinecraft().player;
final Entity view = viewPoint;
needsParticleUpdate.removeIf((pos) -> {
if (view == null || world == null)
return true;
if (world.isBlockLoaded(pos) && view.getDistanceSq(pos) <= 64 * 64) {
TileEntity inWorld = world.getTileEntity(pos);
if (inWorld instanceof TileConjured) {
((TileConjured) inWorld).doParticles();
return false;
}
}
return true;
});
}
}
代码示例来源:origin: TeamLapen/Vampirism
continue;
if (e instanceof EntityLivingBase && e.getDistanceSq(this) < 4) {
EntityLivingBase entity = (EntityLivingBase) e;
entity.addPotionEffect(new PotionEffect(MobEffects.SLOWNESS, 200, 1));
代码示例来源:origin: P3pp3rF1y/AncientWarfare2
private void addAI() {
//noinspection Guava - because dependency on what vanilla does
Predicate<Entity> selector = entity -> {
//noinspection ConstantConditions
if (!isHostileTowards(entity)) {
return false;
}
if (hasHome()) {
BlockPos home = getHomePosition();
double dist = entity.getDistanceSq(home.getX() + 0.5d, home.getY(), home.getZ() + 0.5d);
if (dist > 30 * 30) {
return false;
}
}
return true;
};
tasks.addTask(0, new EntityAISwimming(this));
tasks.addTask(0, new EntityAIRestrictOpenDoor(this));
tasks.addTask(0, new NpcAIDoor(this, true));
tasks.addTask(1, new NpcAIFollowPlayer(this));
tasks.addTask(2, new NpcAIFactionArcherStayAtHome(this));
tasks.addTask(3, new NpcAIFactionRangedAttack(this));
tasks.addTask(101, new EntityAIWatchClosest2(this, EntityPlayer.class, 3.0F, 1.0F));
tasks.addTask(102, new NpcAIWander(this));
tasks.addTask(103, new NpcAIWatchClosest(this, EntityLiving.class, 8.0F));
targetTasks.addTask(1, new NpcAIHurt(this));
targetTasks.addTask(2, new NpcAIAttackNearest(this, selector));
}
代码示例来源:origin: P3pp3rF1y/AncientWarfare2
private void addAI() {
//noinspection Guava
Predicate<Entity> selector = entity -> {
//noinspection ConstantConditions
if (!isHostileTowards(entity)) {
return false;
}
if (hasHome()) {
BlockPos home = getHomePosition();
double dist = entity.getDistanceSq(home.getX() + 0.5d, home.getY(), home.getZ() + 0.5d);
if (dist > 30 * 30) {
return false;
}
}
return true;
};
tasks.addTask(0, new EntityAISwimming(this));
tasks.addTask(0, new EntityAIRestrictOpenDoor(this));
tasks.addTask(0, new NpcAIDoor(this, true));
tasks.addTask(1, new NpcAIFollowPlayer(this));
tasks.addTask(2, new NpcAIMoveHome(this, 50.f, 5.f, 30.f, 5.f));
tasks.addTask(2, new NpcAIFactionArcherStayAtHome(this));
tasks.addTask(3, new NpcAIFactionRangedAttack(this));
tasks.addTask(101, new EntityAIWatchClosest2(this, EntityPlayer.class, 3.0F, 1.0F));
tasks.addTask(102, new NpcAIWander(this));
tasks.addTask(103, new NpcAIWatchClosest(this, EntityLiving.class, 8.0F));
targetTasks.addTask(1, new NpcAIHurt(this));
targetTasks.addTask(2, new NpcAIAttackNearest(this, selector));
}
内容来源于网络,如有侵权,请联系作者删除!