Jump to content

Recommended Posts

Posted

I've recently started on a mod dealing extensively with plants, and with a heavy focus on mod compatibility. To that end, I'm working on a function that, given an IPlantable, can get out information I need like what metadata means fully grown, what drops it has, etc. Unfortunately, this only works for plants that actually USE metadata- ie wheat type plants that grow within one block and drop different things depending on how grown they are. The difficulty comes with things like mushrooms and cacti. With plants like wheat, I could just call the getDrops method for all the metadatas and with various random seeds, and from there figure out when it stops growing. For something like cacti or mushrooms though, getDrops is worthless because the drops don't change. It seems to me like the only way to figure out if a plant grows is to basically call UpdateTick on it a bunch of times and see what happens. And herein lies my problem. Since, for example, mushroom growth actually depends on the world around it (eg must have a certain light level, must have an adjacent block that supports mushrooms), I can't just use an arbitrary point for the x,y,z parameters like I did for getDrops. From my understanding, I'd actually have to place it in world somewhere, with the right conditions, and see what happens. The parsing function is purely analytical though, and so it shouldn't actually change the world. So the options I see are as follows: make a new world object (seems like a terrible idea) and mess around in there instead of the real world, temporarily make arbitrary point in the world a testing area (possible, but something I have limited understanding of, and potentially either A. Is seen by the player B. Messes up some build or C. Generates new terrain), or somehow simulate an UpdateTick with ideal conditions, which would be nice but I don't really think is possible. So, with all that said, A. Is there a better method I'm missing, B. Is there some way to simulate UpdateTick without changing the world, and C. If not, what's the best way to get an area that is as yet untouched and is unable to be seen by any player?

Posted

A better question is:

What are you trying to do?  With that answered, we might be able to provide a shortcut around simulating the world (which is doable, but takes a lot of work you really really don't need).

 

In the end though, there might be some plants you just can't examine their behaviors and estimate accurately for.  For vanilla ones you can fake it by going, "I know what this behavior is, use this edgeCaseFunction." Mod-added plants you won't have much luck with, except by looking at what mods people might want to use and see if there are edge-case plants there you have to account for.  Then build an API that lets other mods tell you, "Hey this is an edge case plant, here's an edgeCaseFunction I'd like you to call for it."

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.

Posted

Ideally, I'd like to get at LEAST the following information out of a plant:

-Light level (easy)

-Average(ish) # of Drops(relatively easy through GetDrops())

-UpdateTick behavior

And therein lies the issue. For anything based on BlockCrops, I can assume the metadata changes (for example, I dropped in RotaryCraft for testing purposes and its Canola plant worked perfectly). An easy way to test if it doesn't fit the BlockCrops format is see if GetDrops() never changes what it returns. The next step is to see if it spreads like a mushroom/grass (the two are equivalent for my purposes), or grows up like a cactus. Max height would be nice if it does, but isn't necessary. And presumably tree stuff at one point, but that's not terribly important atm. If the plant is actually placed in world, its fairly trivial to update it a bunch, then look at the blocks adjacent. Are some or all of the horizontally adjacent blocks the same as the block I started with? Then it spreads like a mushroom. Is the one on top the same? Then it spreads like cactus/sugarcane. The problem is how/where to do this testing without any lasting effects on the world and with minimal resource usage. Currently I'm looking at making a 1 chunk sized, inaccessible dimension so I don't have to worry about players ever interacting with it or creating/destroying new chunks (if you can even destroy chunks?), but honestly I have no idea if that would just be 1000x worse anyway.

Posted

Ideally, I'd like to get at LEAST the following information out of a plant

 

No, I mean why do you need that information?  What are you doing with it?

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.

Posted

OK... A typical chain of events might go like this:

1. Plant a is parsed, avg yield is obtained and stored

2. Plant b is parsed, avg yield is obtained and stored

3. Avg yield trait of plant b is applied to plant a

4. HarvestDropsEvent handler makes plant a have a (yieldb/yieldb-yielda) chance of spawning twice the drops

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...

×   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.

Announcements



×
×
  • Create New...

Important Information

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