diff --git a/src/main/java/baubles/api/expanded/BaubleExpandedSlots.java b/src/main/java/baubles/api/expanded/BaubleExpandedSlots.java index a367ced..e97dd44 100644 --- a/src/main/java/baubles/api/expanded/BaubleExpandedSlots.java +++ b/src/main/java/baubles/api/expanded/BaubleExpandedSlots.java @@ -1,6 +1,7 @@ package baubles.api.expanded; import java.util.ArrayList; +import java.util.Arrays; import baubles.api.BaubleType; import cpw.mods.fml.common.Loader; @@ -8,321 +9,342 @@ import cpw.mods.fml.common.LoaderState; public class BaubleExpandedSlots { - //The total number of slots that can be added. - //Please keep in mind that increases to this limit are possible with minimal changes. - public static final int slotLimit = 20; + //The total number of slots that can be added. + //Please keep in mind that increases to this limit are possible with minimal changes. + public static final int slotLimit = 20; - //The type used in place of null. - public static final String unknownType = "unknown"; + //The type used in place of null. + public static final String unknownType = "unknown"; - //Ppre-registered types. - public static final String ringType = "ring"; - public static final String amuletType = "amulet"; - public static final String beltType = "belt"; - public static final String headType = "head"; - public static final String bodyType = "body"; - public static final String charmType = "charm"; - public static final String capeType = "cape"; - public static final String shieldType = "shield"; - public static final String quiverType = "quiver"; - public static final String gauntletType = "gauntlet"; + //Ppre-registered types. + public static final String ringType = "ring"; + public static final String amuletType = "amulet"; + public static final String beltType = "belt"; + public static final String headType = "head"; + public static final String bodyType = "body"; + public static final String charmType = "charm"; + public static final String capeType = "cape"; + public static final String shieldType = "shield"; + public static final String quiverType = "quiver"; + public static final String gauntletType = "gauntlet"; - /** - * Registers a type and returns true if the type could be or has been registered. - * Types can only be registered while the loader state is pre-initialization. - * - * @param type The type to register. - * @return If a type was registered or had been registered previously. - */ - public static boolean tryRegisterType(String type) { - if(type != null && type.length() > 0) { - if(isTypeRegistered(type)) { - return true; - } else { - if(Loader.instance().getLoaderState() == LoaderState.PREINITIALIZATION) { - registeredTypes.add(type); - return true; - } - } - } - return false; - } + /** + * Registers a type and returns true if the type could be or has been registered. + * Types can only be registered while the loader state is pre-initialization. + * + * @param type The type to register. + * @return If a type was registered or had been registered previously. + */ + public static boolean tryRegisterType(String type) { + if(type != null && type.length() > 0) { + if(isTypeRegistered(type)) { + return true; + } else { + if(Loader.instance().getLoaderState() == LoaderState.PREINITIALIZATION) { + registeredTypes.add(type); + return true; + } + } + } + return false; + } - /** - * Returns false if the type is unregistered or unknown, the minimum number of - * assigned slots cannot be met, or the loader state is not pre-initialization. - * - * @param type The type of the slot to evaluate and possibly assign. - * @param minumumOfType The minimum slots of type to be assigned. - * - * @return If the total assigned slots of the specified type equals or is more than the minimum. - */ - public static boolean tryAssignSlotsUpToMinimum(String type, int minumumOfType) { - if(minumumOfType >= 1 && isTypeRegistered(type) && !type.equals(unknownType) && Loader.instance().getLoaderState() == LoaderState.PREINITIALIZATION) { - int total = 0; - for(int slotToCheck = 0; slotToCheck < slotLimit; slotToCheck++) { - if(assignedSlots[slotToCheck].equals(type)) { - total++; - } - } - if(total < minumumOfType) { - total = minumumOfType - total; - for(int i = 0; i < total; i++) { - if(newSlotsRemaining >= 1) { - assignedSlots[slotLimit - newSlotsRemaining] = type; - newSlotsRemaining--; - } else { - return false; - } - } - } else { - return true; - } - } - return false; - } + /** + * Returns false if the type is unregistered or unknown, the minimum number of + * assigned slots cannot be met, or the loader state is not pre-initialization. + * + * @param type The type of the slot to evaluate and possibly assign. + * @param minumumOfType The minimum slots of type to be assigned. + * + * @return If the total assigned slots of the specified type equals or is more than the minimum. + */ + public static boolean tryAssignSlotsUpToMinimum(String type, int minumumOfType) { + if(minumumOfType >= 1 && isTypeRegistered(type) && !type.equals(unknownType) && Loader.instance().getLoaderState() == LoaderState.PREINITIALIZATION) { + int total = 0; + for(int slotToCheck = 0; slotToCheck < slotLimit; slotToCheck++) { + if(assignedSlots[slotToCheck].equals(type)) { + total++; + } + } + if(total < minumumOfType) { + total = minumumOfType - total; + for(int i = 0; i < total; i++) { + if(newSlotsRemaining >= 1) { + assignedSlots[slotLimit - newSlotsRemaining] = type; + newSlotsRemaining--; + } else { + return false; + } + } + } else { + return true; + } + } + return false; + } - /** - * Returns false if the type is unregistered or unknown, or the - * loader state is not pre-initialization. - * - * @param type The type of the slot to evaluate and possibly unassign. - * @param minumumOfType The minimum slots of type to be assigned. - * - * @return If the total assigned slots of the specified type equals or is less then the maximum. - */ - public static boolean tryUnassignSlotsDownToMaximum(String type, int maximumOfType) { - if(maximumOfType < 0) maximumOfType = 0; - if(isTypeRegistered(type) && !type.equals(unknownType) && Loader.instance().getLoaderState() == LoaderState.PREINITIALIZATION) { - int total = 0; - for(int slotToCheck = 0; slotToCheck < slotLimit; slotToCheck++) { - if(assignedSlots[slotToCheck].equals(type)) { - total++; - } - } - if(total > maximumOfType) { - total -= maximumOfType; - for(int i = 0; i < total; i++) { - for(int slotToCheck = slotsCurrentlyUsed(); slotToCheck > 0; slotToCheck--) { - if(assignedSlots[slotToCheck].equals(type)) { - for(int slotToMove = slotToCheck + 1; slotToMove < slotLimit; slotToMove++) { - assignedSlots[slotToMove - 1] = assignedSlots[slotToMove]; - } - assignedSlots[slotLimit - 1] = unknownType; - newSlotsRemaining++; - break; - } - } - } - } - return true; - } - return false; - } + /** + * Returns false if the type is unregistered or unknown, or the + * loader state is not pre-initialization. + * + * @param type The type of the slot to evaluate and possibly unassign. + * @param minumumOfType The minimum slots of type to be assigned. + * + * @return If the total assigned slots of the specified type equals or is less then the maximum. + */ + public static boolean tryUnassignSlotsDownToMaximum(String type, int maximumOfType) { + if(maximumOfType < 0) maximumOfType = 0; + if(isTypeRegistered(type) && !type.equals(unknownType) && Loader.instance().getLoaderState() == LoaderState.PREINITIALIZATION) { + int total = 0; + for(int slotToCheck = 0; slotToCheck < slotLimit; slotToCheck++) { + if(assignedSlots[slotToCheck].equals(type)) { + total++; + } + } + if(total > maximumOfType) { + total -= maximumOfType; + for(int i = 0; i < total; i++) { + for(int slotToCheck = slotsCurrentlyUsed(); slotToCheck > 0; slotToCheck--) { + if(assignedSlots[slotToCheck].equals(type)) { + for(int slotToMove = slotToCheck + 1; slotToMove < slotLimit; slotToMove++) { + assignedSlots[slotToMove - 1] = assignedSlots[slotToMove]; + } + assignedSlots[slotLimit - 1] = unknownType; + newSlotsRemaining++; + break; + } + } + } + } + return true; + } + return false; + } - /** - * Returns if a slot was assigned successfully. - * Does not assign a type to a slot if the type is unregistered, no slots - * are free, or the loader state is not pre-initialization. - * - * @param type The type to attempt assigning to a slot. - * - * @return If assigning a type to a slot was successful or not. - */ - public static boolean tryAssignSlotOfType(String type) { - if(newSlotsRemaining >= 1 && isTypeRegistered(type) && !type.equals(unknownType) && Loader.instance().getLoaderState() == LoaderState.PREINITIALIZATION) { - assignedSlots[slotLimit - newSlotsRemaining] = type; - newSlotsRemaining--; - return true; - } else { - return false; - } - } + /** + * Returns if a slot was assigned successfully. + * Does not assign a type to a slot if the type is unregistered, no slots + * are free, or the loader state is not pre-initialization. + * + * @param type The type to attempt assigning to a slot. + * + * @return If assigning a type to a slot was successful or not. + */ + public static boolean tryAssignSlotOfType(String type) { + if(newSlotsRemaining >= 1 && isTypeRegistered(type) && !type.equals(unknownType) && Loader.instance().getLoaderState() == LoaderState.PREINITIALIZATION) { + assignedSlots[slotLimit - newSlotsRemaining] = type; + newSlotsRemaining--; + return true; + } else { + return false; + } + } /** - * Unassigns the last slot of the specified type if one can be found - * and the loader state is pre-initialization. - * - * @param type The type of the slot to be unassigned. - * - * @return If unassigning a slot was successful or not. - */ - public static boolean tryUnassignSlotOfType(String type) { - if(newSlotsRemaining < slotLimit && type != null && !type.equals(unknownType) && Loader.instance().getLoaderState() == LoaderState.PREINITIALIZATION) { - for(int slotToCheck = slotsCurrentlyUsed(); slotToCheck > 0; slotToCheck--) { - if(assignedSlots[slotToCheck].equals(type)) { - for(int slotToMove = slotToCheck + 1; slotToMove < slotLimit; slotToMove++) { - assignedSlots[slotToMove - 1] = assignedSlots[slotToMove]; - } - assignedSlots[slotLimit - 1] = unknownType; - newSlotsRemaining++; - return true; - } - } - } - return false; - } + * Unassigns the last slot of the specified type if one can be found + * and the loader state is pre-initialization. + * + * @param type The type of the slot to be unassigned. + * + * @return If unassigning a slot was successful or not. + */ + public static boolean tryUnassignSlotOfType(String type) { + if(newSlotsRemaining < slotLimit && type != null && !type.equals(unknownType) && Loader.instance().getLoaderState() == LoaderState.PREINITIALIZATION) { + for(int slotToCheck = slotsCurrentlyUsed(); slotToCheck > 0; slotToCheck--) { + if(assignedSlots[slotToCheck].equals(type)) { + for(int slotToMove = slotToCheck + 1; slotToMove < slotLimit; slotToMove++) { + assignedSlots[slotToMove - 1] = assignedSlots[slotToMove]; + } + assignedSlots[slotLimit - 1] = unknownType; + newSlotsRemaining++; + return true; + } + } + } + return false; + } - /** - * Returns the current number of slots with a matching type. - * - * @param type The type of slot being counted. - * - * @return The current total slots with a matching type assigned. - */ - public static int totalCurrentlyAssignedSlotsOfType(String type) { - int total = 0; - if(isTypeRegistered(type)) { - for(int slotToCheck = 0; slotToCheck < slotLimit; slotToCheck++) { - if(assignedSlots[slotToCheck].equals(type)) { - total++; - } - } - } - return total; - } + /** + * Returns the current number of slots with a matching type. + * + * @param type The type of slot being counted. + * + * @return The current total slots with a matching type assigned. + */ + public static int totalCurrentlyAssignedSlotsOfType(String type) { + int total = 0; + if(isTypeRegistered(type)) { + for(int slotToCheck = 0; slotToCheck < slotLimit; slotToCheck++) { + if(assignedSlots[slotToCheck].equals(type)) { + total++; + } + } + } + return total; + } - /** - * Returns if the type is registered or not. - * - * @param type The type to check the registration of. - * - * @return If the type is registered or not. - */ - public static boolean isTypeRegistered(String type) { - return registeredTypes.contains(type); - } + /** + * Returns an array of slot indexis that have the specified type assigned. + * Do not treat results from this as final until postinit or later. + * + * @param type The type of slot being checked. + * + * @return an array of slot indexes with the specified type. + */ + public static int[] getIndexesOfAssignedSlotsOfType(String type) { + int slotIndexes[] = new int[0]; + if(isTypeRegistered(type)) { + for(int slotToCheck = 0; slotToCheck < slotLimit; slotToCheck++) { + if(assignedSlots[slotToCheck].equals(type)) { + slotIndexes = Arrays.copyOf(slotIndexes, slotIndexes.length + 1); + slotIndexes[slotIndexes.length - 1] = slotToCheck; + } + } + } + return slotIndexes; + } - /** - * Returns the number of bauble slots that are currently used. - * - * @return The number of bauble slots currently used. - */ - public static int slotsCurrentlyUsed() { - return slotLimit - newSlotsRemaining; - } + /** + * Returns if the type is registered or not. + * + * @param type The type to check the registration of. + * + * @return If the type is registered or not. + */ + public static boolean isTypeRegistered(String type) { + return registeredTypes.contains(type); + } - /** - * Returns the number of bauble slots that are currently unused. - * - * @return The number of bauble slots currently unused. - */ - public static int slotsCurrentlyUnused() { - return newSlotsRemaining; - } + /** + * Returns the number of bauble slots that are currently used. + * + * @return The number of bauble slots currently used. + */ + public static int slotsCurrentlyUsed() { + return slotLimit - newSlotsRemaining; + } - /** - * Returns the type of the specified slot, "unknown" if out of range. - * - * @param slot The slot to check - * @return The type of the specified slot or unknown. - */ - public static String getSlotType(int slot) { - if (slot >= 0 & slot < slotLimit) { - return assignedSlots[slot]; - } else { - return unknownType; - } - } + /** + * Returns the number of bauble slots that are currently unused. + * + * @return The number of bauble slots currently unused. + */ + public static int slotsCurrentlyUnused() { + return newSlotsRemaining; + } - /** - * Returns the index of a certain type in the registeredType array - * or -1 if it cannot be found. - * - * @param type The type to get the index of - * @return Index of a type or negative one - */ - public static int getIndexOfTypeInRegisteredTypes(String type) { - return registeredTypes.indexOf(type); - } + /** + * Returns the type of the specified slot, "unknown" if out of range. + * + * @param slot The slot to check + * @return The type of the specified slot or unknown. + */ + public static String getSlotType(int slot) { + if (slot >= 0 & slot < slotLimit) { + return assignedSlots[slot]; + } else { + return unknownType; + } + } - /** - * Returns the currently registered bauble types. - * If pre-initialization is done this list is effectively final. - * - * @return The currently registered bauble types. - */ - public static ArrayList getCurrentlyRegisteredTypes() { - return registeredTypes; - } + /** + * Returns the index of a certain type in the registeredType array + * or -1 if it cannot be found. + * + * @param type The type to get the index of + * @return Index of a type or negative one + */ + public static int getIndexOfTypeInRegisteredTypes(String type) { + return registeredTypes.indexOf(type); + } - /** - * Returns the current slot assignments as a string array. - * If initialization is done this list is effectively final. - * - * @return The current contents of the slots array. - */ - public static String[] getCurrentSlotAssignments() { - return assignedSlots; - } + /** + * Returns the currently registered bauble types. + * If pre-initialization is done this list is effectively final. + * + * @return The currently registered bauble types. + */ + public static ArrayList getCurrentlyRegisteredTypes() { + return registeredTypes; + } - /** - * Returns a type based on the specified BaubleType. - * - * @param type The BaubleType to get a matching type from. - * - * @return The type matching the BaubleType or unknown. - */ - public static String getTypeFromBaubleType(BaubleType type) { - switch(type) { - case RING: - return ringType; - case AMULET: - return amuletType; - case BELT: - return beltType; - default: - return unknownType; - } - } + /** + * Returns the current slot assignments as a string array. + * If initialization is done this list is effectively final. + * + * @return The current contents of the slots array. + */ + public static String[] getCurrentSlotAssignments() { + return assignedSlots; + } - /** - * This is only intended to be used by the Baubles manualSlotSelection config option, if it is enabled. - * Overrides assigned slots with the contents of a string array. - * Any entry that would go over slotLimit is ignored. - * If an array is shorter than slotLimit all remaining slots are set to unknown. - * Invalid slot types are set to unknown. - * - * @param overrideSlots The array to override assigned slots with. - */ - public static void overrideSlots(String[] overrideSlots) { - if(Loader.instance().getLoaderState() == LoaderState.INITIALIZATION) { - newSlotsRemaining = 0; - for(int slot = 0; slot < slotLimit; slot++) { - if(slot < overrideSlots.length && isTypeRegistered(overrideSlots[slot])) { - assignedSlots[slot] = overrideSlots[slot]; - newSlotsRemaining++; - } else { - assignedSlots[slot] = unknownType; - } - } - } - } + /** + * Returns a type based on the specified BaubleType. + * + * @param type The BaubleType to get a matching type from. + * + * @return The type matching the BaubleType or unknown. + */ + public static String getTypeFromBaubleType(BaubleType type) { + switch(type) { + case RING: + return ringType; + case AMULET: + return amuletType; + case BELT: + return beltType; + default: + return unknownType; + } + } - private static int newSlotsRemaining; - private static String[] assignedSlots = 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(capeType); - registeredTypes.add(shieldType); - registeredTypes.add(quiverType); - registeredTypes.add(gauntletType); + /** + * This is only intended to be used by the Baubles manualSlotSelection config option, if it is enabled. + * Overrides assigned slots with the contents of a string array. + * Any entry that would go over slotLimit is ignored. + * If an array is shorter than slotLimit all remaining slots are set to unknown. + * Invalid slot types are set to unknown. + * + * @param overrideSlots The array to override assigned slots with. + */ + public static void overrideSlots(String[] overrideSlots) { + if(Loader.instance().getLoaderState() == LoaderState.INITIALIZATION) { + newSlotsRemaining = 0; + for(int slot = 0; slot < slotLimit; slot++) { + if(slot < overrideSlots.length && isTypeRegistered(overrideSlots[slot])) { + assignedSlots[slot] = overrideSlots[slot]; + newSlotsRemaining++; + } else { + assignedSlots[slot] = unknownType; + } + } + } + } - assignedSlots[0] = amuletType; - assignedSlots[1] = ringType; - assignedSlots[2] = ringType; - assignedSlots[3] = beltType; - newSlotsRemaining = slotLimit - 4; - for(int slot = 4; slot < slotLimit; slot++) { - assignedSlots[slot] = unknownType; - } - } + private static int newSlotsRemaining; + private static String[] assignedSlots = 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(capeType); + registeredTypes.add(shieldType); + registeredTypes.add(quiverType); + registeredTypes.add(gauntletType); + + assignedSlots[0] = amuletType; + assignedSlots[1] = ringType; + assignedSlots[2] = ringType; + assignedSlots[3] = beltType; + newSlotsRemaining = slotLimit - 4; + for(int slot = 4; slot < slotLimit; slot++) { + assignedSlots[slot] = unknownType; + } + } } diff --git a/src/main/java/baubles/api/package-info.java b/src/main/java/baubles/api/package-info.java index 40421b5..43babf1 100644 --- a/src/main/java/baubles/api/package-info.java +++ b/src/main/java/baubles/api/package-info.java @@ -1,4 +1,4 @@ -@API(owner = "Baubles", apiVersion = "2.0.0", provides = "Baubles|API") +@API(owner = "Baubles", apiVersion = "2.0.1", provides = "Baubles|API") package baubles.api; import cpw.mods.fml.common.API; diff --git a/src/main/java/baubles/common/Baubles.java b/src/main/java/baubles/common/Baubles.java index 90619c4..4c9bbb0 100644 --- a/src/main/java/baubles/common/Baubles.java +++ b/src/main/java/baubles/common/Baubles.java @@ -28,7 +28,7 @@ public class Baubles { public static final String MODID = "Baubles"; public static final String MODNAME = "Baubles"; - public static final String VERSION = "2.0.0"; + public static final String VERSION = "GRADLETOKEN_VERSION"; @SidedProxy(clientSide = "baubles.client.ClientProxy", serverSide = "baubles.common.CommonProxy") public static CommonProxy proxy; diff --git a/src/main/java/baubles/common/ItemDebugger.java b/src/main/java/baubles/common/ItemDebugger.java index 98bf554..f4e9631 100644 --- a/src/main/java/baubles/common/ItemDebugger.java +++ b/src/main/java/baubles/common/ItemDebugger.java @@ -2,11 +2,14 @@ package baubles.common; import java.util.List; +import org.lwjgl.input.Keyboard; + import baubles.api.BaubleType; import baubles.api.expanded.BaubleExpandedSlots; import baubles.api.expanded.IBaubleExpanded; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.client.gui.GuiScreen; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.entity.EntityLivingBase; @@ -14,105 +17,116 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.util.IIcon; +import net.minecraft.util.StatCollector; public class ItemDebugger extends Item implements IBaubleExpanded { - public ItemDebugger() { - super(); - this.setMaxStackSize(1); - this.setHasSubtypes(true); - setCreativeTab(BaublesConfig.hideDebugItem ? null : CreativeTabs.tabTools); - } + public ItemDebugger() { + super(); + this.setMaxStackSize(1); + this.setHasSubtypes(true); + setCreativeTab(BaublesConfig.hideDebugItem ? null : CreativeTabs.tabTools); + } - @SideOnly(Side.CLIENT) - private IIcon[] icons; - - @SideOnly(Side.CLIENT) - @Override - public void registerIcons(IIconRegister ir) { - 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)); - } - } - - @SideOnly(Side.CLIENT) - @Override - public IIcon getIconFromDamage(int meta) { - return icons[meta >= icons.length ? 0 : meta]; - } - - @SideOnly(Side.CLIENT) - @Override - public void getSubItems(Item item, CreativeTabs tab, List list) { + @SideOnly(Side.CLIENT) + private IIcon[] icons; + + @SideOnly(Side.CLIENT) + @Override + public void registerIcons(IIconRegister ir) { + icons = new IIcon[BaubleExpandedSlots.getCurrentlyRegisteredTypes().size()]; for(int i = 0; i < icons.length; i++) { - list.add(new ItemStack(this, 1, i)); + icons[i] = ir.registerIcon("baubles:empty_bauble_slot_" + BaubleExpandedSlots.getCurrentlyRegisteredTypes().get(i)); } - } + } - @Override - public String[] getBaubleTypes(ItemStack itemStack) { - String type; - int meta = itemStack.getItemDamage(); - if(meta <= 0 || meta > icons.length) { - type = BaubleExpandedSlots.unknownType; - } else { - type = BaubleExpandedSlots.getCurrentlyRegisteredTypes().get(meta); - } - return new String[] {type}; - } + @SideOnly(Side.CLIENT) + @Override + public IIcon getIconFromDamage(int meta) { + return icons[meta >= icons.length ? 0 : meta]; + } - @Override - public BaubleType getBaubleType(ItemStack itemStack) { - return null; - } + @SideOnly(Side.CLIENT) + @Override + public void getSubItems(Item item, CreativeTabs tab, List list) { + for(int i = 0; i < icons.length; i++) { + list.add(new ItemStack(this, 1, i)); + } + } - public void addInformation(ItemStack itemStack, EntityPlayer player, List list, boolean par4) { - list.add("Usable bauble slot types:"); - for(String type : getBaubleTypes(itemStack)) { - list.add(type); - } - } + @Override + public String[] getBaubleTypes(ItemStack itemStack) { + String type; + int meta = itemStack.getItemDamage(); + if(meta <= 0 || meta > icons.length) { + type = BaubleExpandedSlots.unknownType; + } else { + type = BaubleExpandedSlots.getCurrentlyRegisteredTypes().get(meta); + } + return new String[] {type}; + } - @Override - public void onWornTick(ItemStack itemStack, EntityLivingBase player) { - } + @Override + public BaubleType getBaubleType(ItemStack itemStack) { + return null; + } - @Override - public boolean hasEffect(ItemStack itemStack, int a) { - return true; - } + @SideOnly(Side.CLIENT) + @Override + public void addInformation(ItemStack stack, EntityPlayer player, List tooltip, boolean debug) { + if(GuiScreen.isShiftKeyDown()) { + tooltip.add(StatCollector.translateToLocal("tooltip.compatibleslots")); - @Override - public String getUnlocalizedName(ItemStack itemStack) { - return super.getUnlocalizedName();// + "." + itemStack.getItemDamage(); - } + String[] types = getBaubleTypes(stack); + for(int i = 0; i < types.length; i++) { + String type = StatCollector.translateToLocal("slot." + types[i]); + if(i < types.length - 1) type += ","; + tooltip.add(type); + } + } else { + tooltip.add(StatCollector.translateToLocal("tooltip.shiftprompt").replaceAll("%key%", Keyboard.getKeyName(42))); + } + } - @Override - public void onEquipped(ItemStack itemStack, EntityLivingBase player) { - } + @Override + public void onWornTick(ItemStack itemStack, EntityLivingBase player) { + } - @Override - public void onUnequipped(ItemStack itemStack, EntityLivingBase player) { - } + @Override + public boolean hasEffect(ItemStack itemStack, int a) { + return true; + } - @Override - public boolean canEquip(ItemStack itemStack, EntityLivingBase player) { - return true; - } + /*@Override + public String getUnlocalizedName(ItemStack itemStack) { + return super.getUnlocalizedName() + "." + itemStack.getItemDamage(); + }*/ - @Override - public boolean canUnequip(ItemStack itemStack, EntityLivingBase player) { - return true; - } - - @SideOnly(Side.CLIENT) - public IIcon getBackgroundIconForSlotType(String type) { - if(type != null && BaubleExpandedSlots.isTypeRegistered(type)) { - return icons[BaubleExpandedSlots.getIndexOfTypeInRegisteredTypes(type)]; - } else { - return icons[0]; - } - } + @Override + public void onEquipped(ItemStack itemStack, EntityLivingBase player) { + } + + @Override + public void onUnequipped(ItemStack itemStack, EntityLivingBase player) { + } + + @Override + public boolean canEquip(ItemStack itemStack, EntityLivingBase player) { + return true; + } + + @Override + public boolean canUnequip(ItemStack itemStack, EntityLivingBase player) { + return true; + } + + @SideOnly(Side.CLIENT) + public IIcon getBackgroundIconForSlotType(String type) { + if(type != null && BaubleExpandedSlots.isTypeRegistered(type)) { + return icons[BaubleExpandedSlots.getIndexOfTypeInRegisteredTypes(type)]; + } else { + return icons[0]; + } + } } diff --git a/src/main/resources/assets/baubles/lang/en_US.lang b/src/main/resources/assets/baubles/lang/en_US.lang index 4536e97..9bcafe3 100644 --- a/src/main/resources/assets/baubles/lang/en_US.lang +++ b/src/main/resources/assets/baubles/lang/en_US.lang @@ -1,5 +1,5 @@ # -# ITEMS +# Items item.baubleSlotDebugTool.name=Bauble Slot Debug Tool # # GUI @@ -7,4 +7,21 @@ button.baubles=Baubles button.normal=Normal # # Keybinding -keybind.baublesinventory=Baubles Inventory \ No newline at end of file +keybind.baublesinventory=Baubles Inventory +# +# Tooltips +tooltip.compatibleslots=Equippable in the following Bauble slots: +tooltip.shiftprompt=Hold §b%key%§7 for more info. +# +# Slots +slot.amulet=§aAmulet§7 +slot.belt=§aBelt§7 +slot.body=§aBody§7 +slot.cape=§aCape§7 +slot.charm=§aCharm§7 +slot.gauntlet=§aGauntlet§7 +slot.head=§aHead§7 +slot.quiver=§aQuiver§7 +slot.ring=§aRing§7 +slot.shield=§aShield§7 +slot.unknown=§aUnknown§7