當前位置: 首頁>>代碼示例>>Java>>正文


Java Entity類代碼示例

本文整理匯總了Java中net.minecraft.entity.Entity的典型用法代碼示例。如果您正苦於以下問題:Java Entity類的具體用法?Java Entity怎麽用?Java Entity使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


Entity類屬於net.minecraft.entity包,在下文中一共展示了Entity類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: removeEntity

import net.minecraft.entity.Entity; //導入依賴的package包/類
/**
 * Schedule the entity for removal during the next tick. Marks the entity dead in anticipation.
 */
public void removeEntity(Entity entityIn)
{
    if (entityIn.riddenByEntity != null)
    {
        entityIn.riddenByEntity.mountEntity((Entity)null);
    }

    if (entityIn.ridingEntity != null)
    {
        entityIn.mountEntity((Entity)null);
    }

    entityIn.setDead();

    if (entityIn instanceof EntityPlayer)
    {
        this.playerEntities.remove(entityIn);
        this.updateAllPlayersSleepingFlag();
        this.onEntityRemoved(entityIn);
    }
}
 
開發者ID:Notoh,項目名稱:DecompiledMinecraft,代碼行數:25,代碼來源:World.java

示例2: setRotationAngles

import net.minecraft.entity.Entity; //導入依賴的package包/類
/**
 * Sets the model's various rotation angles. For bipeds, par1 and par2 are used for animating the movement of arms
 * and legs, where par1 represents the time(so that arms and legs swing back and forth) and par2 represents how
 * "far" arms and legs can swing at most.
 */
public void setRotationAngles(float limbSwing, float limbSwingAmount, float ageInTicks, float netHeadYaw, float headPitch, float scaleFactor, Entity entityIn)
{
    super.setRotationAngles(limbSwing, limbSwingAmount, ageInTicks, netHeadYaw, headPitch, scaleFactor, entityIn);
    this.head.rotateAngleY = netHeadYaw * 0.017453292F;
    this.head.rotateAngleX = headPitch * 0.017453292F;
    this.body.rotateAngleY = netHeadYaw * 0.017453292F * 0.25F;
    float f = MathHelper.sin(this.body.rotateAngleY);
    float f1 = MathHelper.cos(this.body.rotateAngleY);
    this.rightHand.rotateAngleZ = 1.0F;
    this.leftHand.rotateAngleZ = -1.0F;
    this.rightHand.rotateAngleY = 0.0F + this.body.rotateAngleY;
    this.leftHand.rotateAngleY = (float)Math.PI + this.body.rotateAngleY;
    this.rightHand.rotationPointX = f1 * 5.0F;
    this.rightHand.rotationPointZ = -f * 5.0F;
    this.leftHand.rotationPointX = -f1 * 5.0F;
    this.leftHand.rotationPointZ = f * 5.0F;
}
 
開發者ID:F1r3w477,項目名稱:CustomWorldGen,代碼行數:23,代碼來源:ModelSnowMan.java

示例3: collideWithNearbyEntities

import net.minecraft.entity.Entity; //導入依賴的package包/類
protected void collideWithNearbyEntities()
{
    List<Entity> list = this.worldObj.getEntitiesWithinAABBExcludingEntity(this, this.getEntityBoundingBox());

    if (list != null && !list.isEmpty())
    {
        for (int i = 0; i < list.size(); ++i)
        {
            Entity entity = (Entity)list.get(i);

            if (entity instanceof EntityMinecart && ((EntityMinecart)entity).getMinecartType() == EntityMinecart.EnumMinecartType.RIDEABLE && this.getDistanceSqToEntity(entity) <= 0.2D)
            {
                entity.applyEntityCollision(this);
            }
        }
    }
}
 
開發者ID:SkidJava,項目名稱:BaseClient,代碼行數:18,代碼來源:EntityArmorStand.java

示例4: getViewVector

