Jump to content

[1.8] Create a block that ticks one time exactly every 1000 worldTicks ?<SOLVED>


Recommended Posts

good days

im trying to make a block thath ticks every thousand worldTicks to keep track of day|night cicles to close or open a custom door


soo i was looking in the crops class becose that block ticks and find a method




    public int tickRate(World worldIn)


        return 1000;



but the block is not ticking


for block to ticks i have to put in the constructor an


this.needsRandomTick= true;


but then the block begins to ramdomly tick  not every 1000 ticks as i wish to



so how i make this block ticks exactly every thousand ticks ??


this is so far what i have





Link to comment
Share on other sites

First of all:

Blocks are not meant to tick that often, if you want that sort of control you may be better off making a TileEntity

This is totally true - make TE with integer counter, fire code every if (count % 1000 == 0).


The Block#tickRate method is actually never called by any internal MC system. It exists in Block class as a design choice (kind of an abstraction).

Lookup its callbacks.


Anyway - what you can do is use World#schedule(Block)Update on given blockpos and then when update is fired you can reschedule one after next 1000 ticks.

1.7.10 is no longer supported by forge, you are on your own.

Link to comment
Share on other sites

If you go with TE, You Make TileEntity implements ITickable, you amke field int count. You make an if (count % 1000 ==0) in update(). Now you run your code once per 1000 ticks.


If you don't want to use TileEntity - you can use this.worldObj.scheduleUpdate(pos, blockIn, delay);

You simply make a call and after "delay" it will call Block#updateTick. In Block#updateTick you can re-call worldObj.scheduleUpdate and basically make infinite 1000tick-loop.

1.7.10 is no longer supported by forge, you are on your own.

Link to comment
Share on other sites


i wass thinking tile entityes was just for storing things

i make another tileEntity this one tickiable




but realize something else

the orinal plan was to get the world time and do something like


tiempo = this.worldObj.getWorldTime();


int hour = tiempo % 24000 / 1000;

int min =  tiempo % 1000;


but just realize than WorldTime is not synced whith day/nigth cicle if i do and an

/set time 100 


to set the sun to the first hour in the morning WorldTime is not afected so if i do an

if (hour == 6)


//is the midday


this would be acurated at all


to get when close or open the doors i need the sun position in the sky or well the value od the visible clock based on sun position or something


¿¿  some idea ??



Link to comment
Share on other sites

BlockDaylightDetector is your friend. Lookup how dimensions (WorldProvider) calculates celestial angles. Note that different worls can use different providers - thus different day-lenght.

1.7.10 is no longer supported by forge, you are on your own.

Link to comment
Share on other sites

The daylight detector raises another opportunity: The game already has time, so you probably don't even need a counter, just a check against world time % 1000.

The debugger is a powerful and necessary tool in any IDE, so learn how to use it. You'll be able to tell us more and get better help here if you investigate your runtime problems in the debugger before posting.

Link to comment
Share on other sites

just fixed

imede the clock works whith the solar angle


float f = this.worldObj.getCelestialAngleRadians(1.0F);


worldtime is not synced whith th sun position if you the /time set comand world time dont'n change

and becoze this is for control the doors from mi custom settlement  to close the door at down and open again in the dust



Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Create New...

Important Information

By using this site, you agree to our Terms of Use.