perromercenary00 Posted March 1, 2016 Posted March 1, 2016 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 //###########################################################3 @Override 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 https://gist.github.com/anonymous/40e144fcd67df6d7c2ea Quote
Ernio Posted March 1, 2016 Posted March 1, 2016 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. Quote 1.7.10 is no longer supported by forge, you are on your own.
perromercenary00 Posted March 1, 2016 Author Posted March 1, 2016 well originally i wanna make a tile entity this block has tile entity extended but how i made that whith tile entityes if they dont'n have an @Override /** * Called to update the entity's position/logic. */ public void onUpdate() { super.onUpdate(); } as the normal entityes ¿ or it have ? Quote
perromercenary00 Posted March 1, 2016 Author Posted March 1, 2016 hey wrehe i use this this.worldObj.scheduleUpdate(pos, blockIn, delay); Quote
Ernio Posted March 1, 2016 Posted March 1, 2016 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. Quote 1.7.10 is no longer supported by forge, you are on your own.
perromercenary00 Posted March 1, 2016 Author Posted March 1, 2016 yea i wass thinking tile entityes was just for storing things i make another tileEntity this one tickiable https://gist.github.com/anonymous/484ec7d902c2050f11ae 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 ?? Quote
Ernio Posted March 1, 2016 Posted March 1, 2016 BlockDaylightDetector is your friend. Lookup how dimensions (WorldProvider) calculates celestial angles. Note that different worls can use different providers - thus different day-lenght. Quote 1.7.10 is no longer supported by forge, you are on your own.
jeffryfisher Posted March 1, 2016 Posted March 1, 2016 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. Quote 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.
perromercenary00 Posted March 2, 2016 Author Posted March 2, 2016 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 Quote
Recommended Posts
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.