import net.minecraft.entity.Entity; //導入依賴的package包/類
protected Vector3f getViewVector(Entity entityIn, double partialTicks)
{
    float f = (float)((double)entityIn.prevRotationPitch + (double)(entityIn.rotationPitch - entityIn.prevRotationPitch) * partialTicks);
    float f1 = (float)((double)entityIn.prevRotationYaw + (double)(entityIn.rotationYaw - entityIn.prevRotationYaw) * partialTicks);

    if (Minecraft.getMinecraft().gameSettings.thirdPersonView == 2)
    {
        f += 180.0F;
    }

    float f2 = MathHelper.cos(-f1 * 0.017453292F - (float)Math.PI);
    float f3 = MathHelper.sin(-f1 * 0.017453292F - (float)Math.PI);
    float f4 = -MathHelper.cos(-f * 0.017453292F);
    float f5 = MathHelper.sin(-f * 0.017453292F);
    return new Vector3f(f3 * f4, f5, f2 * f4);
}
 
開發者ID:F1r3w477,項目名稱:CustomWorldGen,代碼行數:17,代碼來源:RenderGlobal.java

示例5: onUserHurt

import net.minecraft.entity.Entity; //導入依賴的package包/類
/**
 * Whenever an entity that has this enchantment on one of its associated items is damaged this method will be
 * called.
 */
public void onUserHurt(EntityLivingBase user, Entity attacker, int level)
{
    Random random = user.getRNG();
    ItemStack itemstack = EnchantmentHelper.getEnchantedItem(Enchantment.thorns, user);

    if (func_92094_a(level, random))
    {
        if (attacker != null)
        {
            attacker.attackEntityFrom(DamageSource.causeThornsDamage(user), (float)func_92095_b(level, random));
            attacker.playSound("damage.thorns", 0.5F, 1.0F);
        }

        if (itemstack != null)
        {
            itemstack.damageItem(3, user);
        }
    }
    else if (itemstack != null)
    {
        itemstack.damageItem(1, user);
    }
}
 
開發者ID:Notoh,項目名稱:DecompiledMinecraft,代碼行數:28,代碼來源:EnchantmentThorns.java

示例6: entityToNBT

import net.minecraft.entity.Entity; //導入依賴的package包/類
protected static NBTTagCompound entityToNBT(Entity theEntity)
{
    NBTTagCompound nbttagcompound = theEntity.writeToNBT(new NBTTagCompound());

    if (theEntity instanceof EntityPlayer)
    {
        ItemStack itemstack = ((EntityPlayer)theEntity).inventory.getCurrentItem();

        if (!itemstack.func_190926_b())
        {
            nbttagcompound.setTag("SelectedItem", itemstack.writeToNBT(new NBTTagCompound()));
        }
    }

    return nbttagcompound;
}
 
開發者ID:sudofox,項目名稱:Backmemed,代碼行數:17,代碼來源:CommandBase.java

示例7: renderParticle

import net.minecraft.entity.Entity; //導入依賴的package包/類
/**
 * Renders the particle
 */
public void renderParticle(VertexBuffer worldRendererIn, Entity entityIn, float partialTicks, float rotationX, float rotationZ, float rotationYZ, float rotationXY, float rotationXZ)
{
    float f = ((float)this.age + partialTicks) / (float)this.maxAge;
    f = f * f;
    double d0 = this.item.posX;
    double d1 = this.item.posY;
    double d2 = this.item.posZ;
    double d3 = this.target.lastTickPosX + (this.target.posX - this.target.lastTickPosX) * (double)partialTicks;
    double d4 = this.target.lastTickPosY + (this.target.posY - this.target.lastTickPosY) * (double)partialTicks + (double)this.yOffset;
    double d5 = this.target.lastTickPosZ + (this.target.posZ - this.target.lastTickPosZ) * (double)partialTicks;
    double d6 = d0 + (d3 - d0) * (double)f;
    double d7 = d1 + (d4 - d1) * (double)f;
    double d8 = d2 + (d5 - d2) * (double)f;
    int i = this.getBrightnessForRender(partialTicks);
    int j = i % 65536;
    int k = i / 65536;
    OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, (float)j, (float)k);
    GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
    d6 = d6 - interpPosX;
    d7 = d7 - interpPosY;
    d8 = d8 - interpPosZ;
    GlStateManager.enableLighting();
    this.renderManager.doRenderEntity(this.item, d6, d7, d8, this.item.rotationYaw, partialTicks, false);
}
 
