Java Code Examples for net.minecraft.world.World#getDifficulty()
The following examples show how to use
net.minecraft.world.World#getDifficulty() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: WitchWaterBlock.java From the-hallow with MIT License | 5 votes |
@Override public void onEntityCollision(BlockState blockState, World world, BlockPos pos, Entity entity) { if(!world.isClient) { if (entity instanceof LivingEntity) { LivingEntity livingEntity = (LivingEntity) entity; if (!livingEntity.isUndead() && !(livingEntity instanceof PumpcownEntity) && !(livingEntity instanceof WitchEntity)) { livingEntity.addStatusEffect(new StatusEffectInstance(StatusEffects.POISON, 100)); livingEntity.addStatusEffect(new StatusEffectInstance(StatusEffects.REGENERATION, 100)); livingEntity.addStatusEffect(new StatusEffectInstance(StatusEffects.BLINDNESS, 100)); } if (pos.equals(entity.getBlockPos())) { if (entity.getType() == EntityType.SKELETON) { WitherSkeletonEntity witherSkeletonEntity = new WitherSkeletonEntity(EntityType.WITHER_SKELETON, world); witherSkeletonEntity.copyPositionAndRotation(entity); entity.remove(); world.spawnEntity(witherSkeletonEntity); } else if (entity.getType() == EntityType.SPIDER) { CaveSpiderEntity caveSpiderEntity = new CaveSpiderEntity(EntityType.CAVE_SPIDER, world); caveSpiderEntity.copyPositionAndRotation(entity); entity.remove(); world.spawnEntity(caveSpiderEntity); } else if (entity.getType() == EntityType.COW) { PumpcownEntity pumpcownEntity = new PumpcownEntity(HallowedEntities.PUMPCOWN, world); pumpcownEntity.copyPositionAndRotation(entity); entity.remove(); world.spawnEntity(pumpcownEntity); } else if (entity.getType() == EntityType.VILLAGER && world.getDifficulty() != Difficulty.PEACEFUL) { WitchEntity witchEntity = new WitchEntity(EntityType.WITCH, world); witchEntity.copyPositionAndRotation(entity); entity.remove(); world.spawnEntity(witchEntity); } } } } super.onEntityCollision(blockState, world, pos, entity); }
Example 2
Source File: MobSpawnEventHandler.java From EnderZoo with Creative Commons Zero v1.0 Universal | 5 votes |
private void applyGlobalModifiers(EntityLivingBase entity, World world) { if (world == null || world.getDifficulty() == null) { return; } double attackModifier = otherAttackMods.get(world.getDifficulty()); double healthModifier = otherHealthMods.get(world.getDifficulty()); if (attackModifier != 1) { adjustBaseAttack(entity, attackModifier); } if (healthModifier != 1) { addjustBaseHealth(entity, healthModifier); } }
Example 3
Source File: MobSpawnEventHandler.java From EnderZoo with Creative Commons Zero v1.0 Universal | 5 votes |
private void applyEnderZooModifiers(EntityLivingBase entity, World world) { if (world == null || world.getDifficulty() == null) { return; } double attackModifier = ezAttackMods.get(world.getDifficulty()); double healthModifier = ezHealthMods.get(world.getDifficulty()); if (attackModifier != 1) { adjustBaseAttack(entity, attackModifier); } if (healthModifier != 1) { addjustBaseHealth(entity, healthModifier); } }
Example 4
Source File: EntityUtil.java From EnderZoo with Creative Commons Zero v1.0 Universal | 4 votes |
public static boolean isHardDifficulty(World worldObj) { return worldObj.getDifficulty() == EnumDifficulty.HARD; }