fixed the mod not working on servers

closes #346
This commit is contained in:
Ell 2024-03-29 13:17:40 +01:00
parent 16582e6d25
commit 3ae1246ec6
2 changed files with 20 additions and 16 deletions

View file

@ -42,8 +42,11 @@ public class PacketClient implements CustomPacketPayload {
return PacketClient.ID; return PacketClient.ID;
} }
@SuppressWarnings("Convert2Lambda")
public static void onMessage(PacketClient message, PlayPayloadContext ctx) { public static void onMessage(PacketClient message, PlayPayloadContext ctx) {
ctx.workHandler().execute(() -> { ctx.workHandler().execute(new Runnable() {
@Override
public void run() {
var mc = Minecraft.getInstance(); var mc = Minecraft.getInstance();
if (mc.level != null) { if (mc.level != null) {
switch (message.type) { switch (message.type) {
@ -60,6 +63,7 @@ public class PacketClient implements CustomPacketPayload {
} }
} }
} }
}
}); });
} }

View file

@ -67,7 +67,7 @@ public class PacketParticles implements CustomPacketPayload {
public static void onMessage(PacketParticles message, PlayPayloadContext ctx) { public static void onMessage(PacketParticles message, PlayPayloadContext ctx) {
ctx.workHandler().execute(() -> { ctx.workHandler().execute(() -> {
Level level = Minecraft.getInstance().level; var level = ctx.level().orElseThrow();
if (level != null) if (level != null)
message.type.action.accept(message, level); message.type.action.accept(message, level);
}); });