Add max anvil cost config and EnchantCommand mixin
Introduces a configurable max anvil cost via the config and enforces it in AnvilScreenHandlerMixin. Adds EnchantCommandMixin to support custom enchantment levels in the /enchant command. Updates mod version to 1.10 and registers the new mixin in the mixins config.
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
package com.kasetoatz.superenchants.mixin;
|
||||
|
||||
import net.minecraft.enchantment.Enchantment;
|
||||
import net.minecraft.server.command.EnchantCommand;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||
|
||||
import static com.kasetoatz.superenchants.util.Util.getCustomLevel;
|
||||
|
||||
@Mixin(EnchantCommand.class)
|
||||
public class EnchantCommandMixin
|
||||
{
|
||||
@Redirect(method="execute", at= @At(value = "INVOKE", target = "Lnet/minecraft/enchantment/Enchantment;getMaxLevel()I"))
|
||||
private static int execute(Enchantment enchant)
|
||||
{
|
||||
int custom = getCustomLevel(enchant);
|
||||
return (custom > 0) ? custom : enchant.getMaxLevel();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user