neoforged / Documentation

The repository containing Neo's documentation
MIT License
23 stars 36 forks source link

SimpleImpl out of date #30

Closed elifoster closed 5 months ago

elifoster commented 7 months ago

Packet handler is no longer passed a Supplier<NetworkEvent.Context> it is passed the NetworkEvent.Context directly.

public static void handle(MyMessage msg, Supplier<NetworkEvent.Context> ctx) {
  ctx.get().enqueueWork(() -> {
    // Work that needs to be thread-safe (most work)
    ServerPlayer sender = ctx.get().getSender(); // the client that sent this packet
    // Do stuff
  });
  ctx.get().setPacketHandled(true);
}

becomes

public static void handle(MyMessage msg, NetworkEvent.Context ctx) {
  ctx.enqueueWork(() -> {
    // Work that needs to be thread-safe (most work)
    ServerPlayer sender = ctx.getSender(); // the client that sent this packet
    // Do stuff
  });
  ctx.setPacketHandled(true);
}

Unsure if anything else there needs updating.

ChampionAsh5357 commented 5 months ago

Closed by rewrite via #42