Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
[versions]
minecraft = "1.21.1"
neoForge = "21.1.152"
neoForge = "21.1.217"
registrate = "MC1.21-1.3.0+62"
anvillib = "1.4.0+build.172"
anvilcraft = "1.5.0+hotfix.1570"
curios = "9.0.15+1.21.1"
jei = "19.21.0.247"
jei = "19.25.0.322"
jade = "15.3.4+neoforge"
modDevGradle = "2.0.78"
lombok = "8.7.1"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"command.ac_guideme.item": "%s :ɯǝʇI",
"gui.ac_guideme.mod_info.loaded": "¡pǝpɐoꞀ sı %s",
"gui.ac_guideme.mod_info.unloaded": "¡pǝpɐoꞀ ʇ,usı %s"
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"command.ac_guideme.item": "Item: %s",
"gui.ac_guideme.mod_info.loaded": "%s is Loaded!",
"gui.ac_guideme.mod_info.unloaded": "%s isn't Loaded!"
}
15 changes: 14 additions & 1 deletion src/main/java/dev/anvilcraft/guideme/AnvilCraftGuideME.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.mojang.logging.LogUtils;
import com.tterrag.registrate.Registrate;
import dev.anvilcraft.guideme.command.AddonCommands;
import dev.anvilcraft.guideme.data.ModDatagen;
import dev.anvilcraft.guideme.guide.compiler.tag.GradientColourTagCompiler;
import dev.anvilcraft.guideme.guide.compiler.tag.KeyMapTagCompiler;
Expand All @@ -16,6 +17,9 @@
import net.neoforged.bus.api.IEventBus;
import net.neoforged.fml.ModContainer;
import net.neoforged.fml.common.Mod;
import net.neoforged.neoforge.common.NeoForge;
import net.neoforged.neoforge.event.RegisterCommandsEvent;
import org.jetbrains.annotations.NotNull;
import org.slf4j.Logger;

@Mod(AnvilCraftGuideME.MOD_ID)
Expand All @@ -28,9 +32,10 @@ public class AnvilCraftGuideME {
@Getter
private static Guide guideme;

public AnvilCraftGuideME(IEventBus modEventBus, ModContainer modContainer) {
public AnvilCraftGuideME(IEventBus bus, ModContainer container) {
ModDatagen.init();
this.guide();
this.registerEvents(bus);
}

private void guide() {
Expand All @@ -44,7 +49,15 @@ private void guide() {
.build();
}

private void registerEvents(@NotNull IEventBus eventBus) {
NeoForge.EVENT_BUS.addListener(AnvilCraftGuideME::registerCommand);
}

public static ResourceLocation of(String path) {
return ResourceLocation.fromNamespaceAndPath(MOD_ID, path);
}

public static void registerCommand(RegisterCommandsEvent event) {
AddonCommands.register(event.getDispatcher());
}
}
16 changes: 16 additions & 0 deletions src/main/java/dev/anvilcraft/guideme/command/AddonCommands.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package dev.anvilcraft.guideme.command;

import com.mojang.brigadier.CommandDispatcher;
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
import net.minecraft.commands.CommandSourceStack;
import org.jetbrains.annotations.NotNull;

import static net.minecraft.commands.Commands.literal;

public class AddonCommands {
public static void register(@NotNull CommandDispatcher<CommandSourceStack> dispatcher) {
LiteralArgumentBuilder<CommandSourceStack> root = literal("anvilcraft_guideme");
GetHandCommand.registerCommand(root);
dispatcher.register(root);
}
}
49 changes: 49 additions & 0 deletions src/main/java/dev/anvilcraft/guideme/command/GetHandCommand.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
package dev.anvilcraft.guideme.command;

import com.mojang.brigadier.builder.LiteralArgumentBuilder;
import com.mojang.brigadier.context.CommandContext;
import net.minecraft.ChatFormatting;
import net.minecraft.commands.CommandSourceStack;
import net.minecraft.network.chat.ClickEvent;
import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.Style;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;

import java.util.concurrent.atomic.AtomicInteger;

import static net.minecraft.commands.Commands.literal;

public class GetHandCommand {
private static int showInfo(CommandContext<CommandSourceStack> ctx) {
ServerPlayer player = ctx.getSource().getPlayer();
AtomicInteger returnValue = new AtomicInteger(0);
if (player == null) return returnValue.get();
returnValue.set(1);

ItemStack itemStack = player.getMainHandItem();
Item item = itemStack.getItem();

Component message = Component.translatable(
"command.ac_guideme.item",
itemStack.getDisplayName()
).withStyle(ChatFormatting.GREEN);


ctx.getSource().sendSystemMessage(copy(message, item.toString()));
return returnValue.get();
}

public static void registerCommand(LiteralArgumentBuilder<CommandSourceStack> parent) {
LiteralArgumentBuilder<CommandSourceStack> commandRoot = literal("hand")
.executes(GetHandCommand::showInfo);
parent.then(commandRoot);
}

private static Component copy(Component c, String copy) {
return Component.literal("- ")
.withStyle(Style.EMPTY.withClickEvent(new ClickEvent(ClickEvent.Action.COPY_TO_CLIPBOARD, copy)))
.append(c);
}
}
2 changes: 1 addition & 1 deletion src/main/java/dev/anvilcraft/guideme/data/ModDatagen.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

import static dev.anvilcraft.guideme.AnvilCraftGuideME.REGISTRATE;

@EventBusSubscriber(modid = AnvilCraftGuideME.MOD_ID, bus = EventBusSubscriber.Bus.MOD)
@EventBusSubscriber(modid = AnvilCraftGuideME.MOD_ID)
public class ModDatagen {
@SubscribeEvent
public static void gatherData(GatherDataEvent event) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package dev.anvilcraft.guideme.data.lang;

import com.tterrag.registrate.providers.RegistrateLangProvider;

public class CommandLang {
public static void init(RegistrateLangProvider provider) {
provider.add("command.ac_guideme.item", "Item: %s");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@
public class LangHandler {
public static void init(RegistrateLangProvider provider) {
ModInfoLang.init(provider);
RecipeLang.init(provider);
CommandLang.init(provider);
}
}

This file was deleted.