Add MC hold to eat delay #4144

Merged
the-real-herowl merged 19 commits from Eliy21/MineClone2:eating_delay into master 2024-01-25 03:06:18 +01:00
Contributor

Fixes #3256

Testing

-Test eating foods by holding right-click or holding a double tap on touchscreen. (Make sure your hunger bar is not full)
-Test eating cakes, potions, golden apples, milk buckets and sus stew
-Test on creative and survival
-Test the mcl_eating_delay in settings

<!-- Please follow our contributing guidelines first: https://git.minetest.land/MineClone2/MineClone2/src/branch/master/CONTRIBUTING.md#how-you-can-help-as-a-programmer By submitting this pull request, you agree to follow our Code of Conduct: https://git.minetest.land/MineClone2/MineClone2/src/branch/master/CODE_OF_CONDUCT.md --> Fixes #3256 ### Testing -Test eating foods by holding right-click or holding a double tap on touchscreen. (Make sure your hunger bar is not full) -Test eating cakes, potions, golden apples, milk buckets and sus stew -Test on creative and survival -Test the mcl_eating_delay in settings
Author
Contributor

This pull request has changes conflicting with the target branch.

  • settingtypes.txt

Oh crap. Please help. I allowed edits to PR if that can help. Otherwise I'll just remake the branch and PR without the settingtypes.txt as everything else is functional.

> This pull request has changes conflicting with the target branch. > > * settingtypes.txt Oh crap. Please help. I allowed edits to PR if that can help. Otherwise I'll just remake the branch and PR without the settingtypes.txt as everything else is functional.
Member

Looks good!, just like MC. Question, Is the default delay the exact same as in MC?

Looks good!, just like MC. Question, Is the default delay the exact same as in MC?

This pull request has changes conflicting with the target branch.

  • settingtypes.txt

Oh crap. Please help. I allowed edits to PR if that can help. Otherwise I'll just remake the branch and PR without the settingtypes.txt as everything else is functional.

Pull the branch and apply the settings change again.

> > This pull request has changes conflicting with the target branch. > > > > * settingtypes.txt > > Oh crap. Please help. I allowed edits to PR if that can help. Otherwise I'll just remake the branch and PR without the settingtypes.txt as everything else is functional. Pull the branch and apply the settings change again.
Member

This pull request has changes conflicting with the target branch.

  • settingtypes.txt

Oh crap. Please help. I allowed edits to PR if that can help. Otherwise I'll just remake the branch and PR without the settingtypes.txt as everything else is functional.

I can help!
Let me get setup.

> > This pull request has changes conflicting with the target branch. > > > > * settingtypes.txt > > Oh crap. Please help. I allowed edits to PR if that can help. Otherwise I'll just remake the branch and PR without the settingtypes.txt as everything else is functional. I can help! Let me get setup.
Author
Contributor

Looks good!, just like MC. Question, Is the default delay the exact same as in MC?

Yes. https://minecraft.wiki/w/Food#Usage

Pull the branch and apply the settings change again.

I'll remake the whole thing again. Please wait.

> Looks good!, just like MC. Question, Is the default delay the exact same as in MC? Yes. https://minecraft.wiki/w/Food#Usage > Pull the branch and apply the settings change again. I'll remake the whole thing again. Please wait.

Mesehub falling apart again... wait before pulling.

Mesehub falling apart again... wait before pulling.
Author
Contributor

I can help!
Let me get setup.

Okay, I'll not remake the whole thing again for now while I wait for your help.

> I can help! > Let me get setup. Okay, I'll not remake the whole thing again for now while I wait for your help.

Looks good!, just like MC. Question, Is the default delay the exact same as in MC?

Yes. https://minecraft.wiki/w/Food#Usage

Pull the branch and apply the settings change again.

I'll remake the whole thing again. Please wait.

Don't remake. Just pull master into your branch and add the change.

> > > Looks good!, just like MC. Question, Is the default delay the exact same as in MC? > > Yes. https://minecraft.wiki/w/Food#Usage > > > Pull the branch and apply the settings change again. > > I'll remake the whole thing again. Please wait. Don't remake. Just pull master into your branch and add the change.
Author
Contributor

Mesehub falling apart again... wait before pulling.

Is that why the "Update by rebase" button keeps failing?

>Mesehub falling apart again... wait before pulling. Is that why the "Update by rebase" button keeps failing?

