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


Java DifficultyInstance.getClampedAdditionalDifficulty方法代码示例

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


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

示例1: onInitialSpawn

import net.minecraft.world.DifficultyInstance; //导入方法依赖的package包/类
@Nullable
public IEntityLivingData onInitialSpawn(DifficultyInstance difficulty, @Nullable IEntityLivingData livingdata) {
	livingdata = super.onInitialSpawn(difficulty, livingdata);
	float f = difficulty.getClampedAdditionalDifficulty();
	this.setCanPickUpLoot(false);
	this.setEquipmentBasedOnDifficulty(difficulty);
	this.setEnchantmentBasedOnDifficulty(difficulty);
	this.setCombatTask();

	this.getEntityAttribute(SharedMonsterAttributes.KNOCKBACK_RESISTANCE).applyModifier(
			new AttributeModifier("Random spawn bonus", this.rand.nextDouble() * 0.05000000074505806D, 0));
	double d0 = this.rand.nextDouble() * 1.5D * (double) f;

	if (d0 > 1.0D) {
		this.getEntityAttribute(SharedMonsterAttributes.FOLLOW_RANGE)
				.applyModifier(new AttributeModifier("Random zombie-spawn bonus", d0, 2));
	}

	return livingdata;
}
 
开发者ID:the-realest-stu,项目名称:Infernum,代码行数:21,代码来源:EntityPigZombieMage.java

示例2: setEnchantmentBasedOnDifficulty

import net.minecraft.world.DifficultyInstance; //导入方法依赖的package包/类
/**
 * Enchants Entity's current equipments based on given DifficultyInstance
 */
protected void setEnchantmentBasedOnDifficulty(DifficultyInstance difficulty)
{
    float f = difficulty.getClampedAdditionalDifficulty();

    if (this.getHeldItem() != null && this.rand.nextFloat() < 0.25F * f)
    {
        EnchantmentHelper.addRandomEnchantment(this.rand, this.getHeldItem(), (int)(5.0F + f * (float)this.rand.nextInt(18)));
    }

    for (int i = 0; i < 4; ++i)
    {
        ItemStack itemstack = this.getCurrentArmor(i);

        if (itemstack != null && this.rand.nextFloat() < 0.5F * f)
        {
            EnchantmentHelper.addRandomEnchantment(this.rand, itemstack, (int)(5.0F + f * (float)this.rand.nextInt(18)));
        }
    }
}
 
开发者ID:Notoh,项目名称:DecompiledMinecraft,代码行数:23,代码来源:EntityLiving.java

示例3: setEnchantmentBasedOnDifficulty

import net.minecraft.world.DifficultyInstance; //导入方法依赖的package包/类
/**
 * Enchants Entity's current equipments based on given DifficultyInstance
 */
protected void setEnchantmentBasedOnDifficulty(DifficultyInstance difficulty)
{
    float f = difficulty.getClampedAdditionalDifficulty();

    if (!this.getHeldItemMainhand().func_190926_b() && this.rand.nextFloat() < 0.25F * f)
    {
        this.setItemStackToSlot(EntityEquipmentSlot.MAINHAND, EnchantmentHelper.addRandomEnchantment(this.rand, this.getHeldItemMainhand(), (int)(5.0F + f * (float)this.rand.nextInt(18)), false));
    }

    for (EntityEquipmentSlot entityequipmentslot : EntityEquipmentSlot.values())
    {
        if (entityequipmentslot.getSlotType() == EntityEquipmentSlot.Type.ARMOR)
        {
            ItemStack itemstack = this.getItemStackFromSlot(entityequipmentslot);

            if (!itemstack.func_190926_b() && this.rand.nextFloat() < 0.5F * f)
            {
                this.setItemStackToSlot(entityequipmentslot, EnchantmentHelper.addRandomEnchantment(this.rand, itemstack, (int)(5.0F + f * (float)this.rand.nextInt(18)), false));
            }
        }
    }
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:26,代码来源:EntityLiving.java

示例4: onInitialSpawn

import net.minecraft.world.DifficultyInstance; //导入方法依赖的package包/类
/**
 * 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
 */
public IEntityLivingData onInitialSpawn(DifficultyInstance difficulty, 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.mountEntity(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).func_111104_a(this.worldObj.rand);
        }
    }

    if (livingdata instanceof EntitySpider.GroupData)
    {
        int i = ((EntitySpider.GroupData)livingdata).potionEffectId;

        if (i > 0 && Potion.potionTypes[i] != null)
        {
            this.addPotionEffect(new PotionEffect(i, Integer.MAX_VALUE));
        }
    }

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

示例5: onInitialSpawn

import net.minecraft.world.DifficultyInstance; //导入方法依赖的package包/类
/**
 * 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
 */
public IEntityLivingData onInitialSpawn(DifficultyInstance difficulty, IEntityLivingData livingdata)
{
    int i = this.rand.nextInt(3);

    if (i < 2 && this.rand.nextFloat() < 0.5F * difficulty.getClampedAdditionalDifficulty())
    {
        ++i;
    }

    int j = 1 << i;
    this.setSlimeSize(j);
    return super.onInitialSpawn(difficulty, livingdata);
}
 
