Content: Slate Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate Marble
Background: Slate Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate Marble
Pattern: Blank Waves Notes Sharp Wood Rockface Leather Honey Vertical Triangles
Welcome to TerraFirmaCraft Forums

Register now to gain access to all of our features. Once registered and logged in, you will be able to contribute to this site by submitting your own content or replying to existing content. You'll be able to customize your profile, receive reputation points as a reward for submitting content, while also communicating with other members via your own private inbox, plus much more! This message will be removed once you have signed in.

  • Announcements

    • Dries007

      ATTENTION Forum Database Breach   03/04/2019

      There has been a breach of our database. Please make sure you change your password (use a password manager, like Lastpass).
      If you used this password anywhere else, change that too! The passwords themselves are stored hashed, but may old accounts still had old, insecure (by today's standards) hashes from back when they where created. This means they can be "cracked" more easily. Other leaked information includes: email, IP, account name.
      I'm trying my best to find out more and keep everyone up to date. Discord (http://invite.gg/TerraFirmaCraft) is the best option for up to date news and questions. I'm sorry for this, but the damage has been done. All I can do is try to make sure it doesn't happen again.
    • Claycorp

      This forum is now READ ONLY!   01/20/2020

      As of this post and forever into the future this forum has been put into READ ONLY MODE. There will be no new posts! A replacement is coming SoonTM . If you wish to stay up-to-date on whats going on or post your content. Please use the Discord or Sub-Reddit until the new forums are running.

      Any questions or comments can be directed to Claycorp on either platform.
Sign in to follow this  
Followers 0
Peffern

TFC Crop System Expansion

16 posts in this topic

So, as part of TerraFirmaPumpkins, I had to use ASM to alter some parts of the TFC crop code which were hardcoded to only work with the 18 built-in TFC crops. I realized the other day that an extensible system for adding crops might be a good thing to have so that a) multiple people can add crops without worrying about ASM conflicts, and b ) people don't have to worry about crop IDs.

I figure this will mostly be useful for other addon developers who want to add crops without worrying about compatibility – I'm adding another layer of abstraction over the TFC crop system so people can just call into the registry to add crops without bothering with ASM at all.

Does anybody have any other ideas I should include / criticism / questions?

I'm currently testing it and it will probably be available some time in the next week or so.

0

Share this post


Link to post
Share on other sites

Bless you.  I wish I had some grand suggestion but all I can do is thank you for making this possible.

0

Share this post


Link to post
Share on other sites

Okay I have a trial version available on GitHub: https://github.com/Peffern
It seems to work reasonably well, let me know if it does what you want.

0

Share this post


Link to post
Share on other sites

You are a wonder!

O.k. here come the noob questions....

 

1.after i run setup and point eclipse to the working folder:

 Do I add your packages to my mod project folder via copy and past,

or

do I just add your project folder to my project eclipse workspace along with my own?

or

is it better to use it as an independent mod in its own eclipse work space?

next

in BaseCrops it says:

"If you just want to implement a crop so that it works with TFC, use this implementation."

in read me it says "

The entry point for TFC Crop Index is the static method CropsRegistry.addCrop(). This method accepts as an argument an ICrop instance, which is how you define the crop you want to add. The registry will use information from the ICrop to create a new TFC crop with the appropriate parameters, as well as creating a seed item with the appropriate crop ID

"All of the parameters are in the constructor, so you should be able to just pass in a load of values and then pass the BaseCrop to the CropsRegistry.

If you want to change the rendering behavior you can override the appropriate method.

Reflective pass-throughs to TFC's crop rendering utility methods are static on RenderCustomCrop, so you can use them.

In practice this means you pass a bunch of parameters to the BaseCrop constructor, pass the result to the CropsRegistry, and the mod handles it from there"

 

So to create a new crop I would edit  BaseCrop?