Mesehub falling apart again... wait before pulling.

Is that why the "Update by rebase" button keeps failing?

Yeah. It may take a few hours or so until in works properly.

> >Mesehub falling apart again... wait before pulling. > > Is that why the "Update by rebase" button keeps failing? Yeah. It may take a few hours or so until in works properly.
Member

I can help!
Let me get setup.

Okay, I'll not remake the whole thing again for now while I wait for your help.

umm, how do i make a PR for a repo thats already a fork?
or can you just add me to your repo?

> > > I can help! > > Let me get setup. > > Okay, I'll not remake the whole thing again for now while I wait for your help. umm, how do i make a PR for a repo thats already a fork? or can you just add me to your repo?
Author
Contributor

umm, how do i make a PR for a repo thats already a fork?
or can you just add me to your repo?

I have no idea. It's probably easier if I remake the whole thing.

> umm, how do i make a PR for a repo thats already a fork? > or can you just add me to your repo? I have no idea. It's probably easier if I remake the whole thing.
Author
Contributor

Okay here's my plan. I make an empty branch and make a new PR and then rebase it before doing any commits. Please wait...

Okay here's my plan. I make an empty branch and make a new PR and then rebase it before doing any commits. Please wait...
Member

Just a question, How long does it take for someone to get write access on this repo @the-real-herowl?
It would be useful so i can work on a PR's branch.

Just a question, How long does it take for someone to get write access on this repo @the-real-herowl? It would be useful so i can work on a PR's branch.
Member

Okay here's my plan. I make an empty branch and make a new PR and then rebase it before doing any commits. Please wait...

Okay, but i really need to learn how to do that, so i can contribute to other peoples PRs

> Okay here's my plan. I make an empty branch and make a new PR and then rebase it before doing any commits. Please wait... Okay, but i really need to learn how to do that, so i can contribute to other peoples PRs
Author
Contributor

Okay, but i really need to learn how to do that, so i can contribute to other peoples PRs

Um should I wait for you on that. It's fine with me but I already PR'ed the thing. I'm fine either way but I'll just finish the other PR first. I don't mind if I waste my time there.

> Okay, but i really need to learn how to do that, so i can contribute to other peoples PRs Um should I wait for you on that. It's fine with me but I already PR'ed the thing. I'm fine either way but I'll just finish the other PR first. I don't mind if I waste my time there.
Member

Okay, but i really need to learn how to do that, so i can contribute to other peoples PRs

Um should I wait for you on that. It's fine with me but I already PR'ed the thing. I'm fine either way but I'll just finish the other PR first. I don't mind if I waste my time there.

Can you give me write access to your repo please?
So i can push changes.

I cant figure out how to make a PR on a fork of a fork.

> > Okay, but i really need to learn how to do that, so i can contribute to other peoples PRs > > Um should I wait for you on that. It's fine with me but I already PR'ed the thing. I'm fine either way but I'll just finish the other PR first. I don't mind if I waste my time there. Can you give me write access to your repo please? So i can push changes. I cant figure out how to make a PR on a fork of a fork.
Author
Contributor

Can you give me write access to your repo please?
So i can push changes.

I cant figure out how to make a PR on a fork of a fork.

I don't know how to do that. Can you tell me how?

> Can you give me write access to your repo please? > So i can push changes. > > I cant figure out how to make a PR on a fork of a fork. I don't know how to do that. Can you tell me how?

Just a question, How long does it take for someone to get write access on this repo @the-real-herowl?
It would be useful so i can work on a PR's branch.

Write access to regular branches on this repo has no hard cutoff, depends on how we feel about it, some got it after their first PR.

So anyway yes this mean that @Eliy21, you are eligible for it – if you want. You @Impulse not yet. Both of you, join our discord if you want. The link is in the Readme.md file.

Now, returning to the question, @Impulse, write access to regular branches of the repo doesn't grant you access to branches on forks anyway, even if someone ticks the "allow edits..." box.

And while you don't have access to the regular branches of the repo, you can make a PR targeting a branch (even those with master write access sometimes make such PRs, see #4019). You theoretically should be able to make a PR on a fork, but tbh better don't. Better keep it all in one place.

