Jump to content

Babatunde

Members
  • Posts

    15
  • Joined

  • Last visited

Everything posted by Babatunde

  1. Intellij IDEA Ultimate. Oh nice! completely forgot about that line lmao. This is what I've got so far, I'm kinda stuck because I have no idea what to do: public class ChangeTabListEvents { private final Field fieldPlayers = ObfuscationReflectionHelper.findField(SPlayerListItemPacket.class, "field_179769_b"); private final Field fieldDisplayName = ObfuscationReflectionHelper.findField(SPlayerListItemPacket.AddPlayerData.class, "field_179965_e"); @SubscribeEvent public void onPlayerLogin(PlayerEvent.PlayerLoggedInEvent event) { PlayerEntity player = event.getPlayer(); if (player.getServer() != null) { try { } catch (Throwable e) { e.printStackTrace(); } player.getServer().getPlayerList().sendPacketToAllPlayers(new SPlayerListItemPacket(SPlayerListItemPacket.Action.UPDATE_DISPLAY_NAME, (ServerPlayerEntity) player)); player.sendMessage(new KeybindTextComponent("Display name updated.")); } } } Do I need to get the list somehow, or do I need to make my own and set my list as the players list? And why do I need the 'displayName'? Thanks for the help so far, I appreciate it!
  2. refreshDisplayName is from 1.12.2. A lot is the documentation is outdated. Thanks, I forgot that existed. I'm sorry, I've never worked with packets before. is there a tutorial or documentation on how to create packets?
  3. So, I've looked at reflection together with a friend of mine, but we could get it to work. We now have this: @SubscribeEvent public void onPlayerLogin(EntityJoinWorldEvent event) { if (event.getEntity() instanceof PlayerEntity) { PlayerEntity player = (PlayerEntity) event.getEntity(); if (player.getServer() != null) { ForgeEventFactory.getPlayerDisplayName(player, player.getGameProfile().getName()); try { Field field = ObfuscationReflectionHelper.findField(SPlayerListItemPacket.class, "field_179769_b"); } catch (Throwable e) { e.printStackTrace(); } player.getServer().getPlayerList().sendPacketToAllPlayers(new SPlayerListItemPacket(SPlayerListItemPacket.Action.UPDATE_DISPLAY_NAME, (ServerPlayerEntity) player)); player.sendMessage(new KeybindTextComponent("Display name updated.")); } } } field_179769_b = players from: private final List<SPlayerListItemPacket.AddPlayerData> players = Lists.newArrayList(); from the SPlayerListItemPacket class. That is the entries you were talking about right? But we don't know wat to do now. P.S. I'm still using the ForgeEventFactory because getDisplayname() wouldn't fire the even for some reason... Help would be much apriciated, thanks.
  4. That doesn't seem to work for me 🤔 This is what I got rn: public class ChangeTabListEvents { @SubscribeEvent public void onNameFormat(PlayerEvent.NameFormat event) { if (event.getEntity() instanceof PlayerEntity) { event.setDisplayname(event.getUsername() + " (" + event.getPlayer().getMaxHealth() + ")"); event.getEntity().sendMessage(new KeybindTextComponent("NameFormat event fired.")); } } @SubscribeEvent public void onPlayerLogin(EntityJoinWorldEvent event) { if (event.getEntity() instanceof PlayerEntity) { PlayerEntity player = (PlayerEntity) event.getEntity(); if (player.getServer() != null) { ForgeEventFactory.getPlayerDisplayName(player, player.getGameProfile().getName()); player.getServer().getPlayerList().sendPacketToAllPlayers(new SPlayerListItemPacket(SPlayerListItemPacket.Action.UPDATE_DISPLAY_NAME)); player.sendMessage(new KeybindTextComponent("Display name updated.")); } } } }
  5. How would I do this? I've never worked with packets before.
  6. Im not very familiar with client side mods but this should do the job: returns true if player is in Creative: Minecraft.getInstance().player.isCreative(); returns true if player is in Spectator: Minecraft.getInstance().player.isSpectator(); returns String of serverIP: Minecraft.getInstance().getCurrentServerData().serverIP;
  7. Hi everyone, I want to add a suffix to every players name, but I cant get it to work. I'm doing it like this: @SubscribeEvent public void onNameFormat(PlayerEvent.NameFormat event) { if (event.getEntity() instanceof PlayerEntity) { event.setDisplayname(event.getUsername() + " test"); } } If I use event.getDisplayname() it shows the name + test, but it doesn't change on the tab list. Do I need to somehow update the tab list for it to work or am I doing it completely wrong? Thanks!
  8. Hi Modders, I'm working on a mod where a player starts with 1 heart and every time they die they gain a heart until they have 10 hearts. But I struggling with how I save the amount a hearts the player has. If I put it in the player data, it will be deleted when the player dies. Same goes for capabilities. I've tried it with a Hashmap but I know its not the best way of doing thing so I'd like some feedback from you guys. Thanks.
  9. Hi Modders, I'm working on a mod where a player starts with 1 heart and every time they die they gain a heart until they have 10 hearts. But I struggling with how I save the amount a hearts the player has. If I put it in the player data, it will be deleted when the player dies. Same goes for capabilities. I've tried it with a Hashmap but I know its not the best way of doing thing so I'd like some feedback from you guys. Thanks. EDIT: I'm using 1.15.2 and 1.14.4.
  10. Ye, I've tried everything I could think of and I have done hours of research.
  11. I don't think there is a way to get the number of deaths with ServerPlayerEntity#getStats either
  12. You cant get the amount of deaths using the Stats class
  13. Hello Modders, Is there a way to get the number of deaths a player has from his statistics? MC version 1.15.2 I have been looking for a solution for hours but I cant find the answer.
×
×
  • Create New...

Important Information

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