Java Code Examples for net.minecraft.world.World.isDaytime()

The following are Jave code examples for showing how to use isDaytime() of the net.minecraft.world.World class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
Example 1
Project: Bewitchment   File: BlockMoonbell.java   Source Code and License Vote up 5 votes
@Override
public void updateTick(World world, BlockPos pos, IBlockState state, Random r) {
	if (!state.getValue(placed) && (world.isDaytime() || world.getMoonPhase() != 4)) {
		world.setBlockToAir(pos);
		for (int i = 0; i < 7; i++) {
			world.spawnParticle(EnumParticleTypes.FIREWORKS_SPARK, pos.getX() + r.nextDouble(), pos.getY() + r.nextDouble(), pos.getZ() + r.nextDouble(), r.nextGaussian() * 0.01, r.nextDouble() * 0.01, r.nextGaussian() * 0.01);
		}
	}
}
 
Example 2
Project: Bewitchment   File: BlockMoonbell.java   Source Code and License Vote up 5 votes
@SubscribeEvent
public void spawnFlowers(PlayerTickEvent evt) {
	if (evt.side == Side.SERVER && evt.phase == Phase.START) {
		World w = evt.player.world;
		if (w.getTotalWorldTime() % 20 == 0 && validBiomesMoonBell.contains(w.getBiome(evt.player.getPosition()))) {
			Random r = evt.player.getRNG();
			if (w.provider.getDimension() == 0 && w.provider.getMoonPhase(w.getWorldTime()) == 4 && !w.isDaytime() && evt.player.getRNG().nextDouble() < 0.2) {
				int dx = (r.nextInt(7) - 3) * 10;
				int dz = (r.nextInt(7) - 3) * 10;
				MutableBlockPos pos = new MutableBlockPos(evt.player.getPosition().add(dx, 0, dz));
				tryAndSpawn(w, pos);
			}
		}
	}
}
 
Example 3
Project: OpenSensors   File: ItemWorldSensor.java   Source Code and License Vote up 5 votes
@Override
@Callback
public Object[] get(Context context, Arguments args, World worldIn, TileEntitySensor teIn) {
	if (args.checkString(0).equalsIgnoreCase("biome")) {
		return new Object[] { worldIn.getBiomeGenForCoords((teIn.xCoord + rangeLimit(args.optInteger(1, 0))), (teIn.zCoord + rangeLimit(args.optInteger(1, 0)))).biomeName };
	} else if (args.checkString(0).equalsIgnoreCase("lightlevel")) {
		return new Object[] { worldIn.getBlockLightValue((teIn.xCoord + rangeLimit(args.optInteger(1, 0))), (teIn.yCoord + rangeLimit(rangeLimit(args.optInteger(1, 0)))), (teIn.zCoord + rangeLimit(args.optInteger(1, 0)))) };
	} else if (args.checkString(0).equalsIgnoreCase("raining")) {
		return new Object[] { worldIn.isRaining() };
	} else if (args.checkString(0).equalsIgnoreCase("thundering")) {
		return new Object[] { worldIn.isThundering() };
	} else if (args.checkString(0).equalsIgnoreCase("daytime")) {
		return new Object[] { worldIn.isDaytime() };
	} else if (args.checkString(0).equalsIgnoreCase("moonphase")) {
		return new Object[] { worldIn.getCurrentMoonPhaseFactor() };
	} else if (args.checkString(0).equalsIgnoreCase("celestialangle")) {
		return new Object[] { worldIn.getCelestialAngle(1.0F)};
	} else if (args.checkString(0).equalsIgnoreCase("dimension")) {
		return new Object[] { worldIn.getWorldInfo().getVanillaDimension()};
	} else if (args.checkString(0).equalsIgnoreCase("temperature") || args.checkString(0).equalsIgnoreCase("temp")) {
		return new Object[] { worldIn.getBiomeGenForCoords((teIn.xCoord + rangeLimit(args.optInteger(1, 0))), (teIn.zCoord + rangeLimit(args.optInteger(1, 0)))).temperature};
	} else if (args.checkString(0).equalsIgnoreCase("highhumidity")) {
		return new Object[] { worldIn.getBiomeGenForCoords((teIn.xCoord + rangeLimit(args.optInteger(1, 0))), (teIn.zCoord + rangeLimit(args.optInteger(1, 0)))).isHighHumidity()};
	} else if (args.checkString(0).equalsIgnoreCase("humidity")) {
		return new Object[] { worldIn.getBiomeGenForCoords((teIn.xCoord + rangeLimit(args.optInteger(1, 0))), (teIn.zCoord + rangeLimit(args.optInteger(1, 0)))).rainfall};
	} else if (args.checkString(0).equalsIgnoreCase("worldseed")) {
		return new Object[] { worldIn.getSeed()};
	}
	return new Object[] { "No method passed, or not found" };
}
 
Example 4
Project: Bewitchment   File: RitualHighMoon.java   Source Code and License Vote up 4 votes
@Override
public boolean isValid(EntityPlayer player, World world, BlockPos pos, List<ItemStack> recipe) {
	return world.isDaytime();
}
 
Example 5
Project: Metalworks   File: Util.java   Source Code and License Vote up 4 votes
public static boolean isDayTime(World world){
    return world.isDaytime();
}