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


Java EntityPlayer类代码示例

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


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

示例1: onDeath

import net.minecraft.entity.player.EntityPlayer; //导入依赖的package包/类
/**
 * Called when the mob's health reaches 0.
 */
public void onDeath(DamageSource cause)
{
    super.onDeath(cause);

    if (cause.getSourceOfDamage() instanceof EntityArrow && cause.getEntity() instanceof EntityPlayer)
    {
        EntityPlayer entityplayer = (EntityPlayer)cause.getEntity();
        double d0 = entityplayer.posX - this.posX;
        double d1 = entityplayer.posZ - this.posZ;

        if (d0 * d0 + d1 * d1 >= 2500.0D)
        {
            entityplayer.triggerAchievement(AchievementList.snipeSkeleton);
        }
    }
    else if (cause.getEntity() instanceof EntityCreeper && ((EntityCreeper)cause.getEntity()).getPowered() && ((EntityCreeper)cause.getEntity()).isAIEnabled())
    {
        ((EntityCreeper)cause.getEntity()).func_175493_co();
        this.entityDropItem(new ItemStack(Items.skull, 1, this.getSkeletonType() == 1 ? 1 : 0), 0.0F);
    }
}
 
开发者ID:Notoh,项目名称:DecompiledMinecraft,代码行数:25,代码来源:EntitySkeleton.java

示例2: shouldAttackPlayer

import net.minecraft.entity.player.EntityPlayer; //导入依赖的package包/类
/**
 * Checks to see if this enderman should be attacking this player
 */
private boolean shouldAttackPlayer(EntityPlayer player)
{
    ItemStack itemstack = player.inventory.armorInventory[3];

    if (itemstack != null && itemstack.getItem() == Item.getItemFromBlock(Blocks.pumpkin))
    {
        return false;
    }
    else
    {
        Vec3 vec3 = player.getLook(1.0F).normalize();
        Vec3 vec31 = new Vec3(this.posX - player.posX, this.getEntityBoundingBox().minY + (double)(this.height / 2.0F) - (player.posY + (double)player.getEyeHeight()), this.posZ - player.posZ);
        double d0 = vec31.lengthVector();
        vec31 = vec31.normalize();
        double d1 = vec3.dotProduct(vec31);
        return d1 > 1.0D - 0.025D / d0 ? player.canEntityBeSeen(this) : false;
    }
}
 
开发者ID:SkidJava,项目名称:BaseClient,代码行数:22,代码来源:EntityEnderman.java

示例3: EntitySheep

import net.minecraft.entity.player.EntityPlayer; //导入依赖的package包/类
public EntitySheep(World worldIn)
{
    super(worldIn);
    this.setSize(0.9F, 1.3F);
    ((PathNavigateGround)this.getNavigator()).setAvoidsWater(true);
    this.tasks.addTask(0, new EntityAISwimming(this));
    this.tasks.addTask(1, new EntityAIPanic(this, 1.25D));
    this.tasks.addTask(2, new EntityAIMate(this, 1.0D));
    this.tasks.addTask(3, new EntityAITempt(this, 1.1D, Items.wheat, false));
    this.tasks.addTask(4, new EntityAIFollowParent(this, 1.1D));
    this.tasks.addTask(5, this.entityAIEatGrass);
    this.tasks.addTask(6, new EntityAIWander(this, 1.0D));
    this.tasks.addTask(7, new EntityAIWatchClosest(this, EntityPlayer.class, 6.0F));
    this.tasks.addTask(8, new EntityAILookIdle(this));
    this.inventoryCrafting.setInventorySlotContents(0, new ItemStack(Items.dye, 1, 0));
    this.inventoryCrafting.setInventorySlotContents(1, new ItemStack(Items.dye, 1, 0));
}
 
开发者ID:SkidJava,项目名称:BaseClient,代码行数:18,代码来源:EntitySheep.java

示例4: onMessage

import net.minecraft.entity.player.EntityPlayer; //导入依赖的package包/类
@Override
public IMessage onMessage(final PacketClassGui message, final MessageContext ctx) 
{			
	IThreadListener mainThread = Minecraft.getMinecraft();
	mainThread.addScheduledTask(new Runnable()
	{
		@Override
		public void run() 
		{
			EntityPlayer player = Minecraft.getMinecraft().player;
			PlayerInformation playerInfo = (PlayerInformation) player.getCapability(CapabilityPlayerInformation.PLAYER_INFORMATION, null);
			
			if (playerInfo != null && playerInfo.getPlayerClass() == 0)
			{
				player.openGui(LootSlashConquer.instance, GuiHandler.CLASS_SELECTION, player.getEntityWorld(), player.getPosition().getX(), player.getPosition().getY(), player.getPosition().getZ());
			}
		}
	});
	
	return null;
}
 
