Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix/hotbar index out of bounds #5931

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ public boolean onTouchEvent(MotionEvent event) {
mDropGesture.cancel();
return true;
}
int hotbarIndex = (int)MathUtils.map(x, 0, mWidth, 0, HOTBAR_KEYS.length);
int hotbarIndex = (int)MathUtils.map(x, 0, mWidth, 0, HOTBAR_KEYS.length - 1);
// Check if the slot changed and we need to make a key press
if(hotbarIndex == mLastIndex) {
// Only check for doubletapping if the slot has not changed
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ public void setStateLimited(ModItem item) {
drawable.setCornerRadius(mCornerDimensionCache * bm.getHeight());
mIconView.setImageDrawable(drawable);
};
mIconCache.getImage(mImageReceiver, mModItem.getIconCacheTag(), mModItem.imageUrl);
if (mModItem.imageUrl != null) mIconCache.getImage(mImageReceiver, mModItem.getIconCacheTag(), mModItem.imageUrl);
mSourceView.setImageResource(getSourceDrawable(item.apiSource));
mTitle.setText(item.title);
mDescription.setText(item.description);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,12 +79,19 @@ public SearchResult searchMod(SearchFilters searchFilters, SearchResult previous
Log.i("CurseforgeApi", "Skipping modpack "+dataElement.get("name").getAsString() + " because curseforge sucks");
continue;
}
String logoUrl;
try {
logoUrl = dataElement.getAsJsonObject("logo").get("thumbnailUrl").getAsString();
} catch (Exception e) {
Log.e("error", Tools.printToString(e));
logoUrl = null;
}
ModItem modItem = new ModItem(Constants.SOURCE_CURSEFORGE,
searchFilters.isModpack,
dataElement.get("id").getAsString(),
dataElement.get("name").getAsString(),
dataElement.get("summary").getAsString(),
dataElement.getAsJsonObject("logo").get("thumbnailUrl").getAsString());
logoUrl);
modItemList.add(modItem);
}
if(curseforgeSearchResult == null) curseforgeSearchResult = new CurseforgeSearchResult();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package net.kdt.pojavlaunch.modloaders.modpacks.api;

import android.util.Log;

import com.google.gson.JsonArray;
import com.google.gson.JsonObject;
import com.kdt.mcgui.ProgressLayout;
Expand Down Expand Up @@ -64,13 +66,20 @@ public SearchResult searchMod(SearchFilters searchFilters, SearchResult previous
ModItem[] items = new ModItem[responseHits.size()];
for(int i=0; i<responseHits.size(); ++i){
JsonObject hit = responseHits.get(i).getAsJsonObject();
String iconUrl;
try {
iconUrl = hit.get("icon_url").getAsString();
} catch (Exception e) {
Log.e("error", Tools.printToString(e));
iconUrl = null;
}
items[i] = new ModItem(
Constants.SOURCE_MODRINTH,
hit.get("project_type").getAsString().equals("modpack"),
hit.get("project_id").getAsString(),
hit.get("title").getAsString(),
hit.get("description").getAsString(),
hit.get("icon_url").getAsString()
iconUrl
);
}
if(modrinthSearchResult == null) modrinthSearchResult = new ModrinthSearchResult();
Expand Down
Loading