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

The following examples show how to use net.minecraft.world.World#getWorldTime() . 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: BlockSaltPan.java    From TofuCraftReload with 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 File: ItemGrowingTofu.java    From TofuCraftReload with 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
Source File: WorldTimeSensor.java    From PneumaticCraft with GNU General Public License v3.0 4 votes vote down vote up
@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 File: WorldUtils.java    From TofuCraftReload with MIT License 3 votes vote down vote up
public static boolean isMorning(World world) {

        long timeDay = world.getWorldTime() % 24000;

        return timeDay > 0 && timeDay < 800;

    }