Spoiled Food

Discussion in 'Plugin Requests' started by IAmKnight, Aug 20, 2016.

Thread Status:
Not open for further replies.
  1. Offline

    IAmKnight

    Plugin category: Mechanics, Fun

    Minecraft version: 1.10+

    Suggested name: SpoiledFood

    What I want:
    I've seen a few rotten food plugins that I've tried and tested, however none exactly fit my criteria. I'd simply like a plugin which, while hovering over food in the inventory, tells you information about that item such as:
    - Fresh Cooked Beef
    - Hour Old Cooked Beef
    - Two-Hours Old Cooked Beef
    - Spoiled Beef
    The only way I can think of this working without it being too hard is disabling food stacking, like the old days. I'm fine with this. It might need a database, but I'm not sure as I'm only new to Java. In the config, players can change the above text that is shown, along with the time interval between each one. They could even increase the list of texts.

    The plugin would attempt to track all food in inventories and chests, but I fear that may be too hard. There could be some time from adding the food to the chest and removing it, then just using maths to calculate how much time the food has. In this case, food you hover your mouse over in chests won't show it's status.

    If possible, cooking spoiled raw food should make spoiled cooked food, and not revert it back to the fresh state.
    Also, it would be awesome if you could "Freeze" the food, by putting snow in chests. Maybe 1 snow for 1 food, so that any amount of food exceeding the amount of snow would continue to spoil. I understand if this would be too hard to implement.

    The config should allow players to choose which food they want spoiled on the server, so that some foods, such as Golden Apples, don't have a spoil date.

    Ideas for commands: I don't think commands would be needed.

    Ideas for permissions: I don't think permissions are needed for this, settings for the plugin would be edited in the config.

    When I'd like it by: I won't be too picky about this. I'd prefer it within the month, maybe more, take your time :)

    Thanks for reading, and thanks in advance if you decide to help out!
    I'll answer questions as they come, and don't worry if some things seem too difficult, like the freezing. As long as the rough outline of what I'd like it to be is somewhat met, I'll be as happy as a dog in christmas.

    EDIT:
    Another little function that could possibly be done
    - Add "salted" meat (By using meat texture but giving and individual ID)
    - Make salt by putting water bottle into crafting table, the output would be the Sugar texture, but it'll be Salt
    - Increase life expectancy of meat by amount in config for salted meats
    - Make salted meat by getting cooked meat and salt into a crafting grid

    The reason for putting the water bottle into a crafting grid instead of a furnace is because I use the Thirst plugin, which turns it into Boiled Water.
     
    Last edited: Aug 22, 2016
  2. Offline

    Jake861

    EDIT: Too complicated. I'll let someone else grab it.
     
  3. Offline

    IAmKnight

    Haha, thanks for trying at least, man

    Editing the above post for a little extra if somewhat relatively possible:
    - Add "salted" meat (By using meat texture but giving and individual ID)
    - Make salt by putting water bottle into crafting table, the output would be the Sugar texture, but it'll be Salt
    - Increase life expectancy of meat by amount in config for salted meats
    - Make salted meat by getting cooked meat and salt into a crafting grid

    The reason for putting the water bottle into a crafting grid instead of a furnace is because I use the Thirst plugin, which turns it into Boiled Water.
    This is totally optional, by the way.
     
  4. Offline

    Lordloss

    For me this plugin sounds very challenging, without any promise i would give it a try. A way this could work would be a timestamp in the item lore, which would mean all items with the same time would be stackable.
    EDIT:
    Maybe there is a way of storing the timestamp without beeing visible to the players, i have to try around with it. May i ask what the rotten stuff is supposed to do? Will it transform to rotten flesh or just get a (maybe red) name saying in example "Rotten Potato"? Can it be eaten & will harm the player?
     
    Last edited: Aug 22, 2016
  5. Offline

    IAmKnight

    I think the food would just get a red name saying "Rotten/Spoiled Beef" or something. It could be eaten, but it would give the player hunger and poison for a certain amount of time. Perhaps in the config it could be set up so that each stage (One hour, two hour long food) would have certain effects against the player from eating. And to make it even more complicated (which is why I'm totally understanding if it's just too hard) is maybe reduce the amount of hunger bars that specific food gives after being too old. I'm not sure if it can be done since I have very limited experience with Bukkit coding.
     
  6. Offline

    Lordloss

    How hard it really is im gonna find out after trying around a bit. I did quite complex stuff in the past, and at least im optimistic now ;) Im aiming for a really good system like it is in Dont Starve (if you know that game..) but we will see what comes out.
     
  7. Offline

    IAmKnight

    Haha, I've heard of it but haven't played it. I'm assuming that a system as complex as something from that game would be impressive, so I'll be happy with whatever kind of plugin is developed. :)
     
  8. Offline

    Lordloss

    At the moment i can tell that everything i tried so far works like a charm. Im pretty sure that most of your required features can be made.
     
  9. Offline

    I Al Istannen

    @Lordloss
    For the storage: NBT. I have used in the plugin here. Source code is packaged within, any Ide should be able to read that. Or open it with a zip program (7-zip, winrar,...)

    I too think the features should all be possible, so good luck! If I can be of any help, just write it ;)
     
    Lordloss likes this.
  10. Offline

    Lordloss

    @I Al Istannen the data storage part is allready done. But thanks :)
     
  11. Offline

    I Al Istannen

    @Lordloss
    Nice!
    May I ask how you solved it? :)
     
  12. Offline

    Lordloss

    @I Al Istannen sure, i used this util class which hides the data in color codes.
    EDIT:
    The only thing which is bothering me is this animation which occurs if an item in the hand gets updated. It makes eating it a bit buggy. But afaik there is no way of changing this. An option would be to not update the item in the hand until it gets eaten which is not really nice.
     
    Last edited: Aug 22, 2016
  13. Offline

    I Al Istannen

    @Lordloss
    Cool! Not as seamless as NBT but way more creative ;)

    This animation exits since 1.8 I think. And it is really annoying. I have tried for quite some time to find a work around sometime ago, but I couldn't find one. Guess you will have to live with it :/

    Why does it make eating buggy though? Do yo need to update it while the player eats it?
     
    Lordloss likes this.
  14. Offline

    Lordloss

    @I Al Istannen yeah i thought so =/.
    Not exactly, the items get updated in configurable intervals. If you put in a low delay between checks, there is a good chance the "hopping" animation appears while eating. Its not this bad though, especially because i use for testing a ridiculous short delay. On my testserver they get updated every second, while in practice 10, 30 or 60 seconds should be more than enough. I made this flexible because i dont know how the plugin will affect performance, dozens of players with their inv full of food maybe cause problems, maybe not.
    It depends on how "realtime" the user want the spoilage to happen ;)
     
    I Al Istannen likes this.
  15. Offline

    I Al Istannen

    @Lordloss
    Ah, I see. Makes sense now ;)

    It's a shame that it was made this way though, but I guess you can't have everything :/

    Zombie made a stress test thread here. You should be fine :p But making it configurable is the good choice ;)

    I definitely look forward to it, keep it up!

    Sadly I will be gone for about 10 days, starting at wednesday, so I will probably not see it that fast :(
     
  16. Offline

    Lordloss

    @I Al Istannen thanks for the link, the item thing is good to know.
    I would be glad if you take a look at it, i know you as a creative, talented programmer ;) You can also look at the code if youre interested, im trying hard to fill requests as good as i can.
     
  17. Offline

    I Al Istannen

    @Lordloss
    Thanks :) Though you are too kind :)

    I will, but I don't think I will find anything to improve ;) Well, we will see in a week or so.

    Have fun doing the requests and have a nice day!
     
    timtower likes this.
  18. Offline

    IAmKnight

    Wow, if you can get most of my required features that'll be brilliant :D
    Seriously though, thanks for helping out! :)
     
  19. Offline

    Lordloss

    Im glad to tell you that most of the basic stuff is now finished. But i have some questions:

    Would it be OK to make the snow like the salt so you have to craft them together with the food to get "preserved food"?
    If not because you want the snow in chest thing, i need some further informations.
    - Should storing food in a chest with snow transform it to "preserved food" which enlarges the durability permanent, and remove the snow?
    - Or should it instead slow down the spoilage process while it is inside the chest with snow? In this case snow cannot be consumed that easily, i would have to think about this more.
    - Should snow in chest be consumed at all?
    - Should placing food in a chest with snow stop the spoiling process completely?

    For the salt creation, should the player get the empty bottle back?
     
    IAmKnight likes this.
  20. Offline

    IAmKnight

    Thank you for asking these questions, I did not think about mentioning them in the original post.
    I would have it so that the snow would be stored in the chest, along with the food. The snow then gets removed and one food item gets it's lifetime increased. However, once the food gets removed from the chest, it's durability goes back to it's previous state, except maybe a small increased amount of time for it's defrosting process.
    This is to allow mass food storage, as long as players have sufficient snowballs. Note that the snowballs won't infinitely increase the spoilage in the chest; it will only increase the lifetime by a large amount. To make it easier for other server owners to customise, these time values should be changeable in the config, such as how long the snow increases the lifetime, and how long it takes for food to "defrost" after being taken from a chest with a snowball.
    Players should get the empty bottle back.
    I hope that answered what you needed to know.

    Once again, thank you for doing this :)
     
  21. Offline

    Lordloss

    So that would mean in example: You have a chest with a Stack of 10 beef, and add 5 snowballs into it. The snow would be removed, and 5 of the steaks get splitted up from the original stack and become preserved. They stay preserved as long as they are in the chest, after removing they Start to warm up. Then they spoil as fast as usual. Am i right?
     
  22. Offline

    IAmKnight

    Almost. They still have a lifetime in the chest, it is just a LOT longer, Probably defined within the config. Everything else is correct.
     
  23. Offline

    Lordloss

    Well it will not be that easy, but i try my best.
     
  24. Offline

    IAmKnight

    It's alright if it is too complicated, I'm already happy with your investment in the project :)
     
  25. Offline

    I Al Istannen

    @IAmKnight
    If they are frozen and you put more snowballs in there, what happens? What is the stacking limit for freezing? Would they consume the other snowballs, once they get unfrozen?

    And to torture @Lordloss a bit, does the Block Temperature affect it? So a chest in an ice biome is frozen anyways. This could be quite hard to implement, so it is merly a suggestion :)
     
  26. Offline

    Lordloss

    @I Al Istannen well allready preserved stacks wont consume more snow, and they stay in the "chilled" state until they get out of the chest.

    For the biome part, take my code and do it yourself xD
     
    I Al Istannen likes this.
  27. Offline

    IAmKnight

    These are the ideals @I Al Istannen :
    Preferably food has a "chilled" state in the chest. Over time, that chilled state runs out, however, and another snowball is consumed. This is to prevent the exploitation of using one snowball and keeping some beef in a chest for a full real life year. However, I'm not sure if this is easy to implement.
    Block temperature... Would be awesome, but extremely hard to code, I'm assuming. I'm not expecting it so I don't mind either way.

    Another thing I was thinking about... Snow Blocks should have 4 times the length of the "Chilled" state of the food, should it be implemented.
    From what I can think of, if this were all coded, it should act like this:
    - Food has it's "Lifetime".
    - "Chilled" is a separate value.
    - When food in a chest gets "Chilled", their "Lifetime" gets paused, until "Chilled" runs out.
    - If there is another snowball/snow block in the chest, it will get consumed and the "Chilled" timer resets.
    - If there are no snowballs/snow blocks in the chest, the "Chilled" state ceases and the food's "Lifetime" resumes.
    - Salt is different. It simply increases the food's "Lifetime".

    I was thinking. I use the Thirst plugin (mentioned), which is why I mentioned putting water in a crafting table instead of putting it into a furnace. Is it possible to boil the water in the furnace, like in Thirst, providing Boiled Water as an output, but replacing the input into that Salt ID?
    I think it's possible if that slot was changed, but I'm not too sure.

    I'm trying to iron out the details as much as possible, so that anything realistic can be done.
    Thanks again, @Lordloss :)
     
  28. Offline

    Lordloss

    Thank you for this more detailed description. Thats a bit late especially for the freezing part, as im about 80 % done with it.
    But it shouldnt be too hard to change the things you want different. I understood it this way that food is frozen as long as it is kept in the chest where it got freezed, and it only starts to warm up if taken out. But this is not hard to change so dont mind. What you said now makes more sense.
    One thing i implemented different is how freezing affects the food. Atm you can define a percentage in the config how much the lifetime gets enlarged. That means it will still spoil after a while, dependent on the number in the config. In example if you put in 200, the lifetime gets added 200 % while it is frozen. Meaning it will last three times as long as usual. But you can put in an incredibly high number if you dont really want it to spoil, so it takes realtime years. ;)
    The snow block thing im gonna add, no big issue.
    For the salt you mean that my plugin cooperates with the thirst plugin? For this i have to take a look how it works exactly, im gonna download it as soon as i get home. Another question about salt, to make sure i really understand: Does it permanently slow down the spoilage process, or does it "restore" lifetime? In Example 50 % spoiled meat gets salted and after that it has 80 %, but spoils as fast as usual?
     
  29. Offline

    IAmKnight

    Your example is correct, if meat that is 50% spoiled gets salted, then the salt adds lifetime to it, such as 30%(or whatever is in the config), making the salted meat 80%. It still spoils as fast as usual, yes.
     
  30. Offline

    Lordloss

    Im sorry to say that the freezing thing is currently "on ice", because of your change that it can also warm up while it is in the chest it will be much harder to calculate. I will come back to it after i finished everything else, and hope to solve the problem.
    I try to describe whats the issue:
    All player inventories and currently opened other inventories get checked frequently. With checking i mean updating the item status. Updating the remaining time for the food to spoil, the display name, the timestamp since last check, the snow consuming and some other stuff.
    All chests not currently opened stay as they are, and will be updated the next time opened by a player. The time distance between the last check and now gets calculated, and the food gets refreshed based on this.
    As snow comes into play, additional calcualtion for how many of the containing items the snow is sufficient, is needed. I must know how much of the time the stack was frozen, how much not. The "freeze time" must be distributed equally on all items, and if snow or food gets into the chest without update, in example by a hopper or plugin (maybe magnet chest function) things get messed up.

    I cant promise that this will work as intended, but i will try my best as soon as the rest is finished. I have to re-think how this is done the best way possible.
     
Thread Status:
Not open for further replies.

Share This Page