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

Hey folks,

I am triing to rework how crops work.

What I am triing to achieve is that crops, that are fully grown and dont get harvested go bad after a specific time.

Sadly Im not sure how to do that.

One idea I had was to subscribe to the event that was fired when IGrowable groes, and start a timer there (mb TickEvent or MinecraftQueue) that will check if the crop is still there after x seconds, but Im not sure if that is the correct approach.

 

Any help is appreciated.

 

Greetz Fail

You will need ASM.

 

Alternatively you can try basing your mood off of AppleCore (which does that for you) and hiking into the appropriate events.

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

Alright. I am at the point where I feel totally retarded. The mod wants me to get 1.8.9 . But I cant find forge for 1.8.9, only for 1.8 which seems to get me 1.8.0

Download Recommended 1.8.9 - 11.15.1.1722

 

BTW, Have you looked at how crops grow in the first place? Can you see a way to override a method so that the final stage has a chance to roll around to the 1st stage?

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.

Can you see a way to override a method so that the final stage has a chance to roll around to the 1st stage?

I would assume the term 'spoil', even in Minecraft terms, doesn't mean returning to seedling stage, but I could be wrong :P

 

Crops generally use a metadata-based growing system with the block's age (i.e. metadata, typically using the first 3 of the 4 available bits) incrementing randomly during the block's update tick.

 

I'm not aware of any global notification that occurs for metadata / state changes, so without introducing your own via ASM or using an existing API that does so as Draco suggested, I don't think it would be possible.

 

EDIT: Actually, there is the Forge block snapshot system that was added somewhat recently (recently being within the last year or so...). That might be the hook you are looking for.

  • Author

@SubscribeEvent
public void onPlantGrowth(GrowthTick event) {
	if(event.world.isRemote) return;
	if(event.block instanceof IGrowable) {
		IGrowable growable = (IGrowable) event.block;
		if(!growable.canGrow(event.world, event.pos, event.currentState, false)) {
			addDecayer(new PlantDecayer(event.currentState, event.pos, event.world, TIME_TO_DECAY_MIN+event.world.rand.nextInt(TIME_TO_DECAY_RND)));

		}
	}


}

This is what I am doing right now. The add decayer is registering the position to a watcher that is a tick handler that checks after x seconds if the plant is still there.

There you could just go ahead and get the blockstate with metadata 0, because thats normally the seed stage. Even if thats not what im triing to accomplish :b

Question for you: does it persist across the save-load boundary?

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.

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.