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

The following are Jave code examples for showing how to use getTotalWorldTime() 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: pnc-repressurized   File: ModuleAirGrate.java   Source Code and License Vote up 6 votes
private void coolHeatSinks(World world, BlockPos pos, int range) {
    if (grateRange > 2) {
        int curTeIndex = (int) (world.getTotalWorldTime() % 27);
        BlockPos curPos = pos.offset(dir, 2).add(-1 + curTeIndex % 3, -1 + curTeIndex / 3 % 3, -1 + curTeIndex / 9 % 3);
        TileEntity te = world.getTileEntity(curPos);
        if (te instanceof TileEntityHeatSink) heatSinks.add((TileEntityHeatSink) te);

        Iterator<TileEntityHeatSink> iterator = heatSinks.iterator();
        while (iterator.hasNext()) {
            TileEntityHeatSink heatSink = iterator.next();
            if (heatSink.isInvalid()) {
                iterator.remove();
            } else {
                for (int i = 0; i < 4; i++)
                    heatSink.onFannedByAirGrate();
            }
        }
    }
}
 
Example 2
Project: HeroUtils   File: SafeTimeTracker.java   Source Code and License Vote up 6 votes
/** Return true if a given delay has passed since last time marked was called successfully. */
public boolean markTimeIfDelay(World world, long delay) {
    if (world == null) {
        return false;
    }

    long currentTime = world.getTotalWorldTime();

    if (currentTime < lastMark) {
        lastMark = currentTime;
        return false;
    } else if (lastMark + delay + lastRandomDelay <= currentTime) {
        duration = currentTime - lastMark;
        lastMark = currentTime;
        lastRandomDelay = (int) (Math.random() * randomRange);

        return true;
    } else {
        return false;
    }
}
 
Example 3
Project: WirelessRedstone   File: RedstoneEtherServer.java   Source Code and License Vote up 6 votes
private void entityJamTest(World world)
{
    if(world.getTotalWorldTime() % 10 != 0)
        return;
    
    int dimension = CommonUtils.getDimension(world);
    for(Iterator<BlockPos> iterator = ethers.get(dimension).jammerset.iterator(); iterator.hasNext();)
    {
        BlockPos jammer = iterator.next();
        List<Entity> entitiesinrange = world.getEntitiesWithinAABBExcludingEntity(null, new AxisAlignedBB(jammer.getX()-9.5, jammer.getY()-9.5, jammer.getZ()-9.5, jammer.getX()+10.5, jammer.getY()+10.5, jammer.getZ()+10.5));
        for(Iterator<Entity> iterator2 = entitiesinrange.iterator(); iterator2.hasNext();)
        {
            Entity entity = iterator2.next();
            if(!(entity instanceof EntityLivingBase))
                continue;
            
            if(entity instanceof EntityPlayer)
                if(isPlayerJammed((EntityPlayer)entity))
                    continue;
            
            jamEntitySometime((EntityLivingBase) entity);
        }
    }
}
 
Example 4
Project: Industrial-Foregoing   File: WaterStrawHandler.java   Source Code and License Vote up 5 votes
@Override
public void onDrink(World world, BlockPos pos, FluidStack stack, EntityPlayer player, boolean fromFluidContainer) {
    player.extinguish();
    NBTTagCompound tag = player.getEntityData();
    if (tag.hasKey("lavaDrink") && world.getTotalWorldTime() - tag.getLong("lavaDrink") < 120) { //6 Seconds to drink water after drinking lava to create obsidian
        player.entityDropItem(new ItemStack(Blocks.OBSIDIAN), player.getEyeHeight());

        tag.setLong("lavaDrink", 0);
        world.playSound(null, player.posX, player.posY, player.posZ, SoundEvents.ENTITY_PLAYER_BURP, SoundCategory.PLAYERS, 1.5F, world.rand.nextFloat() * 0.1F + 0.9F);
    }
}
 
