diff --git a/README.md b/README.md index 405dbcb..ad2d6c8 100644 --- a/README.md +++ b/README.md @@ -2,10 +2,10 @@ A Fabric Minecraft mod which disables the increased durability loss in combat and enables Looting for axes. -Axes normally lose 2 durability when hitting things because they are considered a mining tool, not a weapon. -This mod fixes that, making them lose only 1 durability point, just like swords. -It also enables Looting for axes but no more so to not take away from swords - Knockback and Fire Aspect are still exclusive to them. +Axes normally lose 2 durability when hitting things because they are considered a mining tool, not a weapon. +This mod fixes that, making them lose only 1 durability point, just like swords. +It also enables Looting for axes, while Knockback and Fire Aspect can be enabled in the config. -- requires Minecraft 1.16.2+, Fabric Loader 0.11.1+ +- requires Minecraft 1.16.2+, Fabric Loader 0.11.1+ and [Cloth Config](https://www.curseforge.com/minecraft/mc-mods/cloth-config) - works server-only - works in single player when installed on the client \ No newline at end of file diff --git a/build.gradle b/build.gradle index ef8b591..68ed055 100644 --- a/build.gradle +++ b/build.gradle @@ -9,10 +9,23 @@ archivesBaseName = project.archives_base_name version = project.mod_version group = project.maven_group +repositories { + maven { url "https://maven.shedaniel.me/" } + maven { url "https://maven.terraformersmc.com/" } +} + dependencies { minecraft "com.mojang:minecraft:${project.minecraft_version}" mappings "net.fabricmc:yarn:${project.yarn_mappings}:v2" modImplementation "net.fabricmc:fabric-loader:${project.loader_version}" + + modImplementation("com.terraformersmc:modmenu:${project.modmenu_version}") { + exclude(group: "net.fabricmc.fabric-api") + } + + modApi("me.shedaniel.cloth:cloth-config-fabric:${project.cloth_config_version}") { + exclude(group: "net.fabricmc.fabric-api") + } } processResources { diff --git a/gradle.properties b/gradle.properties index a94c682..9ab00ed 100644 --- a/gradle.properties +++ b/gradle.properties @@ -7,6 +7,9 @@ yarn_mappings=1.16.5+build.6 loader_version=0.11.3 # Mod Properties -mod_version=1.0 +mod_version=1.1 maven_group=fourmisain archives_base_name=AxesAreWeapons + +cloth_config_version=4.11.19 +modmenu_version=1.16.9 \ No newline at end of file diff --git a/src/main/java/fourmisain/axesareweapons/AxesAreWeapons.java b/src/main/java/fourmisain/axesareweapons/AxesAreWeapons.java new file mode 100644 index 0000000..c8d4972 --- /dev/null +++ b/src/main/java/fourmisain/axesareweapons/AxesAreWeapons.java @@ -0,0 +1,15 @@ +package fourmisain.axesareweapons; + +import fourmisain.axesareweapons.config.Configuration; +import me.shedaniel.autoconfig.AutoConfig; +import me.shedaniel.autoconfig.serializer.JanksonConfigSerializer; +import net.fabricmc.api.ModInitializer; + +public class AxesAreWeapons implements ModInitializer { + public static Configuration CONFIG; + + @Override + public void onInitialize() { + CONFIG = AutoConfig.register(Configuration.class, JanksonConfigSerializer::new).getConfig(); + } +} diff --git a/src/main/java/fourmisain/axesareweapons/config/Configuration.java b/src/main/java/fourmisain/axesareweapons/config/Configuration.java new file mode 100644 index 0000000..b415608 --- /dev/null +++ b/src/main/java/fourmisain/axesareweapons/config/Configuration.java @@ -0,0 +1,17 @@ +package fourmisain.axesareweapons.config; + +import me.shedaniel.autoconfig.ConfigData; +import me.shedaniel.autoconfig.annotation.Config; +import me.shedaniel.autoconfig.annotation.ConfigEntry; + +@Config(name = "axesareweapons") +public class Configuration implements ConfigData { + + @ConfigEntry.Gui.Tooltip(count = 2) + public boolean enableLooting = true; + @ConfigEntry.Gui.Tooltip(count = 2) + public boolean enableKnockback = false; + @ConfigEntry.Gui.Tooltip(count = 2) + public boolean enableFireAspect = false; + +} \ No newline at end of file diff --git a/src/main/java/fourmisain/axesareweapons/config/ModMenuImpl.java b/src/main/java/fourmisain/axesareweapons/config/ModMenuImpl.java new file mode 100644 index 0000000..b113feb --- /dev/null +++ b/src/main/java/fourmisain/axesareweapons/config/ModMenuImpl.java @@ -0,0 +1,15 @@ +package fourmisain.axesareweapons.config; + +import com.terraformersmc.modmenu.api.ConfigScreenFactory; +import com.terraformersmc.modmenu.api.ModMenuApi; +import me.shedaniel.autoconfig.AutoConfig; +import net.fabricmc.api.EnvType; +import net.fabricmc.api.Environment; + +@Environment(EnvType.CLIENT) +public class ModMenuImpl implements ModMenuApi { + @Override + public ConfigScreenFactory getModConfigScreenFactory() { + return parent -> AutoConfig.getConfigScreen(Configuration.class, parent).get(); + } +} \ No newline at end of file diff --git a/src/main/java/fourmisain/axesareweapons/mixin/AxeItemMixin.java b/src/main/java/fourmisain/axesareweapons/mixin/AxeItemMixin.java index 9283666..f545878 100644 --- a/src/main/java/fourmisain/axesareweapons/mixin/AxeItemMixin.java +++ b/src/main/java/fourmisain/axesareweapons/mixin/AxeItemMixin.java @@ -1,6 +1,5 @@ package fourmisain.axesareweapons.mixin; - import net.minecraft.entity.EquipmentSlot; import net.minecraft.entity.LivingEntity; import net.minecraft.item.AxeItem; diff --git a/src/main/java/fourmisain/axesareweapons/mixin/LuckEnchantmentMixin.java b/src/main/java/fourmisain/axesareweapons/mixin/EnchantmentMixin.java similarity index 54% rename from src/main/java/fourmisain/axesareweapons/mixin/LuckEnchantmentMixin.java rename to src/main/java/fourmisain/axesareweapons/mixin/EnchantmentMixin.java index 8661f13..195d50e 100644 --- a/src/main/java/fourmisain/axesareweapons/mixin/LuckEnchantmentMixin.java +++ b/src/main/java/fourmisain/axesareweapons/mixin/EnchantmentMixin.java @@ -1,7 +1,10 @@ package fourmisain.axesareweapons.mixin; +import fourmisain.axesareweapons.AxesAreWeapons; import net.minecraft.enchantment.Enchantment; +import net.minecraft.enchantment.EnchantmentTarget; import net.minecraft.enchantment.Enchantments; +import net.minecraft.entity.EquipmentSlot; import net.minecraft.item.AxeItem; import net.minecraft.item.ItemStack; import org.spongepowered.asm.mixin.Mixin; @@ -10,11 +13,15 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; @Mixin(Enchantment.class) -public abstract class LuckEnchantmentMixin { +public abstract class EnchantmentMixin { @Inject(method = "isAcceptableItem", at = @At("HEAD"), cancellable = true) public void isAcceptableItem(ItemStack stack, CallbackInfoReturnable cir) { - if ((Object) this == Enchantments.LOOTING && stack.getItem() instanceof AxeItem) { - cir.setReturnValue(true); + if (AxesAreWeapons.CONFIG.enableLooting && (Object) this == Enchantments.LOOTING + || AxesAreWeapons.CONFIG.enableKnockback && (Object) this == Enchantments.KNOCKBACK + || AxesAreWeapons.CONFIG.enableFireAspect && (Object) this == Enchantments.FIRE_ASPECT) { + if (stack.getItem() instanceof AxeItem) { + cir.setReturnValue(true); + } } } } diff --git a/src/main/resources/assets/axesareweapons/lang/de_de.json b/src/main/resources/assets/axesareweapons/lang/de_de.json new file mode 100644 index 0000000..d7d116c --- /dev/null +++ b/src/main/resources/assets/axesareweapons/lang/de_de.json @@ -0,0 +1,12 @@ +{ + "modmenu.descriptionTranslation.axesareweapons": "Entfernt den erhöhten Haltbarkeitsverlust im Kampf und erlaubt Plünderung für Äxte", + "text.autoconfig.axesareweapons.option.enableLooting": "Erlaube Plünderung auf Äxten", + "text.autoconfig.axesareweapons.option.enableKnockback": "Erlaube Rückstoß auf Äxten", + "text.autoconfig.axesareweapons.option.enableFireAspect": "Erlaube Verbrennung auf Äxten", + "text.autoconfig.axesareweapons.option.enableLooting.@Tooltip[0]": "Sobald die Verzauberung auf einer Axt ist, bleibt", + "text.autoconfig.axesareweapons.option.enableLooting.@Tooltip[1]": "sie dort, selbst wenn die Option ausgeschalten wird", + "text.autoconfig.axesareweapons.option.enableKnockback.@Tooltip[0]": "Sobald die Verzauberung auf einer Axt ist, bleibt", + "text.autoconfig.axesareweapons.option.enableKnockback.@Tooltip[1]": "sie dort, selbst wenn die Option ausgeschalten wird", + "text.autoconfig.axesareweapons.option.enableFireAspect.@Tooltip[0]": "Sobald die Verzauberung auf einer Axt ist, bleibt", + "text.autoconfig.axesareweapons.option.enableFireAspect.@Tooltip[1]": "sie dort, selbst wenn die Option ausgeschalten wird" +} \ No newline at end of file diff --git a/src/main/resources/assets/axesareweapons/lang/en_us.json b/src/main/resources/assets/axesareweapons/lang/en_us.json new file mode 100644 index 0000000..aae4c0f --- /dev/null +++ b/src/main/resources/assets/axesareweapons/lang/en_us.json @@ -0,0 +1,12 @@ +{ + "text.autoconfig.axesareweapons.title": "Axes Are Weapons", + "text.autoconfig.axesareweapons.option.enableLooting": "Enable Looting for Axes", + "text.autoconfig.axesareweapons.option.enableKnockback": "Enable Knockback for Axes", + "text.autoconfig.axesareweapons.option.enableFireAspect": "Enable Fire Aspect for Axes", + "text.autoconfig.axesareweapons.option.enableLooting.@Tooltip[0]": "Once on an axe, the enchantment will stay", + "text.autoconfig.axesareweapons.option.enableLooting.@Tooltip[1]": "on there, even if the option is disabled", + "text.autoconfig.axesareweapons.option.enableKnockback.@Tooltip[0]": "Once on an axe, the enchantment will stay", + "text.autoconfig.axesareweapons.option.enableKnockback.@Tooltip[1]": "on there, even if the option is disabled", + "text.autoconfig.axesareweapons.option.enableFireAspect.@Tooltip[0]": "Once on an axe, the enchantment will stay", + "text.autoconfig.axesareweapons.option.enableFireAspect.@Tooltip[1]": "on there, even if the option is disabled" +} \ No newline at end of file diff --git a/src/main/resources/axesareweapons.mixins.json b/src/main/resources/axesareweapons.mixins.json index cfc8227..d10a1ff 100644 --- a/src/main/resources/axesareweapons.mixins.json +++ b/src/main/resources/axesareweapons.mixins.json @@ -5,7 +5,7 @@ "compatibilityLevel": "JAVA_8", "mixins": [ "AxeItemMixin", - "LuckEnchantmentMixin", + "EnchantmentMixin", "MiningToolItemMixin" ], "injectors": { diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json index 693413a..3f432e9 100644 --- a/src/main/resources/fabric.mod.json +++ b/src/main/resources/fabric.mod.json @@ -15,11 +15,20 @@ "license": "MIT", "icon": "assets/axesareweapons/icon.png", "environment": "*", + "entrypoints": { + "main": [ + "fourmisain.axesareweapons.AxesAreWeapons" + ], + "modmenu": [ + "fourmisain.axesareweapons.config.ModMenuImpl" + ] + }, "mixins": [ "axesareweapons.mixins.json" ], "depends": { "fabricloader": ">=0.11.1", - "minecraft": ">=1.16.2" + "minecraft": ">=1.16.2", + "cloth-config2": ">=4.8.0" } }