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

The following are Jave code examples for showing how to use getWorldTime() 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: BaseClient   File: CustomSky.java   Source Code and License Vote up 5 votes
public static void renderSky(World p_renderSky_0_, TextureManager p_renderSky_1_, float p_renderSky_2_, float p_renderSky_3_)
{
    if (worldSkyLayers != null)
    {
        if (Config.getGameSettings().renderDistanceChunks >= 8)
        {
            int i = p_renderSky_0_.provider.getDimensionId();

            if (i >= 0 && i < worldSkyLayers.length)
            {
                CustomSkyLayer[] acustomskylayer = worldSkyLayers[i];

                if (acustomskylayer != null)
                {
                    long j = p_renderSky_0_.getWorldTime();
                    int k = (int)(j % 24000L);

                    for (int l = 0; l < acustomskylayer.length; ++l)
                    {
                        CustomSkyLayer customskylayer = acustomskylayer[l];

                        if (customskylayer.isActive(p_renderSky_0_, k))
                        {
                            customskylayer.render(k, p_renderSky_2_, p_renderSky_3_);
                        }
                    }

                    Blender.clearBlend(p_renderSky_3_);
                }
            }
        }
    }
}
 
Example 2
Project: BaseClient   File: CustomSkyLayer.java   Source Code and License Vote up 5 votes
public boolean isActive(World p_isActive_1_, int p_isActive_2_)
{
    if (this.timeBetween(p_isActive_2_, this.endFadeOut, this.startFadeIn))
    {
        return false;
    }
    else
    {
        if (this.days != null)
        {
            long i = p_isActive_1_.getWorldTime();
            long j;

            for (j = i - (long)this.startFadeIn; j < 0L; j += (long)(24000 * this.daysLoop))
            {
                ;
            }

            int k = (int)(j / 24000L);
            int l = k % this.daysLoop;

            if (!this.days.isInRange(l))
            {
                return false;
            }
        }

        return true;
    }
}
 
Example 3
Project: BaseClient   File: CustomSky.java   Source Code and License Vote up 5 votes
public static void renderSky(World p_renderSky_0_, TextureManager p_renderSky_1_, float p_renderSky_2_, float p_renderSky_3_)
{
    if (worldSkyLayers != null)
    {
        if (Config.getGameSettings().renderDistanceChunks >= 8)
        {
            int i = p_renderSky_0_.provider.getDimensionId();

            if (i >= 0 && i < worldSkyLayers.length)
            {
                CustomSkyLayer[] acustomskylayer = worldSkyLayers[i];

                if (acustomskylayer != null)
                {
                    long j = p_renderSky_0_.getWorldTime();
                    int k = (int)(j % 24000L);

                    for (int l = 0; l < acustomskylayer.length; ++l)
                    {
                        CustomSkyLayer customskylayer = acustomskylayer[l];

                        if (customskylayer.isActive(k))
                        {
                            customskylayer.render(k, p_renderSky_2_, p_renderSky_3_);
                        }
                    }

                    Blender.clearBlend(p_renderSky_3_);
                }
            }
        }
    }
}
 
Example 4
Project: modName   File: EventHandlerCommon.java   Source Code and License Vote up 5 votes
@SubscribeEvent
public void onServerTick(ServerTickEvent e)
{
	if(counter == 1)
	{
		MinecraftServer server = FMLCommonHandler.instance().getMinecraftServerInstance();
		World world = server.getEntityWorld();
	
		if(world.isRemote == false) 
		{
		
			long totalTime = world.getWorldTime();
			long currentTime = totalTime % 24000;
		
			if(currentTime == 1)
			{
				System.out.println("Time is 0");
				WorldTurn turn = WorldTurn.get(world);
				int currentTurn = turn.advanceTurn();
				System.out.println("New Turn!!  The World Turn is now " + currentTurn);
				ArrayList<EntityPlayerMP> playerList = (ArrayList<EntityPlayerMP>)(world.getMinecraftServer().getServer().getPlayerList().getPlayers());
				for(int i=0; i < playerList.size(); i++)
				{
					EntityPlayer player = playerList.get(i);
					ITurn playerTurn = player.getCapability(CapPlayerTurn.TURN_CAP, null);
					playerTurn.addTurn();
				}
			}
		}
		
		counter = 0;
	}
	else
	{
		counter++;
	}
}
 
