Jump to content

How to correctly get the player that sent a message to the server


Recommended Posts

Posted (edited)

Hi!

I am sending a message to the server from the player using this:

PacketHandler.instance.send(PacketDistributor.SERVER.noArg(), new SWeightMessage(intWeight));

When it arrives it updates the player's capability like so.

@Override
	public void handle(SWeightMessage message, Supplier<Context> supplier) {
		supplier.get().enqueueWork(() -> {
			supplier.get().getSender().getCapability(WeightProvider.WEIGHT_CAP).ifPresent(w -> {
				w.set(message.weight);
			});
		});

		supplier.get().setPacketHandled(true);

	}

The issue is that this is changing the Weight of EVERY player to this value and I have no idea why. Any help would be greatly appreciated!

 

This message is fired from the client everytime they equip or unequip an item of armor or join the world.

Edited by squidlex

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.