開發者ID:F1r3w477,項目名稱:CustomWorldGen,代碼行數:28,代碼來源:ParticleItemPickup.java

示例8: joinEntityInSurroundings

import net.minecraft.entity.Entity; //導入依賴的package包/類
/**
 * spwans an entity and loads surrounding chunks
 */
public void joinEntityInSurroundings(Entity entityIn)
{
    int i = MathHelper.floor_double(entityIn.posX / 16.0D);
    int j = MathHelper.floor_double(entityIn.posZ / 16.0D);
    int k = 2;

    for (int l = i - k; l <= i + k; ++l)
    {
        for (int i1 = j - k; i1 <= j + k; ++i1)
        {
            this.getChunkFromChunkCoords(l, i1);
        }
    }

    if (!this.loadedEntityList.contains(entityIn))
    {
        this.loadedEntityList.add(entityIn);
    }
}
 
開發者ID:SkidJava,項目名稱:BaseClient,代碼行數:23,代碼來源:World.java

示例9: addCollisionBoxToList

import net.minecraft.entity.Entity; //導入依賴的package包/類
/**
 * @reason the overwritten method is only one line, we need to overwrite to mutate the AABB and pass params into the event constructor
 * @author Brady
 */
@Overwrite
@Deprecated
public void addCollisionBoxToList(IBlockState state, World worldIn, BlockPos pos, AxisAlignedBB entityBox, List<AxisAlignedBB> collidingBoxes, @Nullable Entity entityIn, boolean p_185477_7_) {
    Block block = (Block) (Object) (this);
    AxisAlignedBB axisalignedbb = block.getCollisionBoundingBox(state, worldIn, pos);

    BoundingBoxEvent event = new BoundingBoxEvent(block, pos, axisalignedbb, collidingBoxes, entityIn);
    ClientAPI.EVENT_BUS.post(event);
    if (event.isCancelled())
        return;

    axisalignedbb = event.getBoundingBox();

    addCollisionBoxToList(pos, entityBox, collidingBoxes, axisalignedbb);
}
 
開發者ID:ImpactDevelopment,項目名稱:ClientAPI,代碼行數:20,代碼來源:MixinBlock.java

示例10: setRotationAngles

import net.minecraft.entity.Entity; //導入依賴的package包/類
public void setRotationAngles(float x, float y, float z, float yaw, float pitch, float tick, Entity entity)
{
	super.setRotationAngles(x, y, z, yaw, pitch, tick, entity);
	
	// Looking at things
	this.head.rotateAngleY = yaw / (180F / (float) Math.PI);
	this.head.rotateAngleX = pitch / (180F / (float) Math.PI);
	
	// Leg movement when wandering around?
	this.legC1.rotateAngleX = MathHelper.cos(x * 0.6662F) * 1.4F * y;
	this.legC1.rotateAngleY = 0.0F;
	 
	this.legC2.rotateAngleX = MathHelper.cos(x * 0.6662F + (float)Math.PI) * 1.4F * y;
	this.legC2.rotateAngleY = 0.0F;
	  
	this.legC3.rotateAngleX = MathHelper.cos(x * 0.6662F) * 1.4F * y;
	this.legC3.rotateAngleY = 0.0F;
	  
	this.legC4.rotateAngleX = MathHelper.cos(x * 0.6662F + (float)Math.PI) * 1.4F * y;
	this.legC4.rotateAngleY = 0.0F;
}
 
