ghostwolf_ Posted February 22, 2018 Share Posted February 22, 2018 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. 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? Quote Link to comment Share on other sites More sharing options...
ghostwolf_ Posted February 25, 2018 Author Share Posted February 25, 2018 Bump Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.