net.minecraft.world.Difficulty Java Examples

The following examples show how to use net.minecraft.world.Difficulty. 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 vote down vote up
@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: PendingDifficulty.java    From multiconnect with MIT License 4 votes vote down vote up
public static Difficulty getPendingDifficulty() {
    return pendingDifficulty;
}
 
Example #3
Source File: PendingDifficulty.java    From multiconnect with MIT License 4 votes vote down vote up
public static void setPendingDifficulty(Difficulty pendingDifficulty) {
    PendingDifficulty.pendingDifficulty = pendingDifficulty;
}
 
Example #4
Source File: DifficultyChangeEvent.java    From patchwork-api with GNU Lesser General Public License v2.1 4 votes vote down vote up
public DifficultyChangeEvent(Difficulty difficulty, Difficulty oldDifficulty) {
	this.difficulty = difficulty;
	this.oldDifficulty = oldDifficulty;
}
 
Example #5
Source File: DifficultyChangeEvent.java    From patchwork-api with GNU Lesser General Public License v2.1 4 votes vote down vote up
public Difficulty getDifficulty() {
	return difficulty;
}
 
Example #6
Source File: DifficultyChangeEvent.java    From patchwork-api with GNU Lesser General Public License v2.1 4 votes vote down vote up
public Difficulty getOldDifficulty() {
	return oldDifficulty;
}