当前位置: 首页>>代码示例>>Java>>正文


Java Entity.getDistanceSqToEntity方法代码示例

本文整理汇总了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;
}
 
开发者ID:rafradek,项目名称:Mods,代码行数:32,代码来源:TF2Util.java

示例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();
    }
}
 
开发者ID:SkidJava,项目名称:BaseClient,代码行数:60,代码来源:Render.java

示例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);
			}
		}
	}

}
 
开发者ID:rafradek,项目名称:Mods,代码行数:50,代码来源:ItemMedigun.java


注:本文中的net.minecraft.entity.Entity.getDistanceSqToEntity方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。