本文整理汇总了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);
}
}
}
示例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);
}
示例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));
}
}
示例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);
}
}
}
}
示例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());
}
示例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));
}
}
}
示例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();
}
示例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));
}
}
}
示例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);
}
示例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();
}
示例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();
}
示例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);
}
}
}
}
示例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();
}
}
示例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;
}
示例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());
}
}
}
}