Cosmetic Armor Reworked

Cosmetic Armor Reworked

109M Downloads

API usage of setSkinArmor

snakehugo opened this issue ยท 5 comments

commented

I'm using CosmeticArmorReworked-1.16.5-v5 in both server and clients.

When calling setSkinArmor(3, true) I can hide the player's helmet but other players will not see that change. Also it doesn't save it at disconnect/reconnect. So it might be an issue on the API not sending informations to the server and that could explain both of this issues. Let me know what can we do about this.

Also do you have a discord server, it might be more usefull to use that to communicate?

commented

Thanks, it solved it! I didn't know that we had to deal with packets, didn't see the comment in code

commented

With this code:
CAStacksBase invCosArmor = CosArmorAPI.getCAStacksClient(player.getUniqueID());
if(invCosArmor.isSkinArmor(3)) // helmet is hidden
{
invCosArmor.setSkinArmor(3, false);
}
else
{
invCosArmor.setSkinArmor(3, true);
}

commented

As stated here, you should only make changes on server side.
If you need to make changes on client side, you will need to manually send sync packets yourself, and make sure your changes is invoked on the correct thread.

I do not have a Discord server.

commented

I don't get it. My system is like this:
Players can hit a key to open a menu and if they click on a button on this menu, it will call
CAStacksBase invCosArmor = CosArmorAPI.getCAStacksClient(player.getUniqueID()); if(invCosArmor.isSkinArmor(3)) // helmet is hidden { invCosArmor.setSkinArmor(3, false); } else { invCosArmor.setSkinArmor(3, true); }

To toggle the visibility of the helmet. And it works fine for the player perspective, but other players won't see any changes.

So it is like your buttons that we have to click to show each of the slots but it doesn't work properly with the API (1.16.5-v5)

I want to call your code but not use your inventory buttons. Is that not the right code to use? I'm confused, I'm really sorry to bother you with that. Sorry again

commented

Basically, if your button executes code on client side, you need this ModObjects.network.sendToServer(new PacketSetSkinArmor(3, invCosArmor.isSkinArmor(3))) after setSkinArmor().
And, if your button executes code on server side, you don't need to do that.