Skip to content

Commit

Permalink
Merge pull request #5 from FTBTeam/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
desht authored Mar 22, 2024
2 parents e5ec274 + ee1c846 commit 6135b75
Show file tree
Hide file tree
Showing 30 changed files with 271 additions and 137 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Java CI - Build on Push

on:
push:
branches: [ main, dev, "1.*" ]
branches: [ main, dev, "1.**" ]
workflow_dispatch:
inputs:
skip_maven_publish:
Expand Down
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,9 @@ run
custom.gradle
.architectury-transformer/debug.log
common/src/generated/.cache/*
**/extra-mods-*/

# Files from bad operating systems :^)
Thumbs.db
.DS_Store
.architectury-transformer
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [2.0.1]

* Ported to MC 1.20.4. Supports Forge, NeoForge & Fabric.

## [1.0.2]


Expand Down
10 changes: 8 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import me.modmuss50.mpp.ReleaseType

plugins {
id "architectury-plugin" version "3.4-SNAPSHOT"
id "dev.architectury.loom" version "1.3-SNAPSHOT" apply false
id "dev.architectury.loom" version "1.5-SNAPSHOT" apply false
id "me.modmuss50.mod-publish-plugin" version "0.4.5"
}

Expand Down Expand Up @@ -113,12 +113,18 @@ publishMods {

curseforge("forge") {
from curseOptions
modLoaders.add("neoforge")
modLoaders.add("forge")
file = project(":forge").tasks.remapJar.archiveFile
displayName = "[FORGE] FTB Filter System ${mod_version} MC ${minecraft_version}"
}

curseforge("neoforge") {
from curseOptions
modLoaders.add("neoforge")
file = project(":neoforge").tasks.remapJar.archiveFile
displayName = "[NEOFORGE] FTB Filter System ${mod_version} MC ${minecraft_version}"
}

curseforge("fabric") {
from curseOptions
modLoaders.add("fabric")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@
import net.minecraft.resources.ResourceLocation;

public class Textures {
public static final ResourceLocation INFO_ICON = guiTexture("info.png");
public static final ResourceLocation CHECKBOX = guiTexture("checkbox.png");
public static final ResourceLocation BACKGROUND = guiTexture("background.png");
public static final ResourceLocation EDIT_BUTTON = guiTexture("edit.png");
public static final ResourceLocation INFO_ICON = guiSpriteTexture("info");
public static final ResourceLocation BACKGROUND = guiSpriteTexture("background");
public static final ResourceLocation EDIT_BUTTON = guiSpriteTexture("edit");
public static final ResourceLocation EDIT_BUTTON_HI = guiSpriteTexture("edit_hi");

private static ResourceLocation guiTexture(String name) {
return FTBFilterSystemAPI.rl("textures/gui/" + name);
private static ResourceLocation guiSpriteTexture(String name) {
return FTBFilterSystemAPI.rl(name);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -81,15 +81,16 @@ public final Rect2i getGuiBounds() {
protected void init() {
setupGuiDimensions();

LinearLayout bottomPanel = new LinearLayout(leftPos, topPos + guiHeight - 25, guiWidth, 20, LinearLayout.Orientation.HORIZONTAL);
LinearLayout bottomPanel = new LinearLayout(leftPos, topPos + guiHeight - 25, LinearLayout.Orientation.HORIZONTAL);
bottomPanel.addChild(new FrameLayout(guiWidth / 2, 20))
.addChild(Button.builder(Component.translatable("gui.done"), b -> applyChanges()).width(70).build());
bottomPanel.addChild(new FrameLayout(guiWidth / 2, 20))
.addChild(Button.builder(Component.translatable("gui.cancel"), b -> onClose()).width(70).build());
bottomPanel.arrangeElements();
bottomPanel.visitWidgets(this::addRenderableWidget);

ImageWidget img = addRenderableWidget(new ImageWidget(leftPos + guiWidth - 19, topPos + 3, 16, 16, Textures.INFO_ICON));
ImageWidget img = addRenderableWidget(ImageWidget.sprite(16, 16, Textures.INFO_ICON));
img.setPosition(leftPos + guiWidth - 19, topPos + 3);
img.setTooltip(Tooltip.create(AbstractSmartFilter.getTooltip(filter.getId())));
}

Expand All @@ -111,20 +112,23 @@ public void onClose() {

@Override
public void render(GuiGraphics guiGraphics, int pMouseX, int pMouseY, float pPartialTick) {
renderBackground(guiGraphics);

guiGraphics.blitNineSliced(Textures.BACKGROUND, leftPos, topPos, guiWidth, guiHeight, 4, 32, 32, 0, 0);
super.render(guiGraphics, pMouseX, pMouseY, pPartialTick);

guiGraphics.hLine(leftPos + 3, leftPos + guiWidth - 4, topPos + guiHeight - 29, 0x80404040);
guiGraphics.hLine(leftPos + 3, leftPos + guiWidth - 4, topPos + guiHeight - 28, 0x80FFFFFF);

guiGraphics.drawString(font, title, leftPos + 8, topPos + 6, 0x404040, false);
}

super.render(guiGraphics, pMouseX, pMouseY, pPartialTick);
@Override
public void renderBackground(GuiGraphics guiGraphics, int mouseX, int mouseY, float partialTick) {
super.renderBackground(guiGraphics, mouseX, mouseY, partialTick);

guiGraphics.blitSprite(Textures.BACKGROUND, leftPos, topPos, guiWidth, guiHeight);
}

protected final EditBox makeSearchEditBox(int x, int y, Supplier<String> prevStrSupplier, Consumer<String> prevStrConsumer) {
EditBox editBox = new EditBox(font, x, y, 88, font.lineHeight + 1, Component.empty());
EditBox editBox = new EditBox(font, x, y, 88, font.lineHeight + 4, Component.empty());
editBox.setMaxLength(15);
editBox.setBordered(true);
editBox.setVisible(true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,9 @@

import net.minecraft.client.gui.Font;
import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.client.gui.components.Button;
import net.minecraft.client.gui.components.ImageButton;
import net.minecraft.client.renderer.Rect2i;
import net.minecraft.network.chat.CommonComponents;
import net.minecraft.network.chat.FormattedText;
import net.minecraft.resources.ResourceLocation;

public class GuiUtil {
public static void drawPanel(GuiGraphics graphics, Rect2i area, int bgColor, int borderColor, BorderStyle borderStyle, int borderWidth) {
Expand Down Expand Up @@ -75,10 +72,6 @@ private static int makeRGB(int a, int r, int g, int b) {
return a << 24 | r << 16 | g << 8 | b;
}

public static ImageButton make16x16ImageButton(ResourceLocation texture, Button.OnPress onPress) {
return new ImageButton(0, 0, 16, 16, 0, 0, 0, texture, 16, 16, onPress);
}

public static Rect2i outsetRect(Rect2i orig, int amount) {
return new Rect2i(orig.getX() - amount, orig.getY() - amount, orig.getWidth() + amount * 2, orig.getHeight() + amount * 2);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,8 @@ public boolean keyPressed(int pKeyCode, int pScanCode, int pModifiers) {
}

@Override
public boolean mouseScrolled(double mouseX, double mouseY, double dir) {
adjustVal(dir < 0 ? -1 : 1);
public boolean mouseScrolled(double mouseX, double mouseY, double dirX, double dirY) {
adjustVal(dirY < 0 ? -1 : 1);

return true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@ public class CustomConfigScreen extends AbstractFilterConfigScreen<CustomFilter>
private EditBox extraEditBox;

public CustomConfigScreen(CustomFilter filter, AbstractFilterScreen parentScreen) {
super(filter, parentScreen, 176, 90);
super(filter, parentScreen, 176, 80);
}

@Override
protected void init() {
super.init();

idEditBox = new EditBox(font, leftPos + 8, topPos + 42, guiWidth - 16, font.lineHeight + 1, Component.empty());
idEditBox = new EditBox(font, leftPos + 8, topPos + 40, guiWidth - 16, font.lineHeight + 4, Component.empty());
idEditBox.setMaxLength(1024);
idEditBox.setBordered(true);
idEditBox.setVisible(true);
Expand All @@ -31,7 +31,7 @@ protected void init() {
idEditBox.setFilter(s -> s.isEmpty() || StringUtils.isAlphanumeric(s));
addRenderableWidget(idEditBox);

extraEditBox = new EditBox(font, leftPos + 8, topPos + 72, guiWidth - 16, font.lineHeight + 1, Component.empty());
extraEditBox = new EditBox(font, leftPos + 8, topPos + 70, guiWidth - 16, font.lineHeight + 4, Component.empty());
extraEditBox.setMaxLength(1024);
extraEditBox.setBordered(true);
extraEditBox.setVisible(true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,7 @@
import net.minecraft.Util;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.client.gui.components.Button;
import net.minecraft.client.gui.components.EditBox;
import net.minecraft.client.gui.components.ImageButton;
import net.minecraft.client.gui.components.ObjectSelectionList;
import net.minecraft.client.gui.components.*;
import net.minecraft.client.gui.layouts.FrameLayout;
import net.minecraft.client.gui.layouts.LinearLayout;
import net.minecraft.client.gui.narration.NarrationElementOutput;
Expand Down Expand Up @@ -75,21 +72,21 @@ protected void init() {
// add these early; they will render above other widgets so need to get mouse clicks first
getSelectionPanel().visitWidgets(this::addWidget);

filterList = new FilterList(minecraft, getListWidth(), getListHeight(), topPos + 20, topPos + 20 + getListHeight());
filterList.setLeftPos(leftPos + 8);
filterList = new FilterList(minecraft, topPos + 20, getListWidth(), getListHeight());
filterList.setX(leftPos + 8);
filterList.setRenderBackground(false);
filterList.setRenderTopAndBottom(false);
addWidget(filterList);

titleEditBtn = addRenderableWidget(new ImageButton(leftPos, topPos + 3, 16, 16, 0, 0, 0,
Textures.EDIT_BUTTON, 16, 16, b -> showingTitleEdit = true));
titleEditBtn = addRenderableWidget(new ImageButton(leftPos, topPos + 3, 16, 16,
new WidgetSprites(Textures.EDIT_BUTTON, Textures.EDIT_BUTTON_HI),
b -> showingTitleEdit = true));

titleEditBox = addRenderableWidget(new EditBox(font, leftPos + 5, topPos + 4, getListWidth(), font.lineHeight + 4, Component.empty()));
titleEditBox.visible = false;
titleEditBox.setValue(title.getString());

int buttonWidth = guiWidth - getListWidth() - 25;
LinearLayout buttonPanel = new LinearLayout(leftPos + getListWidth() + 15, topPos + 20, buttonWidth, 70, LinearLayout.Orientation.VERTICAL);
LinearLayout buttonPanel = new LinearLayout(leftPos + getListWidth() + 15, topPos + 20, LinearLayout.Orientation.VERTICAL).spacing(2);
addFilterBtn = buttonPanel.addChild(Button.builder(Component.translatable("ftbfiltersystem.gui.add"),
b -> getSelectionPanel().setVisible(true)).width(buttonWidth).build());
deleteFilterBtn = buttonPanel.addChild(Button.builder(Component.translatable("ftbfiltersystem.gui.delete"),
Expand All @@ -99,7 +96,7 @@ protected void init() {
buttonPanel.arrangeElements();
buttonPanel.visitWidgets(this::addRenderableWidget);

LinearLayout bottomPanel = new LinearLayout(leftPos, topPos + guiHeight - 25, guiWidth, 20, LinearLayout.Orientation.HORIZONTAL);
LinearLayout bottomPanel = new LinearLayout(leftPos, topPos + guiHeight - 25, LinearLayout.Orientation.HORIZONTAL);
bottomPanel.addChild(new FrameLayout(guiWidth / 2, 20))
.addChild(Button.builder(CommonComponents.GUI_DONE, b -> applyChanges()).size(80, 20).build());
bottomPanel.addChild(new FrameLayout(guiWidth / 2, 20))
Expand Down Expand Up @@ -218,7 +215,7 @@ public void tick() {
titleEditBox.visible = true;
titleEditBtn.visible = false;
if (Screen.hasShiftDown()) {
titleEditBox.moveCursorToEnd();
titleEditBox.moveCursorToEnd(false);
titleEditBox.setHighlightPos(0);
}
setFocused(titleEditBox);
Expand All @@ -232,22 +229,18 @@ public void tick() {

@Override
public void render(GuiGraphics guiGraphics, int mouseX, int mouseY, float partialTick) {
renderBackground(guiGraphics);
super.render(guiGraphics, mouseX, mouseY, partialTick);

if (guiHeight > 0) {
guiGraphics.blitNineSliced(Textures.BACKGROUND, leftPos, topPos, guiWidth, guiHeight, 4, 32, 32, 0, 0);
GuiUtil.drawPanel(guiGraphics, new Rect2i(leftPos + 7, topPos + 20, getListWidth() + 2, getListHeight()),
0xFFA0A0A0, 0xFFA0A0A0, GuiUtil.BorderStyle.INSET, 1);
filterList.render(guiGraphics, mouseX, mouseY, partialTick);

Component displayTitle = newTitle == null ? title : newTitle;
guiGraphics.drawString(font, displayTitle,leftPos + 8, topPos + 7, 0x404040, false);
titleEditBtn.setX(leftPos + font.width(displayTitle) + 8);

filterList.render(guiGraphics, mouseX, mouseY, partialTick);
}

super.render(guiGraphics, mouseX, mouseY, partialTick);

if (getSelectionPanel().isVisible()) {
guiGraphics.pose().pushPose();
guiGraphics.pose().translate(0, 0, 200);
Expand All @@ -257,6 +250,13 @@ public void render(GuiGraphics guiGraphics, int mouseX, int mouseY, float partia
}
}

@Override
public void renderBackground(GuiGraphics guiGraphics, int mouseX, int mouseY, float partialTick) {
super.renderBackground(guiGraphics, mouseX, mouseY, partialTick);

guiGraphics.blitSprite(Textures.BACKGROUND, leftPos, topPos, guiWidth, guiHeight);
}

@Override
public void onClose() {
getSelectionPanel().setVisible(false);
Expand Down Expand Up @@ -366,8 +366,8 @@ private class FilterList extends ObjectSelectionList<FilterList.FilterEntry> {
private FilterEntry dragging = null;
private SmartFilter.Compound dragTarget = null;

public FilterList(Minecraft minecraft, int width, int height, int top, int bottom) {
super(minecraft, width, height, top, bottom, ELEMENT_HEIGHT);
public FilterList(Minecraft minecraft, int y, int width, int height) {
super(minecraft, width, height, y, ELEMENT_HEIGHT);

addChildren();
}
Expand Down Expand Up @@ -402,7 +402,7 @@ protected int getScrollbarPosition() {
}

@Override
public void updateNarration(NarrationElementOutput narrationElementOutput) {
public void updateWidgetNarration(NarrationElementOutput narrationElementOutput) {
}

@Override
Expand Down Expand Up @@ -472,8 +472,8 @@ protected void renderDecorations(GuiGraphics guiGraphics, int pMouseX, int pMous

@Override
protected void renderSelection(GuiGraphics guiGraphics, int pTop, int pWidth, int pHeight, int pOuterColor, int pInnerColor) {
int minX = this.x0 + (this.width - pWidth) / 2;
int maxX = this.x0 + (this.width + pWidth) / 2;
int minX = this.getX() + (this.width - pWidth) / 2;
int maxX = this.getX() + (this.width + pWidth) / 2;
int col = isFocused() ? 0xFFE1F1FD : 0xFFA6B4C4;
GuiUtil.drawPanel(guiGraphics, new Rect2i(minX + 1, pTop - 2, maxX - minX - 2, pHeight + 3), col,
0xFF4663AC, GuiUtil.BorderStyle.PLAIN, 1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public class ItemConfigScreen extends AbstractFilterConfigScreen<ItemFilter> imp
private ItemWidget selectedWidget;

public ItemConfigScreen(ItemFilter filter, AbstractFilterScreen parentScreen) {
super(filter, parentScreen,194, 115);
super(filter, parentScreen,194, 117);

cachedInventoryEntries = null; // recheck inventory each time we open
}
Expand Down Expand Up @@ -92,7 +92,7 @@ protected void init() {
}
}

scrollArea = new Rect2i(leftPos + 174, topPos + 52, 14, 70);
scrollArea = new Rect2i(leftPos + 174, topPos + 55, 14, 70);

setSelectedStack(new ItemStack(filter.getMatchItem()));

Expand Down Expand Up @@ -121,18 +121,19 @@ public void render(GuiGraphics guiGraphics, int pMouseX, int pMouseY, float pPar

guiGraphics.fill(scrollArea.getX() - 2, scrollArea.getY() - 2, scrollArea.getX() + scrollArea.getWidth(), scrollArea.getY() + scrollArea.getHeight(), 0xFF808080);
guiGraphics.fill(scrollArea.getX() - 1, scrollArea.getY() - 1, scrollArea.getX() + scrollArea.getWidth() - 1, scrollArea.getY() + scrollArea.getHeight() - 1, 0xFFA0A0A0);
guiGraphics.blit(SCROLL_TEXTURE, sx, sy1 + (int) ((sy2 - sy1 - 17) * currentScroll), 232 + (needsScrollBars() ? 0 : 12), 0, 12, 15);
// guiGraphics.blit(SCROLL_TEXTURE, sx, sy1 + (int) ((sy2 - sy1 - 17) * currentScroll), 232 + (needsScrollBars() ? 0 : 12), 0, 12, 15);
guiGraphics.blitSprite(new ResourceLocation("container/creative_inventory/scroller"), sx, sy1 + (int) ((sy2 - sy1 - 17) * currentScroll), 12, 15);
}

@Override
public boolean mouseScrolled(double x, double y, double dir) {
if (dir != 0 && needsScrollBars()) {
public boolean mouseScrolled(double x, double y, double dirX, double dirY) {
if (dirY != 0 && needsScrollBars()) {
int j = currentStacks.size() / (SEARCH_COLS + 1) - (SEARCH_ROWS - 1) + 1;
float i = dir > 0 ? 1f : -1f;
float i = dirY > 0 ? 1f : -1f;
scrollTo(Mth.clamp(currentScroll - i / j, 0.0, 1.0));
return true;
}
return super.mouseScrolled(x, y, dir);
return super.mouseScrolled(x, y, dirX, dirY);
}

@Override
Expand Down Expand Up @@ -287,7 +288,7 @@ public boolean test(String searchString){

private class SearchItemWidget extends ItemWidget {
public SearchItemWidget(int row, int col) {
super(ItemConfigScreen.this.leftPos + 8 + 18 * col, ItemConfigScreen.this.topPos + 50 + 18 * row, 18, 18, ItemStack.EMPTY);
super(ItemConfigScreen.this.leftPos + 8 + 18 * col, ItemConfigScreen.this.topPos + 53 + 18 * row, 18, 18, ItemStack.EMPTY);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,15 @@ public ItemTagConfigScreen(ItemTagFilter filter, AbstractFilterScreen parentScre
protected void init() {
super.init();

searchField = makeSearchEditBox(leftPos + 8, topPos + 20, () -> lastSearch, s -> lastSearch = s);
searchField = makeSearchEditBox(leftPos + 8, topPos + 18, () -> lastSearch, s -> lastSearch = s);

updateSearchEntries();

itemTagList = new ItemTagList(minecraft, getListWidth() + 8, getListHeight(), topPos + 32, topPos + 35 + getListHeight());
itemTagList.setLeftPos(leftPos + 8);
// itemTagList = new ItemTagList(minecraft, getListWidth() + 8, getListHeight(), topPos + 32, topPos + 35 + getListHeight());
itemTagList = new ItemTagList(minecraft,topPos + 32, getListWidth(), getListHeight());
itemTagList.setX(leftPos + 8);
itemTagList.setRenderBackground(false);
itemTagList.setRenderTopAndBottom(false);
// itemTagList.setRenderTopAndBottom(false);
addWidget(itemTagList);

itemTagList.children().stream()
Expand Down Expand Up @@ -99,10 +100,8 @@ private void updateSearchEntries() {
private class ItemTagList extends CustomSelectionList<ItemTagList.ItemTagEntry> {
private static final int ELEMENT_HEIGHT = 12;

public ItemTagList(Minecraft minecraft, int width, int height, int top, int bottom) {
super(minecraft, width, height, top, bottom, ELEMENT_HEIGHT);

addChildren();
public ItemTagList(Minecraft minecraft, int y, int width, int height) {
super(minecraft, width, height, y, ELEMENT_HEIGHT);
}

@Override
Expand Down
Loading

0 comments on commit 6135b75

Please sign in to comment.