> Just a question, How long does it take for someone to get write access on this repo @the-real-herowl? > It would be useful so i can work on a PR's branch. Write access to regular branches on this repo has no hard cutoff, depends on how we feel about it, some got it after their first PR. So anyway yes this mean that @Eliy21, you are eligible for it – if you want. You @Impulse not yet. Both of you, join our discord if you want. The link is in the Readme.md file. Now, returning to the question, @Impulse, write access to regular branches of the repo doesn't grant you access to branches on forks anyway, even if someone ticks the "allow edits..." box. And while you don't have access to the regular branches of the repo, you can make a PR targeting a branch (even those with master write access sometimes make such PRs, see #4019). You theoretically should be able to make a PR on a fork, but tbh better don't. Better keep it all in one place.

@Eliy21 making the second PR for the same thing was unnecessary really over such a small thing.

@Eliy21 making the second PR for the same thing was unnecessary really over such a small thing.
Author
Contributor

Write access to regular branches on this repo has no hard cutoff, depends on how we feel about it, some got it after their first PR.

So anyway yes this mean that @Eliy21, you are eligible for it – if you want. You @Impulse not yet. Both of you, join our discord if you want. The link is in the Readme.md file.

Thank you for the write access offer but I don't trust myself to not accidentally nuke stuff like when I oopsie'd my whole main fork and branches to oblivion. If there's a pressing need for it maybe but for now I'll just gratefully appreciate the thought.

> Write access to regular branches on this repo has no hard cutoff, depends on how we feel about it, some got it after their first PR. > > So anyway yes this mean that @Eliy21, you are eligible for it – if you want. You @Impulse not yet. Both of you, join our discord if you want. The link is in the Readme.md file. Thank you for the write access offer but I don't trust myself to not accidentally nuke stuff like when I oopsie'd my whole main fork and branches to oblivion. If there's a pressing need for it maybe but for now I'll just gratefully appreciate the thought.
Author
Contributor

@Eliy21 making the second PR for the same thing was unnecessary really over such a small thing.

lol sorry

> @Eliy21 making the second PR for the same thing was unnecessary really over such a small thing. lol sorry
Member

Okay i am ready to push to your fork, fixed it. I just need privs @Eliy21

Okay i am ready to push to your fork, fixed it. I just need privs @Eliy21
Author
Contributor

Okay i am ready to push to your fork, fixed it. I just need privs @Eliy21

How can I do it? Please teach me. @Impulse

> Okay i am ready to push to your fork, fixed it. I just need privs @Eliy21 How can I do it? Please teach me. @Impulse
Member

Here is the patch file:

These are the instructions @Eliy21

  • git pull your master branch so its updated with upstream
  • Reset the eating_delay branch to master
  • Run git apply /path/to/my_patch.patch
Here is the patch file: These are the instructions @Eliy21 - `git pull` your `master` branch so its updated with `upstream` - Reset the `eating_delay` branch to `master` - Run `git apply /path/to/my_patch.patch`
Author
Contributor

Here is the patch file:

These are the instructions @Eliy21

  • git pull your master branch so its updated with upstream
  • Reset the eating_delay branch to master
  • Run git apply /path/to/my_patch.patch

Um how do I do it in the gui?

> Here is the patch file: > > These are the instructions @Eliy21 > - `git pull` your `master` branch so its updated with `upstream` > - Reset the `eating_delay` branch to `master` > - Run `git apply /path/to/my_patch.patch` Um how do I do it in the gui?
Member

Okay i am ready to push to your fork, fixed it. I just need privs @Eliy21

How can I do it? Please teach me. @Impulse

Go here and add me and i can push the changed for you:

https://git.minetest.land/Eliy21/MineClone2/settings/collaboration

EDIT: sorry i put wrong url in, now it works.

