當前位置: 首頁>>代碼示例>>Java>>正文


Java EnumDifficulty類代碼示例

本文整理匯總了Java中net.minecraft.world.EnumDifficulty的典型用法代碼示例。如果您正苦於以下問題:Java EnumDifficulty類的具體用法?Java EnumDifficulty怎麽用?Java EnumDifficulty使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


EnumDifficulty類屬於net.minecraft.world包,在下文中一共展示了EnumDifficulty類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: setCombatTask

import net.minecraft.world.EnumDifficulty; //導入依賴的package包/類
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,代碼行數:22,代碼來源:EntityPigZombieMage.java

示例2: GameSettings

import net.minecraft.world.EnumDifficulty; //導入依賴的package包/類
public GameSettings(Minecraft mcIn, File p_i46326_2_)
{
    this.keyBindings = (KeyBinding[])((KeyBinding[])ArrayUtils.addAll(new KeyBinding[] {this.keyBindAttack, this.keyBindUseItem, this.keyBindForward, this.keyBindLeft, this.keyBindBack, this.keyBindRight, this.keyBindJump, this.keyBindSneak, this.keyBindSprint, this.keyBindDrop, this.keyBindInventory, this.keyBindChat, this.keyBindPlayerList, this.keyBindPickBlock, this.keyBindCommand, this.keyBindScreenshot, this.keyBindTogglePerspective, this.keyBindSmoothCamera, this.keyBindStreamStartStop, this.keyBindStreamPauseUnpause, this.keyBindStreamCommercials, this.keyBindStreamToggleMic, this.keyBindFullscreen, this.keyBindSpectatorOutlines}, this.keyBindsHotbar));
    this.difficulty = EnumDifficulty.NORMAL;
    this.lastServer = "";
    this.fovSetting = 70.0F;
    this.language = "en_US";
    this.forceUnicodeFont = false;
    this.mc = mcIn;
    this.optionsFile = new File(p_i46326_2_, "options.txt");
    this.optionsFileOF = new File(p_i46326_2_, "optionsof.txt");
    this.limitFramerate = (int)GameSettings.Options.FRAMERATE_LIMIT.getValueMax();
    this.ofKeyBindZoom = new KeyBinding("Zoom", 46, "key.categories.misc");
    this.keyBindings = (KeyBinding[])((KeyBinding[])ArrayUtils.add(this.keyBindings, this.ofKeyBindZoom));
    GameSettings.Options.RENDER_DISTANCE.setValueMax(32.0F);
    this.renderDistanceChunks = 8;
    this.loadOptions();
    Config.initGameSettings(this);
}
 
開發者ID:SkidJava,項目名稱:BaseClient,代碼行數:20,代碼來源:GameSettings.java

示例3: updateTask

import net.minecraft.world.EnumDifficulty; //導入依賴的package包/類
/**
 * 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,代碼行數:29,代碼來源:EntityAIBreakDoor.java

示例4: setDifficultyForAllWorlds

import net.minecraft.world.EnumDifficulty; //導入依賴的package包/類
public void setDifficultyForAllWorlds(EnumDifficulty difficulty)
{
    for (WorldServer worldserver : this.worldServers)
    {
        if (worldserver != null)
        {
            if (worldserver.getWorldInfo().isHardcoreModeEnabled())
            {
                worldserver.getWorldInfo().setDifficulty(EnumDifficulty.HARD);
                worldserver.setAllowedSpawnTypes(true, true);
            }
            else if (this.isSinglePlayer())
            {
                worldserver.getWorldInfo().setDifficulty(difficulty);
                worldserver.setAllowedSpawnTypes(worldserver.getDifficulty() != EnumDifficulty.PEACEFUL, true);
            }
            else
            {
                worldserver.getWorldInfo().setDifficulty(difficulty);
                worldserver.setAllowedSpawnTypes(this.allowSpawnMonsters(), this.canSpawnAnimals);
            }
        }
    }
}
 
開發者ID:F1r3w477,項目名稱:CustomWorldGen,代碼行數:25,代碼來源:MinecraftServer.java

示例5: updateTask

import net.minecraft.world.EnumDifficulty; //導入依賴的package包/類
@Override
@SuppressWarnings("ConstantConditions")
public void updateTask() {
	EntityLivingBase target = eye.getAttackTarget();

	if(!eye.canEntityBeSeen(target)) {
		eye.setAttackTarget(null);
	} else if(tickCounter++ >= 10) {
		float f = 1.0F;

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

		target.attackEntityFrom(DamageSource.causeIndirectMagicDamage(eye, eye), f);
		target.attackEntityFrom(DamageSource.causeMobDamage(eye), (float) eye.getEntityAttribute(SharedMonsterAttributes.ATTACK_DAMAGE).getAttributeValue());
		eye.setAttackTarget(null);
	}
	eye.getLookHelper().setLookPosition(target.posX, target.posY + (double) target.getEyeHeight(), target.posZ, (float) eye.getHorizontalFaceSpeed(), (float) eye.getVerticalFaceSpeed());
}
 
開發者ID:ArekkuusuJerii,項目名稱:Solar,代碼行數:21,代碼來源:EntityEyeOfSchrodinger.java

示例6: setEquipmentBasedOnDifficulty

import net.minecraft.world.EnumDifficulty; //導入依賴的package包/類
/**
 * 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:Notoh,項目名稱:DecompiledMinecraft,代碼行數:22,代碼來源:EntityZombie.java

示例7: readPacketData

import net.minecraft.world.EnumDifficulty; //導入依賴的package包/類
/**
 * Reads the raw packet data from the data stream.
 */
