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


Java EntityPlayer.addExhaustion方法代码示例

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


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

示例1: harvestBlock

import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
public void harvestBlock(World worldIn, EntityPlayer player, BlockPos pos, IBlockState state, TileEntity te)
{
    player.triggerAchievement(StatList.mineBlockStatArray[getIdFromBlock(this)]);
    player.addExhaustion(0.025F);

    if (this.canSilkHarvest() && EnchantmentHelper.getSilkTouchModifier(player))
    {
        ItemStack itemstack = this.createStackedBlock(state);

        if (itemstack != null)
        {
            spawnAsEntity(worldIn, pos, itemstack);
        }
    }
    else
    {
        int i = EnchantmentHelper.getFortuneModifier(player);
        this.dropBlockAsItem(worldIn, pos, state, i);
    }
}
 
开发者ID:Notoh,项目名称:DecompiledMinecraft,代码行数:21,代码来源:Block.java

示例2: harvestBlock

import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
public void harvestBlock(World worldIn, EntityPlayer player, BlockPos pos, IBlockState state, @Nullable TileEntity te, ItemStack stack)
{
    player.addStat(StatList.getBlockStats(this));
    player.addExhaustion(0.005F);

    if (this.canSilkHarvest() && EnchantmentHelper.getEnchantmentLevel(Enchantments.SILK_TOUCH, stack) > 0)
    {
        ItemStack itemstack = this.getSilkTouchDrop(state);
        spawnAsEntity(worldIn, pos, itemstack);
    }
    else
    {
        int i = EnchantmentHelper.getEnchantmentLevel(Enchantments.FORTUNE, stack);
        this.dropBlockAsItem(worldIn, pos, state, i);
    }
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:17,代码来源:Block.java

示例3: harvestBlock

import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
@Override
public void harvestBlock(World worldIn, EntityPlayer player, BlockPos pos, IBlockState state, @Nullable TileEntity te, @Nullable ItemStack stack) {
	player.addStat(StatList.getBlockStats(this));
	player.addExhaustion(0.025F);
	ItemStack itemstack = new ItemStack(this);
	NBTTagCompound nbttagcompound = new NBTTagCompound();
	te.writeToNBT(nbttagcompound);
	itemstack.setTagInfo("BlockEntityTag", nbttagcompound);
	spawnAsEntity(worldIn, pos, itemstack);
}
 
开发者ID:p455w0rd,项目名称:DankNull,代码行数:11,代码来源:BlockDankNullDock.java

示例4: harvestBlockImpl

import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
public static <T extends Block & IImplementableBlock> void harvestBlockImpl(T self, World worldIn, EntityPlayer player, BlockPos pos, IBlockState state, @Nullable TileEntity te, ItemStack stack) {
    player.addStat(StatList.getBlockStats(self));
    player.addExhaustion(0.005F);

    self.setHarvester(player);
    int i = EnchantmentHelper.getEnchantmentLevel(Enchantments.FORTUNE, stack);
    self.dropBlockAsItemWithChance(worldIn, pos, state, 1f, i, te);
    self.setHarvester(null);
}
 
开发者ID:Randores,项目名称:Randores2,代码行数:10,代码来源:RandoresItemHelper.java

示例5: harvestBlock

import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
public void harvestBlock(World worldIn, EntityPlayer player, BlockPos pos, IBlockState state, TileEntity te)
{
    player.triggerAchievement(StatList.mineBlockStatArray[Block.getIdFromBlock(this)]);
    player.addExhaustion(0.025F);

    if (this.canSilkHarvest() && EnchantmentHelper.getSilkTouchModifier(player))
    {
        ItemStack itemstack = this.createStackedBlock(state);

        if (itemstack != null)
        {
            spawnAsEntity(worldIn, pos, itemstack);
        }
    }
    else
    {
        if (worldIn.provider.doesWaterVaporize())
        {
            worldIn.setBlockToAir(pos);
            return;
        }

        int i = EnchantmentHelper.getFortuneModifier(player);
        this.dropBlockAsItem(worldIn, pos, state, i);
        Material material = worldIn.getBlockState(pos.down()).getBlock().getMaterial();

        if (material.blocksMovement() || material.isLiquid())
        {
            worldIn.setBlockState(pos, Blocks.flowing_water.getDefaultState());
        }
    }
}
 
开发者ID:Notoh,项目名称:DecompiledMinecraft,代码行数:33,代码来源:BlockIce.java

示例6: harvestBlock

import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
public void harvestBlock(World worldIn, EntityPlayer player, BlockPos pos, IBlockState state, TileEntity te) {
	player.triggerAchievement(StatList.mineBlockStatArray[getIdFromBlock(this)]);
	player.addExhaustion(0.025F);

	if (this.canSilkHarvest() && EnchantmentHelper.getSilkTouchModifier(player)) {
		ItemStack itemstack = this.createStackedBlock(state);

		if (itemstack != null) {
			spawnAsEntity(worldIn, pos, itemstack);
		}
	} else {
		int i = EnchantmentHelper.getFortuneModifier(player);
		this.dropBlockAsItem(worldIn, pos, state, i);
	}
}
 
开发者ID:SkidJava,项目名称:BaseClient,代码行数:16,代码来源:Block.java

示例7: harvestBlock

import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
public void harvestBlock(World worldIn, EntityPlayer player, BlockPos pos, IBlockState state, @Nullable TileEntity te, ItemStack stack)
{
    player.addStat(StatList.getBlockStats(this));
    player.addExhaustion(0.005F);

    if (this.canSilkHarvest() && EnchantmentHelper.getEnchantmentLevel(Enchantments.SILK_TOUCH, stack) > 0)
    {
        spawnAsEntity(worldIn, pos, this.getSilkTouchDrop(state));
    }
    else
    {
        if (worldIn.provider.doesWaterVaporize())
        {
            worldIn.setBlockToAir(pos);
            return;
        }

        int i = EnchantmentHelper.getEnchantmentLevel(Enchantments.FORTUNE, stack);
        this.dropBlockAsItem(worldIn, pos, state, i);
        Material material = worldIn.getBlockState(pos.down()).getMaterial();

        if (material.blocksMovement() || material.isLiquid())
        {
            worldIn.setBlockState(pos, Blocks.FLOWING_WATER.getDefaultState());
        }
    }
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:28,代码来源:BlockIce.java

示例8: harvestBlock

import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
public void harvestBlock(World worldIn, EntityPlayer player, BlockPos pos, IBlockState state, @Nullable TileEntity te, ItemStack stack)
{
    if (te instanceof IWorldNameable && ((IWorldNameable)te).hasCustomName())
    {
        player.addStat(StatList.getBlockStats(this));
        player.addExhaustion(0.005F);

        if (worldIn.isRemote)
        {
            return;
        }

        int i = EnchantmentHelper.getEnchantmentLevel(Enchantments.FORTUNE, stack);
        Item item = this.getItemDropped(state, worldIn.rand, i);

        if (item == Items.field_190931_a)
        {
            return;
        }

        ItemStack itemstack = new ItemStack(item, this.quantityDropped(worldIn.rand));
        itemstack.setStackDisplayName(((IWorldNameable)te).getName());
        spawnAsEntity(worldIn, pos, itemstack);
    }
    else
    {
        super.harvestBlock(worldIn, player, pos, state, (TileEntity)null, stack);
    }
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:30,代码来源:BlockContainer.java

示例9: harvestBlock

import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
public void harvestBlock(World worldIn, EntityPlayer player, BlockPos pos, IBlockState state, @Nullable TileEntity te, @Nullable ItemStack stack)
{
    player.addStat(StatList.getBlockStats(this));
    player.addExhaustion(0.025F);

    if (this.canSilkHarvest(worldIn, pos, state, player) && EnchantmentHelper.getEnchantmentLevel(Enchantments.SILK_TOUCH, stack) > 0)
    {
        java.util.List<ItemStack> items = new java.util.ArrayList<ItemStack>();
        ItemStack itemstack = this.createStackedBlock(state);

        if (itemstack != null)
        {
            items.add(itemstack);
        }

        net.minecraftforge.event.ForgeEventFactory.fireBlockHarvesting(items, worldIn, pos, state, 0, 1.0f, true, player);
        for (ItemStack is : items)
            spawnAsEntity(worldIn, pos, is);
    }
    else
    {
        if (worldIn.provider.doesWaterVaporize())
        {
            worldIn.setBlockToAir(pos);
            return;
        }

        int i = EnchantmentHelper.getEnchantmentLevel(Enchantments.FORTUNE, stack);
        harvesters.set(player);
        this.dropBlockAsItem(worldIn, pos, state, i);
        harvesters.set(null);
        Material material = worldIn.getBlockState(pos.down()).getMaterial();

        if (material.blocksMovement() || material.isLiquid())
        {
            worldIn.setBlockState(pos, Blocks.FLOWING_WATER.getDefaultState());
        }
    }
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:40,代码来源:BlockIce.java

示例10: harvestBlock

import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
public void harvestBlock(World worldIn, EntityPlayer player, BlockPos pos, IBlockState state, @Nullable TileEntity te, @Nullable ItemStack stack)
{
    player.addStat(StatList.getBlockStats(this));
    player.addExhaustion(0.025F);

    if (this.canSilkHarvest(worldIn, pos, state, player) && EnchantmentHelper.getEnchantmentLevel(Enchantments.SILK_TOUCH, stack) > 0)
    {
        java.util.List<ItemStack> items = new java.util.ArrayList<ItemStack>();
        ItemStack itemstack = this.createStackedBlock(state);

        if (itemstack != null)
        {
            items.add(itemstack);
        }

        net.minecraftforge.event.ForgeEventFactory.fireBlockHarvesting(items, worldIn, pos, state, 0, 1.0f, true, player);
        for (ItemStack item : items)
        {
            spawnAsEntity(worldIn, pos, item);
        }
    }
    else
    {
        harvesters.set(player);
        int i = EnchantmentHelper.getEnchantmentLevel(Enchantments.FORTUNE, stack);
        this.dropBlockAsItem(worldIn, pos, state, i);
        harvesters.set(null);
    }
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:30,代码来源:Block.java

示例11: onReceived

import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
@Override
public void onReceived(MessagePacketRingUpdate message, EntityPlayer player) {
	if(message.ringType < 2)
	{
		ArrayList<Item> ringTypeItem = new ArrayList<Item>();
		ringTypeItem.add(HarshenItems.TELERING);
		ringTypeItem.add(HarshenItems.MINERING);
		if(HarshenUtils.containsItem(player,ringTypeItem.get(message.ringType)))
		{
			World world = player.world;
			Vec3d vec = new Vec3d(player.posX + (player.getLookVec().x * 4f),
					player.posY + (player.getLookVec().y * 4f), player.posZ + (player.getLookVec().z* 4f));
			BlockPos blockpos = message.ringType == 0? HarshenUtils.getTopBlock(world, vec) : HarshenUtils.getBottomBlockAir(world, vec);
			Vec3d vecPos = new Vec3d(blockpos).addVector(0.5, 0, 0.5);
			if(blockpos.getY() != -1 && player.getFoodStats().getFoodLevel() > 0)
			{
				((EntityPlayerMP)player).velocityChanged = true;
				((EntityPlayerMP)player).fallDistance = 0;
				HarshenNetwork.sendToPlayer(player, new MessagePacketPlayerTeleportEffects(vecPos));
				((EntityPlayerMP)player).setPositionAndUpdate(vecPos.x, vecPos.y, vecPos.z);
				world.playSound((EntityPlayer)null, player.posX, player.posY, player.posZ, SoundEvents.ITEM_CHORUS_FRUIT_TELEPORT, SoundCategory.PLAYERS, 1.0F, 1.0F);
                player.playSound(SoundEvents.ITEM_CHORUS_FRUIT_TELEPORT, 1.0F, 1.0F);
                player.addExhaustion(0.5F);
                HarshenUtils.damageFirstOccuringItem(player, ringTypeItem.get(message.ringType));
			}
		}			
	}
	else if(message.ringType == 2 && HarshenUtils.containsItem(player, HarshenItems.COMBAT_PENDANT))
	{
		EntityLivingBase entityToAttack = HarshenUtils.getFirstEntityInDirection(player.world, player.getPositionVector(), player.getLookVec().normalize(), 5, EntityLivingBase.class);
		if(entityToAttack == null)
		{
			List<EntityLivingBase> list = player.world.getEntitiesWithinAABB(EntityLivingBase.class, new AxisAlignedBB(player.posX - 4d, player.posY - 4d, player.posZ - 4d, player.posX + 4d, player.posY + 4d, player.posZ + 4d));
			if(!list.isEmpty())
				entityToAttack = list.get(0);
		}
		if(!player.equals(entityToAttack) && (entityToAttack != null || (entityToAttack instanceof EntityPlayerMP && player.canAttackPlayer((EntityPlayerMP)entityToAttack)
				&& HarshenUtils.toArray(GameType.SURVIVAL, GameType.ADVENTURE).contains(((EntityPlayerMP)entityToAttack).interactionManager.getGameType()))))
		{
			Vec3d position = entityToAttack.getPositionVector();
			Vec3d playerPosNoY = position.addVector(movePos(), 0, movePos());
			Vec3d pos = new Vec3d(playerPosNoY.x, HarshenUtils.getTopBlock(player.world, new BlockPos(playerPosNoY)).getY(), playerPosNoY.z);
			double d0 = position.x - pos.x;
            double d1 = position.y - (pos.y + (double)player.getEyeHeight() - entityToAttack.height / 2f + 0.1f);
            double d2 = position.z - pos.z;
            double d3 = (double)MathHelper.sqrt(d0 * d0 + d2 * d2);
            float yaw = (float)(MathHelper.atan2(d2, d0) * (180D / Math.PI)) - 90.0F;
            float pitch = (float)(-(MathHelper.atan2(d1, d3) * (180D / Math.PI)));
			((EntityPlayerMP)player).velocityChanged = true;
			((EntityPlayerMP)player).connection.setPlayerLocation(pos.x, pos.y, pos.z, yaw, pitch);
		}
	}
}
 
开发者ID:kenijey,项目名称:harshencastle,代码行数:54,代码来源:MessagePacketRingUpdate.java

示例12: onLivingHurt

import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
@SubscribeEvent(priority = EventPriority.LOWEST) //so all other can modify their damage first, and we apply after that
public static void onLivingHurt(LivingHurtEvent event) {
    EntityLivingBase entity = event.getEntityLiving();
    float amountToDamage = event.getAmount();
    if (entity.getEntityWorld().isRemote || !(entity instanceof EntityPlayer))
        return;
    EntityPlayer player = (EntityPlayer) entity;
    AbstractPlayerDamageModel damageModel = PlayerDataManager.getDamageModel(player);
    DamageSource source = event.getSource();

    if (amountToDamage == Float.MAX_VALUE) {
        damageModel.forEach(damageablePart -> damageablePart.currentHealth = 0F);
        if (player instanceof EntityPlayerMP)
            Arrays.stream(EnumPlayerPart.VALUES).forEach(part -> FirstAid.NETWORKING.sendTo(new MessageReceiveDamage(part, Float.MAX_VALUE, 0F), (EntityPlayerMP) player));
        event.setCanceled(true);
        CommonUtils.killPlayer(player, source);
        return;
    }

    amountToDamage = ArmorUtils.applyGlobalPotionModifiers(player, source, amountToDamage);

    //VANILLA COPY - combat tracker and exhaustion
    if (amountToDamage != 0.0F) {
        player.addExhaustion(source.getHungerDamage());
        //2nd param is actually never queried, no need to worry about wrong values
        player.getCombatTracker().trackDamage(source, -1, amountToDamage);
    }

    boolean addStat = amountToDamage < 3.4028235E37F;
    IDamageDistribution damageDistribution = FirstAidRegistryImpl.INSTANCE.getDamageDistribution(source);

    if (source.isProjectile()) {
        Pair<Entity, RayTraceResult> rayTraceResult = hitList.remove(player);
        if (rayTraceResult != null) {
            Entity entityProjectile = rayTraceResult.getLeft();
            EntityEquipmentSlot slot = ProjectileHelper.getPartByPosition(entityProjectile, player);
            if (slot != null)
                damageDistribution = new PreferredDamageDistribution(slot);
        }
    }

    float left = damageDistribution.distributeDamage(amountToDamage, player, source, addStat);
    if (left > 0) {
        damageDistribution = RandomDamageDistribution.NEAREST_KILL;
        damageDistribution.distributeDamage(left, player, source, addStat);
    }

    event.setCanceled(true);
    if (damageModel.isDead(player))
        CommonUtils.killPlayer(player, source);

    hitList.remove(player);
}
 
开发者ID:ichttt,项目名称:FirstAid,代码行数:54,代码来源:EventHandler.java


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