mirror of
https://github.com/GTNewHorizons/Baubles-Expanded.git
synced 2026-11-21 04:22:17 +00:00
Polished slot icon handling
This commit is contained in:
1 parent
50a9b2a161
commit
a42d1e3d6c
5 files changed
+15
-13
No files matched your search
@@ -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<String> registeredTypes = new ArrayList<String>();
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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];
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user