本文整理汇总了Java中net.minecraft.world.EnumDifficulty.NORMAL属性的典型用法代码示例。如果您正苦于以下问题:Java EnumDifficulty.NORMAL属性的具体用法?Java EnumDifficulty.NORMAL怎么用?Java EnumDifficulty.NORMAL使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类net.minecraft.world.EnumDifficulty
的用法示例。
在下文中一共展示了EnumDifficulty.NORMAL属性的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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());
}
}
}
}
示例2: EntityLightningBolt
public EntityLightningBolt(World worldIn, double posX, double posY, double posZ)
{
super(worldIn);
this.setLocationAndAngles(posX, posY, posZ, 0.0F, 0.0F);
this.lightningState = 2;
this.boltVertex = this.rand.nextLong();
this.boltLivingTime = this.rand.nextInt(3) + 1;
BlockPos blockpos = new BlockPos(this);
if (!worldIn.isRemote && worldIn.getGameRules().getBoolean("doFireTick") && (worldIn.getDifficulty() == EnumDifficulty.NORMAL || worldIn.getDifficulty() == EnumDifficulty.HARD) && worldIn.isAreaLoaded(blockpos, 10))
{
if (worldIn.getBlockState(blockpos).getBlock().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).getBlock().getMaterial() == Material.air && Blocks.fire.canPlaceBlockAt(worldIn, blockpos1))
{
worldIn.setBlockState(blockpos1, Blocks.fire.getDefaultState());
}
}
}
}
示例3: onKillEntity
/**
* This method gets called when the entity kills another one.
*/
public void onKillEntity(EntityLivingBase entityLivingIn)
{
super.onKillEntity(entityLivingIn);
if ((this.worldObj.getDifficulty() == EnumDifficulty.NORMAL || this.worldObj.getDifficulty() == EnumDifficulty.HARD) && entityLivingIn instanceof EntityVillager)
{
if (this.worldObj.getDifficulty() != EnumDifficulty.HARD && this.rand.nextBoolean())
{
return;
}
EntityLiving entityliving = (EntityLiving)entityLivingIn;
EntityZombie entityzombie = new EntityZombie(this.worldObj);
entityzombie.copyLocationAndAnglesFrom(entityLivingIn);
this.worldObj.removeEntity(entityLivingIn);
entityzombie.onInitialSpawn(this.worldObj.getDifficultyForLocation(new BlockPos(entityzombie)), (IEntityLivingData)null);
entityzombie.setVillager(true);
if (entityLivingIn.isChild())
{
entityzombie.setChild(true);
}
entityzombie.setNoAI(entityliving.isAIDisabled());
if (entityliving.hasCustomName())
{
entityzombie.setCustomNameTag(entityliving.getCustomNameTag());
entityzombie.setAlwaysRenderNameTag(entityliving.getAlwaysRenderNameTag());
}
this.worldObj.spawnEntityInWorld(entityzombie);
this.worldObj.playAuxSFXAtEntity((EntityPlayer)null, 1016, new BlockPos((int)this.posX, (int)this.posY, (int)this.posZ), 0);
}
}
示例4: 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;
}
}
示例5: attackEntityAsMob
public boolean attackEntityAsMob(Entity entityIn)
{
if (super.attackEntityAsMob(entityIn))
{
if (entityIn instanceof EntityLivingBase)
{
int i = 0;
if (this.world.getDifficulty() == EnumDifficulty.NORMAL)
{
i = 7;
}
else if (this.world.getDifficulty() == EnumDifficulty.HARD)
{
i = 15;
}
if (i > 0)
{
((EntityLivingBase)entityIn).addPotionEffect(new PotionEffect(MobEffects.POISON, i * 20, 0));
}
}
return true;
}
else
{
return false;
}
}
示例6: GameSettings
public GameSettings()
{
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;
}
示例7: onKillEntity
/**
* This method gets called when the entity kills another one.
*/
public void onKillEntity(EntityLivingBase entityLivingIn)
{
super.onKillEntity(entityLivingIn);
if ((this.worldObj.getDifficulty() == EnumDifficulty.NORMAL || this.worldObj.getDifficulty() == EnumDifficulty.HARD) && entityLivingIn instanceof EntityVillager)
{
if (this.worldObj.getDifficulty() != EnumDifficulty.HARD && this.rand.nextBoolean())
{
return;
}
EntityVillager entityvillager = (EntityVillager)entityLivingIn;
EntityZombie entityzombie = new EntityZombie(this.worldObj);
entityzombie.copyLocationAndAnglesFrom(entityLivingIn);
this.worldObj.removeEntity(entityLivingIn);
entityzombie.onInitialSpawn(this.worldObj.getDifficultyForLocation(new BlockPos(entityzombie)), new EntityZombie.GroupData(false, true));
entityzombie.setVillagerType(entityvillager.getProfessionForge());
entityzombie.setChild(entityLivingIn.isChild());
entityzombie.setNoAI(entityvillager.isAIDisabled());
if (entityvillager.hasCustomName())
{
entityzombie.setCustomNameTag(entityvillager.getCustomNameTag());
entityzombie.setAlwaysRenderNameTag(entityvillager.getAlwaysRenderNameTag());
}
this.worldObj.spawnEntityInWorld(entityzombie);
this.worldObj.playEvent((EntityPlayer)null, 1026, new BlockPos((int)this.posX, (int)this.posY, (int)this.posZ), 0);
}
}
示例8: GameSettings
public GameSettings()
{
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;
}
示例9: getDifficultyFromCommand
protected EnumDifficulty getDifficultyFromCommand(String p_180531_1_) throws CommandException, NumberInvalidException
{
return !p_180531_1_.equalsIgnoreCase("peaceful") && !p_180531_1_.equalsIgnoreCase("p") ? (!p_180531_1_.equalsIgnoreCase("easy") && !p_180531_1_.equalsIgnoreCase("e") ? (!p_180531_1_.equalsIgnoreCase("normal") && !p_180531_1_.equalsIgnoreCase("n") ? (!p_180531_1_.equalsIgnoreCase("hard") && !p_180531_1_.equalsIgnoreCase("h") ? EnumDifficulty.getDifficultyEnum(parseInt(p_180531_1_, 0, 3)) : EnumDifficulty.HARD) : EnumDifficulty.NORMAL) : EnumDifficulty.EASY) : EnumDifficulty.PEACEFUL;
}
示例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;
}
示例11: 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;
}
}
示例12: 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();
}
}
示例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();
}
}
示例14: onUpdate
/**
* Handles the food game logic.
*/
public void onUpdate(EntityPlayer player)
{
EnumDifficulty enumdifficulty = player.world.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);
}
}
boolean flag = player.world.getGameRules().getBoolean("naturalRegeneration");
if (flag && this.foodSaturationLevel > 0.0F && player.shouldHeal() && this.foodLevel >= 20)
{
++this.foodTimer;
if (this.foodTimer >= 10)
{
float f = Math.min(this.foodSaturationLevel, 6.0F);
player.heal(f / 6.0F);
this.addExhaustion(f);
this.foodTimer = 0;
}
}
else if (flag && this.foodLevel >= 18 && player.shouldHeal())
{
++this.foodTimer;
if (this.foodTimer >= 80)
{
player.heal(1.0F);
this.addExhaustion(6.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;
}
}