i so i decide to give my crop the number  3654  (so it is unlikely to conflict with other crop indexes from other people then in BaseCrop,java ....

Edited by Dulakaba
0

Share this post


Link to post
Share on other sites

First of all, you probably shouldn't post code in the forums. Use pastebin or something for the formatting.

Secondly, I apologize for being unclear. You don't need to download or edit my code (unless you want to) – instead you should just be able to use my .jar file (the mod itself).

Here's how I would do it:
 

1. Download the compiled jar (tfccrops.jar).
2. Import it into your mod project (into the libs folder). 
3. Make sure you configure gradle to know about the tfccrops.jar or your code won't compile when you go to export your mod.
4. Add the jar to your project as a dependency jar. 
5. In your item setup area, execute the following code:

 

String[] icons = new String[]{tfcs:plants/crops/Nrustica (1),//and all other growth};
ICrop crop = new BaseCrop("ItemNRusticaPlant",2,36,icons,8,0.9F,2,new ItemStack(ItemNRleaf,5),"NRseeds","tfcs:plants/seeds/NRSeeds","Mapacho");
Item seeds = CropsRegistry.add
Crop(crop);

Then make sure the seeds item gets saved to somewhere. If you look at my code in TerraFirmaPumpkins and TFC with IE Hemp, you can see how I did this.

The point of this system that I made is that you don't need to worry about the IDs or rendering at all – the subsystem handles it for you. You don't need to look at the internals of BaseCrop or CropsRegistry at all. If you *do* want to change how BaseCrop works, you should subclass it instead of editing the original.

Also, I forgot to provide the link to the compiled jar: here it is:http://www.mediafire.com/file/t4dcd1ltnk150ka/%5B1.7.10%5Dtfccrops-1.0.jar

EDIT: Im finding some bugs – remember this is still experimental.

Edited by Peffern
0

Share this post


Link to post
Share on other sites

Thanks,

I think I know how to do all you mentioned:

1. Download the compiled jar (tfccrops.jar).DONE
2. Import it into your mod project (into the libs folder). DONE
3. Make sure you configure gradle to know about the tfccrops.jar or your code won't compile when you go to export your mod. (Done in gradle.build? I think that's right but I figure i would ask to make sure.
4. Add the jar to your project as a dependency jar. Done via buildpath / configure buildpath/ libraries 'add external jar'
when you say item set up area you mean in a new item class for the plant file rather than where i register items? So not in the file where I use     public static Item itemZombieDust;: and itemZombieDust = new ItemZombieDust().setUnlocalizedName  and GameRegistry.registerItem(itemZombieDust,itemZombieDust.getUnlocalizedName(),etc... right?

 

looking at your files for  TerraFirmaPumpkins and TFC with IE Hemp to get some insight.

Sorry for all the question.

0

Share this post


Link to post
Share on other sites

You should do it in the same file where you set up your items

so you should have a bunch of calls to GameRegistry.registerItem()

IN the same general area, you should call the CropsRegistry.addCrop()

0

Share this post


Link to post
Share on other sites

Thanks,

I appreciate you taking the time to field my questions. If you like, when I get it all figured out i will do a video tutorial.

0

Share this post


Link to post
Share on other sites

No problem – if you're still confused, look at TFC with IE Hemp Plants, it's a simple one-class mod that demos how to use the Crops Registry.

0

Share this post


Link to post
Share on other sites

Hi again, 

So I thought I had everything ready to go. but I think i have somehow missed something.

I think I missed a point of setting up. 

I downloaded the jar, put it in my lib folder in my tfcshaman project, right clicked my project and selected buildpath - configure build path - chose the 'Libraries' tab,, chose add external jar and then navigated to the lib folder in the src folder of my project and selected your jar.

having done that Eclipse added the your mod's little jar icon to the bottom of the jar list in my project ( there are many jar icons and then your jar below  a folder icon with 3 zeros labeled 'start' (that has some gradle stuff in it and a cache)

if I click the jar icon named after your jar, it has all your packages in it (com.peffern.crops etc.). 

I have made no changes to build.gradle  since I must study how to configure gradle to know about the tfccrops.jar and I assumed that could wait until I was ready to do the jar build.

when I run the game in eclipse  it starts minecraft, begins the loading process and then crashes. here is the crash report

Minecraft Crash Report

any insight as to why?

after more investigation  I see this in the console after crash:

Caused by: java.lang.NoSuchMethodError: com.peffern.crops.BlockCustomCrop.func_149676_a(FFFFFF)V
                      at com.peffern.crops.BlockCustomCrop.<init>(BlockCustomCrop.java:26)

 

The line in BlocCustomCrop that it refers to is:

        this.setBlockBounds(0, 0, 0, 1, 0.2f, 1);

Edited by Dulakaba
0

Share this post


Link to post
Share on other sites

Oops - this one's on me. You should be using the deobf jar, not the regular jar, for development. I have added deobf jars to the Mod-Jars repository.

0

Share this post


Link to post
Share on other sites

o.k. I have got the deobf.jar, do I add that to the lib folder  the same way I added your jar?

That just tells me i have dupilicates

Edited by Dulakaba
0

Share this post


Link to post
Share on other sites

Actually it appears the issue is based in how I set up my mod in Bletch's template.  

Previously I had coded my mod in vanilla 1.7.10 and then  did a  lot of copy and paste of packages and classes from the vanilla forge eclipse work space into a new  TFC eclipse work space made with Bletch's tutorial.  I had basically just deleted all Bletch's mod template files under source/main/java ,  and source/main/resources and then put in my own packages, classes and resources in the appropriate locations to make a copy of my vanilla mod.  Everything worked fine for my vanilla coding. However clearly somewhere in this I deleted something in his template that hooks into  tfc in such a way as to make your api get recognized. I went back and redid the Bletch tutorial and set up in a fresh copy of eclipse, made all the name changes needed for a new  add on project  and then put in your plant add on jar in the lib folder. After pointing eclipse to your jar it all loads.

I either need to find out what I cut out from Bletch's Template or else start the tedious process of  moving everything over to his template. This is a big problem as I did my coding based on the tutorials by MrCrayfish and his overall structure / approach is to do things mostly in the main class file where as Bletch has so many packages that I can barely make heads or tails of it.

My assumption is that your IE hemp mod and Pumpkin mod MUST have the same code type that I cut from Bletch's template and I am hoping that a hard study of them will help me figure out what I am missing.

0

Share this post


Link to post
Share on other sites

Well, as long as its working then I guess you're good to go.

0

Share this post


Link to post
Share on other sites

So I still can't get it to go I thought it was working but then it did not... 

The weird thing is that  I downloaded your IE Hemp project,  unzipped it, ran setup.bat and then imported  it in Eclipse and when I run it , it gives me duplicate file warning for  tfccrops because of the tfccrops-dobf. If I remove tfccrops-dobf, it get the same error as on my project.  " cpw.mods.fml.common.LoaderException: java.lang.NoSuchMethodError: com.peffern.crops.BlockCustomCrop.func_149676_a(FFFFFF)V "

I am really at a loss because this is your Github project. What method do you use to run it without getting dup error  and what method do you use to set up the files in lib

Also what version of Eclipse are you using?

I tried it with just having the files in lib and also with  buildpath / configure buildpath/ libraries 'add external jar' and selecting the lib folder

Edited by Dulakaba
0

Share this post


Link to post
Share on other sites

Just wanted to take the time to thank Pefffern for all the help tracking down my issues and helping a new modder. We are lucky to have peffern and I want to make clear that all issues have been cleared up.

Thank you for all your work to help us modders make our TFC plant dreams come true!

0

Share this post


Link to post
Share on other sites
Sign in to follow this  
Followers 0