开发者ID:TheXFactor117,项目名称:Loot-Slash-Conquer,代码行数:22,代码来源:PacketClassGui.java

示例5: emulateSendMotion

import net.minecraft.entity.player.EntityPlayer; //导入依赖的package包/类
private static void emulateSendMotion(EntityPlayer player) {
    // emulate client player's sendMotion
    Vec3d newPosition = null;
    if (player.isRiding()) {
        // needs improvement
        newPosition = getPosition(player);
        emulateHandleMotion(player, newPosition, getOnGround(player));
    } else if (getView() == player) {
        double dx = getX(sentPosition) - getX(player);
        double dy = getY(sentPosition) - getY(player);
        double dz = getZ(sentPosition) - getZ(player);
        boolean sync = (dx*dx + dy*dy + dz*dz > 9.0E-4D
            || ticksForForceSync >= 20);
        ++ticksForForceSync;
        if (sync) {
            newPosition = sentPosition = getPosition(player);
            ticksForForceSync = 0;
        }
        emulateHandleMotion(player, newPosition, getOnGround(player));
    }
}
 
开发者ID:NSExceptional,项目名称:Zombe-Modpack,代码行数:22,代码来源:Motion.java

示例6: onFallenUpon

import net.minecraft.entity.player.EntityPlayer; //导入依赖的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:Notoh,项目名称:DecompiledMinecraft,代码行数:21,代码来源:BlockFarmland.java

示例7: onCreated

import net.minecraft.entity.player.EntityPlayer; //导入依赖的package包/类
/** Makes your Item Enchanted when it is crafted */
public void onCreated(ItemStack item, World world, EntityPlayer player) 
{
    item.addEnchantment(Enchantment.sharpness, 5);
    // Replace the "." after "Enchantment" to see options
    // The number is the Enchantment Level
}
 
开发者ID:marcus8448,项目名称:IceMod,代码行数:8,代码来源:IceFragment.java

示例8: EntitySkeleton

import net.minecraft.entity.player.EntityPlayer; //导入依赖的package包/类
public EntitySkeleton(World worldIn)
{
    super(worldIn);
    this.tasks.addTask(1, new EntityAISwimming(this));
    this.tasks.addTask(2, new EntityAIRestrictSun(this));
    this.tasks.addTask(3, new EntityAIFleeSun(this, 1.0D));
    this.tasks.addTask(3, new EntityAIAvoidEntity(this, EntityWolf.class, 6.0F, 1.0D, 1.2D));
    this.tasks.addTask(4, new EntityAIWander(this, 1.0D));
    this.tasks.addTask(6, new EntityAIWatchClosest(this, EntityPlayer.class, 8.0F));
    this.tasks.addTask(6, new EntityAILookIdle(this));
    this.targetTasks.addTask(1, new EntityAIHurtByTarget(this, false, new Class[0]));
    this.targetTasks.addTask(2, new EntityAINearestAttackableTarget(this, EntityPlayer.class, true));
    this.targetTasks.addTask(3, new EntityAINearestAttackableTarget(this, EntityIronGolem.class, true));

    if (worldIn != null && !worldIn.isRemote)
    {
        this.setCombatTask();
    }
}
 
开发者ID:Notoh,项目名称:DecompiledMinecraft,代码行数:20,代码来源:EntitySkeleton.java

示例9: ContainerHopper

import net.minecraft.entity.player.EntityPlayer; //导入依赖的package包/类
public ContainerHopper(InventoryPlayer playerInventory, IInventory hopperInventoryIn, EntityPlayer player)
{
    this.hopperInventory = hopperInventoryIn;
    hopperInventoryIn.openInventory(player);
    int i = 51;

    for (int j = 0; j < hopperInventoryIn.getSizeInventory(); ++j)
    {
        this.addSlotToContainer(new Slot(hopperInventoryIn, j, 44 + j * 18, 20));
    }

    for (int l = 0; l < 3; ++l)
    {
        for (int k = 0; k < 9; ++k)
        {
            this.addSlotToContainer(new Slot(playerInventory, k + l * 9 + 9, 8 + k * 18, l * 18 + i));
        }
    }

    for (int i1 = 0; i1 < 9; ++i1)
    {
        this.addSlotToContainer(new Slot(playerInventory, i1, 8 + i1 * 18, 58 + i));
    }
}
 
开发者ID:Notoh,项目名称:DecompiledMinecraft,代码行数:25,代码来源:ContainerHopper.java

示例10: findPlayers