public void readPacketData(PacketBuffer buf) throws IOException
{
    this.entityId = buf.readInt();
    int i = buf.readUnsignedByte();
    this.hardcoreMode = (i & 8) == 8;
    i = i & -9;
    this.gameType = WorldSettings.GameType.getByID(i);
    this.dimension = buf.readByte();
    this.difficulty = EnumDifficulty.getDifficultyEnum(buf.readUnsignedByte());
    this.maxPlayers = buf.readUnsignedByte();
    this.worldType = WorldType.parseWorldType(buf.readStringFromBuffer(16));

    if (this.worldType == null)
    {
        this.worldType = WorldType.DEFAULT;
    }

    this.reducedDebugInfo = buf.readBoolean();
}
 
開發者ID:Notoh,項目名稱:DecompiledMinecraft,代碼行數:23,代碼來源:S01PacketJoinGame.java

示例8: setEquipmentBasedOnDifficulty

import net.minecraft.world.EnumDifficulty; //導入依賴的package包/類
/**
 * Gives armor or weapon for entity based on given DifficultyInstance
 */
protected void setEquipmentBasedOnDifficulty(DifficultyInstance difficulty)
{
    super.setEquipmentBasedOnDifficulty(difficulty);

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

        if (i == 0)
        {
            this.setItemStackToSlot(EntityEquipmentSlot.MAINHAND, new ItemStack(Items.IRON_SWORD));
        }
        else
        {
            this.setItemStackToSlot(EntityEquipmentSlot.MAINHAND, new ItemStack(Items.IRON_SHOVEL));
        }
    }
}
 
開發者ID:sudofox,項目名稱:Backmemed,代碼行數:22,代碼來源:EntityZombie.java

示例9: GameSettings

import net.minecraft.world.EnumDifficulty; //導入依賴的package包/類
public GameSettings(Minecraft mcIn, File p_i46326_2_)
{
    this.keyBindings = (KeyBinding[])((KeyBinding[])ArrayUtils.addAll(new KeyBinding[] {this.keyBindAttack, this.keyBindUseItem, this.keyBindForward, this.keyBindLeft, this.keyBindBack, this.keyBindRight, this.keyBindJump, this.keyBindSneak, this.keyBindSprint, this.keyBindDrop, this.keyBindInventory, this.keyBindChat, this.keyBindPlayerList, this.keyBindPickBlock, this.keyBindCommand, this.keyBindScreenshot, this.keyBindTogglePerspective, this.keyBindSmoothCamera, this.keyBindStreamStartStop, this.keyBindStreamPauseUnpause, this.keyBindStreamCommercials, this.keyBindStreamToggleMic, this.keyBindFullscreen, this.keyBindSpectatorOutlines}, this.keyBindsHotbar));
    this.difficulty = EnumDifficulty.NORMAL;
    this.lastServer = "";
    this.fovSetting = 70.0F;
    this.language = "en_US";
    this.forceUnicodeFont = false;
    this.mc = mcIn;
    this.optionsFile = new File(p_i46326_2_, "options.txt");
    this.optionsFileOF = new File(p_i46326_2_, "optionsof.txt");
    this.limitFramerate = (int)GameSettings.Options.FRAMERATE_LIMIT.getValueMax();
    this.ofKeyBindZoom = new KeyBinding("of.key.zoom", 46, "key.categories.misc");
    this.keyBindings = (KeyBinding[])((KeyBinding[])ArrayUtils.add(this.keyBindings, this.ofKeyBindZoom));
    GameSettings.Options.RENDER_DISTANCE.setValueMax(32.0F);
    this.renderDistanceChunks = 8;
    this.loadOptions();
    Config.initGameSettings(this);
}
 
開發者ID:SkidJava,項目名稱:BaseClient,代碼行數:20,代碼來源:GameSettings.java

