Jump to content

iYM8jXCs3pcvblTE

Members
  • Posts

    30
  • Joined

  • Last visited

Recent Profile Visitors

5499 profile views

iYM8jXCs3pcvblTE's Achievements

Tree Puncher

Tree Puncher (2/8)

0

Reputation

  1. 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.
  2. 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.
  3. 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.
  4. 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.
  5. Yes, although I'm currently studying, I still feel like my current basics are terrible.
  6. When I get the player's entity data, I don't seem to find the 'sethealth' method, and I'm not sure if this is because I'm overlooking him. When I try to look at 'LivingEntity', I find that it is an abstract class and I may not be able to instantiate 'LivingEntity' directly. But currently I hold the entity data provided by the player when he enters the game, I can try to inherit 'LivingEntity' and use the entity data as a parameter to try to modify the target's health.
  7. I thought I could instantiate 'LivingEntity', but I realized later that 'LivingEntity' is an abstract class that I can't instantiate.' LivingEntity' seems to require me to provide an entity's data for 'LivingEntity' to work. Currently I've got the player entity data by listening to the player login. But currently I'm looking for a way to change their properties through this data. The code is as follows main.java package com.AJ.LifeShareing;; import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.LivingEntity; import net.minecraftforge.event.entity.living.LivingHurtEvent; import net.minecraftforge.event.entity.player.PlayerEvent; import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.common.Mod; @Mod(Utils.MOD_ID) @Mod.EventBusSubscriber() public class Main { public static Entity [] playerList = new Entity[10]; public static int length = 0; @SubscribeEvent public static void getPlayerList(PlayerEvent.PlayerLoggedInEvent event){ GetPlayerList getPlayerList = new GetPlayerList(); length = GetPlayerList.getPlayerList(event.getEntity(),playerList,length); } @SubscribeEvent public static void setHealth(LivingHurtEvent event){ } } getPlayerList.java package com.AJ.LifeShareing; import net.minecraft.world.entity.Entity; public class GetPlayerList { public static int getPlayerList(Entity player,Entity [] playerList,int length) { for (int i = 0; i == length; i++) { System.out.println("aaaaaaaaaaaaaaaaaaaa" + i); if (player != playerList[i]) { if (i == length) { playerList[i] = player; System.out.println("jjjjjjjjjjjjjj" + playerList[i]); length++; break; } } else { break; } } return length; } }
  8. In 'LivingEntity', regarding the 'entity' parameter, should I fill in the player's entity information?
  9. Hi, The 'LivingEntity' class I tried to instantiate before and then I found out that it is an abstract class. I tried to create a new class to inherit from 'LivingEntity' but I found that it seems that the class I inherit from cannot modify/get data about 'LivingEntity'. It is possible that I am trying the wrong way, I will try again later to create a new class and inherit the class from 'LivingEntity'. I will get back to you with the results.
  10. This code seems to have generated an error when I entered the translation device, please wait while I correct it.
  11. I'm sorry, I just read the following and I may not have expressed myself clearly. I see that 'Attributes.MAX_HEALTH' is the maximum health, can this method/parameter be used to set the current health of a player? If combined with my usage scenario. If a player takes damage (this listener I have implemented to listen to all entities taking damage), then the other players will take the same damage (no change in max health). When a player health reverts (this listener I have implemented to listen for all entities health reverting), then the other players will also revert the same health. Above is the first question: How should I change the current health of other players/self? I get the 'event.getEntity()' injured entity in the event that listens to an entity that is injured, which could also be the entity that caused the injury, I'm still testing that at the moment. Since not all entities need to be injured, I need to execute my code. For example, if I inflict damage on a zombie, I don't need to execute this code. So I added a judgment below the event, but I don't know how to determine an 'Entity' parameter. My current idea is that I listen for events where a player enters the world, and then when a player enters the world, I get that player's entity. Then I put the entity data into an array, and then I determine in the judgment whether the injured entity data is the same as a member of the array. The specific code is as follows for (int i = 0;i < PlayerListArrays.length;i++){ if (event.getEntity() == PlayerListArrays[i]){ } } I know this code may not execute for various reasons, as this is just a rough idea that I have not implemented yet.
  12. Hello, guys. My goal is to change the health of all other players after listening to the health change of one player. I am currently listening to the progress of the entity's health change with the help of all of you. The code is as follows @SubscribeEvent public static void demo04(LivingHurtEvent event){ } In this listener event, I can use 'setAmount' to change the damage caused by this event. I can also use 'getAmount' to get the value of the damage caused by this event. But I've searched the source code of this event/class for a long time, but I still can't find a way to change the health of myself or other players. I only found a way to change health in the 'minecraft' game.(net.minecraft.world.entity.LivingEntity) setHealth public void setHealth(float p_21154_) But when I want to call it, I find that I don't have the parameter needed for this method. The parameter could be the player's parameter or the target entity's parameter. I'm not sure, I'm still double checking this source code. Ultimately, my question is whether there is a more convenient class/event/method for 'forge' to change the player's health. If this idea doesn't fit, are there other ways to achieve the same goal.
  13. Mr. diesieben07 und Mr. Luis_ST. Ich danke Ihnen für Ihre Geduld. Erst jetzt habe ich gelernt, dass "Listen Events" als Parameter zurückgegeben werden, also habe ich auch gelernt, dass man Methoden direkt mit Parametern aufrufen kann. Ich stelle den Ereigniscode zur Verfügung, weil es sich um ein geringfügiges Problem handelt und ich ein sehr schlechter Fragesteller wäre, wenn Sie auch für dieses Problem den Ereigniscode selbst durchgehen müssten. Ich verwende derzeit ein Übersetzungsgerät, um mit Ihnen zu kommunizieren, daher werden viele Wörter nicht klar und deutlich zu verstehen sein, und ich entschuldige mich für etwaige Missverständnisse. Ich bin Ihnen beiden dankbar, dass Sie sich trotz Ihres vollen Terminkalenders die Zeit genommen haben, um meine Fragen zu beantworten. Ich gebe Ihnen beiden ein Dankeschön, um meine Dankbarkeit auszudrücken. Ich danke Ihnen nochmals. :):)
  14. Thanks for the tip, I managed to get the data I wanted in the return parameters of the listened event. Here is part of the code @SubscribeEvent public static void Demo02(LivingHurtEvent event) { System.out.println("sadawedawdawdawdadwa" + '\n' + event.getAmount()); }
  15. It occurred to me. Can I get the data I want by getting the parameters of the event instantiation.
×
×
  • Create New...

Important Information

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