Example 5
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 6
Project: WirelessRedstone   File: RedstoneEtherServer.java   Source Code and License Vote up 5 votes
private void randomJamTest(World world)
{
    if(world.getTotalWorldTime() % 600 != 0)//30 seconds
        return;
    
    for(Entry<Integer, DimensionalEtherHash> entry : ethers.entrySet())
        if(entry.getValue().jammerset != null)
            for(Iterator<BlockPos> iterator = entry.getValue().jammerset.iterator(); iterator.hasNext();)
                jamNodesInAOEOfJammer(world, iterator.next(), entry.getKey());
}
 
Example 7
Project: Metalworks   File: Util.java   Source Code and License Vote up 5 votes
/**
 * This function is presented to you by you neat helper in every situation, Actually Additions
 * @param world The world the player does live in
 * @return The coloration of something
 */
@SideOnly(Side.CLIENT)
public static float[] getWheelColor(World world){
    long time = world.getTotalWorldTime() % 256;
    if(time < 85){
        return new float[]{time * 3.0F, 255.0f - time * 3.0f, 0.0f};
    }
    if(time < 170){
        return new float[]{255.0f - (time -= 85) * 3.0f, 0.0f, time * 3.0f};
    }
    return new float[]{0.0f, (time -= 170) * 3.0f, 255.0f - time * 3.0f};
}
 
Example 8
Project: DecompiledMinecraft   File: BlockRedstoneTorch.java   Source Code and License Vote up 5 votes
public void updateTick(World worldIn, BlockPos pos, IBlockState state, Random rand)
{
    boolean flag = this.shouldBeOff(worldIn, pos, state);
    List<BlockRedstoneTorch.Toggle> list = (List)toggles.get(worldIn);

    while (list != null && !list.isEmpty() && worldIn.getTotalWorldTime() - ((BlockRedstoneTorch.Toggle)list.get(0)).time > 60L)
    {
        list.remove(0);
    }

    if (this.isOn)
    {
        if (flag)
        {
            worldIn.setBlockState(pos, Blocks.unlit_redstone_torch.getDefaultState().withProperty(FACING, state.getValue(FACING)), 3);

            if (this.isBurnedOut(worldIn, pos, true))
            {
                worldIn.playSoundEffect((double)((float)pos.getX() + 0.5F), (double)((float)pos.getY() + 0.5F), (double)((float)pos.getZ() + 0.5F), "random.fizz", 0.5F, 2.6F + (worldIn.rand.nextFloat() - worldIn.rand.nextFloat()) * 0.8F);

                for (int i = 0; i < 5; ++i)
                {
                    double d0 = (double)pos.getX() + rand.nextDouble() * 0.6D + 0.2D;
                    double d1 = (double)pos.getY() + rand.nextDouble() * 0.6D + 0.2D;
                    double d2 = (double)pos.getZ() + rand.nextDouble() * 0.6D + 0.2D;
                    worldIn.spawnParticle(EnumParticleTypes.SMOKE_NORMAL, d0, d1, d2, 0.0D, 0.0D, 0.0D, new int[0]);
                }

                worldIn.scheduleUpdate(pos, worldIn.getBlockState(pos).getBlock(), 160);
            }
        }
    }
    else if (!flag && !this.isBurnedOut(worldIn, pos, false))
    {
        worldIn.setBlockState(pos, Blocks.redstone_torch.getDefaultState().withProperty(FACING, state.getValue(FACING)), 3);
    }
}
 