import net.minecraft.entity.player.EntityPlayer; //导入依赖的package包/类
@SideOnly(Side.CLIENT)
public void findPlayers()
{
    Iterator<String> ite = playersNames.iterator();
    while(ite.hasNext())
    {
        String s = ite.next();
        if(Minecraft.getMinecraft().world != null)
        {
            EntityPlayer player = Minecraft.getMinecraft().world.getPlayerEntityByName(s);
            if(player != null && player.isEntityAlive())
            {
                players.put(player, 0);
                ite.remove();
            }
        }
    }
}
 
开发者ID:iChun,项目名称:Clef,代码行数:19,代码来源:Track.java

示例11: distributeDamage

import net.minecraft.entity.player.EntityPlayer; //导入依赖的package包/类
@Override
public float distributeDamage(float damage, @Nonnull EntityPlayer player, @Nonnull DamageSource source, boolean addStat) {
    AbstractPlayerDamageModel damageModel = PlayerDataManager.getDamageModel(player);
    for (Pair<EntityEquipmentSlot, EnumPlayerPart[]> pair : getPartList()) {
        EntityEquipmentSlot slot = pair.getLeft();
        damage = ArmorUtils.applyArmor(player, player.getItemStackFromSlot(slot), source, damage, slot);
        if (damage <= 0F)
            return 0F;
        damage = ArmorUtils.applyEnchantmentModifiers(player.getItemStackFromSlot(slot), source, damage);
        if (damage <= 0F)
            return 0F;

        damage = distributeDamageOnParts(damage, damageModel, pair.getRight(), player, addStat);
        if (damage == 0F)
            break;
    }
    return damage;
}
 
开发者ID:ichttt,项目名称:FirstAid,代码行数:19,代码来源:DamageDistribution.java

示例12: onItemRightClick

import net.minecraft.entity.player.EntityPlayer; //导入依赖的package包/类
public ActionResult<ItemStack> onItemRightClick(ItemStack itemStackIn, World worldIn, EntityPlayer playerIn, EnumHand hand)
{
    EntityEquipmentSlot entityequipmentslot = EntityLiving.getSlotForItemStack(itemStackIn);
    ItemStack itemstack = playerIn.getItemStackFromSlot(entityequipmentslot);

    if (itemstack == null)
    {
        playerIn.setItemStackToSlot(entityequipmentslot, itemStackIn.copy());
        itemStackIn.stackSize = 0;
        return new ActionResult(EnumActionResult.SUCCESS, itemStackIn);
    }
    else
    {
        return new ActionResult(EnumActionResult.FAIL, itemStackIn);
    }
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:17,代码来源:ItemElytra.java

示例13: sendMessageToAllTeamMembers

import net.minecraft.entity.player.EntityPlayer; //导入依赖的package包/类
public void sendMessageToAllTeamMembers(EntityPlayer player, IChatComponent message)
{
    Team team = player.getTeam();

    if (team != null)
    {
        for (String s : team.getMembershipCollection())
        {
            EntityPlayerMP entityplayermp = this.getPlayerByUsername(s);

            if (entityplayermp != null && entityplayermp != player)
            {
                entityplayermp.addChatMessage(message);
            }
        }
    }
}
 
开发者ID:SkidJava,项目名称:BaseClient,代码行数:18,代码来源:ServerConfigurationManager.java

示例14: isAllowedToEdit

import net.minecraft.entity.player.EntityPlayer; //导入依赖的package包/类
private boolean isAllowedToEdit(EntityPlayer player, ItemStack remote) {
    NBTTagCompound tag = remote.getTagCompound();
    if (tag != null) {
        if (tag.hasKey("securityX")) {
            int x = tag.getInteger("securityX");
            int y = tag.getInteger("securityY");
            int z = tag.getInteger("securityZ");
            int dimensionId = tag.getInteger("securityDimension");
            WorldServer world = DimensionManager.getWorld(dimensionId);
            if (world != null) {
                TileEntity te = world.getTileEntity(new BlockPos(x, y, z));
                if (te instanceof TileEntitySecurityStation) {
                    boolean canAccess = ((TileEntitySecurityStation) te).doesAllowPlayer(player);
                    if (!canAccess) {
                        player.sendStatusMessage(new TextComponentTranslation("gui.remote.noEditRights", x, y, z), false);
                    }
                    return canAccess;
                }
            }
        }
    }
    return true;
}
 
开发者ID:TeamPneumatic,项目名称:pnc-repressurized,代码行数:24,代码来源:ItemRemote.java

示例15: usedBy

import net.minecraft.entity.player.EntityPlayer; //导入依赖的package包/类
public boolean usedBy(EntityPlayer player)
{
    if (!player.canUseCommandBlock())
    {
        return false;
    }
    else
    {
        if (player.getEntityWorld().isRemote)
        {
            player.openEditStructure(this);
        }

        return true;
    }
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:17,代码来源:TileEntityStructure.java


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