#changing player skin through packets
1 messages ยท Page 1 of 1 (latest)
I've worked out so far ClientboundRespawnPacket packet = new ClientboundRespawnPacket(nmsLevel.dimensionTypeId(), nmsLevel.dimension(), nmsLevel.getSeed(), npc.gameMode.getGameModeForPlayer(), null, false, false, true, null);
No clue how the respawn packet does anything. It has no reference to the player at all
@grim pumice ^
wow thank you very much!
It's because the respawn packet is just for the player in question itself; so like if i send a respawn packet to your client, your client will think it has information to fetch about urself
(i think)
ah ok
so that would do 4)
ServerLevel taken from World
I use my own utils to avoid CraftBukkit imports, so for me it ServerLevel nmsWorld = (ServerLevel) NMSUtils.getServerLevel(location.getWorld());
My NMSUtils https://paste.md-5.net/ciseyazosu.java
thank you so much !! i'll try and tell you
@lament zenith hmm the more i get into it, the more i feel i'm heading into a really hacky stuff
https://i.imgur.com/6KhGqrf.png
cuz yeah they advise to send 2 respawn packets to prevent bugs
give me a sec to test
I'm getting a null error, but I am doing it in the join event, well 20 ticks delayed
ah seems it requires the last field
aha lastdeath?
this is how u must change skin
public static void changeSkin(ServerPlayer player, String texture, String signature){
GameProfile profile = player.getGameProfile();
profile.getProperties().removeAll("textures");
profile.getProperties().put("textures", new Property("textures", texture, signature));
}```
texture + sig
the PlayerTextures.setSkin(...) is for npc
yeah I was trying a quick way and giving a url
yeah someone confirmed me that PlayerTextures.setSkin(URL) will not put a signed skin whatever url u put
don't forget: before changing skin, playerinfopacket 'remove' ur player, after changing skin, playerinfopack "add" ur player
that shouldn;t be required just for yourself
ah yeah
on the second link in the first post of this thread, someone said that:
https://i.imgur.com/TJrMeWJ.png
all that is very confusing ๐
Tell me if u got sth working, i'm trying to fix my compiler once again lmao
got it working
was teh instant I logged in. I just did it in the join event
it should be instant
its literally 1 packet
can u try to change it while already connected? (so u can see ur skin change live)
yep
tysm
rrespawn packet?
yes
i see
I'm going to put a delay on applying the skin for 100 ticks so I can log in first
I'm doing a broadcast when it tries to set it
oki
i feel like "playerjoinevent" is part of "preparing the player instance" and therefore it works
hmmm
I just have to find the packet I'm missing
new ClientboundPlayerInfoPacket(ClientboundPlayerInfoPacket.Action.REMOVE_PLAYER, player)
I'm trying just add
yeah
add player.updateInventory(); at the very end
not ServerPlayer but bukkit player
it's what they did in the 2nd link of the first post of this thread
amazing
if u have an axe in hand (or whatever tool with cooldown)
While it sends the respawn packet, does your tool refresh?
like do some kind of animation off cooldown
(cuz as i'm planning for animated skin, that would be a bit offsetting to have constantly cooldown animation xd)
I was in 3rd person view and it does flash teh screen once
no idea on animations though
aha
this is everything to change your own skin. It won;t update for others though```java
public void changeSkin(Player player, String[] skin) {
Bukkit.broadcastMessage("Setting Skin for " + player.getName());
ServerPlayer serverPlayer = (ServerPlayer) NMSUtils.getServerPlayer(player);
ServerLevel nmsLevel = serverPlayer.getLevel();
GlobalPos pos = GlobalPos.of(nmsLevel.dimension(), serverPlayer.blockPosition());
setSkin(serverPlayer, skin);
ClientboundPlayerInfoPacket playerInfoAdd = new ClientboundPlayerInfoPacket(ClientboundPlayerInfoPacket.Action.ADD_PLAYER, serverPlayer);
ClientboundRespawnPacket respawn = new ClientboundRespawnPacket(nmsLevel.dimensionTypeId(), nmsLevel.dimension(), nmsLevel.getSeed(), serverPlayer.gameMode.getGameModeForPlayer(), null, false, false, true, Optional.of(pos));
serverPlayer.connection.send(playerInfoAdd);
serverPlayer.connection.send(respawn);
player.updateInventory();
}
private void setSkin(ServerPlayer player, String[] skin) {
String texture = skin[0];
String signature = skin[1];
player.getGameProfile().getProperties().removeAll("textures");
player.getGameProfile().getProperties().put("textures", new Property("textures", texture, signature));
}```
๐
it's irritating to do blind coding xd (having hard time with fken gradle)
Yeah I have so many test projects setup for this purpose but I also use Maven so simpler
i wish i could but with paperweight (for nms basically) u need gradle i think
It also helps I only finished yesterday messing about with NPC/fake player creation
I have the head pitch wrong at teh moment, but thats all