Skip to content

Commit

Permalink
Add NBT only filters
Browse files Browse the repository at this point in the history
Closes #11
  • Loading branch information
henkelmax committed Mar 18, 2021
1 parent ecfdc9c commit a219098
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 12 deletions.
4 changes: 2 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ mod_packagename=de.maxhenkel.pipez
mod_id=pipez
mod_name=Pipez
mod_vendor=Max Henkel
mod_version=1.16.5-1.1.4
mod_version=1.16.5-1.1.5
mod_minecraft_version=1.16.5
mod_loader_version=[36,)
mod_forge_version=[36.0.0,)

forge_version=36.0.48
forge_version=36.1.0

curse_id=443900
curse_release_type=alpha
Expand Down
18 changes: 10 additions & 8 deletions src/main/java/de/maxhenkel/pipez/gui/FilterList.java
Original file line number Diff line number Diff line change
Expand Up @@ -165,15 +165,17 @@ protected void drawGuiContainerBackgroundLayer(MatrixStack matrixStack, float pa
} else {
drawStringSmall(matrixStack, guiLeft + 22, startY + 5, new TranslationTextComponent("message.pipez.filter.tag", new StringTextComponent(filter.getTag().getName().toString()).withStyle(TextFormatting.BLUE)).withStyle(TextFormatting.WHITE));
}
if (filter.getMetadata() != null && filter.getMetadata().size() > 0) {
IFormattableTextComponent tags = new TranslationTextComponent("message.pipez.filter.nbt.tag" + (filter.getMetadata().size() != 1 ? "s" : ""), filter.getMetadata().size()).withStyle(TextFormatting.DARK_PURPLE);
IFormattableTextComponent nbtStr = new TranslationTextComponent("message.pipez.filter.nbt", tags).withStyle(TextFormatting.WHITE);
if (filter.isExactMetadata()) {
nbtStr.append(" ").append(new TranslationTextComponent("message.pipez.filter.nbt.exact"));
}
drawStringSmall(matrixStack, guiLeft + 22, startY + 10, nbtStr);
}
}
} else {
drawStringSmall(matrixStack, guiLeft + 22, startY + 5, new TranslationTextComponent("message.pipez.filter.any_item").withStyle(TextFormatting.WHITE));
}
if (filter.getMetadata() != null && filter.getMetadata().size() > 0) {
IFormattableTextComponent tags = new TranslationTextComponent("message.pipez.filter.nbt.tag" + (filter.getMetadata().size() != 1 ? "s" : ""), filter.getMetadata().size()).withStyle(TextFormatting.DARK_PURPLE);
IFormattableTextComponent nbtStr = new TranslationTextComponent("message.pipez.filter.nbt", tags).withStyle(TextFormatting.WHITE);
if (filter.isExactMetadata()) {
nbtStr.append(" ").append(new TranslationTextComponent("message.pipez.filter.nbt.exact"));
}
drawStringSmall(matrixStack, guiLeft + 22, startY + 10, nbtStr);
}

if (filter.isInvert()) {
Expand Down
9 changes: 7 additions & 2 deletions src/main/java/de/maxhenkel/pipez/gui/FilterScreen.java
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ private boolean hasNBT() {
@Override
public void tick() {
super.tick();
submitButton.active = filter.getTag() != null;
submitButton.active = filter.getTag() != null || filter.getMetadata() != null;
}

public void onItemTextChanged(String text) {
Expand Down Expand Up @@ -351,7 +351,12 @@ public void onClose() {
@Override
public boolean mouseClicked(double mouseX, double mouseY, int button) {
if (itemHoverArea.isHovered(leftPos, topPos, (int) mouseX, (int) mouseY)) {
onInsertStack(minecraft.player.inventory.getCarried());
if (hasShiftDown()) {
item.setValue("");
filter.setTag(null);
} else {
onInsertStack(minecraft.player.inventory.getCarried());
}
return true;
}
if (destinationHoverArea.isHovered(leftPos, topPos, (int) mouseX, (int) mouseY)) {
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/assets/pipez/lang/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
"tooltip.pipez.item": "Items",
"message.pipez.filter.tag": "Tag: %s",
"message.pipez.filter.item": "Item: %s",
"message.pipez.filter.any_item": "Any item",
"message.pipez.filter.nbt": "NBT: %s",
"message.pipez.filter.nbt.tags": "%s Tags",
"message.pipez.filter.nbt.tag": "%s Tag",
Expand Down

0 comments on commit a219098

Please sign in to comment.