开发者ID:Notoh,项目名称:DecompiledMinecraft,代码行数:18,代码来源:EntitySlime.java

示例6: onInitialSpawn

import net.minecraft.world.DifficultyInstance; //导入方法依赖的package包/类
/**
 * 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)
{
    int i = this.rand.nextInt(3);

    if (i < 2 && this.rand.nextFloat() < 0.5F * difficulty.getClampedAdditionalDifficulty())
    {
        ++i;
    }

    int j = 1 << i;
    this.setSlimeSize(j);
    return super.onInitialSpawn(difficulty, livingdata);
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:19,代码来源:EntitySlime.java

示例7: onInitialSpawn

import net.minecraft.world.DifficultyInstance; //导入方法依赖的package包/类
/**
 * 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,代码行数:41,代码来源:EntitySpider.java

示例8: setEquipmentBasedOnDifficulty

import net.minecraft.world.DifficultyInstance; //导入方法依赖的package包/类
/**
 * Gives armor or weapon for entity based on given DifficultyInstance
 */
protected void setEquipmentBasedOnDifficulty(DifficultyInstance difficulty)
{
    if (this.rand.nextFloat() < 0.15F * difficulty.getClampedAdditionalDifficulty())
    {
        int i = this.rand.nextInt(2);
        float f = this.worldObj.getDifficulty() == EnumDifficulty.HARD ? 0.1F : 0.25F;

        if (this.rand.nextFloat() < 0.095F)
        {
            ++i;
        }

        if (this.rand.nextFloat() < 0.095F)
        {
            ++i;
        }

        if (this.rand.nextFloat() < 0.095F)
        {
            ++i;
        }

        for (int j = 3; j >= 0; --j)
        {
            ItemStack itemstack = this.getCurrentArmor(j);

            if (j < 3 && this.rand.nextFloat() < f)
            {
                break;
            }

            if (itemstack == null)
            {
                Item item = getArmorItemForSlot(j + 1, i);

                if (item != null)
                {
                    this.setCurrentItemOrArmor(j + 1, new ItemStack(item));
                }
            }
        }
    }
}
 
开发者ID:Notoh,项目名称:DecompiledMinecraft,代码行数:47,代码来源:EntityLiving.java

示例9: onInitialSpawn

import net.minecraft.world.DifficultyInstance; //导入方法依赖的package包/类
@Nullable

    /**
     * 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
     */
    public IEntityLivingData onInitialSpawn(DifficultyInstance difficulty, @Nullable IEntityLivingData livingdata)
    {
        livingdata = super.onInitialSpawn(difficulty, livingdata);
        float f = difficulty.getClampedAdditionalDifficulty();
        this.setCanPickUpLoot(this.rand.nextFloat() < 0.55F * f);

        if (livingdata == null)
        {
            livingdata = new EntityZombie.GroupData(this.world.rand.nextFloat() < 0.05F);
        }

        if (livingdata instanceof EntityZombie.GroupData)
        {
            EntityZombie.GroupData entityzombie$groupdata = (EntityZombie.GroupData)livingdata;

            if (entityzombie$groupdata.isChild)
            {
                this.setChild(true);

                if ((double)this.world.rand.nextFloat() < 0.05D)
                {
                    List<EntityChicken> list = this.world.<EntityChicken>getEntitiesWithinAABB(EntityChicken.class, this.getEntityBoundingBox().expand(5.0D, 3.0D, 5.0D), EntitySelectors.IS_STANDALONE);

                    if (!list.isEmpty())
                    {
                        EntityChicken entitychicken = (EntityChicken)list.get(0);
                        entitychicken.setChickenJockey(true);
                        this.startRiding(entitychicken);
                    }
                }
                else if ((double)this.world.rand.nextFloat() < 0.05D)
                {
                    EntityChicken entitychicken1 = new EntityChicken(this.world);
                    entitychicken1.setLocationAndAngles(this.posX, this.posY, this.posZ, this.rotationYaw, 0.0F);
                    entitychicken1.onInitialSpawn(difficulty, (IEntityLivingData)null);
                    entitychicken1.setChickenJockey(true);
                    this.world.spawnEntityInWorld(entitychicken1);
                    this.startRiding(entitychicken1);
                }
            }
        }

        this.setBreakDoorsAItask(this.rand.nextFloat() < f * 0.1F);
        this.setEquipmentBasedOnDifficulty(difficulty);
        this.setEnchantmentBasedOnDifficulty(difficulty);

        if (this.getItemStackFromSlot(EntityEquipmentSlot.HEAD).func_190926_b())
        {
            Calendar calendar = this.world.getCurrentDate();

            if (calendar.get(2) + 1 == 10 && calendar.get(5) == 31 && this.rand.nextFloat() < 0.25F)
            {
                this.setItemStackToSlot(EntityEquipmentSlot.HEAD, new ItemStack(this.rand.nextFloat() < 0.1F ? Blocks.LIT_PUMPKIN : Blocks.PUMPKIN));
                this.inventoryArmorDropChances[EntityEquipmentSlot.HEAD.getIndex()] = 0.0F;
            }
        }

        this.getEntityAttribute(SharedMonsterAttributes.KNOCKBACK_RESISTANCE).applyModifier(new AttributeModifier("Random spawn bonus", this.rand.nextDouble() * 0.05000000074505806D, 0));
        double d0 = this.rand.nextDouble() * 1.5D * (double)f;

        if (d0 > 1.0D)
        {
            this.getEntityAttribute(SharedMonsterAttributes.FOLLOW_RANGE).applyModifier(new AttributeModifier("Random zombie-spawn bonus", d0, 2));
        }

        if (this.rand.nextFloat() < f * 0.05F)
        {
            this.getEntityAttribute(SPAWN_REINFORCEMENTS_CHANCE).applyModifier(new AttributeModifier("Leader zombie bonus", this.rand.nextDouble() * 0.25D + 0.5D, 0));
            this.getEntityAttribute(SharedMonsterAttributes.MAX_HEALTH).applyModifier(new AttributeModifier("Leader zombie bonus", this.rand.nextDouble() * 3.0D + 1.0D, 2));
            this.setBreakDoorsAItask(true);
        }

        return livingdata;
    }
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:81,代码来源:EntityZombie.java