Example 9
Project: DecompiledMinecraft   File: BlockRedstoneTorch.java   Source Code and License Vote up 5 votes
public void updateTick(World worldIn, BlockPos pos, IBlockState state, Random rand)
{
    boolean flag = this.shouldBeOff(worldIn, pos, state);
    List<BlockRedstoneTorch.Toggle> list = (List)toggles.get(worldIn);

    while (list != null && !list.isEmpty() && worldIn.getTotalWorldTime() - ((BlockRedstoneTorch.Toggle)list.get(0)).time > 60L)
    {
        list.remove(0);
    }

    if (this.isOn)
    {
        if (flag)
        {
            worldIn.setBlockState(pos, Blocks.unlit_redstone_torch.getDefaultState().withProperty(FACING, state.getValue(FACING)), 3);

            if (this.isBurnedOut(worldIn, pos, true))
            {
                worldIn.playSoundEffect((double)((float)pos.getX() + 0.5F), (double)((float)pos.getY() + 0.5F), (double)((float)pos.getZ() + 0.5F), "random.fizz", 0.5F, 2.6F + (worldIn.rand.nextFloat() - worldIn.rand.nextFloat()) * 0.8F);

                for (int i = 0; i < 5; ++i)
                {
                    double d0 = (double)pos.getX() + rand.nextDouble() * 0.6D + 0.2D;
                    double d1 = (double)pos.getY() + rand.nextDouble() * 0.6D + 0.2D;
                    double d2 = (double)pos.getZ() + rand.nextDouble() * 0.6D + 0.2D;
                    worldIn.spawnParticle(EnumParticleTypes.SMOKE_NORMAL, d0, d1, d2, 0.0D, 0.0D, 0.0D, new int[0]);
                }

                worldIn.scheduleUpdate(pos, worldIn.getBlockState(pos).getBlock(), 160);
            }
        }
    }
    else if (!flag && !this.isBurnedOut(worldIn, pos, false))
    {
        worldIn.setBlockState(pos, Blocks.redstone_torch.getDefaultState().withProperty(FACING, state.getValue(FACING)), 3);
    }
}
 
Example 10
Project: BaseClient   File: BlockRedstoneTorch.java   Source Code and License Vote up 5 votes
public void updateTick(World worldIn, BlockPos pos, IBlockState state, Random rand)
{
    boolean flag = this.shouldBeOff(worldIn, pos, state);
    List<BlockRedstoneTorch.Toggle> list = (List)toggles.get(worldIn);

    while (list != null && !list.isEmpty() && worldIn.getTotalWorldTime() - ((BlockRedstoneTorch.Toggle)list.get(0)).time > 60L)
    {
        list.remove(0);
    }

    if (this.isOn)
    {
        if (flag)
        {
            worldIn.setBlockState(pos, Blocks.unlit_redstone_torch.getDefaultState().withProperty(FACING, state.getValue(FACING)), 3);

            if (this.isBurnedOut(worldIn, pos, true))
            {
                worldIn.playSoundEffect((double)((float)pos.getX() + 0.5F), (double)((float)pos.getY() + 0.5F), (double)((float)pos.getZ() + 0.5F), "random.fizz", 0.5F, 2.6F + (worldIn.rand.nextFloat() - worldIn.rand.nextFloat()) * 0.8F);

                for (int i = 0; i < 5; ++i)
                {
                    double d0 = (double)pos.getX() + rand.nextDouble() * 0.6D + 0.2D;
                    double d1 = (double)pos.getY() + rand.nextDouble() * 0.6D + 0.2D;
                    double d2 = (double)pos.getZ() + rand.nextDouble() * 0.6D + 0.2D;
                    worldIn.spawnParticle(EnumParticleTypes.SMOKE_NORMAL, d0, d1, d2, 0.0D, 0.0D, 0.0D, new int[0]);
                }

                worldIn.scheduleUpdate(pos, worldIn.getBlockState(pos).getBlock(), 160);
            }
        }
    }
    else if (!flag && !this.isBurnedOut(worldIn, pos, false))
    {
        worldIn.setBlockState(pos, Blocks.redstone_torch.getDefaultState().withProperty(FACING, state.getValue(FACING)), 3);
    }
}
 
