本文整理汇总了Java中net.minecraft.entity.Entity.getDistanceSqToEntity方法的典型用法代码示例。如果您正苦于以下问题:Java Entity.getDistanceSqToEntity方法的具体用法?Java Entity.getDistanceSqToEntity怎么用?Java Entity.getDistanceSqToEntity使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.minecraft.entity.Entity
的用法示例。
在下文中一共展示了Entity.getDistanceSqToEntity方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: calculateCritPost
import net.minecraft.entity.Entity; //导入方法依赖的package包/类
public static int calculateCritPost(Entity target, EntityLivingBase shooter, int initial, ItemStack stack) {
if (initial > 0 && (target instanceof EntityLivingBase && ((EntityLivingBase) target).getActivePotionEffect(TF2weapons.backup) != null))
initial = 0;
if (initial == 0 && (target instanceof EntityLivingBase && (((EntityLivingBase) target).getActivePotionEffect(TF2weapons.markDeath) != null
|| ((EntityLivingBase) target).getActivePotionEffect(TF2weapons.jarate) != null)))
initial = 1;
if (initial == 0 && !stack.isEmpty() && !target.onGround && !target.isInWater() && TF2Attribute.getModifier("Minicrit Airborne", stack, 0, shooter) != 0)
initial = 1;
if (initial == 0 && !stack.isEmpty() && shooter != null) {
float mindist=TF2Attribute.getModifier("Minicrit Distance", stack, 0, shooter);
mindist*=mindist;
if(mindist != 0f && target.getDistanceSqToEntity(shooter) >= mindist)
initial = 1;
}
if (initial < 2 && (!stack.isEmpty() && target.isBurning() && TF2Attribute.getModifier("Crit Burn", stack, 0, shooter) != 0))
initial = 2;
if (initial < 2 && (!stack.isEmpty() && (target instanceof EntityLivingBase && ((EntityLivingBase) target).getActivePotionEffect(TF2weapons.stun) != null))
&& TF2Attribute.getModifier("Crit Stun", stack, 0, shooter) != 0)
initial = 2;
if (initial < 2 && (!stack.isEmpty() && shooter != null && shooter instanceof EntityPlayer &&
(shooter.getCapability(TF2weapons.WEAPONS_CAP, null).isExpJump() || shooter.isElytraFlying())
&& TF2Attribute.getModifier("Crit Rocket", stack, 0, shooter) != 0))
initial = 2;
if (initial == 1 && (!stack.isEmpty() && shooter != null && shooter instanceof EntityPlayer && TF2Attribute.getModifier("Crit Mini", stack, 0, shooter) != 0))
initial = 2;
if (target instanceof EntityTF2Boss && initial == 1)
initial = 0;
if (target instanceof EntityMerasmus && ((EntityMerasmus) target).getActivePotionEffect(TF2weapons.stun) != null)
initial = 2;
return initial;
}
示例2: renderLivingLabel
import net.minecraft.entity.Entity; //导入方法依赖的package包/类
/**
* Renders an entity's name above its head
*/
protected void renderLivingLabel(Entity entityIn, String str, double x, double y, double z, int maxDistance)
{
if (entityIn instanceof EntityPlayer)
{
NametagRenderEvent event = new NametagRenderEvent(entityIn, str, x, y, z);
event.call();
if (event.isCancelled()) return;
}
double d0 = entityIn.getDistanceSqToEntity(this.renderManager.livingPlayer);
if (d0 <= (double)(maxDistance * maxDistance))
{
FontRenderer fontrenderer = this.getFontRendererFromRenderManager();
float f = 1.6F;
float f1 = 0.016666668F * f;
GlStateManager.pushMatrix();
GlStateManager.translate((float)x + 0.0F, (float)y + entityIn.height + 0.5F, (float)z);
GL11.glNormal3f(0.0F, 1.0F, 0.0F);
GlStateManager.rotate(-this.renderManager.playerViewY, 0.0F, 1.0F, 0.0F);
GlStateManager.rotate(this.renderManager.playerViewX, 1.0F, 0.0F, 0.0F);
GlStateManager.scale(-f1, -f1, f1);
GlStateManager.disableLighting();
GlStateManager.depthMask(false);
GlStateManager.disableDepth();
GlStateManager.enableBlend();
GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0);
Tessellator tessellator = Tessellator.getInstance();
WorldRenderer worldrenderer = tessellator.getWorldRenderer();
byte b0 = 0;
if (str.equals("deadmau5"))
{
b0 = -10;
}
int i = fontrenderer.getStringWidth(str) / 2;
GlStateManager.disableTexture2D();
worldrenderer.begin(7, DefaultVertexFormats.POSITION_COLOR);
worldrenderer.pos((double)(-i - 1), (double)(-1 + b0), 0.0D).color(0.0F, 0.0F, 0.0F, 0.25F).endVertex();
worldrenderer.pos((double)(-i - 1), (double)(8 + b0), 0.0D).color(0.0F, 0.0F, 0.0F, 0.25F).endVertex();
worldrenderer.pos((double)(i + 1), (double)(8 + b0), 0.0D).color(0.0F, 0.0F, 0.0F, 0.25F).endVertex();
worldrenderer.pos((double)(i + 1), (double)(-1 + b0), 0.0D).color(0.0F, 0.0F, 0.0F, 0.25F).endVertex();
tessellator.draw();
GlStateManager.enableTexture2D();
fontrenderer.drawString(str, -fontrenderer.getStringWidth(str) / 2, b0, 553648127);
GlStateManager.enableDepth();
GlStateManager.depthMask(true);
fontrenderer.drawString(str, -fontrenderer.getStringWidth(str) / 2, b0, -1);
GlStateManager.enableLighting();
GlStateManager.disableBlend();
GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
GlStateManager.popMatrix();
}
}
示例3: onUpdate
import net.minecraft.entity.Entity; //导入方法依赖的package包/类
@Override
public void onUpdate(ItemStack par1ItemStack, World par2World, Entity par3Entity, int par4, boolean par5) {
super.onUpdate(par1ItemStack, par2World, par3Entity, par4, par5);
if (par1ItemStack.isEmpty())
return;
if (par5 && !this.canFire(par2World, (EntityLivingBase) par3Entity, par1ItemStack)) {
par3Entity.getCapability(TF2weapons.WEAPONS_CAP, null).setHealTarget(-1);
}
Potion effect=Potion.getPotionFromResourceLocation(ItemFromData.getData(par1ItemStack).getString(PropertyType.EFFECT_TYPE));
if (!par2World.isRemote&&par1ItemStack.getTagCompound().getBoolean("Activated")) {
par1ItemStack.getTagCompound().setFloat("ubercharge",
Math.max(0, par1ItemStack.getTagCompound().getFloat("ubercharge") - 0.00625f));
if(par5 && effect != null && par3Entity.ticksExisted%4==0)
((EntityLivingBase)par3Entity).addPotionEffect(new PotionEffect(effect,15));
if (par1ItemStack.getTagCompound().getFloat("ubercharge") == 0) {
par1ItemStack.getTagCompound().setBoolean("Activated", false);
TF2Util.playSound(par3Entity,ItemFromData.getSound(par1ItemStack, PropertyType.UBER_STOP_SOUND), 1.5f, 1);
((EntityLivingBase)par3Entity).removePotionEffect(effect);
// TF2weapons.sendTracking(new
// TF2Message.PropertyMessage("UberCharged",
// (byte)0,par3Entity),par3Entity);
}
}
if(par5){
Entity healTargetEnt = par2World.getEntityByID(par3Entity.getCapability(TF2weapons.WEAPONS_CAP, null).getHealTarget());
if(healTargetEnt != null && healTargetEnt instanceof EntityLivingBase){
EntityLivingBase healTarget=(EntityLivingBase) healTargetEnt;
// System.out.println("healing:
// "+ItemUsable.itemProperties.server.get(par3Entity).getInteger("HealTarget"));
if (!par2World.isRemote && healTarget != null && par3Entity.getDistanceSqToEntity(healTarget) > 72) {
par3Entity.getCapability(TF2weapons.WEAPONS_CAP, null).setHealTarget(-1);
// TF2weapons.sendTracking(new
// TF2Message.PropertyMessage("HealTarget",
// -1,par3Entity),par3Entity);
} else if (healTarget != null && healTarget instanceof EntityLivingBase) {
if(!par2World.isRemote)
this.heal(par1ItemStack, (EntityLivingBase) par3Entity, par2World, (EntityLivingBase) healTarget);
if (effect != null && par1ItemStack.getTagCompound().getBoolean("Activated") && (healTarget.getActivePotionEffect(effect)==null||healTarget.ticksExisted%4==0))
healTarget.addPotionEffect(new PotionEffect(effect,15));
// TF2weapons.sendTracking(new
// TF2Message.PropertyMessage("UberCharged",
// (byte)1,healTarget),healTarget);
}
}
}
}