Skip to content

Commit

Permalink
update toast
Browse files Browse the repository at this point in the history
  • Loading branch information
C10udburst committed Feb 16, 2022
1 parent da085a7 commit 0ebc25a
Show file tree
Hide file tree
Showing 7 changed files with 76 additions and 10 deletions.
3 changes: 3 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ processResources {

filesMatching("fabric.mod.json") {
expand "version": project.version

filter { line -> line.replace("@mc_version@", project.minecraft_version) }
filter { line -> line.replace("@gh_hash@", System.getenv("GITHUB_SHA") ?: "unknown") }
}
}

Expand Down
6 changes: 3 additions & 3 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
org.gradle.jvmargs=-Xmx2G

# Fabric (https://fabricmc.net/versions.html)
minecraft_version=1.18
yarn_version=1.18+build.1
loader_version=0.12.6
minecraft_version=1.18.1
yarn_version=1.18.1+build.14
loader_version=0.12.12

# Mod Properties
mod_version=0.1
Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.1-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
22 changes: 22 additions & 0 deletions src/main/java/me/ghosttypes/orion/mixins/TitleScreenMixin.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package me.ghosttypes.orion.mixins;

import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;

import net.minecraft.client.gui.screen.TitleScreen;
import net.minecraft.client.util.math.MatrixStack;

import me.ghosttypes.orion.utils.UpdateUtil;
import meteordevelopment.meteorclient.utils.network.MeteorExecutor;

@Mixin(value = TitleScreen.class)
public class TitleScreenMixin {
@Inject(method = "render", at = @At("TAIL"))
private void onRender(MatrixStack matrices, int mouseX, int mouseY, float delta, CallbackInfo info) {
MeteorExecutor.execute(() -> {
UpdateUtil.checkUpdate();
});
}
}
36 changes: 36 additions & 0 deletions src/main/java/me/ghosttypes/orion/utils/UpdateUtil.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package me.ghosttypes.orion.utils;

import com.google.gson.JsonObject;
import net.minecraft.item.Items;

import net.fabricmc.loader.api.FabricLoader;
import me.ghosttypes.orion.Orion;
import meteordevelopment.meteorclient.utils.network.Http;
import meteordevelopment.meteorclient.utils.render.MeteorToast;

import static meteordevelopment.meteorclient.MeteorClient.mc;

public class UpdateUtil {
private static boolean firstTimeTitleScreen = true;
private static final String TAGNAME = "latest-1.18";

public static void checkUpdate() {
if (!firstTimeTitleScreen) return;
firstTimeTitleScreen = false;

Orion.LOG.info("Checking for Orion update...");

String gitHash = FabricLoader
.getInstance()
.getModContainer("orion")
.get().getMetadata()
.getCustomValue("updater:sha")
.getAsString().trim();

JsonObject tag = Http.get("https://api.github.com/repos/AntiCope/orion/git/ref/tags/"+TAGNAME).sendJson(JsonObject.class);
if (tag.get("object").getAsJsonObject().get("sha").getAsString().trim().equals(gitHash)) return;

mc.getToastManager().add(new MeteorToast(Items.OBSIDIAN, "New Orion update.", "Download it from Github", 8000));
}

}
11 changes: 8 additions & 3 deletions src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
"name": "Orion",
"description": "A combat addon for Meteor Client.",
"authors": [
"GhostTypes"
"GhostTypes",
"Cloudburst"
],
"contact": {
"repo": "https://github.com/GhostTypes/orion"
Expand All @@ -20,9 +21,13 @@
"mixins": [
"orion.mixins.json"
],
"custom": {
"meteor-client:color": "251, 96, 139",
"updater:sha": "@gh_hash@"
},
"depends": {
"java": ">=16",
"minecraft": ">=1.17.1",
"meteor-client": ">0.4.3"
"minecraft": ">=@mc_version@",
"meteor-client": "*"
}
}
6 changes: 3 additions & 3 deletions src/main/resources/orion.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
"required": true,
"package": "me.ghosttypes.orion.mixins",
"compatibilityLevel": "JAVA_16",
"client": [],
"injectors": {
"defaultRequire": 1
},
"mixins": [
"NametagMixin"
"client": [
"NametagMixin",
"TitleScreenMixin"
]
}

0 comments on commit 0ebc25a

Please sign in to comment.