Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

Hi

Is there a method in the block class that is called every tick that includes a BlockPos instance and World instance? Or maybe there's an event that includes these parameters? Thanks in advance. (BTW the updateTick method in the block class is not being called [yes my parameters are definately correct])

Development of Plugins [2012 - 2014] Development of Mods [2012 - Current]

Use a tile entity.

  • Author

Why would I create a tile entity for a simple block? Seems like there is an easier way to get a ticker with these needed instances. Thanks for the reply, though. If I need to resort to TE's I will.

Development of Plugins [2012 - 2014] Development of Mods [2012 - Current]

Well, the way I see it, if it need to be ticking it is straying from being a simple block. And I don't think there is such a method anyway. But if you need it for anything particle or rendering related by any chance there's always onRandomDisplayTick (I think that's what it's called) but that is in 1.7 and I don't know if it's still in 1.8.

Hey! Turns out I was wrong (happens sometimes). There is such a method:

updateTick(World world, int x, int y, int z, Random random)

Guess it pays to do research. Now, as for it not getting called, I found this in the JavaDocs:

Ticks the block if it's been scheduled

So you will have to schedule it.

 

It turns out research payed off again. :) After looking at how crops work I found this line of code to do that:

this.setTickRandomly(true);

 

Hope this helps.

Oh sorry, after writing that I realized you are in 1.8 and I'm in 1.7. That method might involve BlockPos instead.

  • Author

Hey thanks for the replies! I was looking as well and now I realize that it kind of makes sense to make this a tile entity, but I'm just trying to find out a simpler way. I've looked in the pressure plate class and pressure plate base class and they do the exact same thing oddly enough with the random tick and update tick method. I really do appreciate your help!

Development of Plugins [2012 - 2014] Development of Mods [2012 - Current]

  • Author

I'm guessing override updateTick and return true for setRandomTick in the block constructor. Trying it now!

Development of Plugins [2012 - 2014] Development of Mods [2012 - Current]

  • Author

Still not working (going to look in the TNT block class cause I'm also using explosives).

Development of Plugins [2012 - 2014] Development of Mods [2012 - Current]

TNT doesn't use ticking because Primed TNT is an entity. I looked at the code too. :)

  • Author

Haha right before you said that I was like "Aww tnt is an entity when primed :(". I'm going to keep trying though! :D

Development of Plugins [2012 - 2014] Development of Mods [2012 - Current]

Block's updateTick function does not run every tick. ......unless you schedule it to. Look at the repeater.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

  • Author

If you really need to receive tick updates more than just "quite rarely" you cannot get any more efficient than a TileEntity.

Thanks for the reply. I thought this as I was finishing some code last night when it was discussed at the beginning of the topic. I'll look into Tile Entities later on.

Development of Plugins [2012 - 2014] Development of Mods [2012 - Current]

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.

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

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.