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


Java EntityLivingBase类代码示例

本文整理汇总了Java中net.minecraft.entity.EntityLivingBase的典型用法代码示例。如果您正苦于以下问题:Java EntityLivingBase类的具体用法?Java EntityLivingBase怎么用?Java EntityLivingBase使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


EntityLivingBase类属于net.minecraft.entity包,在下文中一共展示了EntityLivingBase类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onFallenUpon

import net.minecraft.entity.EntityLivingBase; //导入依赖的package包/类
/**
 * Block's chance to react to a living entity falling on it.
 */
public void onFallenUpon(World worldIn, BlockPos pos, Entity entityIn, float fallDistance)
{
    if (entityIn instanceof EntityLivingBase)
    {
        if (!worldIn.isRemote && worldIn.rand.nextFloat() < fallDistance - 0.5F)
        {
            if (!(entityIn instanceof EntityPlayer) && !worldIn.getGameRules().getBoolean("mobGriefing"))
            {
                return;
            }

            worldIn.setBlockState(pos, Blocks.dirt.getDefaultState());
        }

        super.onFallenUpon(worldIn, pos, entityIn, fallDistance);
    }
}
 
开发者ID:SkidJava,项目名称:BaseClient,代码行数:21,代码来源:BlockFarmland.java

示例2: getNearestTargetPlayer

import net.minecraft.entity.EntityLivingBase; //导入依赖的package包/类
public EntityPlayer getNearestTargetPlayer(EntityLivingBase villageDefender)
{
    double d0 = Double.MAX_VALUE;
    EntityPlayer entityplayer = null;

    for (String s : this.playerReputation.keySet())
    {
        if (this.isPlayerReputationTooLow(s))
        {
            EntityPlayer entityplayer1 = this.worldObj.getPlayerEntityByName(s);

            if (entityplayer1 != null)
            {
                double d1 = entityplayer1.getDistanceSqToEntity(villageDefender);

                if (d1 <= d0)
                {
                    entityplayer = entityplayer1;
                    d0 = d1;
                }
            }
        }
    }

    return entityplayer;
}
 
开发者ID:Notoh,项目名称:DecompiledMinecraft,代码行数:27,代码来源:Village.java

示例3: shouldExecute

import net.minecraft.entity.EntityLivingBase; //导入依赖的package包/类
/**
 * Returns whether the EntityAIBase should begin execution.
 */
public boolean shouldExecute()
{
    EntityLivingBase entitylivingbase = this.attacker.getAttackTarget();

    if (entitylivingbase == null)
    {
        return false;
    }
    else if (!entitylivingbase.isEntityAlive())
    {
        return false;
    }
    else if (this.classTarget != null && !this.classTarget.isAssignableFrom(entitylivingbase.getClass()))
    {
        return false;
    }
    else
    {
        this.entityPathEntity = this.attacker.getNavigator().getPathToEntityLiving(entitylivingbase);
        return this.entityPathEntity != null;
    }
}
 
开发者ID:SkidJava,项目名称:BaseClient,代码行数:26,代码来源:EntityAIAttackOnCollide.java

示例4: adjustPosToNearbyEntity

import net.minecraft.entity.EntityLivingBase; //导入依赖的package包/类
protected BlockPos adjustPosToNearbyEntity(BlockPos pos)
{
    BlockPos blockpos = this.getPrecipitationHeight(pos);
    AxisAlignedBB axisalignedbb = (new AxisAlignedBB(blockpos, new BlockPos(blockpos.getX(), this.getHeight(), blockpos.getZ()))).expandXyz(3.0D);
    List<EntityLivingBase> list = this.getEntitiesWithinAABB(EntityLivingBase.class, axisalignedbb, new Predicate<EntityLivingBase>()
    {
        public boolean apply(@Nullable EntityLivingBase p_apply_1_)
        {
            return p_apply_1_ != null && p_apply_1_.isEntityAlive() && WorldServer.this.canSeeSky(p_apply_1_.getPosition());
        }
    });

    if (!list.isEmpty())
    {
        return ((EntityLivingBase)list.get(this.rand.nextInt(list.size()))).getPosition();
    }
    else
    {
        if (blockpos.getY() == -1)
        {
            blockpos = blockpos.up(2);
        }

        return blockpos;
    }
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:27,代码来源:WorldServer.java

示例5: handleCombatEvent

import net.minecraft.entity.EntityLivingBase; //导入依赖的package包/类
public void handleCombatEvent(S42PacketCombatEvent packetIn) {
	PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.gameController);
	Entity entity = this.clientWorldController.getEntityByID(packetIn.field_179775_c);
	EntityLivingBase entitylivingbase = entity instanceof EntityLivingBase ? (EntityLivingBase) entity : null;

	if (packetIn.eventType == S42PacketCombatEvent.Event.END_COMBAT) {
		long i = (long) (1000 * packetIn.field_179772_d / 20);
		MetadataCombat metadatacombat = new MetadataCombat(this.gameController.thePlayer, entitylivingbase);
		this.gameController.getTwitchStream().func_176026_a(metadatacombat, 0L - i, 0L);
	} else if (packetIn.eventType == S42PacketCombatEvent.Event.ENTITY_DIED) {
		Entity entity1 = this.clientWorldController.getEntityByID(packetIn.field_179774_b);

		if (entity1 instanceof EntityPlayer) {
			MetadataPlayerDeath metadataplayerdeath = new MetadataPlayerDeath((EntityPlayer) entity1,
					entitylivingbase);
			metadataplayerdeath.func_152807_a(packetIn.deathMessage);
			this.gameController.getTwitchStream().func_152911_a(metadataplayerdeath, 0L);
		}
	}
}
 
