You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
privatestaticintsequential = 0;
privatevoidrequestFakePlayer(PlayerInteractEvent.RightClickItemevent) {
if (event.getEntity() instanceofServerPlayerplayer && player.level() instanceofServerLevellevel) {
// This one does NOT leaked because when you have// the same UUID as player you grab the same advancement// so this FakePlayer is not added to Criteria Triggers listenersif (event.getItemStack().getItem() == Items.STONE) {
varfakePlayer = FakePlayerFactory.get(level, player.getGameProfile());
reportFakePlayerCreated(player, fakePlayer);
}
// This one leaks, fails the uuid check and generate new PlayerAdvancements// triggering Criteria listenersif (event.getItemStack().getItem() == Items.STICK) {
vargameProfile = newGameProfile(UUID.randomUUID(), "FakePlayer" + sequential++);
varfakePlayer = FakePlayerFactory.get(level, gameProfile);
reportFakePlayerCreated(player, fakePlayer);
}
// This also leaks, fails the uuid check and generate new PlayerAdvancements// triggering Criteria listenersif (event.getItemStack().getItem() == Items.ACACIA_BUTTON) {
varfakePlayer = FakePlayerFactory.getMinecraft(level);
reportFakePlayerCreated(player, fakePlayer);
}
}
}
privatestaticvoidreportFakePlayerCreated(ServerPlayerplayer, FakePlayerfakePlayer) {
player.sendSystemMessage(Component.translatable("FakePlayer %s created with profile: %s", fakePlayer.getDisplayName(), fakePlayer.getGameProfile().toString()));
}
Code for reference
Grab one of the 3 items (stone, stick, acacia button) to test
Use it
Leave world, come back, check objects
Description of issue: Comments in code
I have seen a lot of modders do not use same UUID as the player, and from what I tested, if you fakePlayer.getAdvancements().stopListening() it bandaid fixes this issue.
The text was updated successfully, but these errors were encountered:
Minecraft Version: 1.21.1
NeoForge Version: 21.1.22
Logs:
Steps to Reproduce:
Description of issue:
Comments in code
I have seen a lot of modders do not use same UUID as the player, and from what I tested, if you
fakePlayer.getAdvancements().stopListening()
it bandaid fixes this issue.The text was updated successfully, but these errors were encountered: