Java Code Examples for net.minecraft.world.World#getWorldTime()

The following examples show how to use net.minecraft.world.World#getWorldTime() . These examples are extracted from open source projects. 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 want to check out the right sidebar which shows the related API usage.
Example 1
Source Project: TofuCraftReload   File: BlockSaltPan.java    License: MIT License 6 votes vote down vote up
private float calcAdaptation(World world, BlockPos pos)
{
    Biome biome = world.getBiome(pos);
    boolean isUnderTheSun = world.canBlockSeeSky(pos);
    boolean isRaining = world.isRaining();
    boolean isDaytime = world.getWorldTime() % 24000 < 12000;
    float humidity = biome.getRainfall();
    float temperature = biome.getTemperature(pos);
    float rate;

    if (!isUnderTheSun || isRaining)
    {
        rate = 0.0F;
    }
    else
    {
        rate = isDaytime ? 2.0F : 1.0F;
        rate *= humidity < 0.2D ? 4.0D : humidity < 0.7D ? 2.0D : humidity < 0.9 ? 1.0D : 0.5D;
        rate *= temperature < 0.0D ? 1.0D : temperature < 0.6D ? 1.5D : temperature < 1.0D ? 2.0D : 4.0D;
    }
    return rate;
}
 
Example 2
Source Project: TofuCraftReload   File: ItemGrowingTofu.java    License: MIT License 5 votes vote down vote up
@Override
public void onUpdate(ItemStack stack, World worldIn, Entity entityIn, int itemSlot, boolean isSelected) {
    if (!worldIn.isRemote) {
        if (worldIn.getWorldTime() % 200 == 0) {
            if (rnd.nextBoolean())
                if (getDamage(stack) > 0 && getEnergy(stack) > 5000) {
                    drain(stack, 500, false);
                    stack.setItemDamage(stack.getItemDamage() - 1);
                }
        }
    }

    super.onUpdate(stack, worldIn, entityIn, itemSlot, isSelected);
}
 
Example 3
@Override
public int getRedstoneValue(World world, int x, int y, int z, int sensorRange, String textBoxText){
    return (int)(world.getWorldTime() % 24000) / 1500;
}
 
Example 4
Source Project: TofuCraftReload   File: WorldUtils.java    License: MIT License 3 votes vote down vote up
public static boolean isMorning(World world) {

        long timeDay = world.getWorldTime() % 24000;

        return timeDay > 0 && timeDay < 800;

    }