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


Java EnumDifficulty.HARD属性代码示例

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


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

示例1: setCombatTask

public void setCombatTask() {
	if (this.world != null && !this.world.isRemote) {
		this.tasks.removeTask(this.aiAttackOnCollide);
		this.tasks.removeTask(this.aiSpellAttack);
		ItemStack itemstack = this.getHeldItemMainhand();

		if (itemstack.getItem() == InfernumItems.SPELL_PAGE
				&& ItemSpellPage.getSpell(itemstack).equals(InfernumSpells.WITHERING_BOLT)) {
			int i = 30;

			if (this.world.getDifficulty() != EnumDifficulty.HARD) {
				i = 50;
			}

			this.aiSpellAttack.setAttackCooldown(i);
			this.tasks.addTask(4, this.aiSpellAttack);
		} else {
			this.tasks.addTask(4, this.aiAttackOnCollide);
		}
	}
}
 
开发者ID:the-realest-stu,项目名称:Infernum,代码行数:21,代码来源:EntityPigZombieMage.java

示例2: updateTask

/**
 * Updates the task
 */
public void updateTask()
{
    super.updateTask();

    if (this.theEntity.getRNG().nextInt(20) == 0)
    {
        this.theEntity.worldObj.playAuxSFX(1010, this.doorPosition, 0);
    }

    ++this.breakingTime;
    int i = (int)((float)this.breakingTime / 240.0F * 10.0F);

    if (i != this.previousBreakProgress)
    {
        this.theEntity.worldObj.sendBlockBreakProgress(this.theEntity.getEntityId(), this.doorPosition, i);
        this.previousBreakProgress = i;
    }

    if (this.breakingTime == 240 && this.theEntity.worldObj.getDifficulty() == EnumDifficulty.HARD)
    {
        this.theEntity.worldObj.setBlockToAir(this.doorPosition);
        this.theEntity.worldObj.playAuxSFX(1012, this.doorPosition, 0);
        this.theEntity.worldObj.playAuxSFX(2001, this.doorPosition, Block.getIdFromBlock(this.doorBlock));
    }
}
 
开发者ID:Notoh,项目名称:DecompiledMinecraft,代码行数:28,代码来源:EntityAIBreakDoor.java

示例3: setEquipmentBasedOnDifficulty

/**
 * Gives armor or weapon for entity based on given DifficultyInstance
 */
protected void setEquipmentBasedOnDifficulty(DifficultyInstance difficulty)
{
    super.setEquipmentBasedOnDifficulty(difficulty);

    if (this.rand.nextFloat() < (this.worldObj.getDifficulty() == EnumDifficulty.HARD ? 0.05F : 0.01F))
    {
        int i = this.rand.nextInt(3);

        if (i == 0)
        {
            this.setCurrentItemOrArmor(0, new ItemStack(Items.iron_sword));
        }
        else
        {
            this.setCurrentItemOrArmor(0, new ItemStack(Items.iron_shovel));
        }
    }
}
 
开发者ID:SkidJava,项目名称:BaseClient,代码行数:21,代码来源:EntityZombie.java

示例4: EntityLightningBolt

