Skip to content

Commit

Permalink
- config file and Mod Menu support, allowing to switch allowed enchan…
Browse files Browse the repository at this point in the history
…tments

- support for knockback and fire aspect
- add German translation
  • Loading branch information
Fourmisain committed Apr 15, 2021
1 parent 7a978f3 commit 466d43e
Show file tree
Hide file tree
Showing 12 changed files with 113 additions and 11 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
13 changes: 13 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
5 changes: 4 additions & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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
15 changes: 15 additions & 0 deletions src/main/java/fourmisain/axesareweapons/AxesAreWeapons.java
Original file line number Diff line number Diff line change
@@ -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();
}
}
17 changes: 17 additions & 0 deletions src/main/java/fourmisain/axesareweapons/config/Configuration.java
Original file line number Diff line number Diff line change
@@ -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;

}
15 changes: 15 additions & 0 deletions src/main/java/fourmisain/axesareweapons/config/ModMenuImpl.java
Original file line number Diff line number Diff line change
@@ -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();
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package fourmisain.axesareweapons.mixin;


import net.minecraft.entity.EquipmentSlot;
import net.minecraft.entity.LivingEntity;
import net.minecraft.item.AxeItem;
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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<Boolean> 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);
}
}
}
}
12 changes: 12 additions & 0 deletions src/main/resources/assets/axesareweapons/lang/de_de.json
Original file line number Diff line number Diff line change
@@ -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"
}
12 changes: 12 additions & 0 deletions src/main/resources/assets/axesareweapons/lang/en_us.json
Original file line number Diff line number Diff line change
@@ -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"
}
2 changes: 1 addition & 1 deletion src/main/resources/axesareweapons.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"compatibilityLevel": "JAVA_8",
"mixins": [
"AxeItemMixin",
"LuckEnchantmentMixin",
"EnchantmentMixin",
"MiningToolItemMixin"
],
"injectors": {
Expand Down
11 changes: 10 additions & 1 deletion src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}

0 comments on commit 466d43e

Please # to comment.