Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (โ‹ฎ) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

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

Featured Replies

Posted

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...
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...

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions โ†’ Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.