開發者ID:Domochevsky,項目名稱:minecraft-quiverbow,代碼行數:22,代碼來源:Model_AA.java

示例11: newExplosion

import net.minecraft.entity.Entity; //導入依賴的package包/類
/**
 * returns a new explosion. Does initiation (at time of writing Explosion is not finished)
 */
public Explosion newExplosion(Entity entityIn, double x, double y, double z, float strength, boolean isFlaming, boolean isSmoking)
{
    Explosion explosion = new Explosion(this, entityIn, x, y, z, strength, isFlaming, isSmoking);
    explosion.doExplosionA();
    explosion.doExplosionB(false);

    if (!isSmoking)
    {
        explosion.func_180342_d();
    }

    for (EntityPlayer entityplayer : this.playerEntities)
    {
        if (entityplayer.getDistanceSq(x, y, z) < 4096.0D)
        {
            ((EntityPlayerMP)entityplayer).playerNetServerHandler.sendPacket(new S27PacketExplosion(x, y, z, strength, explosion.getAffectedBlockPositions(), (Vec3)explosion.getPlayerKnockbackMap().get(entityplayer)));
        }
    }

    return explosion;
}
 
開發者ID:Notoh,項目名稱:DecompiledMinecraft,代碼行數:25,代碼來源:WorldServer.java

示例12: setRotationAngles

import net.minecraft.entity.Entity; //導入依賴的package包/類
/**
 * Sets the model's various rotation angles. For bipeds, par1 and par2 are used for animating the movement of arms
 * and legs, where par1 represents the time(so that arms and legs swing back and forth) and par2 represents how
 * "far" arms and legs can swing at most.
 */
public void setRotationAngles(float p_78087_1_, float p_78087_2_, float p_78087_3_, float p_78087_4_, float p_78087_5_, float p_78087_6_, Entity entityIn)
{
    super.setRotationAngles(p_78087_1_, p_78087_2_, p_78087_3_, p_78087_4_, p_78087_5_, p_78087_6_, entityIn);
    float f = MathHelper.sin(this.swingProgress * (float)Math.PI);
    float f1 = MathHelper.sin((1.0F - (1.0F - this.swingProgress) * (1.0F - this.swingProgress)) * (float)Math.PI);
    this.bipedRightArm.rotateAngleZ = 0.0F;
    this.bipedLeftArm.rotateAngleZ = 0.0F;
    this.bipedRightArm.rotateAngleY = -(0.1F - f * 0.6F);
    this.bipedLeftArm.rotateAngleY = 0.1F - f * 0.6F;
    this.bipedRightArm.rotateAngleX = -((float)Math.PI / 2F);
    this.bipedLeftArm.rotateAngleX = -((float)Math.PI / 2F);
    this.bipedRightArm.rotateAngleX -= f * 1.2F - f1 * 0.4F;
    this.bipedLeftArm.rotateAngleX -= f * 1.2F - f1 * 0.4F;
    this.bipedRightArm.rotateAngleZ += MathHelper.cos(p_78087_3_ * 0.09F) * 0.05F + 0.05F;
    this.bipedLeftArm.rotateAngleZ -= MathHelper.cos(p_78087_3_ * 0.09F) * 0.05F + 0.05F;
    this.bipedRightArm.rotateAngleX += MathHelper.sin(p_78087_3_ * 0.067F) * 0.05F;
    this.bipedLeftArm.rotateAngleX -= MathHelper.sin(p_78087_3_ * 0.067F) * 0.05F;
}
 
開發者ID:Notoh,項目名稱:DecompiledMinecraft,代碼行數:24,代碼來源:ModelZombieVillager.java

示例13: onImpact

