Jump to content

Recommended Posts

Posted (edited)

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 by iYM8jXCs3pcvblTE
Posted in the wrong board
Posted
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.

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

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.