示例10: GameSettings

import net.minecraft.world.EnumDifficulty; //導入依賴的package包/類
public GameSettings(Minecraft mcIn, File p_i46326_2_)
{
    this.keyBindings = (KeyBinding[])ArrayUtils.addAll(new KeyBinding[] {this.keyBindAttack, this.keyBindUseItem, this.keyBindForward, this.keyBindLeft, this.keyBindBack, this.keyBindRight, this.keyBindJump, this.keyBindSneak, this.keyBindSprint, this.keyBindDrop, this.keyBindInventory, this.keyBindChat, this.keyBindPlayerList, this.keyBindPickBlock, this.keyBindCommand, this.keyBindScreenshot, this.keyBindTogglePerspective, this.keyBindSmoothCamera, this.keyBindStreamStartStop, this.keyBindStreamPauseUnpause, this.keyBindStreamCommercials, this.keyBindStreamToggleMic, this.keyBindFullscreen, this.keyBindSpectatorOutlines}, this.keyBindsHotbar);
    this.difficulty = EnumDifficulty.NORMAL;
    this.lastServer = "";
    this.fovSetting = 70.0F;
    this.language = "en_US";
    this.forceUnicodeFont = false;
    this.mc = mcIn;
    this.optionsFile = new File(p_i46326_2_, "options.txt");

    if (mcIn.isJava64bit() && Runtime.getRuntime().maxMemory() >= 1000000000L)
    {
        GameSettings.Options.RENDER_DISTANCE.setValueMax(32.0F);
    }
    else
    {
        GameSettings.Options.RENDER_DISTANCE.setValueMax(16.0F);
    }

    this.renderDistanceChunks = mcIn.isJava64bit() ? 12 : 8;
    this.loadOptions();
}
 
開發者ID:Notoh,項目名稱:DecompiledMinecraft,代碼行數:24,代碼來源:GameSettings.java

示例11: readPacketData

import net.minecraft.world.EnumDifficulty; //導入依賴的package包/類
/**
 * Reads the raw packet data from the data stream.
 */
public void readPacketData(PacketBuffer buf) throws IOException
{
    this.playerId = buf.readInt();
    int i = buf.readUnsignedByte();
    this.hardcoreMode = (i & 8) == 8;
    i = i & -9;
    this.gameType = GameType.getByID(i);
    this.dimension = buf.readInt();
    this.difficulty = EnumDifficulty.getDifficultyEnum(buf.readUnsignedByte());
    this.maxPlayers = buf.readUnsignedByte();
    this.worldType = WorldType.parseWorldType(buf.readStringFromBuffer(16));

    if (this.worldType == null)
    {
        this.worldType = WorldType.DEFAULT;
    }

    this.reducedDebugInfo = buf.readBoolean();
}
 
開發者ID:sudofox,項目名稱:Backmemed,代碼行數:23,代碼來源:SPacketJoinGame.java

示例12: setDifficultyForAllWorlds

import net.minecraft.world.EnumDifficulty; //導入依賴的package包/類
public void setDifficultyForAllWorlds(EnumDifficulty difficulty)
{
    for (int i = 0; i < this.worldServers.length; ++i)
    {
        World world = this.worldServers[i];

        if (world != null)
        {
            if (world.getWorldInfo().isHardcoreModeEnabled())
            {
                world.getWorldInfo().setDifficulty(EnumDifficulty.HARD);
                world.setAllowedSpawnTypes(true, true);
            }
            else if (this.isSinglePlayer())
            {
                world.getWorldInfo().setDifficulty(difficulty);
                world.setAllowedSpawnTypes(world.getDifficulty() != EnumDifficulty.PEACEFUL, true);
            }
            else
            {
                world.getWorldInfo().setDifficulty(difficulty);
                world.setAllowedSpawnTypes(this.allowSpawnMonsters(), this.canSpawnAnimals);
            }
        }
    }
}
 
開發者ID:SkidJava,項目名稱:BaseClient,代碼行數:27,代碼來源:MinecraftServer.java

示例13: onUpdate

import net.minecraft.world.EnumDifficulty; //導入依賴的package包/類
/**
 * 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,代碼行數:13,代碼來源:EntityDummy.java

示例14: onInitialSpawn

import net.minecraft.world.EnumDifficulty; //導入依賴的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:SkidJava,項目名稱:BaseClient,代碼行數:40,代碼來源:EntitySpider.java

示例15: EntityLightningBolt

import net.minecraft.world.EnumDifficulty; //導入依賴的package包/類
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,代碼行數:29,代碼來源:EntityLightningBolt.java


注:本文中的net.minecraft.world.EnumDifficulty類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。