Skip to content

Commit

Permalink
fix(neoforge): Fix wrong packet class being sent
Browse files Browse the repository at this point in the history
  • Loading branch information
BlayTheNinth committed Jan 15, 2024
1 parent ecbb9e2 commit bca5eb3
Showing 1 changed file with 2 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -212,19 +212,10 @@ public <T> void registerServerboundPacket(ResourceLocation identifier, Class<T>
registrations.messagesByIdentifier.put(identifier, messageRegistration);
}

@SuppressWarnings("unchecked")
private <T> void sendPacket(PacketDistributor.PacketTarget target, T message) {
MessageRegistration<T> messageRegistration = getMessageRegistrationOrThrow(message);
target.send(new CustomPacketPayload() {
@Override
public void write(FriendlyByteBuf buf) {
messageRegistration.getEncodeFunc().accept(message, buf);
}

@Override
public ResourceLocation id() {
return messageRegistration.getIdentifier();
}
});
target.send(new WrappedPacket(messageRegistration.getIdentifier(), message, (BiConsumer<Object, FriendlyByteBuf>) messageRegistration.getEncodeFunc()));
}

public void register(String modId, IEventBus eventBus) {
Expand Down

0 comments on commit bca5eb3

Please sign in to comment.