diff --git a/src/main/java/wayoftime/bloodmagic/BloodMagic.java b/src/main/java/wayoftime/bloodmagic/BloodMagic.java index 12ee47f4..c25a03d4 100644 --- a/src/main/java/wayoftime/bloodmagic/BloodMagic.java +++ b/src/main/java/wayoftime/bloodmagic/BloodMagic.java @@ -20,7 +20,9 @@ import net.minecraftforge.common.crafting.CraftingHelper; import net.minecraftforge.event.RegistryEvent; import net.minecraftforge.eventbus.api.IEventBus; import net.minecraftforge.eventbus.api.SubscribeEvent; +import net.minecraftforge.fml.ModLoadingContext; import net.minecraftforge.fml.common.Mod; +import net.minecraftforge.fml.config.ModConfig; import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent; import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent; import net.minecraftforge.fml.event.lifecycle.FMLLoadCompleteEvent; @@ -117,6 +119,9 @@ public class BloodMagic // Register ourselves for server and other game events we are interested in MinecraftForge.EVENT_BUS.register(this); + + ModLoadingContext context = ModLoadingContext.get(); + context.registerConfig(ModConfig.Type.CLIENT, ConfigManager.CLIENT_SPEC); } private void registerRecipes(RegistryEvent.Register> event) diff --git a/src/main/java/wayoftime/bloodmagic/ConfigManager.java b/src/main/java/wayoftime/bloodmagic/ConfigManager.java new file mode 100644 index 00000000..6863c46b --- /dev/null +++ b/src/main/java/wayoftime/bloodmagic/ConfigManager.java @@ -0,0 +1,36 @@ +package wayoftime.bloodmagic; + +import org.apache.commons.lang3.tuple.Pair; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + +import net.minecraftforge.common.ForgeConfigSpec; + +public class ConfigManager +{ + private static final Logger LOGGER = LogManager.getLogger(); + + public static final ClientConfig CLIENT; + public static final ForgeConfigSpec CLIENT_SPEC; + + static + { + final Pair specPair = new ForgeConfigSpec.Builder().configure(ClientConfig::new); + CLIENT_SPEC = specPair.getRight(); + CLIENT = specPair.getLeft(); + } + + public static class ClientConfig + { + public final ForgeConfigSpec.DoubleValue demonWillGaugeX; + public final ForgeConfigSpec.DoubleValue demonWillGaugeY; + + ClientConfig(ForgeConfigSpec.Builder builder) + { + builder.comment("Settings for the position of the Demon Will Gauge HUD element.").push("hud"); + demonWillGaugeX = builder.defineInRange("DemonWillGaugePosX", 0.01, 0, 1); + demonWillGaugeY = builder.defineInRange("DemonWillGaugePosY", 0.01, 0, 1); + builder.pop(); + } + } +} diff --git a/src/main/java/wayoftime/bloodmagic/client/hud/Elements.java b/src/main/java/wayoftime/bloodmagic/client/hud/Elements.java index cf21ce9e..e1b771d0 100644 --- a/src/main/java/wayoftime/bloodmagic/client/hud/Elements.java +++ b/src/main/java/wayoftime/bloodmagic/client/hud/Elements.java @@ -3,12 +3,13 @@ package wayoftime.bloodmagic.client.hud; import net.minecraft.util.ResourceLocation; import net.minecraft.util.math.vector.Vector2f; import wayoftime.bloodmagic.BloodMagic; +import wayoftime.bloodmagic.ConfigManager; import wayoftime.bloodmagic.client.hud.element.ElementDemonAura; public class Elements { public static void registerElements() { - ElementRegistry.registerHandler(new ResourceLocation(BloodMagic.MODID, "demon_will_aura"), new ElementDemonAura(), new Vector2f(0.01F, 0.01F)); + ElementRegistry.registerHandler(new ResourceLocation(BloodMagic.MODID, "demon_will_aura"), new ElementDemonAura(), new Vector2f(ConfigManager.CLIENT.demonWillGaugeX.get().floatValue(), ConfigManager.CLIENT.demonWillGaugeY.get().floatValue())); } } diff --git a/src/main/java/wayoftime/bloodmagic/command/CommandBloodMagic.java b/src/main/java/wayoftime/bloodmagic/command/CommandBloodMagic.java new file mode 100644 index 00000000..c24d195f --- /dev/null +++ b/src/main/java/wayoftime/bloodmagic/command/CommandBloodMagic.java @@ -0,0 +1,14 @@ +package wayoftime.bloodmagic.command; + +import com.mojang.brigadier.CommandDispatcher; +import com.mojang.brigadier.builder.LiteralArgumentBuilder; + +import net.minecraft.command.CommandSource; + +public class CommandBloodMagic +{ + public CommandBloodMagic(CommandDispatcher dispatcher) + { + dispatcher.register(LiteralArgumentBuilder.literal("bloodmagic")); + } +} \ No newline at end of file diff --git a/src/main/java/wayoftime/bloodmagic/command/sub/SubCommandBind.java b/src/main/java/wayoftime/bloodmagic/command/sub/SubCommandBind.java new file mode 100644 index 00000000..c71d3d82 --- /dev/null +++ b/src/main/java/wayoftime/bloodmagic/command/sub/SubCommandBind.java @@ -0,0 +1,111 @@ +package wayoftime.bloodmagic.command.sub; + +import net.minecraft.command.CommandException; +import net.minecraft.command.CommandSource; +import net.minecraft.entity.player.ServerPlayerEntity; + +public class SubCommandBind +{ + public ServerPlayerEntity player; + +// static ArgumentBuilder register() +// { +// return Commands.literal("generate") +// .requires(cs->cs.hasPermissionLevel(4)) //permission +// .then(Commands.argument("pos", BlockPosArgument.blockPos()) +// .then(Commands.argument("count", IntegerArgumentType.integer(1)) +// .then(Commands.argument("dim", DimensionArgument.getDimension()) +// .then(Commands.argument("interval", IntegerArgumentType.integer()) +// .executes(ctx -> execute(ctx.getSource(), BlockPosArgument.getBlockPos(ctx, "pos"), getInt(ctx, "count"), DimensionArgument.getDimensionArgument(ctx, "dim"), getInt(ctx, "interval"))) +// ) +// .executes(ctx -> execute(ctx.getSource(), BlockPosArgument.getBlockPos(ctx, "pos"), getInt(ctx, "count"), DimensionArgument.getDimensionArgument(ctx, "dim"), -1)) +// ) +// .executes(ctx -> execute(ctx.getSource(), BlockPosArgument.getBlockPos(ctx, "pos"), getInt(ctx, "count"), ctx.getSource().getWorld(), -1)) +// ) +// ); +// } + +// public ITextComponent getInfo() +// { +// return player.getName(); +// } +// +// @Override +// public String getName() +// { +// return "bind"; +// } +// +// @Override +// public String getUsage(ICommandSender commandSender) +// { +// return "commands.bloodmagic.bind.usage"; +// } +// +// public String getHelp() +// { +// return "commands.bloodmagic.bind.help"; +// } +// +// @Override +// public int getRequiredPermissionLevel() +// { +// return 2; +// } + + public static int execute(CommandSource source, String[] args) + throws CommandException + { +// if (args.length == 1 && (args[0].equals("?") || args[0].equals("help"))) +// { +// sender.sendMessage(new TranslationTextComponent(getHelp())); +// return; +// } +// if (sender.getEntityWorld().isRemote) +// return; +// ServerPlayerEntity player = args.length < 2 ? getCommandSenderAsPlayer(sender) +// : getPlayer(server, sender, args[0]); +// ItemStack held = player.getHeldItemMainhand(); +// boolean bind = true; +// if (held.getItem() instanceof IBindable) +// { +// Binding binding = ((IBindable) held.getItem()).getBinding(held); +// if (binding != null) +// bind = false; +// if (args.length < 2) +// if (args.length == 1) +// if (isBoolean(args[0])) +// bind = Boolean.parseBoolean(args[0]); +// else +// player = getPlayer(server, sender, args[0]); +// if (bind) +// { +// if (binding.getOwnerName().equals(player.getName())) +// { +// sender.sendMessage(new TranslationTextComponent("commands.bloodmagic.bind.error.ownerEqualsTarget")); +// return; +// } +// binding = new Binding(player.getGameProfile().getId(), player.getGameProfile().getName()); +// BindableHelper.applyBinding(held, binding); +// this.player = player; +// sender.sendMessage(new TranslationTextComponent("commands.bloodmagic.bind.success", getInfo())); +// } else +// { +// if (binding == null) +// { +// sender.sendMessage(new TranslationTextComponent("commands.bloodmagic.bind.error.notBound")); +// } +// held.getTagCompound().removeTag("binding"); +// sender.sendMessage(new TranslationTextComponent("commands.bloodmagic.bind.remove.success")); +// } +// } else +// sender.sendMessage(new TranslationTextComponent("commands.bloodmagic.bind.error.notBindable")); + + return 1; + } + + private boolean isBoolean(String string) + { + return string.equalsIgnoreCase("true") || string.equalsIgnoreCase("false"); + } +}