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

API and Visibility

17 posts in this topic

I thought it might be a good idea to copy the section of the README regarding the API to this forum.

 

"The current policy for development of the API is that changes are only made at the request of addon authors who would like improved compatibility. It isn't possible for us to think of all the different things and addon would like to implement, so if you feel that the API is lacking a specific functionality, please let us know."

 
In addition to this, if there is anything without visibility in either the core mod or the API that you would like to be changed to protected or even public, please let us know. We're more than happy to change a modifier or add getters and setters so addon authors don't have to do ASM or reflection to implement something.
 
Feel free to either respond to this topic with a requested change, or create a pull request on GitHub for it. If you do the latter, please make sure you read the rest of the README so you understand the procedures regarding pull requests.
0

Share this post


Link to post
Share on other sites

I was wondering if a change could be made so that addon creators could access different bits of information regarding mobs, such as mob size, age, gender, maybe even strength to determine our mob drops. Currently all of this information is set to private within the mob classes, and is therefore inaccessible.

0

Share this post


Link to post
Share on other sites

There are getter and setter methods for all of those variables as of 79.26 which released over a week ago.

0

Share this post


Link to post
Share on other sites

I completely missed that in the changelog thanks Kitty. :)

0

Share this post


Link to post
Share on other sites

First off, the amount of visibility in both the core mod and API is awesome. Furthermore, your amount of dedication to the community and this mod is quite impressive.

 

With that, I am interested in adding visibility to the maximum food consumption of a food item, which is currently hard-coded at 5. In addition, it would be nice to be able to add or remove food items that can be used for a specific animal. It is totally possible that there is a method that I have overlooked, but I have not seen anything that would allow this to be done. If this is something that you would be interested in approving, just say so and I will gladly make a pull request.

0

Share this post


Link to post
Share on other sites

Maximum food consumption is not hardcoded at 5. Case in point, you can eat an entire sandwich in one bite. You just need to have your food extend ItemMeal and override getEatAmount.

 

If you're talking about adding food to feed animals with and to tempt them with, you'll have to create your own animal class that extends ours and spawns instead of ours. The tempting is just an AI that you add to the animal, and isFood for feeding is also a public method.

0

Share this post


Link to post
Share on other sites

I will explain what I am attempting to do with my addon so you will get a better idea of what and why I want to be able to change these values. I am developing an addon that will expand the eating system to replicate what hunger overhaul and pam's harvestcraft have done with vanilla minecraft but in a manner that is consistent with TFC. To accomplish this, the mod requires players to eat a variety of types of foods rather than eating salads and sandwiches for every meal. I am attempting to reduce the amount a player can eat of a food based on the number of times that food is eaten and the random player's "pickiness" for foods. For example, a picky player can only eat a food item 3 times before they cannot eat it and must eat other food items. This is essentially the behavior that Hunger Overhaul implements, which I know Bioxx does not like but many others do and adds to an increased sense of role play. 

 

What I want to do is reduce the amount a player can eat of a particular TFC food item. Currently, every food item is subject to:

 

float eatAmount = Math.min(amount, 5);

or

float eatAmount = Math.min(weight - decay, 5f);

 

Which means either use 5 relative units of this item or whatever is left to replenish stomach levels and reduce weight of the item. Increasing or decreasing "5" in this has the respective result on the amount used and stomach levels filled. By making a variable and a setter function for this value, a TFC food item usage can be adjusted. I would gladly make a pull request for this or if it will not be consider for submission I will keep my addon as is which replaces all TFC food items with its own. I am avoiding addSubstitutionalias as it breaks MP servers and does not properly register IDs. 

 

Since I am replacing all foods, I have found that it prevents interactions with all animals. I'll admit that I am not as knowledgeable about the TFC mobs code as I am with the foods codes. But from what I can see, adding a dynamically allocated list to call for entity/food interaction would all me to add an item to that list. Again I will make a pull request if this is something that might be approved otherwise I will not make a pull request.

 

Other than these few things, I have found TFC to be highly visible and fairly easy to work with.

0

Share this post


Link to post
Share on other sites

I guess I'm confused here on how you would even access these variables. Where do you expect to call the setter to update the eat amount on the piece of food?

 

The exact same thing goes for animals. It is literally an AI assignment for what food you can hold to get them to follow you. 

 

https://github.com/Deadrik/TFCraft/blob/master/src/Common/com/bioxx/tfc/Entities/Mobs/EntityCowTFC.java#L84

 