public EntityLightningBolt(World worldIn, double x, double y, double z, boolean effectOnlyIn)
{
    super(worldIn);
    this.setLocationAndAngles(x, y, z, 0.0F, 0.0F);
    this.lightningState = 2;
    this.boltVertex = this.rand.nextLong();
    this.boltLivingTime = this.rand.nextInt(3) + 1;
    this.effectOnly = effectOnlyIn;
    BlockPos blockpos = new BlockPos(this);

    if (!effectOnlyIn && !worldIn.isRemote && worldIn.getGameRules().getBoolean("doFireTick") && (worldIn.getDifficulty() == EnumDifficulty.NORMAL || worldIn.getDifficulty() == EnumDifficulty.HARD) && worldIn.isAreaLoaded(blockpos, 10))
    {
        if (worldIn.getBlockState(blockpos).getMaterial() == Material.AIR && Blocks.FIRE.canPlaceBlockAt(worldIn, blockpos))
        {
            worldIn.setBlockState(blockpos, Blocks.FIRE.getDefaultState());
        }

        for (int i = 0; i < 4; ++i)
        {
            BlockPos blockpos1 = blockpos.add(this.rand.nextInt(3) - 1, this.rand.nextInt(3) - 1, this.rand.nextInt(3) - 1);

            if (worldIn.getBlockState(blockpos1).getMaterial() == Material.AIR && Blocks.FIRE.canPlaceBlockAt(worldIn, blockpos1))
            {
                worldIn.setBlockState(blockpos1, Blocks.FIRE.getDefaultState());
            }
        }
    }
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:28,代码来源:EntityLightningBolt.java

示例5: attackEntityAsMob

public boolean attackEntityAsMob(Entity entityIn)
{
    if (super.attackEntityAsMob(entityIn))
    {
        if (entityIn instanceof EntityLivingBase)
        {
            int i = 0;

            if (this.worldObj.getDifficulty() == EnumDifficulty.NORMAL)
            {
                i = 7;
            }
            else if (this.worldObj.getDifficulty() == EnumDifficulty.HARD)
            {
                i = 15;
            }

            if (i > 0)
            {
                ((EntityLivingBase)entityIn).addPotionEffect(new PotionEffect(Potion.poison.id, i * 20, 0));
            }
        }

        return true;
    }
    else
    {
        return false;
    }
}
 
开发者ID:Notoh,项目名称:DecompiledMinecraft,代码行数:30,代码来源:EntityCaveSpider.java

示例6: attractMobs

public static void attractMobs(EntityLivingBase living, World world) {
	if (!world.isRemote && TF2ConfigVars.shootAttract && world.getDifficulty().getDifficultyId()>1) {
		
		int range=world.getDifficulty()==EnumDifficulty.HARD?60:38;
		for (EntityCreature mob : world.getEntitiesWithinAABB(EntityCreature.class,
				living.getEntityBoundingBox().grow(range, range, range), new Predicate<EntityCreature>() {

					@Override
					public boolean apply(EntityCreature input) {
						// TODO Auto-generated method stub
						return input.getAttackTarget() == null && (input instanceof IMob) && input.isNonBoss();
					}

				})) {
			mob.getLookHelper().setLookPositionWithEntity(mob, 60, 30);
			if (!TF2Util.isOnSameTeam(living, mob)) {
				if (mob.getEntitySenses().canSee(living) || mob.getDistanceSqToEntity(living)<150){
					mob.setAttackTarget(living);
					if(mob.getEntityAttribute(SharedMonsterAttributes.FOLLOW_RANGE).getModifier(FOLLOW_MODIFIER)==null)
						mob.getEntityAttribute(SharedMonsterAttributes.FOLLOW_RANGE)
					.applyModifier(new AttributeModifier(FOLLOW_MODIFIER, "Follow Check", 65-mob.getEntityAttribute(SharedMonsterAttributes.FOLLOW_RANGE).getAttributeValue(), 0));
					//mob.getNavigator().tryMoveToEntityLiving(living, 1.1f);
					
					mob.getEntityAttribute(SharedMonsterAttributes.FOLLOW_RANGE).removeModifier(FOLLOW_MODIFIER);
				}
				
				// CoroUtilPath.tryMoveToEntityLivingLongDist((EntityCreature)mob,
				// living, 1.1D);
				;
			}

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

示例7: onInitialSpawn

/**
 * Called only once on an entity when first time spawned, via egg, mob spawner, natural spawning etc, but not called
 * when entity is reloaded from nbt. Mainly used for initializing attributes and inventory
 */
@Nullable
public IEntityLivingData onInitialSpawn(DifficultyInstance difficulty, @Nullable IEntityLivingData livingdata)
{
    livingdata = super.onInitialSpawn(difficulty, livingdata);

    if (this.worldObj.rand.nextInt(100) == 0)
    {
        EntitySkeleton entityskeleton = new EntitySkeleton(this.worldObj);
        entityskeleton.setLocationAndAngles(this.posX, this.posY, this.posZ, this.rotationYaw, 0.0F);
        entityskeleton.onInitialSpawn(difficulty, (IEntityLivingData)null);
        this.worldObj.spawnEntityInWorld(entityskeleton);
        entityskeleton.startRiding(this);
    }

    if (livingdata == null)
    {
        livingdata = new EntitySpider.GroupData();

        if (this.worldObj.getDifficulty() == EnumDifficulty.HARD && this.worldObj.rand.nextFloat() < 0.1F * difficulty.getClampedAdditionalDifficulty())
        {
            ((EntitySpider.GroupData)livingdata).setRandomEffect(this.worldObj.rand);
        }
    }

    if (livingdata instanceof EntitySpider.GroupData)
    {
        Potion potion = ((EntitySpider.GroupData)livingdata).effect;

        if (potion != null)
        {
            this.addPotionEffect(new PotionEffect(potion, Integer.MAX_VALUE));
        }
    }

    return livingdata;
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:40,代码来源:EntitySpider.java

示例8: attackEntityFrom

/**
 * Called when the entity is attacked.
 */
public boolean attackEntityFrom(DamageSource source, float amount)
{
    if (this.isEntityInvulnerable(source))
    {
        return false;
    }
    else if (this.capabilities.disableDamage && !source.canHarmInCreative())
    {
        return false;
    }
    else
    {
        this.entityAge = 0;

        if (this.getHealth() <= 0.0F)
        {
            return false;
        }
        else
        {
            if (this.isPlayerSleeping() && !this.world.isRemote)
            {
                this.wakeUpPlayer(true, true, false);
            }

            if (source.isDifficultyScaled())
            {
                if (this.world.getDifficulty() == EnumDifficulty.PEACEFUL)
                {
                    amount = 0.0F;
                }

                if (this.world.getDifficulty() == EnumDifficulty.EASY)
                {
                    amount = Math.min(amount / 2.0F + 1.0F, amount);
                }

                if (this.world.getDifficulty() == EnumDifficulty.HARD)
                {
                    amount = amount * 3.0F / 2.0F;
                }
            }

            return amount == 0.0F ? false : super.attackEntityFrom(source, amount);
        }
    }
}
 
开发者ID:NSExceptional,项目名称:Zombe-Modpack,代码行数:50,代码来源:EntityPlayer.java

示例9: onImpact

/**
 * Called when this EntityFireball hits a block or entity.
 */
protected void onImpact(MovingObjectPosition movingObject)
{
    if (!this.worldObj.isRemote)
    {
        if (movingObject.entityHit != null)
        {
            if (this.shootingEntity != null)
            {
                if (movingObject.entityHit.attackEntityFrom(DamageSource.causeMobDamage(this.shootingEntity), 8.0F))
                {
                    if (!movingObject.entityHit.isEntityAlive())
                    {
                        this.shootingEntity.heal(5.0F);
                    }
                    else
                    {
                        this.applyEnchantments(this.shootingEntity, movingObject.entityHit);
                    }
                }
            }
            else
            {
                movingObject.entityHit.attackEntityFrom(DamageSource.magic, 5.0F);
            }

            if (movingObject.entityHit instanceof EntityLivingBase)
            {
                int i = 0;

                if (this.worldObj.getDifficulty() == EnumDifficulty.NORMAL)
                {
                    i = 10;
                }
                else if (this.worldObj.getDifficulty() == EnumDifficulty.HARD)
                {
                    i = 40;
                }

                if (i > 0)
                {
                    ((EntityLivingBase)movingObject.entityHit).addPotionEffect(new PotionEffect(Potion.wither.id, 20 * i, 1));
                }
            }
        }

        this.worldObj.newExplosion(this, this.posX, this.posY, this.posZ, 1.0F, false, this.worldObj.getGameRules().getBoolean("mobGriefing"));
        this.setDead();
    }
}
 
开发者ID:Notoh,项目名称:DecompiledMinecraft,代码行数:52,代码来源:EntityWitherSkull.java

示例10: getDifficultyFromCommand

protected EnumDifficulty getDifficultyFromCommand(String difficultyString) throws CommandException, NumberInvalidException
{
    return !"peaceful".equalsIgnoreCase(difficultyString) && !"p".equalsIgnoreCase(difficultyString) ? (!"easy".equalsIgnoreCase(difficultyString) && !"e".equalsIgnoreCase(difficultyString) ? (!"normal".equalsIgnoreCase(difficultyString) && !"n".equalsIgnoreCase(difficultyString) ? (!"hard".equalsIgnoreCase(difficultyString) && !"h".equalsIgnoreCase(difficultyString) ? EnumDifficulty.getDifficultyEnum(parseInt(difficultyString, 0, 3)) : EnumDifficulty.HARD) : EnumDifficulty.NORMAL) : EnumDifficulty.EASY) : EnumDifficulty.PEACEFUL;
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:4,代码来源:CommandDifficulty.java

示例11: updateTask

public void updateTask()
{
    EntityLivingBase entitylivingbase = this.theEntity.getAttackTarget();
    this.theEntity.getNavigator().clearPathEntity();
    this.theEntity.getLookHelper().setLookPositionWithEntity(entitylivingbase, 90.0F, 90.0F);

    if (!this.theEntity.canEntityBeSeen(entitylivingbase))
    {
        this.theEntity.setAttackTarget((EntityLivingBase)null);
    }
    else
    {
        ++this.tickCounter;

        if (this.tickCounter == 0)
        {
            this.theEntity.setTargetedEntity(this.theEntity.getAttackTarget().getEntityId());
            this.theEntity.world.setEntityState(this.theEntity, (byte)21);
        }
        else if (this.tickCounter >= this.theEntity.getAttackDuration())
        {
            float f = 1.0F;

            if (this.theEntity.world.getDifficulty() == EnumDifficulty.HARD)
            {
                f += 2.0F;
            }

            if (this.field_190881_c)
            {
                f += 2.0F;
            }

            entitylivingbase.attackEntityFrom(DamageSource.causeIndirectMagicDamage(this.theEntity, this.theEntity), f);
            entitylivingbase.attackEntityFrom(DamageSource.causeMobDamage(this.theEntity), (float)this.theEntity.getEntityAttribute(SharedMonsterAttributes.ATTACK_DAMAGE).getAttributeValue());
            this.theEntity.setAttackTarget((EntityLivingBase)null);
        }

        super.updateTask();
    }
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:41,代码来源:EntityGuardian.java

示例12: attackEntityFrom

/**
 * Called when the entity is attacked.
 */
public boolean attackEntityFrom(DamageSource source, float amount)
{
    if (this.isEntityInvulnerable(source))
    {
        return false;
    }
    else if (this.capabilities.disableDamage && !source.canHarmInCreative())
    {
        return false;
    }
    else
    {
        this.entityAge = 0;

        if (this.getHealth() <= 0.0F)
        {
            return false;
        }
        else
        {
            if (this.isPlayerSleeping() && !this.worldObj.isRemote)
            {
                this.wakeUpPlayer(true, true, false);
            }

            if (source.isDifficultyScaled())
            {
                if (this.worldObj.getDifficulty() == EnumDifficulty.PEACEFUL)
                {
                    amount = 0.0F;
                }

                if (this.worldObj.getDifficulty() == EnumDifficulty.EASY)
                {
                    amount = amount / 2.0F + 1.0F;
                }

                if (this.worldObj.getDifficulty() == EnumDifficulty.HARD)
                {
                    amount = amount * 3.0F / 2.0F;
                }
            }

            if (amount == 0.0F)
            {
                return false;
            }
            else
            {
                Entity entity = source.getEntity();

                if (entity instanceof EntityArrow && ((EntityArrow)entity).shootingEntity != null)
                {
                    entity = ((EntityArrow)entity).shootingEntity;
                }

                return super.attackEntityFrom(source, amount);
            }
        }
    }
}
 
开发者ID:SkidJava,项目名称:BaseClient,代码行数:64,代码来源:EntityPlayer.java

示例13: onImpact

/**
 * Called when this EntityFireball hits a block or entity.
 */
protected void onImpact(RayTraceResult result)
{
    if (!this.world.isRemote)
    {
        if (result.entityHit != null)
        {
            if (this.shootingEntity != null)
            {
                if (result.entityHit.attackEntityFrom(DamageSource.causeMobDamage(this.shootingEntity), 8.0F))
                {
                    if (result.entityHit.isEntityAlive())
                    {
                        this.applyEnchantments(this.shootingEntity, result.entityHit);
                    }
                    else
                    {
                        this.shootingEntity.heal(5.0F);
                    }
                }
            }
            else
            {
                result.entityHit.attackEntityFrom(DamageSource.magic, 5.0F);
            }

            if (result.entityHit instanceof EntityLivingBase)
            {
                int i = 0;

                if (this.world.getDifficulty() == EnumDifficulty.NORMAL)
                {
                    i = 10;
                }
                else if (this.world.getDifficulty() == EnumDifficulty.HARD)
                {
                    i = 40;
                }

                if (i > 0)
                {
                    ((EntityLivingBase)result.entityHit).addPotionEffect(new PotionEffect(MobEffects.WITHER, 20 * i, 1));
                }
            }
        }

        this.world.newExplosion(this, this.posX, this.posY, this.posZ, 1.0F, false, this.world.getGameRules().getBoolean("mobGriefing"));
        this.setDead();
    }
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:52,代码来源:EntityWitherSkull.java

示例14: onUpdate

/**
 * Handles the food game logic.
 */
public void onUpdate(EntityPlayer player)
{
    EnumDifficulty enumdifficulty = player.worldObj.getDifficulty();
    this.prevFoodLevel = this.foodLevel;

    if (this.foodExhaustionLevel > 4.0F)
    {
        this.foodExhaustionLevel -= 4.0F;

        if (this.foodSaturationLevel > 0.0F)
        {
            this.foodSaturationLevel = Math.max(this.foodSaturationLevel - 1.0F, 0.0F);
        }
        else if (enumdifficulty != EnumDifficulty.PEACEFUL)
        {
            this.foodLevel = Math.max(this.foodLevel - 1, 0);
        }
    }

    if (player.worldObj.getGameRules().getBoolean("naturalRegeneration") && this.foodLevel >= 18 && player.shouldHeal())
    {
        ++this.foodTimer;

        if (this.foodTimer >= 80)
        {
            player.heal(1.0F);
            this.addExhaustion(3.0F);
            this.foodTimer = 0;
        }
    }
    else if (this.foodLevel <= 0)
    {
        ++this.foodTimer;

        if (this.foodTimer >= 80)
        {
            if (player.getHealth() > 10.0F || enumdifficulty == EnumDifficulty.HARD || player.getHealth() > 1.0F && enumdifficulty == EnumDifficulty.NORMAL)
            {
                player.attackEntityFrom(DamageSource.starve, 1.0F);
            }

            this.foodTimer = 0;
        }
    }
    else
    {
        this.foodTimer = 0;
    }
}
 
开发者ID:Notoh,项目名称:DecompiledMinecraft,代码行数:52,代码来源:FoodStats.java

示例15: updateTask

public void updateTask()
{
    EntityLivingBase entitylivingbase = this.theEntity.getAttackTarget();
    this.theEntity.getNavigator().clearPathEntity();
    this.theEntity.getLookHelper().setLookPositionWithEntity(entitylivingbase, 90.0F, 90.0F);

    if (!this.theEntity.canEntityBeSeen(entitylivingbase))
    {
        this.theEntity.setAttackTarget((EntityLivingBase)null);
    }
    else
    {
        ++this.tickCounter;

        if (this.tickCounter == 0)
        {
            this.theEntity.setTargetedEntity(this.theEntity.getAttackTarget().getEntityId());
            this.theEntity.worldObj.setEntityState(this.theEntity, (byte)21);
        }
        else if (this.tickCounter >= this.theEntity.func_175464_ck())
        {
            float f = 1.0F;

            if (this.theEntity.worldObj.getDifficulty() == EnumDifficulty.HARD)
            {
                f += 2.0F;
            }

            if (this.theEntity.isElder())
            {
                f += 2.0F;
            }

            entitylivingbase.attackEntityFrom(DamageSource.causeIndirectMagicDamage(this.theEntity, this.theEntity), f);
            entitylivingbase.attackEntityFrom(DamageSource.causeMobDamage(this.theEntity), (float)this.theEntity.getEntityAttribute(SharedMonsterAttributes.attackDamage).getAttributeValue());
            this.theEntity.setAttackTarget((EntityLivingBase)null);
        }
        else if (this.tickCounter >= 60 && this.tickCounter % 20 == 0)
        {
            ;
        }

        super.updateTask();
    }
}
 
开发者ID:Notoh,项目名称:DecompiledMinecraft,代码行数:45,代码来源:EntityGuardian.java


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