import net.minecraft.entity.Entity; //導入依賴的package包/類
protected void onImpact(RayTraceResult result) {
	if (!this.world.isRemote && this.world instanceof WorldServer) {
		if (result.typeOfHit == RayTraceResult.Type.ENTITY && result.entityHit != null
				&& !result.entityHit.equals(this.caster)) {
			Entity entity = result.entityHit;
			if (!entity.isImmuneToFire()) {
				entity.setFire(7);
			}
		} else if (result.typeOfHit == RayTraceResult.Type.BLOCK && result.getBlockPos() != null
				&& result.sideHit != null) {
			BlockPos offsetPos = result.getBlockPos().offset(result.sideHit);
			if (this.world.getBlockState(offsetPos).getMaterial() != Material.WATER
					&& (this.world.isAirBlock(offsetPos)
							|| this.world.getBlockState(offsetPos).getBlock().isReplaceable(this.world, offsetPos))
					&& Blocks.FIRE.canPlaceBlockAt(this.world, offsetPos)) {
				this.world.setBlockState(offsetPos, Blocks.FIRE.getDefaultState(), 11);
			}
		}
	}
}
 
開發者ID:the-realest-stu,項目名稱:Infernum,代碼行數:21,代碼來源:EntityFireBreath.java

示例14: navigateTo

import net.minecraft.entity.Entity; //導入依賴的package包/類
@Override
public boolean navigateTo(Entity dest, Consumer<BlockPos> job, double maxDist) {
    if (dest == null || dest.isDead) {
        return false;
    }
    double d = getSquareDist(entity, dest);
    if (d > maxDist * maxDist) {
        return false;
    } else if (d < DISTANCE_TOLERANCE) {
        job.accept(dest.getPosition());
    } else if (!entity.getNavigator().tryMoveToEntityLiving(dest, 2.0)) {
        // We need to teleport
        entity.setPositionAndUpdate(dest.posX, dest.posY, dest.posZ);
        job.accept(dest.getPosition());
    } else {
        this.movingToPos = null;
        this.movingToEntity = dest;
        pathTries = 1;
        this.job = job;
    }
    return true;
}
 
開發者ID:McJty,項目名稱:MeeCreeps,代碼行數:23,代碼來源:WorkerHelper.java

示例15: onMessage

import net.minecraft.entity.Entity; //導入依賴的package包/類
@Override
public IMessage onMessage(final TeleportMessage message, final MessageContext ctx)
{
    // Don't act here - if we cause chunk loading on this thread (netty) then chunks will get
    // lost from the server.
    IThreadListener mainThread = null;
    if (ctx.side == Side.CLIENT)
        mainThread = Minecraft.getMinecraft();
    else
        mainThread = MinecraftServer.getServer();
    mainThread.addScheduledTask(new Runnable()
    {
        @Override
        public void run()
        {
            EnumSet<S08PacketPlayerPosLook.EnumFlags> enumset = EnumSet.noneOf(S08PacketPlayerPosLook.EnumFlags.class);
            if (!message.setX)
                enumset.add(S08PacketPlayerPosLook.EnumFlags.X);
            if (!message.setY)
                enumset.add(S08PacketPlayerPosLook.EnumFlags.Y);
            if (!message.setZ)
                enumset.add(S08PacketPlayerPosLook.EnumFlags.Z);
            if (!message.setYaw)
                enumset.add(S08PacketPlayerPosLook.EnumFlags.Y_ROT);
            if (!message.setPitch)
                enumset.add(S08PacketPlayerPosLook.EnumFlags.X_ROT);

            EntityPlayerMP player = ctx.getServerHandler().playerEntity;
            player.mountEntity((Entity) null);
            player.playerNetServerHandler.setPlayerLocation(message.x, message.y, message.z, message.yaw, message.pitch, enumset);
            player.setRotationYawHead(message.yaw);
        }
    });
    return null;
}
 
開發者ID:Yarichi,項目名稱:Proyecto-DASI,代碼行數:36,代碼來源:AbsoluteMovementCommandsImplementation.java


注:本文中的net.minecraft.entity.Entity類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。