> > Okay i am ready to push to your fork, fixed it. I just need privs @Eliy21 > > How can I do it? Please teach me. @Impulse Go here and add me and i can push the changed for you: [https://git.minetest.land/Eliy21/MineClone2/settings/collaboration](https://git.minetest.land/Eliy21/MineClone2/settings/collaboration) EDIT: sorry i put wrong url in, now it works.
Author
Contributor

Go here and add me and i can push the changed for you:

https://git.minetest.land/Impulse/Eliy21/settings/collaboration

It says 404:

The page you are trying to reach either does not exist or you are not authorized to view it.

EDIT:

Ohh okay I see it now. Wait...

> Go here and add me and i can push the changed for you: > > [https://git.minetest.land/Impulse/Eliy21/settings/collaboration](https://git.minetest.land/Impulse/Eliy21/settings/collaboration) It says 404: >The page you are trying to reach either does not exist or you are not authorized to view it. EDIT: Ohh okay I see it now. Wait...
Member

Here is the patch file:

These are the instructions @Eliy21

  • git pull your master branch so its updated with upstream
  • Reset the eating_delay branch to master
  • Run git apply /path/to/my_patch.patch

Um how do I do it in the gui?

I don't think you can do it via a GUI, at least easily. If you add me i can push the changes for you.

> > Here is the patch file: > > > > These are the instructions @Eliy21 > > - `git pull` your `master` branch so its updated with `upstream` > > - Reset the `eating_delay` branch to `master` > > - Run `git apply /path/to/my_patch.patch` > > Um how do I do it in the gui? I don't think you can do it via a GUI, at least easily. If you add me i can push the changes for you.
Author
Contributor

Ok I added you now @Impulse

Ok I added you now @Impulse
Impulse force-pushed eating_delay from e4549d327a to c70ae8e535 2024-01-15 09:45:54 +01:00 Compare
Author
Contributor

@Impulse Did it work properly? When I look at my eating_delay branch it seems like everything got reset. (https://git.minetest.land/Eliy21/MineClone2/src/branch/eating_delay)

@Impulse Did it work properly? When I look at my eating_delay branch it seems like everything got reset. (https://git.minetest.land/Eliy21/MineClone2/src/branch/eating_delay)
Member

Sorry its taking a while, the patch file has a conflict, i am just fixing it.

Sorry its taking a while, the patch file has a conflict, i am just fixing it.
Author
Contributor

Sorry its taking a while, the patch file has a conflict, i am just fixing it.

Okay I'll leave it all up to you here since I gotta go for now.

> Sorry its taking a while, the patch file has a conflict, i am just fixing it. Okay I'll leave it all up to you here since I gotta go for now.
Member

Sorry its taking a while, the patch file has a conflict, i am just fixing it.

Okay I'll leave it all up to you here since I gotta go for now.

Fixed it. Was a pa lava, because another commit in master modified the init.lua file as well as the settingtypes.txt and i had to resolve the conflicts. It should be fine now.

Just make sure to run git pull before you push your changes @Eliy21
It reduces these issues.

> > Sorry its taking a while, the patch file has a conflict, i am just fixing it. > > Okay I'll leave it all up to you here since I gotta go for now. Fixed it. Was a pa lava, because another commit in master modified the `init.lua` file as well as the `settingtypes.txt` and i had to resolve the conflicts. It should be fine now. Just make sure to run git pull before you push your changes @Eliy21 It reduces these issues.
Author
Contributor

Fixed it. Was a pa lava, because another commit in master modified the init.lua file as well as the settingtypes.txt and i had to resolve the conflicts. It should be fine now.

Congrats on fixing it. I don't know what a "pa lava" is but I'm glad to be of use even as a Guinea pig. Thank you for helping me with this PR.

Just make sure to run git pull before you push your changes @Eliy21
It reduces these issues.

I don't use git but I'll try to keep that in mind if I ever do use it in the future. Thanks.

> Fixed it. Was a pa lava, because another commit in master modified the `init.lua` file as well as the `settingtypes.txt` and i had to resolve the conflicts. It should be fine now. Congrats on fixing it. I don't know what a "pa lava" is but I'm glad to be of use even as a Guinea pig. Thank you for helping me with this PR. > Just make sure to run git pull before you push your changes @Eliy21 > It reduces these issues. I don't use git but I'll try to keep that in mind if I ever do use it in the future. Thanks.
Impulse force-pushed eating_delay from c580071ec5 to 2c52c9009f 2024-01-15 18:02:33 +01:00 Compare
the-real-herowl force-pushed eating_delay from 5db662f5ed to 760909f49c 2024-01-20 01:45:21 +01:00 Compare
the-real-herowl added this to the 0.87.0 - Prismatic milestone 2024-01-20 01:53:14 +01:00
the-real-herowl requested changes 2024-01-20 03:25:49 +01:00
@ -183,1 +183,4 @@
local function eat_gapple_delayed(itemstack, placer, pointed_thing)
local function eat_gapple(itemstack, placer, pointed_thing)

Gapples have the same issue as milk, duped infinitely with itemframes.

Gapples have the same issue as milk, duped infinitely with itemframes.
Author
Contributor

Done

Done
the-real-herowl marked this conversation as resolved
@ -147,1 +147,4 @@
local function drink_milk_delayed(itemstack, player, pointed_thing)
local function drink_milk(itemstack, player, pointed_thing)

Milk bucket gets duplicated when putting it into an item frame. I'll leave it to you to find and patch the cause for now.

Milk bucket gets duplicated when putting it into an item frame. I'll leave it to you to find and patch the cause for now.
Author
Contributor

Done

Done
the-real-herowl marked this conversation as resolved
@ -79,2 +79,4 @@
end
local function eat_stew_delayed(itemstack, user, pointed_thing)
-- Wrapper for handling mcl_hunger delayed eating

This function doesn't handle block right-click function when "placing". This results in not being able to put stews in itemframes, among other things. Look at or utilize the normal code for this maybe.

This function doesn't handle block right-click function when "placing". This results in not being able to put stews in itemframes, among other things. Look at or utilize the normal code for this maybe.
Author
Contributor

Done

Done
the-real-herowl marked this conversation as resolved
@ -42,0 +48,4 @@
mcl_hunger.eat_internal[name].replace_with_item = replace_with_item
mcl_hunger.eat_internal[name].itemstack = itemstack
mcl_hunger.eat_internal[name].user = user
mcl_hunger.eat_internal[name].pointed_thing = pointed_thing

Use table.update() (defined in mcl_util) when changing so many predefined fields in one table in one go.

Use `table.update()` (defined in mcl_util) when changing so many predefined fields in one table in one go.
Author
Contributor

Done

Done
the-real-herowl marked this conversation as resolved
@ -187,0 +289,4 @@
end
if not mcl_hunger.eat_internal[player_name].pitch then
mcl_hunger.eat_internal[player_name].pitch = 1 + math.random(-10, 10)*0.005

Out of curiosity, where is this formula from?

Out of curiosity, where is this formula from?
Member

And, can it be documented? Just trying to prevent "magic numbers" as in the future someone will come along, and wonder what the numbers specifically mean. A lot of the code has this, and when we have to do a rewrite it becomes really annoying.

And, can it be documented? Just trying to prevent "magic numbers" as in the future someone will come along, and wonder what the numbers specifically mean. A lot of the code has this, and when we have to do a rewrite it becomes really annoying.
Author
Contributor

The formula was always there before this PR. It was in lines 140 and 171 of /mods/PLAYER/mcl_hunger/hunger.lua previously.

This deals with randomizing the pitch each time a player eats from 0.95 to 1.05 but now that due to this PR the eating behavior will play those consecutively then the code was placed at the start of each eating session so that there is one chosen random pitch for the rest instead of randomizing all the sounds within one eating session.

Of course all of this is negated by the fact that there are two eating sound files that are chosen in random anyways (mcl_hunger_bite.1.ogg and mcl_hunger_bite.2.ogg) but the code is there if in the future the decision to opt for one sound per eating session is chosen.

The formula was always there before this PR. It was in lines 140 and 171 of /mods/PLAYER/mcl_hunger/hunger.lua previously. This deals with randomizing the pitch each time a player eats from 0.95 to 1.05 but now that due to this PR the eating behavior will play those consecutively then the code was placed at the start of each eating session so that there is one chosen random pitch for the rest instead of randomizing all the sounds within one eating session. Of course all of this is negated by the fact that there are **two** eating sound files that are chosen in random anyways (mcl_hunger_bite.1.ogg and mcl_hunger_bite.2.ogg) but the code is there if in the future the decision to opt for one sound per eating session is chosen.
the-real-herowl marked this conversation as resolved
the-real-herowl added the
items
#P3: elevated
player
labels 2024-01-20 03:26:39 +01:00
Eliy21 force-pushed eating_delay from 06962ebd95 to 5154dce8d0 2024-01-21 10:03:38 +01:00 Compare
Eliy21 requested review from the-real-herowl 2024-01-21 10:03:54 +01:00
the-real-herowl approved these changes 2024-01-25 03:05:57 +01:00
the-real-herowl merged commit 1175be45fb into master 2024-01-25 03:06:18 +01:00
Sign in to join this conversation.
No reviewers
No project
No Assignees
4 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: VoxeLibre/VoxeLibre#4144
No description provided.