Example 11
Project: BaseClient   File: BlockRedstoneTorch.java   Source Code and License Vote up 5 votes
public void updateTick(World worldIn, BlockPos pos, IBlockState state, Random rand)
{
    boolean flag = this.shouldBeOff(worldIn, pos, state);
    List<BlockRedstoneTorch.Toggle> list = (List)toggles.get(worldIn);

    while (list != null && !list.isEmpty() && worldIn.getTotalWorldTime() - ((BlockRedstoneTorch.Toggle)list.get(0)).time > 60L)
    {
        list.remove(0);
    }

    if (this.isOn)
    {
        if (flag)
        {
            worldIn.setBlockState(pos, Blocks.unlit_redstone_torch.getDefaultState().withProperty(FACING, state.getValue(FACING)), 3);

            if (this.isBurnedOut(worldIn, pos, true))
            {
                worldIn.playSoundEffect((double)((float)pos.getX() + 0.5F), (double)((float)pos.getY() + 0.5F), (double)((float)pos.getZ() + 0.5F), "random.fizz", 0.5F, 2.6F + (worldIn.rand.nextFloat() - worldIn.rand.nextFloat()) * 0.8F);

                for (int i = 0; i < 5; ++i)
                {
                    double d0 = (double)pos.getX() + rand.nextDouble() * 0.6D + 0.2D;
                    double d1 = (double)pos.getY() + rand.nextDouble() * 0.6D + 0.2D;
                    double d2 = (double)pos.getZ() + rand.nextDouble() * 0.6D + 0.2D;
                    worldIn.spawnParticle(EnumParticleTypes.SMOKE_NORMAL, d0, d1, d2, 0.0D, 0.0D, 0.0D, new int[0]);
                }

                worldIn.scheduleUpdate(pos, worldIn.getBlockState(pos).getBlock(), 160);
            }
        }
    }
    else if (!flag && !this.isBurnedOut(worldIn, pos, false))
    {
        worldIn.setBlockState(pos, Blocks.redstone_torch.getDefaultState().withProperty(FACING, state.getValue(FACING)), 3);
    }
}
 
Example 12
Project: Anima-Mundi   File: ItemAnimaShield.java   Source Code and License Vote up 5 votes
@Override
public void onUpdate(ItemStack stack, World worldIn, Entity entityIn, int itemSlot, boolean isSelected)
{
	if(isOn(stack))
	{
		Shield sh = getShield(stack);
		if(entityIn instanceof EntityPlayer)
		{
			sh.update(stack, (EntityPlayer) entityIn);
			ItemStack active = EntityUtil.getActivePlayerShield((EntityPlayer) entityIn);
			ItemAnimaShield sI = (ItemAnimaShield) active.getItem();
			if(!active.equals(stack) && sI.isOn(active))
			{
				setOff(stack, (EntityPlayer) entityIn);
			}
		}
		if(!stack.isEmpty())
		{
			stack.getTagCompound().setTag("shield", sh.serialize());
			super.onUpdate(stack, worldIn, entityIn, itemSlot, isSelected);
		}

		if(worldIn.getTotalWorldTime() % 40 == 0)
			this.removeCharge(stack, 1);

		if(getCurrentCharge(stack) == 0 && entityIn instanceof EntityPlayer)
		{
			setOff(stack, (EntityPlayer) entityIn);
		}
	}
}
 
Example 13
Project: Proyecto-DASI   File: ServerQuitFromTimeUpImplementation.java   Source Code and License Vote up 5 votes
@Override
protected long getWorldTime()
{
   	World world = null;
   	MinecraftServer server = MinecraftServer.getServer();
   	if (server.worldServers != null && server.worldServers.length != 0)
   		world = server.getEntityWorld();
	return (world != null) ? world.getTotalWorldTime() : 0;
}
 
Example 14
Project: PowerProbe   File: PowerOverlayRender.java   Source Code and License Vote up 5 votes
@SubscribeEvent
public void onWorldUpdate(PlayerTickEvent event) {

  EntityPlayer player = event.player;
  World world = player.world;

  if (!world.isRemote || world.getTotalWorldTime() % 2 != 0) {
    return;
  }

  EntityPlayerSP playerSp = (EntityPlayerSP) player;

  resetOverlays();
  if (wearingHelmet()) {
    updateAreaScan(playerSp, world);
  } else {
    cursorOverlay = null;
  }

  PowerMeterGui.INSTANCE.setPower(0);
  if (holdingProbe()) {
    updateOverlayUnderCursor(world, playerSp);
  } else {
    if (cursorOverlay != null) {
      cursorOverlay.pos = null;
    }
  }
}
 
