From a42d1e3d6cb47124f3be66a5e40ab974e0e8a07a Mon Sep 17 00:00:00 2001 From: jss2a98aj Date: Fri, 5 Nov 2021 15:20:09 -0400 Subject: [PATCH] Polished slot icon handling --- .../api/expanded/BaubleExpandedSlots.java | 12 ++++++++---- src/main/java/baubles/common/ItemDebugger.java | 16 +++++++--------- .../textures/items/empty_bauble_slot_cape.png | Bin 120 -> 120 bytes .../items/empty_bauble_slot_gauntlet.png | Bin 141 -> 141 bytes .../textures/items/empty_bauble_slot_shield.png | Bin 0 -> 166 bytes 5 files changed, 15 insertions(+), 13 deletions(-) create mode 100644 src/main/resources/assets/baubles/textures/items/empty_bauble_slot_shield.png diff --git a/src/main/java/baubles/api/expanded/BaubleExpandedSlots.java b/src/main/java/baubles/api/expanded/BaubleExpandedSlots.java index ab35797..9a55644 100644 --- a/src/main/java/baubles/api/expanded/BaubleExpandedSlots.java +++ b/src/main/java/baubles/api/expanded/BaubleExpandedSlots.java @@ -11,7 +11,7 @@ public class BaubleExpandedSlots { public static final int slotLimit = 20; //Fallback for if a slot type cannot be found - public static final String unknown = "unknown"; + public static final String unknownType = "unknown"; //All "default" types will be registered automatically. public static final String ringType = "ring"; public static final String amuletType = "amulet"; @@ -19,25 +19,30 @@ public class BaubleExpandedSlots { public static final String headType = "head"; public static final String bodyType = "body"; public static final String charmType = "charm"; + public static final String shieldType = "shield"; public static final String gauntletType = "gauntlet"; public static final String capeType = "cape"; private static String[] slots = new String[slotLimit]; private static ArrayList registeredTypes = new ArrayList(); static { + registeredTypes.add(unknownType); registeredTypes.add(ringType); registeredTypes.add(amuletType); registeredTypes.add(beltType); registeredTypes.add(headType); registeredTypes.add(bodyType); registeredTypes.add(charmType); + registeredTypes.add(shieldType); registeredTypes.add(gauntletType); registeredTypes.add(capeType); } private static int newSlotsRemaining = slotLimit; //TODO: Sort slots, locked after post init + //TODO: Prevent items in the wrong slot from applying effects //TODO: Lock removing slots added during pre init + //TODO: Option to show all slots /** * Tries to add a new slot type if the loader state is currently @@ -59,7 +64,6 @@ public class BaubleExpandedSlots { return registeredTypes.indexOf(type); } - /** * Returns if the type is registered or not. * @@ -162,7 +166,7 @@ public class BaubleExpandedSlots { if (slot >= 0 & slot < slotLimit) { return slots[slot]; } else { - return unknown; + return unknownType; } } @@ -181,7 +185,7 @@ public class BaubleExpandedSlots { case BELT: return beltType; default: - return unknown; + return unknownType; } } diff --git a/src/main/java/baubles/common/ItemDebugger.java b/src/main/java/baubles/common/ItemDebugger.java index 1025f3b..5937bab 100644 --- a/src/main/java/baubles/common/ItemDebugger.java +++ b/src/main/java/baubles/common/ItemDebugger.java @@ -37,11 +37,9 @@ public class ItemDebugger extends Item implements IBaubleExpanded { @SideOnly(Side.CLIENT) @Override public void registerIcons(IIconRegister ir) { - icons = new IIcon[1 + BaubleExpandedSlots.getCurrentlyRegisteredTypes().size()]; - icons[0] = ir.registerIcon("baubles:empty_bauble_slot_unknown"); - - for(int i = 1; i < icons.length; i++) { - icons[i] = ir.registerIcon("baubles:empty_bauble_slot_" + BaubleExpandedSlots.getCurrentlyRegisteredTypes().get(i - 1)); + icons = new IIcon[BaubleExpandedSlots.getCurrentlyRegisteredTypes().size()]; + for(int i = 0; i < icons.length; i++) { + icons[i] = ir.registerIcon("baubles:empty_bauble_slot_" + BaubleExpandedSlots.getCurrentlyRegisteredTypes().get(i)); } } @@ -63,10 +61,10 @@ public class ItemDebugger extends Item implements IBaubleExpanded { public String[] getBaubleTypes(ItemStack itemStack) { String type; int meta = itemStack.getItemDamage(); - if(meta <= 0 || meta >= icons.length) { - type = BaubleExpandedSlots.unknown; + if(meta <= 0 || meta > icons.length) { + type = BaubleExpandedSlots.unknownType; } else { - type = BaubleExpandedSlots.getCurrentlyRegisteredTypes().get(meta - 1); + type = BaubleExpandedSlots.getCurrentlyRegisteredTypes().get(meta); } return new String[] {type}; } @@ -118,7 +116,7 @@ public class ItemDebugger extends Item implements IBaubleExpanded { @SideOnly(Side.CLIENT) public IIcon getBackgroundIconForSlotType(String type) { if(type != null && BaubleExpandedSlots.isTypeRegistered(type)) { - return icons[1 + BaubleExpandedSlots.indexOfTypeInRegisteredTypes(type)]; + return icons[BaubleExpandedSlots.indexOfTypeInRegisteredTypes(type)]; } else { return icons[0]; } diff --git a/src/main/resources/assets/baubles/textures/items/empty_bauble_slot_cape.png b/src/main/resources/assets/baubles/textures/items/empty_bauble_slot_cape.png index a9d28f82224f10072010e0a4933744c1ce63113a..b89b6adf175d5ace1fd8ff9781aff640e00b5732 100644 GIT binary patch delta 15 Wcmb=Zn4rThsi4GmQSbOfV^;tr?gZoj delta 15 Wcmb=Zn4rVXz`ziC=yKgeV^;tss0Aee diff --git a/src/main/resources/assets/baubles/textures/items/empty_bauble_slot_gauntlet.png b/src/main/resources/assets/baubles/textures/items/empty_bauble_slot_gauntlet.png index b0b532360e677c3d65cd60261acb27ba0e03040e..61206dd2f3579a5d9473aba7e6b9741deebb6c7a 100644 GIT binary patch delta 17 YcmeBW>}8yw!!D_y#CB2d_(bC<04gg5B>(^b delta 17 YcmeBW>}8yw!_L6K5PIlx-9+Ok04n7LW&i*H diff --git a/src/main/resources/assets/baubles/textures/items/empty_bauble_slot_shield.png b/src/main/resources/assets/baubles/textures/items/empty_bauble_slot_shield.png new file mode 100644 index 0000000000000000000000000000000000000000..fa12e4333843a3075d3ec7f612114f2f4612939d GIT binary patch literal 166 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`xt=bLAr`0CP7V}u5ae*Z-DaQs zzxqu7y(?3nT=cPjB`2uWjX literal 0 HcmV?d00001