Merge pull request #2729 from Lucwousin/varb-thing
mixins: add getVarbitCount and warn instead of throw when varb doesnt exist
This commit is contained in:
@@ -809,6 +809,11 @@ public interface Client extends GameShell
|
||||
*/
|
||||
void setVarbitValue(int[] varps, int varbit, int value);
|
||||
|
||||
/**
|
||||
* @return the total number of VarbitDefinition
|
||||
*/
|
||||
int getVarbitCount();
|
||||
|
||||
/**
|
||||
* Gets the widget flags table.
|
||||
*
|
||||
|
||||
@@ -16,6 +16,8 @@ import net.runelite.rs.api.RSVarbitDefinition;
|
||||
@Mixin(RSClient.class)
|
||||
public abstract class VarbitMixin implements RSClient
|
||||
{
|
||||
private static final int VARBITS_GROUP = 14;
|
||||
|
||||
@Shadow("client")
|
||||
private static RSClient client;
|
||||
|
||||
@@ -69,7 +71,8 @@ public abstract class VarbitMixin implements RSClient
|
||||
|
||||
if (v.getIndex() == 0 && v.getLeastSignificantBit() == 0 && v.getMostSignificantBit() == 0)
|
||||
{
|
||||
throw new IndexOutOfBoundsException("Varbit " + varbitId + " does not exist");
|
||||
getLogger().debug("Varbit {} doesn't exist!", varbitId);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int value = varps[v.getIndex()];
|
||||
@@ -152,4 +155,11 @@ public abstract class VarbitMixin implements RSClient
|
||||
{
|
||||
return getVarcs().getVarcMap();
|
||||
}
|
||||
|
||||
@Inject
|
||||
@Override
|
||||
public int getVarbitCount()
|
||||
{
|
||||
return getConfigArchive().getGroupFileCount(VARBITS_GROUP);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,4 +7,7 @@ public interface RSAbstractArchive extends IndexDataBase
|
||||
{
|
||||
@Import("takeFile")
|
||||
byte[] getConfigData(int archiveId, int fileId);
|
||||
|
||||
@Import("getGroupFileCount")
|
||||
int getGroupFileCount(int group);
|
||||
}
|
||||
|
||||
@@ -457,6 +457,9 @@ public interface RSClient extends RSGameShell, Client
|
||||
@Import("SpriteBuffer_spritePalette")
|
||||
void setIndexedSpritePalette(int[] indexedSpritePalette);
|
||||
|
||||
@Import("archive2")
|
||||
RSArchive getConfigArchive();
|
||||
|
||||
@Import("archive6")
|
||||
RSArchive getMusicTracks();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user