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


Java EnumDifficulty.PEACEFUL属性代码示例

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


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

示例1: onUpdate

/**
 * Called to update the entity's position/logic.
 */
public void onUpdate()
{
    super.onUpdate();

    if (!this.worldObj.isRemote && this.worldObj.getDifficulty() == EnumDifficulty.PEACEFUL)
    {
        this.setDead();
    }
}
 
开发者ID:Herobone,项目名称:HeroUtils,代码行数:12,代码来源:EntityDummy.java

示例2: getCanSpawnHere

@Override
public boolean getCanSpawnHere() {
	if (EasyMappings.world(this).getWorldInfo().getDifficulty() == EnumDifficulty.PEACEFUL || (!ConfigOptions.ENDERMAN_DAY_SPAWN && EasyMappings.world(this).getLightBrightness(new BlockPos(this)) > 0.53f)) {
		return false;
	}
	return EasyMappings.world(this).getBlockState((new BlockPos(this)).down()).canEntitySpawn(this);
}
 
开发者ID:p455w0rd,项目名称:EndermanEvolution,代码行数:7,代码来源:EntityEvolvedEnderman.java

示例3: updateTask

/**
 * Updates the task
 */
public void updateTask()
{
    if (EntityShulker.this.worldObj.getDifficulty() != EnumDifficulty.PEACEFUL)
    {
        --this.attackTime;
        EntityLivingBase entitylivingbase = EntityShulker.this.getAttackTarget();
        EntityShulker.this.getLookHelper().setLookPositionWithEntity(entitylivingbase, 180.0F, 180.0F);
        double d0 = EntityShulker.this.getDistanceSqToEntity(entitylivingbase);

        if (d0 < 400.0D)
        {
            if (this.attackTime <= 0)
            {
                this.attackTime = 20 + EntityShulker.this.rand.nextInt(10) * 20 / 2;
                EntityShulkerBullet entityshulkerbullet = new EntityShulkerBullet(EntityShulker.this.worldObj, EntityShulker.this, entitylivingbase, EntityShulker.this.getAttachmentFacing().getAxis());
                EntityShulker.this.worldObj.spawnEntityInWorld(entityshulkerbullet);
                EntityShulker.this.playSound(SoundEvents.ENTITY_SHULKER_SHOOT, 2.0F, (EntityShulker.this.rand.nextFloat() - EntityShulker.this.rand.nextFloat()) * 0.2F + 1.0F);
            }
        }
        else
        {
            EntityShulker.this.setAttackTarget((EntityLivingBase)null);
        }

        super.updateTask();
    }
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:30,代码来源:EntityShulker.java

示例4: getCanSpawnHere

/**
 * Checks if the entity's current position is a valid location to spawn this entity.
 */
public boolean getCanSpawnHere()
{
    BlockPos blockpos = new BlockPos(MathHelper.floor_double(this.posX), 0, MathHelper.floor_double(this.posZ));
    Chunk chunk = this.worldObj.getChunkFromBlockCoords(blockpos);

    if (this.worldObj.getWorldInfo().getTerrainType() == WorldType.FLAT && this.rand.nextInt(4) != 1)
    {
        return false;
    }
    else
    {
        if (this.worldObj.getDifficulty() != EnumDifficulty.PEACEFUL)
        {
            BiomeGenBase biomegenbase = this.worldObj.getBiomeGenForCoords(blockpos);

            if (biomegenbase == BiomeGenBase.swampland && this.posY > 50.0D && this.posY < 70.0D && this.rand.nextFloat() < 0.5F && this.rand.nextFloat() < this.worldObj.getCurrentMoonPhaseFactor() && this.worldObj.getLightFromNeighbors(new BlockPos(this)) <= this.rand.nextInt(8))
            {
                return super.getCanSpawnHere();
            }

            if (this.rand.nextInt(10) == 0 && chunk.getRandomWithSeed(987234911L).nextInt(10) == 0 && this.posY < 40.0D)
            {
                return super.getCanSpawnHere();
            }
        }

        return false;
    }
}
 
开发者ID:Notoh,项目名称:DecompiledMinecraft,代码行数:32,代码来源:EntitySlime.java

示例5: getCanSpawnHere

/**
 * Checks if the entity's current position is a valid location to spawn this entity.
 */
public boolean getCanSpawnHere()
{
    BlockPos blockpos = new BlockPos(MathHelper.floor_double(this.posX), 0, MathHelper.floor_double(this.posZ));
    Chunk chunk = this.worldObj.getChunkFromBlockCoords(blockpos);

    if (this.worldObj.getWorldInfo().getTerrainType().handleSlimeSpawnReduction(rand, worldObj))
    {
        return false;
    }
    else
    {
        if (this.worldObj.getDifficulty() != EnumDifficulty.PEACEFUL)
        {
            Biome biome = this.worldObj.getBiome(blockpos);

            if (biome == Biomes.SWAMPLAND && this.posY > 50.0D && this.posY < 70.0D && this.rand.nextFloat() < 0.5F && this.rand.nextFloat() < this.worldObj.getCurrentMoonPhaseFactor() && this.worldObj.getLightFromNeighbors(new BlockPos(this)) <= this.rand.nextInt(8))
            {
                return super.getCanSpawnHere();
            }

            if (this.rand.nextInt(10) == 0 && chunk.getRandomWithSeed(987234911L).nextInt(10) == 0 && this.posY < 40.0D)
            {
                return super.getCanSpawnHere();
            }
        }

        return false;
    }
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:32,代码来源:EntitySlime.java

示例6: getCanSpawnHere

/**
 * Checks if the entity's current position is a valid location to spawn this entity.
 */
public boolean getCanSpawnHere()
{
    return this.worldObj.getDifficulty() != EnumDifficulty.PEACEFUL && this.isValidLightLevel() && super.getCanSpawnHere();
}
 
开发者ID:SkidJava,项目名称:BaseClient,代码行数:7,代码来源:EntityMob.java

示例7: 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:Notoh,项目名称:DecompiledMinecraft,代码行数:64,代码来源:EntityPlayer.java

示例8: getCanSpawnHere

/**
 * Checks if the entity's current position is a valid location to spawn this entity.
 */
public boolean getCanSpawnHere()
{
    return this.rand.nextInt(20) == 0 && super.getCanSpawnHere() && this.worldObj.getDifficulty() != EnumDifficulty.PEACEFUL;
}
 
开发者ID:Notoh,项目名称:DecompiledMinecraft,代码行数:7,代码来源:EntityGhast.java

示例9: shouldExecute

/**
 * Returns whether the EntityAIBase should begin execution.
 */
public boolean shouldExecute()
{
    return EntityShulker.this.worldObj.getDifficulty() == EnumDifficulty.PEACEFUL ? false : super.shouldExecute();
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:7,代码来源:EntityShulker.java

示例10: getCanSpawnHere

/**
 * Checks if the entity's current position is a valid location to spawn this entity.
 */
public boolean getCanSpawnHere()
{
    return this.worldObj.getDifficulty() != EnumDifficulty.PEACEFUL;
}
 
开发者ID:Notoh,项目名称:DecompiledMinecraft,代码行数:7,代码来源:EntityMagmaCube.java

示例11: canDispenserPlace

public boolean canDispenserPlace(World worldIn, BlockPos pos, ItemStack stack)
{
    return stack.getMetadata() == 1 && pos.getY() >= 2 && worldIn.getDifficulty() != EnumDifficulty.PEACEFUL && !worldIn.isRemote ? this.getWitherBasePattern().match(worldIn, pos) != null : false;
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:4,代码来源:BlockSkull.java

示例12: 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:SkidJava,项目名称:BaseClient,代码行数:52,代码来源:FoodStats.java

示例13: getCanSpawnHere

/**
 * Checks if the entity's current position is a valid location to spawn this entity.
 */
public boolean getCanSpawnHere()
{
    return this.world.getDifficulty() != EnumDifficulty.PEACEFUL;
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:7,代码来源:EntityMagmaCube.java

示例14: 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

示例15: checkWitherSpawn

public void checkWitherSpawn(World worldIn, BlockPos pos, TileEntitySkull te)
{
    if (te.getSkullType() == 1 && pos.getY() >= 2 && worldIn.getDifficulty() != EnumDifficulty.PEACEFUL && !worldIn.isRemote)
    {
        BlockPattern blockpattern = this.getWitherPattern();
        BlockPattern.PatternHelper blockpattern$patternhelper = blockpattern.match(worldIn, pos);

        if (blockpattern$patternhelper != null)
        {
            for (int i = 0; i < 3; ++i)
            {
                BlockWorldState blockworldstate = blockpattern$patternhelper.translateOffset(i, 0, 0);
                worldIn.setBlockState(blockworldstate.getPos(), blockworldstate.getBlockState().withProperty(NODROP, Boolean.valueOf(true)), 2);
            }

            for (int j = 0; j < blockpattern.getPalmLength(); ++j)
            {
                for (int k = 0; k < blockpattern.getThumbLength(); ++k)
                {
                    BlockWorldState blockworldstate1 = blockpattern$patternhelper.translateOffset(j, k, 0);
                    worldIn.setBlockState(blockworldstate1.getPos(), Blocks.AIR.getDefaultState(), 2);
                }
            }

            BlockPos blockpos = blockpattern$patternhelper.translateOffset(1, 0, 0).getPos();
            EntityWither entitywither = new EntityWither(worldIn);
            BlockPos blockpos1 = blockpattern$patternhelper.translateOffset(1, 2, 0).getPos();
            entitywither.setLocationAndAngles((double)blockpos1.getX() + 0.5D, (double)blockpos1.getY() + 0.55D, (double)blockpos1.getZ() + 0.5D, blockpattern$patternhelper.getForwards().getAxis() == EnumFacing.Axis.X ? 0.0F : 90.0F, 0.0F);
            entitywither.renderYawOffset = blockpattern$patternhelper.getForwards().getAxis() == EnumFacing.Axis.X ? 0.0F : 90.0F;
            entitywither.ignite();

            for (EntityPlayer entityplayer : worldIn.getEntitiesWithinAABB(EntityPlayer.class, entitywither.getEntityBoundingBox().expandXyz(50.0D)))
            {
                entityplayer.addStat(AchievementList.SPAWN_WITHER);
            }

            worldIn.spawnEntityInWorld(entitywither);

            for (int l = 0; l < 120; ++l)
            {
                worldIn.spawnParticle(EnumParticleTypes.SNOWBALL, (double)blockpos.getX() + worldIn.rand.nextDouble(), (double)(blockpos.getY() - 2) + worldIn.rand.nextDouble() * 3.9D, (double)blockpos.getZ() + worldIn.rand.nextDouble(), 0.0D, 0.0D, 0.0D, new int[0]);
            }

            for (int i1 = 0; i1 < blockpattern.getPalmLength(); ++i1)
            {
                for (int j1 = 0; j1 < blockpattern.getThumbLength(); ++j1)
                {
                    BlockWorldState blockworldstate2 = blockpattern$patternhelper.translateOffset(i1, j1, 0);
                    worldIn.notifyNeighborsRespectDebug(blockworldstate2.getPos(), Blocks.AIR, false);
                }
            }
        }
    }
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:54,代码来源:BlockSkull.java


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