Posted July 19, 20232 yr Hello, Mr./Ms. My current requirement is to perform some behavior if the player's oxygen value decreases and some other behavior if the player's oxygen increases. I didn't find an event that `listened to the player's oxygen value` change, so I used `TickEvent.ClientTickEvent` to try to listen to each player's oxygen change per tick. I tried to get the instance of the player using `getEntity` and looked for methods related to oxygen in it, I found `getAirSupply` and `setAirSupply` methods. These two methods do allow me to modify the player's oxygen, but if the player is in air, minecraft automatically restores 1 oxygen per tick, and when flooded, minecraft makes the player consume 1 oxygen per tick. If I want my Mod to rigorously reduce the player's oxygen based on my conditions, can I just calculate and write multiple `if` judgments to rigorously reduce the player's oxygen? Or does `forge` provide a way to cancel the `oxygen consumed/increased` event? Like canceling the injury event. I realized that my topic might be posted in the wrong block and I didn't find the function to delete and lock it. I will post the topic in the correct block and request that the topic that was posted wrong will be locked. Edited July 20, 20232 yr by iYM8jXCs3pcvblTE Posted in the wrong board
July 19, 20232 yr Author 4 minutes ago, iYM8jXCs3pcvblTE said: Hello, Mr./Ms. My current requirement is to perform some behavior if the player's oxygen value decreases and some other behavior if the player's oxygen increases. I didn't find an event that `listened to the player's oxygen value` change, so I used `TickEvent.ClientTickEvent` to try to listen to each player's oxygen change per tick. I tried to get the instance of the player using `getEntity` and looked for methods related to oxygen in it, I found `getAirSupply` and `setAirSupply` methods. These two methods do allow me to modify the player's oxygen, but if the player is in air, minecraft automatically restores 1 oxygen per tick, and when flooded, minecraft makes the player consume 1 oxygen per tick. If I want my Mod to rigorously reduce the player's oxygen based on my conditions, can I just calculate and write multiple `if` judgments to rigorously reduce the player's oxygen? Or does `forge` provide a way to cancel the `oxygen consumed/increased` event? Like canceling the injury event. Addendum: What I said about strictly consuming the player's oxygen is the behavior of my Mod. For example, I need to consume 3 oxygen per tick, but if the player is in air, the player will only actually consume 2 oxygen. And if I need to regain 4 oxygen per tick, but if the player is in water, the player will actually only regain 3 oxygen.
July 20, 20232 yr Author 21 hours ago, iYM8jXCs3pcvblTE said: Addendum: What I said about strictly consuming the player's oxygen is the behavior of my Mod. For example, I need to consume 3 oxygen per tick, but if the player is in air, the player will only actually consume 2 oxygen. And if I need to regain 4 oxygen per tick, but if the player is in water, the player will actually only regain 3 oxygen. Hello Sir/Madam I realized that my topic might be posted in the wrong block and I didn't find the function to delete and lock it. I will post the topic in the correct block and request that the topic that was posted wrong will be locked.
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.