Skip to content
Open
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
7 changes: 7 additions & 0 deletions Common/src/main/java/com/hrznstudio/emojiful/CommonClass.java
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,13 @@ public static String cleanURL(String string){
public static void onRecipesUpdated(RecipeManager manager) {
ClientEmojiHandler.CATEGORIES.removeIf(EmojiCategory::worldBased);
Constants.EMOJI_LIST.removeIf(Emoji::worldBased);
// lambda so we dont iterate twice
Constants.EMOJI_MAP.entrySet().removeIf(e -> {
// first wipe datapack emojis
e.getValue().removeIf(Emoji::worldBased);
// then let the category be wiped if no emojis left in it
return e.getKey().isEmpty();
});
if (Services.CONFIG.loadDatapack()) {
RecipeType<EmojiRecipe> emojiRecipeRecipeType = Services.PLATFORM.getRecipeType();
List<EmojiRecipe> emojiList = manager.getAllRecipesFor(emojiRecipeRecipeType).stream().map(RecipeHolder::value).toList();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ public class EmojiSelectionGui extends IDrawableGuiListener {
private final Rect2i categorySelectionArea;
private final Rect2i emojiInfoArea;
private final Rect2i textFieldRectangle;
private final int categoriesPerScroll = 7;
private int selectionPointer;
private int categoryPointer;
private int openSelectionAreaEmoji;
Expand Down Expand Up @@ -98,7 +99,7 @@ public void render(GuiGraphics guiGraphics) {
progressY = (int) (((this.categorySelectionArea.getHeight() - 10) / ((double) ClientEmojiHandler.CATEGORIES.size() - 7)) * (categoryPointer));
drawRectangle(guiGraphics, new Rect2i(this.categorySelectionArea.getX() + this.categorySelectionArea.getWidth() - 2, this.categorySelectionArea.getY() + progressY + 2, 1, 5), 0xff525252);
EmojiCategory firstCategory = getCategory(selectionPointer);
for (int i = 0; i < 7; i++) {
for (int i = 0; i < Math.min(categoriesPerScroll, Constants.EMOJI_MAP.size()); i++) {
int selCategory = i + categoryPointer;
if (selCategory < ClientEmojiHandler.CATEGORIES.size()) {
EmojiCategory category = ClientEmojiHandler.CATEGORIES.get(selCategory);
Expand Down Expand Up @@ -128,7 +129,7 @@ public boolean mouseClicked(double mouseX, double mouseY, int p_231044_5_) {
if (this.showingSelectionArea) {
fieldWidget.setFocused(textFieldRectangle.contains((int) mouseX, (int) mouseY));
if (categorySelectionArea.contains((int) mouseX, (int) mouseY)) {
for (int i = 0; i < 7; i++) {
for (int i = 0; i < Math.min(categoriesPerScroll, Constants.EMOJI_MAP.size()); i++) {
int selCategory = i + categoryPointer;
if (selCategory < ClientEmojiHandler.CATEGORIES.size()) {
Rect2i rec = new Rect2i(categorySelectionArea.getX() + 6, categorySelectionArea.getY() + 6 + i * 12, 11, 11);
Expand All @@ -145,7 +146,7 @@ public boolean mouseClicked(double mouseX, double mouseY, int p_231044_5_) {
return true;
}
if (selectionArea.contains((int) mouseX, (int) mouseY)) {
for (int line = 0; line < 6; line++) {
for (int line = 0; line < Math.min(categoriesPerScroll, Constants.EMOJI_MAP.size()) - 1; line++) {
Object object = getLineToDraw(line + selectionPointer);
if (object instanceof Emoji[]) {
Emoji[] emojis = (Emoji[]) object;
Expand Down Expand Up @@ -178,13 +179,13 @@ public void mouseMoved(double mouseX, double mouseY) {
public boolean mouseScrolled(double mouseX, double mouseY, double delta, double d) {
if (categorySelectionArea.contains((int) mouseX, (int) mouseY)) {
categoryPointer -= d;
categoryPointer = Mth.clamp(categoryPointer, 0, ClientEmojiHandler.CATEGORIES.size() - 7);
categoryPointer = Mth.clamp(categoryPointer, 0, ClientEmojiHandler.CATEGORIES.size() - Math.min(categoriesPerScroll, Constants.EMOJI_MAP.size()));
return true;
}
if (selectionArea.contains((int) mouseX, (int) mouseY)) {
selectionPointer -= d;
selectionPointer = Mth.clamp(selectionPointer, 1, Math.max(1, getLineAmount() - 5));
categoryPointer = Mth.clamp(Arrays.asList(ClientEmojiHandler.CATEGORIES).indexOf(getCategory(selectionPointer)), 0, ClientEmojiHandler.CATEGORIES.size() - 7);
categoryPointer = Mth.clamp(Arrays.asList(ClientEmojiHandler.CATEGORIES).indexOf(getCategory(selectionPointer)), 0, ClientEmojiHandler.CATEGORIES.size() - Math.min(categoriesPerScroll, Constants.EMOJI_MAP.size()));
return true;
}
return false;
Expand Down