Skip to content

Commit

Permalink
shard collection button
Browse files Browse the repository at this point in the history
  • Loading branch information
sisby-folk committed Nov 30, 2024
1 parent c9a2848 commit 37b2f70
Show file tree
Hide file tree
Showing 9 changed files with 60 additions and 1 deletion.
4 changes: 4 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,13 @@ archivesBaseName = project.slug
repositories {
maven { url "https://server.bbkr.space/artifactory/libs-release" }
maven { url "https://oss.sonatype.org/content/repositories/snapshots" }
maven { url "https://repo.sleeping.town/" }
}

dependencies {
implementation libs.kaleidoConfig
include libs.kaleidoConfig

minecraft libs.mc
mappings variantOf(libs.yarn) { classifier "v2" }

Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ authors=Falkreon, acikek
contributors=Trudle, Tomate0613, afamiliarquiet, FoundationGames, TheEpicBlock, hama
license=MIT
# Mod Version
baseVersion=1.7.1
baseVersion=1.7.2
# Branch Metadata
branch=1.21
tagBranch=1.21
Expand Down
4 changes: 4 additions & 0 deletions libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
loom = "1.7.+"
minotaur = "2.+"

kaleidoConfig = "0.3.1+1.3.1"

mc = "1.21.1"
fl = "0.16.7"
yarn = "1.21.1+build.3"
Expand All @@ -15,6 +17,8 @@ loom = { id = "fabric-loom", version.ref = "loom" }
minotaur = { id = "com.modrinth.minotaur", version.ref = "minotaur" }

[libraries]
kaleidoConfig = { group = "folk.sisby", name = "kaleido-config", version.ref = "kaleidoConfig" }

mc = { group = "mojang", name = "minecraft", version.ref = "mc" }
fl = { group = "net.fabricmc", name = "fabric-loader", version.ref = "fl" }
yarn = { group = "net.fabricmc", name = "yarn", version.ref = "yarn" }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import net.fabricmc.api.ModInitializer;
import net.fabricmc.fabric.api.event.lifecycle.v1.ServerLifecycleEvents;
import net.fabricmc.loader.api.FabricLoader;
import net.minecraft.util.Identifier;
import net.modfest.scatteredshards.api.ScatteredShardsAPI;
import net.modfest.scatteredshards.api.shard.ShardType;
Expand All @@ -17,6 +18,8 @@ public class ScatteredShards implements ModInitializer {

public static final Logger LOGGER = LoggerFactory.getLogger(ID);

public static final ScatteredShardsConfig CONFIG = ScatteredShardsConfig.createToml(FabricLoader.getInstance().getConfigDir(), "", ID, ScatteredShardsConfig.class);

public static Identifier id(String path) {
return Identifier.of(ID, path);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package net.modfest.scatteredshards;

import folk.sisby.kaleido.api.ReflectiveConfig;
import folk.sisby.kaleido.lib.quiltconfig.api.annotations.Comment;
import folk.sisby.kaleido.lib.quiltconfig.api.values.TrackedValue;

public class ScatteredShardsConfig extends ReflectiveConfig {
@Comment("Whether to replace advancements button with a shard collection button")
public final TrackedValue<Boolean> replace_advancements = value(true);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package net.modfest.scatteredshards.mixin.client;

import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
import net.minecraft.client.gui.screen.GameMenuScreen;
import net.minecraft.client.gui.widget.ButtonWidget;
import net.minecraft.client.gui.widget.GridWidget;
import net.minecraft.client.gui.widget.Widget;
import net.minecraft.text.Text;
import net.modfest.scatteredshards.ScatteredShards;
import net.modfest.scatteredshards.client.ScatteredShardsClient;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;

@Mixin(GameMenuScreen.class)
public class GameMenuScreenMixin {
@WrapOperation(method = "initWidgets", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/widget/GridWidget$Adder;add(Lnet/minecraft/client/gui/widget/Widget;)Lnet/minecraft/client/gui/widget/Widget;", ordinal = 0))
private Widget replaceAdvancements(GridWidget.Adder instance, Widget widget, Operation<Widget> original) {
if (!ScatteredShards.CONFIG.replace_advancements.value()) return original.call(instance, widget);
return instance.add(ButtonWidget.builder(Text.translatable("menu.scattered_shards.collection"), b -> ScatteredShardsClient.openShardTablet()).width(98).build());
}
}
1 change: 1 addition & 0 deletions src/main/resources/assets/scattered_shards/lang/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
"gui.scattered_shards.tablet.tooltip.global_collection": "%s of players have this shard",
"gui.scattered_shards.tablet.label.progress.started": "%s Started",
"gui.scattered_shards.tablet.label.progress.total": "%s Total",
"menu.scattered_shards.collection": "Shard Collection",
"toast.scattered_shards.shard_mod.title": "Shard Modification",
"toast.scattered_shards.shard_mod.success": "Successfully modified '%s'",
"toast.scattered_shards.shard_mod.fail": "Failed to modify '%s'",
Expand Down
3 changes: 3 additions & 0 deletions src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@
},
"license": "${license}",
"icon": "assets/${modId}/icon.png",
"mixins": [
"${modId}.mixins.json"
],
"depends": {
"minecraft": ">=${mc}",
"fabricloader": ">=${fl}",
Expand Down
12 changes: 12 additions & 0 deletions src/main/resources/scattered_shards.mixins.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"required": true,
"minVersion": "0.8",
"package": "net.modfest.scatteredshards.mixin",
"compatibilityLevel": "JAVA_21",
"client": [
"client.GameMenuScreenMixin"
],
"injectors": {
"defaultRequire": 1
}
}

0 comments on commit 37b2f70

Please sign in to comment.