Jump to content

[1.18.1] Automatically changing player skin and restoring the original player skin with item


Recommended Posts

Posted (edited)

I'm making a mod that is based on the anime Sword Art online and there is a Item called the <<Hand Mirror>> and when u use this item in the anime it changes you character design to how you look in real life I want to implement this in my mod but so that you start with a random skin and when you use the item it restores your own skin permanently. is this even possible? and how can I do that?

Edited by Leon Henning
  • Shimizu Izumi changed the title to [1.18.1] Automatically changing player skin and restoring the original player skin with item
  • 1 year later...
Posted
On 1/6/2022 at 5:19 PM, Shimizu Izumi said:

I'm making a mod that is based on the anime Sword Art online and there is a Item called the <<Hand Mirror>> and when u use this item in the anime it changes you character design to how you look in real life I want to implement this in my mod but so that you start with a random skin and when you use the item it restores your own skin permanently. is this even possible? and how can I do that?

https://github.com/Totis22/Change-players-skin-1.18.2/tree/main

Remember that in the main method for changing skin, it requires any boolean condition/s. If all conditions are true the skin changes, but if one condition is false, it changes you back to your original skin. 

 

If "start with random skin" means, change player's skin when they enter the world, just use the same ".renderSkin()" method in the RenderHandEvent, selecting a downloaded random skin from your mod, or interacting with a skins web page, then, when you hold the item, stop the .renderSkin

 

something like this:

@SubscribeEvent
    public static void randomSkinManagment(EntityJoinWorldEvent event) {
        if (event.getEntity() instanceof Player) {
            Player player = (Player) event.getEntity();
            skin = skins.get(rand.nextInt(skins.size()));
        }
    }
    @SubscribeEvent
    public static void playerHoldSword(TickEvent.PlayerTickEvent event) {
        if(event.player == null) return;
        Player player = event.player;
        if(player.getMainHandItem().is(Items.DIAMOND_SWORD)) {
            //save NBT Data to player: player.somewhereinNBTDATA.heldSword = true;
        }
    }
    @SubscribeEvent
    public static void renderSkinEvent(RenderLivingEvent event) {
        TotisCustomSkinRenderer.renderSkin(
                new ResourceLocation(Constants.MOD_ID, "textures/skins/" + skin + ".png"),
                event, event.getEntity(),
                false, player.somewhereinNBTDATA.heldSword == true);
    }

 

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.