本文整理匯總了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();
}
}
示例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);
}
示例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();
}
}
示例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;
}
}
示例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;
}
}
示例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();
}
示例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);
}
}
}
}
示例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;
}
示例9: shouldExecute
/**
* Returns whether the EntityAIBase should begin execution.
*/
public boolean shouldExecute()
{
return EntityShulker.this.worldObj.getDifficulty() == EnumDifficulty.PEACEFUL ? false : super.shouldExecute();
}
示例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;
}
示例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;
}
示例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;
}
}
示例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;
}
示例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;
}
示例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);
}
}
}
}
}