示例10: setEquipmentBasedOnDifficulty

import net.minecraft.world.DifficultyInstance; //导入方法依赖的package包/类
/**
 * Gives armor or weapon for entity based on given DifficultyInstance
 */
protected void setEquipmentBasedOnDifficulty(DifficultyInstance difficulty)
{
    if (this.rand.nextFloat() < 0.15F * difficulty.getClampedAdditionalDifficulty())
    {
        int i = this.rand.nextInt(2);
        float f = this.worldObj.getDifficulty() == EnumDifficulty.HARD ? 0.1F : 0.25F;

        if (this.rand.nextFloat() < 0.095F)
        {
            ++i;
        }

        if (this.rand.nextFloat() < 0.095F)
        {
            ++i;
        }

        if (this.rand.nextFloat() < 0.095F)
        {
            ++i;
        }

        boolean flag = true;

        for (EntityEquipmentSlot entityequipmentslot : EntityEquipmentSlot.values())
        {
            if (entityequipmentslot.getSlotType() == EntityEquipmentSlot.Type.ARMOR)
            {
                ItemStack itemstack = this.getItemStackFromSlot(entityequipmentslot);

                if (!flag && this.rand.nextFloat() < f)
                {
                    break;
                }

                flag = false;

                if (itemstack == null)
                {
                    Item item = getArmorByChance(entityequipmentslot, i);

                    if (item != null)
                    {
                        this.setItemStackToSlot(entityequipmentslot, new ItemStack(item));
                    }
                }
            }
        }
    }
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:54,代码来源:EntityLiving.java

示例11: onInitialSpawn

import net.minecraft.world.DifficultyInstance; //导入方法依赖的package包/类
@Nullable

    /**
     * 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
     */
    public IEntityLivingData onInitialSpawn(DifficultyInstance difficulty, @Nullable IEntityLivingData livingdata)
    {
        livingdata = super.onInitialSpawn(difficulty, livingdata);

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

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

            if (this.world.getDifficulty() == EnumDifficulty.HARD && this.world.rand.nextFloat() < 0.1F * difficulty.getClampedAdditionalDifficulty())
            {
                ((EntitySpider.GroupData)livingdata).setRandomEffect(this.world.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:sudofox,项目名称:Backmemed,代码行数:42,代码来源:EntitySpider.java

示例12: setEquipmentBasedOnDifficulty

import net.minecraft.world.DifficultyInstance; //导入方法依赖的package包/类
/**
 * Gives armor or weapon for entity based on given DifficultyInstance
 */
protected void setEquipmentBasedOnDifficulty(DifficultyInstance difficulty)
{
    if (this.rand.nextFloat() < 0.15F * difficulty.getClampedAdditionalDifficulty())
    {
        int i = this.rand.nextInt(2);
        float f = this.world.getDifficulty() == EnumDifficulty.HARD ? 0.1F : 0.25F;

        if (this.rand.nextFloat() < 0.095F)
        {
            ++i;
        }

        if (this.rand.nextFloat() < 0.095F)
        {
            ++i;
        }

        if (this.rand.nextFloat() < 0.095F)
        {
            ++i;
        }

        boolean flag = true;

        for (EntityEquipmentSlot entityequipmentslot : EntityEquipmentSlot.values())
        {
            if (entityequipmentslot.getSlotType() == EntityEquipmentSlot.Type.ARMOR)
            {
                ItemStack itemstack = this.getItemStackFromSlot(entityequipmentslot);

                if (!flag && this.rand.nextFloat() < f)
                {
                    break;
                }

                flag = false;

                if (itemstack.func_190926_b())
                {
                    Item item = getArmorByChance(entityequipmentslot, i);

                    if (item != null)
                    {
                        this.setItemStackToSlot(entityequipmentslot, new ItemStack(item));
                    }
                }
            }
        }
    }
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:54,代码来源:EntityLiving.java


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