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.

Featured Replies

Posted

Hey guys im trying to add a bunch of cosmetic armor slots to the player, where if there is an armor present it will override your actual armor texture. so you can wear the fancy armor for show and wear your normal armor for its effectiveness.

 

i found the cosmetic armor reworked mod, and looked at its source code to get an idea of how they did it link to its source.

but it feels very hacky to me and not a good way to go about it. so im hoping anyone here knows a better way.

 

ItemStackHandler localInv = new ItemStackHandler (4);
		
		private void SwapInv (EntityPlayer p) {
			if (p.hasCapability(CapabilityCosmeticArmor.Cosmetic_Armor_Capability, null) && p.inventory.armorInventory.size() <= 4 ) {
		    	   IItemHandler cosInv = p.getCapability(CapabilityCosmeticArmor.Cosmetic_Armor_Capability, null);
		    	   for (int i = 0; i < cosInv.getSlots(); i++) {
		    		   localInv.insertItem(i, cosInv.extractItem(i, 1, false), false);
		    	   }
		    	   
		    	   NonNullList<ItemStack> armor =  p.inventory.armorInventory;
		    	   for (int i = 0; i < armor.size(); i++) {
		    		   cosInv.insertItem(cosInv.getSlots() - 1 - i, armor.get(i), false);
		    	   }
		    	   
		    	   for (int i = 0; i < localInv.getSlots(); i++) {
		    		   armor.set(localInv.getSlots() - i - 1, localInv.extractItem(i, 1, false));
		    	   }
		       }
		}
		
		@SubscribeEvent
	    public void handleCanceledEvent(RenderPlayerEvent.Pre event)
	    {
			
	    }

	    @SubscribeEvent
	    public void handleEvent(RenderPlayerEvent.Post event)
	    {
			SwapInv(event.getEntityPlayer());

	        
	    }

	    @SubscribeEvent
	    public void handleEvent(RenderPlayerEvent.Pre event)
	    {
			SwapInv(event.getEntityPlayer());


	    }

 

this is my current code, and it kinda works. it has some sync issues but thats because i havent added the packet handling yet for the Capability i added. to sync it between clients.

 

2018-02-22_03_04_09.thumb.png.7acd285bd1e476757003a505bed256e5.png

this is what it looks like in game, i render the armor on the right and i have the armor on the left equipped.but right now every time the render player event gets called the items in those slots get swapped and then swapped back after. is there a smoother way of doing this?

 

 

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.