And their isFood check is a vanilla method that is overwritten.

 

https://github.com/Deadrik/TFCraft/blob/master/src/Common/com/bioxx/tfc/Entities/Mobs/EntityCowTFC.java#L511

 

I'm really don't see where else in the code you would be able to access and edit that, as making it some sort of static list for each mob doesn't make much sense to me.

0

Share this post


Link to post
Share on other sites

Let me begin by saying that I would love a addon like that. This is something that I have requested many times as I do not find believable that the player is able to eat the same sandwich forever and ever and never get tired of the taste. It also should not be healthy.

Not a coder myself, but if the problem you are having is because modifying food makes it so is not interacting with animals, why not just leave raw grain the way it is now, so animals would be attracted to it   and eat it.

Just prevent the player from eating raw grains.

I think you would be able to achieve your goal like that.

This way you would only have to change or create new properties for cooked or baked grains.

0

Share this post


Link to post
Share on other sites

I figure that a mod like this would be useful in allowing increased difficulty and depth that is not appropriate in the base mod; so if a player wants a deeper detail to food this can be in addition to TFC. So this can appease those that want more food options like apple pie, pizza, lemonade, etc or a more intricate and demanding food system that is not nice to new players and take on the demands that some suggestions want that are simply not appropriate in the base TFC.

 

As for where these variables can be called: 

For food items, I know that the PlayerUseItemEvent works fairly good at manipulating the food item a player is eating, at least that is what I am currently using to manipulate eating events and it works fairly well.

 

As for the mobs, I'll probably use LivingSpawnEvent to add the variable before it is spawned.

 

I am quite certain that implementing food changes in this manner will work as that is what I am currently doing with the addon currently and for the mob method I think it will work but I haven't spent much time working on it until I get some indication of potentially considering pull requests for these ideas as I don't want to waste time on something that will certainly be rejected. Realistically, the only variable that I would need to be public is the max eat amount as I could leave all of the TFC items in place and not need to replace them with my own. But I think having a method of adding food to tempt/feed animals might also prove handy.

 

If you think you might consider adding this feature, just say so and I will code it, test it and submit a pull request; If not, I will not waste any more time on the issue and continue to code my addon.

0

Share this post


Link to post
Share on other sites

You can work on a pull request for the max eat amount, which means you won't need to edit the mob feeding, but since the tempt is an AI thing there's really nothing special you need for that bit.

0

Share this post


Link to post
Share on other sites

I know TFC has entered maintenance mode, so this will likely be ignored/denied. However, I would like to be able to get the value for the amount of gunpowder contained inside of an explosive barrel, the int gunpowder inside of EntityBarrel is private, I don't need to change or alter this variable, I just need to retrieve the value.

 

Thanks, :)

 

0

Share this post


Link to post
Share on other sites

Just to make sure, you do realize that EntityBarrel is a barrel that is already lit and is about to explode, right?

Edit: Also, origBarrel is public, and that itemstack has NBT data on it for the original barrel tile entity's contents, which would include the stacks of gunpowder.

Edited by Kittychanley
0

Share this post


Link to post
Share on other sites
1 hour ago, Kittychanley said:

Just to make sure, you do realize that EntityBarrel is a barrel that is already lit and is about to explode, right?

Edit: Also, origBarrel is public, and that itemstack has NBT data on it for the original barrel tile entity's contents, which would include the stacks of gunpowder.

1
 

Yes, I know that is the exploding one, working on a compatibility add-on thing of sorts. I'll look into that other barrel, thanks, Kitty. :)

Edit: I can't seem to find the tag to call, I tried "gunpowder" just as a guess but that's returning zero so it's most likely not the right one. Sorry if I missing something obvious, but I looked through both TEBarrel, BlockBarrel, and EntityBarrel and I don't see where the value is being assigned to origBarrel.

Edited by Powerman913717
0

Share this post


Link to post
Share on other sites

*Bump* Just in case the edit above was missed. :P

0

Share this post


Link to post
Share on other sites

There is no "gunpowder" tag. It's the normal inventory tag and you use that to calculate the gunpowder count the exact same way we do.

0

Share this post


Link to post
Share on other sites
8 hours ago, Kittychanley said:

There is no "gunpowder" tag. It's the normal inventory tag and you use that to calculate the gunpowder count the exact same way we do.

Thanks Kitty, sorry I misunderstood you.

0

Share this post


Link to post
Share on other sites