Skip to content

Commit

Permalink
Backported to 1.20.1 (#167)
Browse files Browse the repository at this point in the history
* update to minecraft 1.20.2

* bump cursegradle version

* add NeoForge support

* fix build and add name of loader in each file

* bugfix: upstream changes to blitSprite would cause icons to render under their frame, and colors to blend with the icon

Signed-off-by: MeeniMc <[email protected]>

* move to architectury loom, this also includes moving some packages around

* upload correct files to CF and Modrinth

* temporary remove additional files from CF upload and add changelog to modrinth

* update gradle/loom for 1.20.4

Signed-off-by: MeeniMc <[email protected]>

* NeoForge for 1.20.4 does not accept 'mandatory' keyword anymore

Signed-off-by: MeeniMc <[email protected]>

* 1.20.4 java changes: displayInfo.getFrame is now getType, getBackground now returns an Optional

Signed-off-by: MeeniMc <[email protected]>

* update some versions

* Create build.yml

* Update build.yml

* Update build.yml

* move to GitHub Actions for building

* add support for multi line changelog messages

* bump some versions

* Making the icon compatible with Mod Menu (#162)

* Update fabric.mod.json

* Add files via upload

* Create better-advancements

* Added an Icon to make it work with Mod Menu

---------

Co-authored-by: Fate <[email protected]>

* Added ability to translate criteria (#165)

* Added ability to translate criteria

* Bumped version to 0.4.2

* Fixed criterion not using the correct colors and formatting. (#166)

* bump versions for development, prep for next MC version

* update to minecraft 1.20.6

* Backported to 1.20.1

---------

Signed-off-by: MeeniMc <[email protected]>
Co-authored-by: way2muchnoise <[email protected]>
Co-authored-by: MeeniMc <[email protected]>
Co-authored-by: Fate (F5T3) <[email protected]>
Co-authored-by: Fate <[email protected]>
  • Loading branch information
5 people committed Jun 21, 2024
1 parent f36a1e4 commit be0bf2e
Show file tree
Hide file tree
Showing 91 changed files with 1,177 additions and 718 deletions.
50 changes: 50 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: 'Build'

on:
push:

env:
MODRINTH_TOKEN: ${{ secrets.PUBLISH_MODRINTH_TOKEN }}
CURSE_KEY: ${{ secrets.PUBLISH_CURSEFORGE_TOKEN }}

permissions:
contents: write

jobs:
build:
runs-on: ubuntu-latest

steps:
# Setup
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Create changelog
run: |
{
echo 'CHANGELOG<<EOF'
git log ${{ github.event.before }}...${{ github.event.after }} --pretty=format:"\[[%h](https://github.com/$GITHUB_REPOSITORY/commit/%H)\] %s (%cn) "
echo ""
echo EOF
} >> "$GITHUB_ENV"
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
distribution: 'microsoft'
java-version: '17'
cache: 'gradle'
- name: Make Gradle Wrapper Executable
if: ${{ runner.os != 'Windows' }}
run: chmod +x ./gradlew
# Build
- name: Build with Gradle
run: ./gradlew clean build
# Publish
- name: Publish CurseForge
run: ./gradlew :Forge:publishCurseForge :Fabric:publishCurseForge :NeoForge:publishCurseForge
- name: Publish Modrinth
run: ./gradlew :Forge:modrinth :Fabric:modrinth :NeoForge:modrinth
- uses: actions/upload-artifact@v4
with:
if-no-files-found: error
path: output/*[^shadow].jar
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,19 @@ out
*.iws
*.iml
.idea/*
!.idea/scopes

# gradle
build
.gradle

# Architectury
.architectury-transformer

# other
eclipse
run


## minecraft
/config/
/mods/
Expand Down
3 changes: 0 additions & 3 deletions .idea/scopes/Fabric_sources.xml

This file was deleted.

3 changes: 0 additions & 3 deletions .idea/scopes/Forge_sources.xml

This file was deleted.

20 changes: 0 additions & 20 deletions .travis.yml

This file was deleted.

38 changes: 6 additions & 32 deletions Common/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,40 +1,14 @@
plugins {
java
id("org.spongepowered.gradle.vanilla") version "0.2.1-SNAPSHOT"
}

// gradle.properties
val minecraftVersion: String by extra

val dependencyProjects: List<Project> = listOf(
project(":CommonApi"),
)

dependencyProjects.forEach {
project.evaluationDependsOn(it.path)
}

minecraft {
version(minecraftVersion)
// no runs are configured for Common
accessWideners(file("src/main/resources/betteradvancements.accesswidener"))
}

sourceSets {
val platforms: String by extra

architectury {
common(platforms.split(","))
}

repositories {
mavenCentral()
loom {
accessWidenerPath.set(file("src/main/resources/betteradvancements.accesswidener"))
}

dependencies {
compileOnly(
group = "org.spongepowered",
name = "mixin",
version = "0.8.5"
)
dependencyProjects.forEach {
implementation(it)
}
api(project(":CommonApi", configuration = "namedElements"))
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package betteradvancements.advancements;
package betteradvancements.common.advancements;

import betteradvancements.api.IBetterDisplayInfo;
import betteradvancements.util.ColorHelper;
import betteradvancements.common.api.IBetterDisplayInfo;
import betteradvancements.common.util.ColorHelper;
import com.google.gson.JsonObject;
import net.minecraft.advancements.Advancement;
import net.minecraft.client.gui.screens.advancements.AdvancementWidgetType;
Expand Down Expand Up @@ -36,10 +36,11 @@ public class BetterDisplayInfo implements IBetterDisplayInfo {

public BetterDisplayInfo(Advancement advancement) {
this(advancement.getId());
if (advancement instanceof IBetterDisplayInfo) {
parseIBetterDisplayInfo((IBetterDisplayInfo) advancement);
}
if (advancement.getDisplay() instanceof IBetterDisplayInfo) {
// TODO: Fix checking this
// if (advancement instanceof IBetterDisplayInfo) {
// parseIBetterDisplayInfo((IBetterDisplayInfo) advancement);
// }
if (advancement.getDisplay() instanceof IBetterDisplayInfo){
parseIBetterDisplayInfo((IBetterDisplayInfo) advancement.getDisplay());
}
}
Expand Down Expand Up @@ -207,6 +208,10 @@ public int getIconColor(AdvancementWidgetType state) {
return state == AdvancementWidgetType.OBTAINED ? getCompletedIconColor() : getUnCompletedIconColor();
}

public int defaultIconColor() {
return WHITE;
}

public int getTitleYMultiplier(AdvancementWidgetType state) {
if (hasCustomTitleColor()) {
return 3;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package betteradvancements.advancements;
package betteradvancements.common.advancements;

import betteradvancements.platform.Services;
import betteradvancements.reference.Constants;
import betteradvancements.common.platform.Services;
import betteradvancements.common.reference.Constants;
import com.google.gson.JsonObject;
import com.google.gson.JsonParseException;
import com.google.gson.JsonParser;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package betteradvancements.gui;
package betteradvancements.common.gui;

import betteradvancements.advancements.BetterDisplayInfo;
import betteradvancements.advancements.BetterDisplayInfoRegistry;
import betteradvancements.common.advancements.BetterDisplayInfo;
import betteradvancements.common.advancements.BetterDisplayInfoRegistry;
import com.google.common.collect.Maps;
import net.minecraft.advancements.Advancement;
import net.minecraft.advancements.DisplayInfo;
Expand All @@ -14,7 +14,6 @@
import net.minecraft.util.Tuple;
import net.minecraft.world.item.ItemStack;

import javax.annotation.Nullable;
import java.util.Map;
import java.util.Objects;

Expand All @@ -31,7 +30,7 @@ public class BetterAdvancementTab {
private final ItemStack icon;
private final Component title;
private final BetterAdvancementWidget root;
protected final Map<Advancement, BetterAdvancementWidget> guis = Maps.newLinkedHashMap();
protected final Map<Advancement, BetterAdvancementWidget> widgets = Maps.newLinkedHashMap();
private final BetterDisplayInfoRegistry betterDisplayInfos;

protected int scrollX, scrollY;
Expand All @@ -51,7 +50,7 @@ public BetterAdvancementTab(Minecraft mc, BetterAdvancementsScreen betterAdvance
this.title = displayInfo.getTitle();
this.betterDisplayInfos = new BetterDisplayInfoRegistry(advancement);
this.root = new BetterAdvancementWidget(this, mc, advancement, displayInfo);
this.addGuiAdvancement(this.root, advancement);
this.addWidget(this.root, advancement);
}

public Advancement getAdvancement() {
Expand Down Expand Up @@ -109,7 +108,7 @@ public void drawToolTips(GuiGraphics guiGraphics, int mouseX, int mouseY, int le
boolean flag = false;

if (mouseX > 0 && mouseX < width && mouseY > 0 && mouseY < height) {
for (BetterAdvancementWidget betterAdvancementWidget : this.guis.values()) {
for (BetterAdvancementWidget betterAdvancementWidget : this.widgets.values()) {
if (betterAdvancementWidget.isMouseOver(this.scrollX, this.scrollY, mouseX, mouseY)) {
flag = true;
betterAdvancementWidget.drawHover(guiGraphics, this.scrollX, this.scrollY, this.fade, left, top);
Expand All @@ -131,7 +130,6 @@ public boolean isMouseOver(int left, int top, int width, int height, double mous
return this.type.isMouseOver(left, top, width, height, this.index, mouseX, mouseY);
}

@Nullable
public static BetterAdvancementTab create(Minecraft mc, BetterAdvancementsScreen betterAdvancementsScreen, int index, Advancement advancement, int width, int height) {
if (advancement.getDisplay() == null) {
return null;
Expand Down Expand Up @@ -159,12 +157,12 @@ public void scroll(double scrollX, double scrollY, int width, int height) {
public void addAdvancement(Advancement advancement) {
if (advancement.getDisplay() != null) {
BetterAdvancementWidget betterAdvancementEntryScreen = new BetterAdvancementWidget(this, this.minecraft, advancement, advancement.getDisplay());
this.addGuiAdvancement(betterAdvancementEntryScreen, advancement);
this.addWidget(betterAdvancementEntryScreen, advancement);
}
}

private void addGuiAdvancement(BetterAdvancementWidget betterAdvancementEntryScreen, Advancement advancement) {
this.guis.put(advancement, betterAdvancementEntryScreen);
private void addWidget(BetterAdvancementWidget betterAdvancementEntryScreen, Advancement advancement) {
this.widgets.put(advancement, betterAdvancementEntryScreen);
int left = betterAdvancementEntryScreen.getX();
int right = left + 28;
int top = betterAdvancementEntryScreen.getY();
Expand All @@ -174,14 +172,13 @@ private void addGuiAdvancement(BetterAdvancementWidget betterAdvancementEntryScr
this.minY = Math.min(this.minY, top);
this.maxY = Math.max(this.maxY, bottom);

for (BetterAdvancementWidget gui : this.guis.values()) {
for (BetterAdvancementWidget gui : this.widgets.values()) {
gui.attachToParent();
}
}

@Nullable
public BetterAdvancementWidget getWidget(Advancement advancement) {
return this.guis.get(advancement);
return this.widgets.get(advancement);
}

public BetterAdvancementsScreen getScreen() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package betteradvancements.gui;
package betteradvancements.common.gui;

import betteradvancements.reference.Resources;
import betteradvancements.common.reference.Resources;
import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.client.gui.screens.advancements.AdvancementTabType;
import net.minecraft.world.item.ItemStack;
Expand Down
Loading

0 comments on commit be0bf2e

Please sign in to comment.