开发者ID:SkidJava,项目名称:BaseClient,代码行数:21,代码来源:NetHandlerPlayClient.java

示例6: shouldExecute

import net.minecraft.entity.EntityLivingBase; //导入依赖的package包/类
/**
 * Returns whether the EntityAIBase should begin execution.
 */
public boolean shouldExecute()
{
    if (!this.theEntity.isTamed())
    {
        return false;
    }
    else if (this.theEntity.isInWater())
    {
        return false;
    }
    else if (!this.theEntity.onGround)
    {
        return false;
    }
    else
    {
        EntityLivingBase entitylivingbase = this.theEntity.getOwner();
        return entitylivingbase == null ? true : (this.theEntity.getDistanceSqToEntity(entitylivingbase) < 144.0D && entitylivingbase.getAITarget() != null ? false : this.isSitting);
    }
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:24,代码来源:EntityAISit.java

示例7: canEasilyReach

import net.minecraft.entity.EntityLivingBase; //导入依赖的package包/类
/**
 * Checks to see if this entity can find a short path to the given target.
 */
private boolean canEasilyReach(EntityLivingBase p_75295_1_)
{
    this.targetSearchDelay = 10 + this.taskOwner.getRNG().nextInt(5);
    PathEntity pathentity = this.taskOwner.getNavigator().getPathToEntityLiving(p_75295_1_);

    if (pathentity == null)
    {
        return false;
    }
    else
    {
        PathPoint pathpoint = pathentity.getFinalPathPoint();

        if (pathpoint == null)
        {
            return false;
        }
        else
        {
            int i = pathpoint.xCoord - MathHelper.floor_double(p_75295_1_.posX);
            int j = pathpoint.zCoord - MathHelper.floor_double(p_75295_1_.posZ);
            return (double)(i * i + j * j) <= 2.25D;
        }
    }
}
 
开发者ID:Notoh,项目名称:DecompiledMinecraft,代码行数:29,代码来源:EntityAITarget.java

示例8: handleBounty

import net.minecraft.entity.EntityLivingBase; //导入依赖的package包/类
@SubscribeEvent
public void handleBounty(LootingLevelEvent event) {
	EntityLivingBase target = event.getEntityLiving();
	EntityLivingBase attacker = target.getAttackingEntity();
	if (attacker instanceof EntityPlayer) {
		EntityPlayer player = (EntityPlayer) attacker;
		Collection<PotionEffect> potions = player.getActivePotionEffects();
		for (PotionEffect potion : potions) {
			if (potion.getPotion() instanceof PotionHunt) {
				PotionHunt huntPotion = (PotionHunt) potion.getPotion();
				if (huntPotion.appliesTo(target)) {
					event.setLootingLevel(event.getLootingLevel() + 2);

					return;
				}
			}
		}
	}
}
 
开发者ID:TeamMelodium,项目名称:Melodium,代码行数:20,代码来源:SongHunt.java

示例9: EntityGuardian

import net.minecraft.entity.EntityLivingBase; //导入依赖的package包/类
public EntityGuardian(World worldIn)
{
    super(worldIn);
    this.experienceValue = 10;
    this.setSize(0.85F, 0.85F);
    this.tasks.addTask(4, new EntityGuardian.AIGuardianAttack(this));
    EntityAIMoveTowardsRestriction entityaimovetowardsrestriction;
    this.tasks.addTask(5, entityaimovetowardsrestriction = new EntityAIMoveTowardsRestriction(this, 1.0D));
    this.tasks.addTask(7, this.wander = new EntityAIWander(this, 1.0D, 80));
    this.tasks.addTask(8, new EntityAIWatchClosest(this, EntityPlayer.class, 8.0F));
    this.tasks.addTask(8, new EntityAIWatchClosest(this, EntityGuardian.class, 12.0F, 0.01F));
    this.tasks.addTask(9, new EntityAILookIdle(this));
    this.wander.setMutexBits(3);
    entityaimovetowardsrestriction.setMutexBits(3);
    this.targetTasks.addTask(1, new EntityAINearestAttackableTarget(this, EntityLivingBase.class, 10, true, false, new EntityGuardian.GuardianTargetSelector(this)));
    this.moveHelper = new EntityGuardian.GuardianMoveHelper(this);
    this.field_175484_c = this.field_175482_b = this.rand.nextFloat();
}
 
开发者ID:SkidJava,项目名称:BaseClient,代码行数:19,代码来源:EntityGuardian.java

示例10: itemInteractionForEntity

import net.minecraft.entity.EntityLivingBase; //导入依赖的package包/类
/**
 * Returns true if the item can be used on the given entity, e.g. shears on sheep.
 */
public boolean itemInteractionForEntity(ItemStack stack, EntityPlayer playerIn, EntityLivingBase target)
{
    if (target instanceof EntitySheep)
    {
        EntitySheep entitysheep = (EntitySheep)target;
        EnumDyeColor enumdyecolor = EnumDyeColor.byDyeDamage(stack.getMetadata());

        if (!entitysheep.getSheared() && entitysheep.getFleeceColor() != enumdyecolor)
        {
            entitysheep.setFleeceColor(enumdyecolor);
            --stack.stackSize;
        }

        return true;
    }
    else
    {
        return false;
    }
}
 
开发者ID:SkidJava,项目名称:BaseClient,代码行数:24,代码来源:ItemDye.java

示例11: onBlockPlaced

import net.minecraft.entity.EntityLivingBase; //导入依赖的package包/类
/**
 * Called by ItemBlocks just before a block is actually set in the world, to
 * allow for adjustments to the IBlockstate
 */
public IBlockState onBlockPlaced(World worldIn, BlockPos pos, EnumFacing facing, float hitX, float hitY, float hitZ,
		int meta, EntityLivingBase placer) {
	IBlockState iblockstate = this.getDefaultState().withProperty(POWERED, Boolean.valueOf(false));

	if (func_181090_a(worldIn, pos, facing.getOpposite())) {
		return iblockstate.withProperty(FACING,
				BlockLever.EnumOrientation.forFacings(facing, placer.getHorizontalFacing()));
	} else {
		for (Object enumfacing0 : EnumFacing.Plane.HORIZONTAL) {
			EnumFacing enumfacing = (EnumFacing) enumfacing0;
			if (enumfacing != facing && func_181090_a(worldIn, pos, enumfacing.getOpposite())) {
				return iblockstate.withProperty(FACING,
						BlockLever.EnumOrientation.forFacings(enumfacing, placer.getHorizontalFacing()));
			}
		}

		if (World.doesBlockHaveSolidTopSurface(worldIn, pos.down())) {
			return iblockstate.withProperty(FACING,
					BlockLever.EnumOrientation.forFacings(EnumFacing.UP, placer.getHorizontalFacing()));
		} else {
			return iblockstate;
		}
	}
}
 
开发者ID:SkidJava,项目名称:BaseClient,代码行数:29,代码来源:BlockLever.java

示例12: shouldExecute

import net.minecraft.entity.EntityLivingBase; //导入依赖的package包/类
public boolean shouldExecute()
{
    if (EntityPolarBear.this.isChild())
    {
        return false;
    }
    else
    {
        if (super.shouldExecute())
        {
            for (EntityPolarBear entitypolarbear : EntityPolarBear.this.world.getEntitiesWithinAABB(EntityPolarBear.class, EntityPolarBear.this.getEntityBoundingBox().expand(8.0D, 4.0D, 8.0D)))
            {
                if (entitypolarbear.isChild())
                {
                    return true;
                }
            }
        }

        EntityPolarBear.this.setAttackTarget((EntityLivingBase)null);
        return false;
    }
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:24,代码来源:EntityPolarBear.java

示例13: doRenderLayer

import net.minecraft.entity.EntityLivingBase; //导入依赖的package包/类
public void doRenderLayer(EntityLivingBase entitylivingbaseIn, float limbSwing, float limbSwingAmount, float partialTicks, float ageInTicks, float netHeadYaw, float headPitch, float scale)
{
    boolean flag = entitylivingbaseIn.getPrimaryHand() == EnumHandSide.RIGHT;
    ItemStack itemstack = flag ? entitylivingbaseIn.getHeldItemOffhand() : entitylivingbaseIn.getHeldItemMainhand();
    ItemStack itemstack1 = flag ? entitylivingbaseIn.getHeldItemMainhand() : entitylivingbaseIn.getHeldItemOffhand();

    if (itemstack != null || itemstack1 != null)
    {
        GlStateManager.pushMatrix();

        if (this.livingEntityRenderer.getMainModel().isChild)
        {
            float f = 0.5F;
            GlStateManager.translate(0.0F, 0.625F, 0.0F);
            GlStateManager.rotate(-20.0F, -1.0F, 0.0F, 0.0F);
            GlStateManager.scale(0.5F, 0.5F, 0.5F);
        }

        this.renderHeldItem(entitylivingbaseIn, itemstack1, ItemCameraTransforms.TransformType.THIRD_PERSON_RIGHT_HAND, EnumHandSide.RIGHT);
        this.renderHeldItem(entitylivingbaseIn, itemstack, ItemCameraTransforms.TransformType.THIRD_PERSON_LEFT_HAND, EnumHandSide.LEFT);
        GlStateManager.popMatrix();
    }
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:24,代码来源:LayerHeldItem.java

示例14: onSkeletonDeath

import net.minecraft.entity.EntityLivingBase; //导入依赖的package包/类
@SubscribeEvent
public void onSkeletonDeath(LivingDeathEvent event) {
    EntityLivingBase entity = event.getEntityLiving();
    Entity sourceOfDamage = event.getSource().getSourceOfDamage();
    if (entity instanceof EntitySkeleton && sourceOfDamage instanceof EntityPlayer &&
      entity.isServerWorld()) {
        spawnWitherSkeleton(entity.getEntityWorld(), entity.getPosition());
        destroyHeldTool((EntityPlayer) sourceOfDamage);
    }
}
 
开发者ID:elifoster,项目名称:MakeClayValuableAgain,代码行数:11,代码来源:ClayProgressionImprovements.java

示例15: freezeNearby

import net.minecraft.entity.EntityLivingBase; //导入依赖的package包/类
public static void freezeNearby(EntityLivingBase living, World worldIn, BlockPos pos, int level)
{
    if (living.onGround)
    {
        float f = (float)Math.min(16, 2 + level);
        BlockPos.MutableBlockPos blockpos$mutableblockpos = new BlockPos.MutableBlockPos(0, 0, 0);

        for (BlockPos.MutableBlockPos blockpos$mutableblockpos1 : BlockPos.getAllInBoxMutable(pos.add((double)(-f), -1.0D, (double)(-f)), pos.add((double)f, -1.0D, (double)f)))
        {
            if (blockpos$mutableblockpos1.distanceSqToCenter(living.posX, living.posY, living.posZ) <= (double)(f * f))
            {
                blockpos$mutableblockpos.setPos(blockpos$mutableblockpos1.getX(), blockpos$mutableblockpos1.getY() + 1, blockpos$mutableblockpos1.getZ());
                IBlockState iblockstate = worldIn.getBlockState(blockpos$mutableblockpos);

                if (iblockstate.getMaterial() == Material.AIR)
                {
                    IBlockState iblockstate1 = worldIn.getBlockState(blockpos$mutableblockpos1);

                    if (iblockstate1.getMaterial() == Material.WATER && ((Integer)iblockstate1.getValue(BlockLiquid.LEVEL)).intValue() == 0 && worldIn.func_190527_a(Blocks.FROSTED_ICE, blockpos$mutableblockpos1, false, EnumFacing.DOWN, (Entity)null))
                    {
                        worldIn.setBlockState(blockpos$mutableblockpos1, Blocks.FROSTED_ICE.getDefaultState());
                        worldIn.scheduleUpdate(blockpos$mutableblockpos1.toImmutable(), Blocks.FROSTED_ICE, MathHelper.getInt(living.getRNG(), 60, 120));
                    }
                }
            }
        }
    }
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:29,代码来源:EnchantmentFrostWalker.java


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