Example 5
Project: uniquecrops   File: Cinderbella.java   Source Code and License Vote up 5 votes
@Override
   public void updateTick(World world, BlockPos pos, IBlockState state, Random rand) {
	
	TileEntity te = world.getTileEntity(pos);
	if (te != null && te instanceof TileCinderbella) {
		TileCinderbella tile = (TileCinderbella)te;
		long time = world.getWorldTime() % 24000L;
		if (tile.plantedCorrect && tile.timePlanted >= (time - 6000)) {
			super.updateTick(world, pos, state, rand);
			return;
		}
	}
	world.setBlockState(pos, Blocks.DEADBUSH.getDefaultState(), 2);
}
 
Example 6
Project: uniquecrops   File: UCDyePlantStitch.java   Source Code and License Vote up 5 votes
@Override
@SideOnly(Side.CLIENT)
public void updateAnimation() {
	
	World world = Minecraft.getMinecraft().theWorld;
	if (world != null) {
		long time = world.getWorldTime() % 24000L;
		this.frameCounter = (int)(time / 1500);
	}
	TextureUtil.uploadTextureMipmap((int[][])this.framesTextureData.get(this.frameCounter), this.width, this.height, this.originX, this.originY, false, false);
}
 
Example 7
Project: Backmemed   File: CustomSky.java   Source Code and License Vote up 5 votes
public static void renderSky(World p_renderSky_0_, TextureManager p_renderSky_1_, float p_renderSky_2_)
{
    if (worldSkyLayers != null)
    {
        int i = p_renderSky_0_.provider.getDimensionType().getId();

        if (i >= 0 && i < worldSkyLayers.length)
        {
            CustomSkyLayer[] acustomskylayer = worldSkyLayers[i];

            if (acustomskylayer != null)
            {
                long j = p_renderSky_0_.getWorldTime();
                int k = (int)(j % 24000L);
                float f = p_renderSky_0_.getCelestialAngle(p_renderSky_2_);
                float f1 = p_renderSky_0_.getRainStrength(p_renderSky_2_);
                float f2 = p_renderSky_0_.getThunderStrength(p_renderSky_2_);

                if (f1 > 0.0F)
                {
                    f2 /= f1;
                }

                for (int l = 0; l < acustomskylayer.length; ++l)
                {
                    CustomSkyLayer customskylayer = acustomskylayer[l];

                    if (customskylayer.isActive(p_renderSky_0_, k))
                    {
                        customskylayer.render(k, f, f1, f2);
                    }
                }

                float f3 = 1.0F - f1;
                Blender.clearBlend(f3);
            }
        }
    }
}
 
Example 8
Project: Backmemed   File: CustomSkyLayer.java   Source Code and License Vote up 5 votes
public boolean isActive(World p_isActive_1_, int p_isActive_2_)
{
    if (this.timeBetween(p_isActive_2_, this.endFadeOut, this.startFadeIn))
    {
        return false;
    }
    else
    {
        if (this.days != null)
        {
            long i = p_isActive_1_.getWorldTime();
            long j;

            for (j = i - (long)this.startFadeIn; j < 0L; j += (long)(24000 * this.daysLoop))
            {
                ;
            }

            int k = (int)(j / 24000L);
            int l = k % this.daysLoop;

            if (!this.days.isInRange(l))
            {
                return false;
            }
        }

        return true;
    }
}
 
Example 9
Project: Mods   File: TNTCannon.java   Source Code and License Vote up 5 votes
@Override
public void onUpdate(ItemStack p_77663_1_, World p_77663_2_, Entity p_77663_3_, int i, boolean p_77663_5_) {
	if (!p_77663_2_.isRemote && p_77663_1_.hasTagCompound()) {
		if (p_77663_1_.getTagCompound().getInteger("explode") > 0)
			p_77663_1_.getTagCompound().setInteger("explode",
					p_77663_1_.getTagCompound().getInteger("explode") - 1);
		EntityPlayer player = (EntityPlayer) p_77663_3_;
		if (p_77663_1_.getTagCompound().getInteger("wait") > 0)
			// ((EntityPlayerMP)player).isChangingQuantityOnly=true;
			p_77663_1_.getTagCompound().setInteger("wait", p_77663_1_.getTagCompound().getInteger("wait") - 1);
		// else if (player instanceof EntityPlayerMP)
		// {
		// ((EntityPlayerMP)player).isChangingQuantityOnly=false;
		// if(p_77663_1_.getTagCompound().getInteger("wait")==0){
		// ((EntityPlayerMP)player).playerNetServerHandler.sendPacket(new
		// S2FPacketSetSlot(-1, -1, player.inventory.getItemStack()));
		// }
		// }
		if (this.isRepeatable(p_77663_1_) && i == player.inventory.currentItem
				&& p_77663_1_.getTagCompound().getInteger("repeat") > 0)
			if (p_77663_2_.getWorldTime() % 2 == 0 && this.allowShot(player, p_77663_1_, player.world)) {
				this.use(p_77663_1_, player.world, player, 1.8f,
						player.inventory.getStackInSlot(this.getSlotForUse(player, p_77663_1_)),
						!(this.getType(p_77663_1_) == 4 && p_77663_1_.getTagCompound().getInteger("repeat") == 2));
				p_77663_1_.getTagCompound().setInteger("repeat",
						p_77663_1_.getTagCompound().getInteger("repeat") - 1);
			}
	}

}
 