Example 15
Project: Backmemed   File: BlockRedstoneTorch.java   Source Code and License Vote up 5 votes
public void updateTick(World worldIn, BlockPos pos, IBlockState state, Random rand)
{
    boolean flag = this.shouldBeOff(worldIn, pos, state);
    List<BlockRedstoneTorch.Toggle> list = (List)toggles.get(worldIn);

    while (list != null && !list.isEmpty() && worldIn.getTotalWorldTime() - ((BlockRedstoneTorch.Toggle)list.get(0)).time > 60L)
    {
        list.remove(0);
    }

    if (this.isOn)
    {
        if (flag)
        {
            worldIn.setBlockState(pos, Blocks.UNLIT_REDSTONE_TORCH.getDefaultState().withProperty(FACING, state.getValue(FACING)), 3);

            if (this.isBurnedOut(worldIn, pos, true))
            {
                worldIn.playSound((EntityPlayer)null, pos, SoundEvents.BLOCK_REDSTONE_TORCH_BURNOUT, SoundCategory.BLOCKS, 0.5F, 2.6F + (worldIn.rand.nextFloat() - worldIn.rand.nextFloat()) * 0.8F);

                for (int i = 0; i < 5; ++i)
                {
                    double d0 = (double)pos.getX() + rand.nextDouble() * 0.6D + 0.2D;
                    double d1 = (double)pos.getY() + rand.nextDouble() * 0.6D + 0.2D;
                    double d2 = (double)pos.getZ() + rand.nextDouble() * 0.6D + 0.2D;
                    worldIn.spawnParticle(EnumParticleTypes.SMOKE_NORMAL, d0, d1, d2, 0.0D, 0.0D, 0.0D, new int[0]);
                }

                worldIn.scheduleUpdate(pos, worldIn.getBlockState(pos).getBlock(), 160);
            }
        }
    }
    else if (!flag && !this.isBurnedOut(worldIn, pos, false))
    {
        worldIn.setBlockState(pos, Blocks.REDSTONE_TORCH.getDefaultState().withProperty(FACING, state.getValue(FACING)), 3);
    }
}
 
Example 16
Project: ExPetrum   File: ItemFood.java   Source Code and License Vote up 5 votes
@Override
public void onUpdate(ItemStack stack, World worldIn, Entity entityIn, int itemSlot, boolean isSelected)
{
	super.onUpdate(stack, worldIn, entityIn, itemSlot, isSelected);
	if (!stack.hasTagCompound() || !stack.getTagCompound().hasKey("exp.foodData"))
	{
		this.initDefaultNBT(stack);
	}
	
	if (worldIn.getTotalWorldTime() % 500 == 0 && entityIn != null)
	{
		this.checkRot(stack, worldIn, entityIn.getPosition(), 1);
	}
}
 
Example 17
Project: ExPetrum   File: ItemFood.java   Source Code and License Vote up 5 votes
@Override
public void onContainerTick(ItemStack is, World w, BlockPos pos, TileEntity container)
{
	if (w.getTotalWorldTime() % 500 == 0)
	{
		this.checkRot(is, w, pos, 1);
	}
}
 
Example 18
Project: NemesisSystem   File: SpawnHandler.java   Source Code and License Vote up 5 votes
private static boolean notReadyToSpawn(World world, NemesisEntry n) {
	if (n.getLastSpawned() == null) {
		return false;
	}
	long delay = (n.getLastSpawned() + SPAWN_COOLDOWN_PERIOD) - world.getTotalWorldTime();
	return delay > 0;
}
 
Example 19
Project: HeroUtils   File: SafeTimeTracker.java   Source Code and License Vote up 4 votes
public void markTime(World world) {
    lastMark = world.getTotalWorldTime();
}
 
Example 20
Project: NemesisSystem   File: Reaper.java   Source Code and License Vote up 4 votes
private boolean shouldBeDespawned(World world, NemesisEntry nemesis) {
	if (nemesis.isLoaded()) {
		return false;
	}
	return (world.getTotalWorldTime() - nemesis.getUnloaded()) > MAX_UNLOAD_TIME;
}