meteor-client
meteor-client copied to clipboard
Some events should not be instanced
Describe the bug
An instanced event's fields can change mid processing because of async tasks (example: processing something on main thread while network thread is sending packets) or the event itself. This affects all events that are instantiated and have fields.
This can lead to weird things like the event not being cancelled or in this case event.packet getting changed.
Steps to reproduce
private boolean recursionFix = false;
@EventHandler
private void onPacketSend(PacketEvent.Send event) {
if (recursionFix) return;
recursionFix = true;
Packet<?> packet = event.packet;
event.setCancelled(true);
// can be any packet
mc.getNetworkHandler().sendPacket(new HandSwingC2SPacket(Hand.MAIN_HAND));
System.out.println(event.packet.getClass());
if (event.packet != packet || !event.isCancelled()) {
throw new RuntimeException();
}
recursionFix = false;
}
Meteor Version
0.5.8-2156
Minecraft Version
1.21.1
Operating System
Windows
Before submitting a bug report
-
[X] This bug wasn't already reported (I have searched bug reports on GitHub).
-
[X] This is a valid bug (I am able to reproduce this on the latest dev build).