Example 10
Project: pnc-repressurized   File: WorldTimeSensor.java   Source Code and License Vote up 4 votes
@Override
public int getRedstoneValue(World world, BlockPos pos, int sensorRange, String textBoxText) {
    return (int) (world.getWorldTime() % 24000) / 1500;
}
 
Example 11
Project: uniquecrops   File: TileCinderbella.java   Source Code and License Vote up 4 votes
public void setAbleToGrow(World world) {
	
	plantedCorrect = true;
	timePlanted = world.getWorldTime();
}
 
Example 12
Project: uniquecrops   File: SeedBehavior.java   Source Code and License Vote up 4 votes
public static boolean canPlantCrop(ItemStack stack, EntityPlayer player, World world, BlockPos pos, EnumFacing side, Block cropBlock) {
	
	if (side != EnumFacing.UP)
		return false;
	
	if (!world.isRemote && cropBlock instanceof BlockCropsBase && !((BlockCropsBase)cropBlock).canPlantCrop()) {
		UCPacketHandler.sendToNearbyPlayers(world, pos, new PacketUCEffect(EnumParticleTypes.BARRIER, pos.getX(), pos.getY() + 2, pos.getZ(), 0));
		return false;
	}
	else if (player.canPlayerEdit(pos, side, stack) && player.canPlayerEdit(pos.offset(EnumFacing.UP), side, stack)) {
		IBlockState state = world.getBlockState(pos);
		if (state.getBlock().canSustainPlant(state, world, pos, EnumFacing.UP, (IPlantable)stack.getItem()) && world.isAirBlock(pos.offset(EnumFacing.UP))) {
			if (cropBlock == UCBlocks.cropCollis) {
				if (!world.provider.isSurfaceWorld() || pos.getY() <= 100)
					return false;
			}
			if (cropBlock == UCBlocks.cropCinderbella) {
				long time = world.getWorldTime() % 24000L;
				if (time >= 18000)
					return false;
				
				BlockPos pos1 = pos.add(0, 1, 0);
				int pumpkins = 0;
				for (EnumFacing facing : EnumFacing.HORIZONTALS) {
					IBlockState pumpkin = world.getBlockState(pos1.offset(facing));
					if (pumpkin.getBlock() != null && pumpkin.getBlock() == Blocks.PUMPKIN && !world.isRemote) {
						pumpkins++;
					}
				}
				if (pumpkins >= 4) {
					cropBlock.onBlockPlacedBy(world, pos.offset(side), cropBlock.getDefaultState(), player, stack);
					return true;
				}
			}
			if (cropBlock == UCBlocks.cropFeroxia) {
				cropBlock.onBlockPlacedBy(world, pos.offset(side), cropBlock.getDefaultState(), player, stack);
				return true;
			}
			if (cropBlock == UCBlocks.cropEula) {
				player.openGui(UniqueCrops.instance, 1, world, (int)player.posX, (int)player.posY, (int)player.posZ);
			}
			if (cropBlock == UCBlocks.cropAbstract) {
				player.renderBrokenItemStack(stack);
				if (!player.worldObj.isRemote)
					setAbstractCropGrowth(player, true);
				return true;
			}
			if (cropBlock == UCBlocks.cropPetramia && pos.offset(side).getY() >= 10) {
				return false;
			}
			world.setBlockState(pos.offset(side), cropBlock.getDefaultState(), 3);
			return true;
		}
	}
	return false;
}
 
Example 13
Project: DebugServerInfo   File: ClientProxy.java   Source Code and License Vote up 4 votes
@SubscribeEvent
public void drawTextEvent(RenderGameOverlayEvent.Text event)
{
    ArrayList<String> list = cfgLeft ? event.getLeft() : event.getRight();

    World world = Minecraft.getMinecraft().world;

    if (world != null)
    {
        StringBuilder mc = new StringBuilder();

        if (show(cfgClockMCDays))
        {
            mc.append("Day ").append(world.getTotalWorldTime() / 24000);
        }

        if (show(cfgClockMC))
        {
            if (mc.length() > 0) mc.append(' ');

            // 0 -> 24000
            int time = (int) world.getWorldTime();
            // minutes = time % 1000
            // hours = (6 + time / 1000) % 24, cause 0 = 6h, max = 24h
            mc.append(doTime((6 + (time / 1000)) % 24, (int) ((time % 1000)*0.06), "MC"));
        }

        if (mc.length() > 0)
        {
            list.add(mc.toString());
        }

        if (show(cfgClockIRL))
        {
            Calendar cal = world.getCurrentDate();
            list.add(doTime(cal.get(Calendar.HOUR_OF_DAY), cal.get(Calendar.MINUTE), "IRL"));
        }
    }

    if (show(cfgModeFPS))
    {
        list.add(String.format("%d FPS", Minecraft.getDebugFPS()));
    }

    if (show(cfgModeRAM_Client))
    {
        drawRAM(list, Side.CLIENT);
    }

    if (show(cfgModeRAM_Server))
    {
        drawRAM(list, Side.SERVER);
    }

    if (show(cfgModeTPS))
    {
        if (dims == null)
        {
            list.add("No server TPS data :(");
        }
        else
        {
            list.add(String.format("Ticktime Overall: %sms (%d TPS)", DECIMAL_FORMAT.format(meanTickTime), (int) Math.min(1000.0 / meanTickTime, 20)));
            for (Map.Entry<Integer, Double> entry : dims.entrySet())
            {
                list.add(String.format("Dim %d: %sms (%d TPS)", entry.getKey(), DECIMAL_FORMAT.format(entry.getValue()), (int) Math.min(1000.0 / entry.getValue(), 20)));
            }
        }
    }
}
 
Example 14
Project: ExPetrum   File: BlockWaterLily.java   Source Code and License Vote up 4 votes
public void checkBlooming(World worldIn, BlockPos pos, IBlockState state, Random rand)
{
	// FIXME Check blooming corresponding to current season, or temp | humidity!
	EnumWaterLilyType type = state.getValue(LILY_TYPE);
	boolean isNight = worldIn.getWorldTime() % 24000 >= 12000;
	boolean blooming = state.getValue(PLANT_BLOOMING);
	float growthChanceModifier = (float) Math.sin(Math.toRadians((worldIn.getWorldTime() % 12000) * 0.015));
	if (isNight)
	{
		if (type.isNightBloomer())
		{
			if (rand.nextDouble() <= growthChanceModifier && !blooming)
			{
				worldIn.setBlockState(pos, this.getDefaultState().withProperty(LILY_TYPE, type).withProperty(PLANT_BLOOMING, true), 2);
			}
		}
		else
		{
			if (rand.nextDouble() <= growthChanceModifier / 3 && blooming)
			{
				worldIn.setBlockState(pos, this.getDefaultState().withProperty(LILY_TYPE, type).withProperty(PLANT_BLOOMING, false), 2);
			}
		}
	}
	else
	{
		if (!type.isNightBloomer())
		{
			if (rand.nextDouble() <= growthChanceModifier && !blooming)
			{
				worldIn.setBlockState(pos, this.getDefaultState().withProperty(LILY_TYPE, type).withProperty(PLANT_BLOOMING, true), 2);
			}
		}
		else
		{
			if (rand.nextDouble() <= growthChanceModifier / 3 && blooming)
			{
				worldIn.setBlockState(pos, this.getDefaultState().withProperty(LILY_TYPE, type).withProperty(PLANT_BLOOMING, false), 2);
			}
		}
	}
}
 
Example 15
Project: Zombe-Modpack   File: ZWrapper.java   Source Code and License Vote up 0 votes
public static long getTime(World world) { return world.getWorldTime(); }