V1.4
This commit is contained in:
@@ -6,7 +6,7 @@ minecraft_version=1.21.8
|
||||
yarn_mappings=1.21.8+build.1
|
||||
loader_version=0.17.2
|
||||
# Mod Properties
|
||||
mod_version=1.3
|
||||
mod_version=1.4
|
||||
maven_group=com.kasetoatz
|
||||
archives_base_name=SuperEnchants
|
||||
# Dependencies
|
||||
|
||||
@@ -29,7 +29,9 @@ public class Config
|
||||
public static boolean ENABLE_CROSSBOW_INFINITY = true;
|
||||
public static boolean TRIDENT_RETURN_TO_SAME_SLOT = true;
|
||||
public static boolean ONLY_BEST_VILLAGER_TRADES = false;
|
||||
public static boolean NO_PRIOR_WORK_PENALTY = true;
|
||||
public static boolean ENABLE_CUSTOM_ENCHANT_LEVELS = true;
|
||||
public static boolean CUSTOM_LEVELS_IN_LOOT_TABLE = false;
|
||||
|
||||
public static Map<Identifier, Integer> LEVELS = new HashMap<>(Map.ofEntries(
|
||||
Map.entry(Identifier.of("minecraft:unbreaking"), 5),
|
||||
@@ -133,10 +135,18 @@ public class Config
|
||||
{
|
||||
ONLY_BEST_VILLAGER_TRADES = data.get("only-best-villager-trades").getAsBoolean();
|
||||
}
|
||||
if (data.has("no-prior-work-penalty"))
|
||||
{
|
||||
NO_PRIOR_WORK_PENALTY = data.get("no-prior-work-penalty").getAsBoolean();
|
||||
}
|
||||
if (data.has("enable-custom-enchant-levels"))
|
||||
{
|
||||
ENABLE_CUSTOM_ENCHANT_LEVELS = data.get("enable-custom-enchant-levels").getAsBoolean();
|
||||
}
|
||||
if (data.has("custom-levels-in-loot-table"))
|
||||
{
|
||||
CUSTOM_LEVELS_IN_LOOT_TABLE = data.get("custom-levels-in-loot-table").getAsBoolean();
|
||||
}
|
||||
if (data.has("custom-levels"))
|
||||
{
|
||||
JsonObject levels = data.get("custom-levels").getAsJsonObject();
|
||||
@@ -168,7 +178,9 @@ public class Config
|
||||
data.addProperty("enable-crossbow-infinity", ENABLE_CROSSBOW_INFINITY);
|
||||
data.addProperty("trident-return-to-same-slot", TRIDENT_RETURN_TO_SAME_SLOT);
|
||||
data.addProperty("only-best-villager-trades", ONLY_BEST_VILLAGER_TRADES);
|
||||
data.addProperty("no-prior-work-penalty", NO_PRIOR_WORK_PENALTY);
|
||||
data.addProperty("enable-custom-enchant-levels", ENABLE_CUSTOM_ENCHANT_LEVELS);
|
||||
data.addProperty("custom-levels-in-loot-table", CUSTOM_LEVELS_IN_LOOT_TABLE);
|
||||
JsonObject levels = new JsonObject();
|
||||
LEVELS.forEach((id, level) -> levels.addProperty(id.toString(), level));
|
||||
data.add("custom-levels", levels);
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
package com.kasetoatz.superenchants.mixin;
|
||||
|
||||
import com.llamalad7.mixinextras.injector.ModifyReturnValue;
|
||||
import com.llamalad7.mixinextras.sugar.Local;
|
||||
import net.minecraft.component.ComponentHolder;
|
||||
import net.minecraft.component.ComponentType;
|
||||
import net.minecraft.component.DataComponentTypes;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
|
||||
import static com.kasetoatz.superenchants.config.Config.NO_PRIOR_WORK_PENALTY;
|
||||
|
||||
@Mixin(ComponentHolder.class)
|
||||
public interface ComponentHolderMixin
|
||||
{
|
||||
@SuppressWarnings("unchecked")
|
||||
@ModifyReturnValue(method="getOrDefault", at= @At("RETURN"))
|
||||
default <T> T getRepairCost(T original, @Local(argsOnly = true) ComponentType<? extends T> type)
|
||||
{
|
||||
if (NO_PRIOR_WORK_PENALTY && type == DataComponentTypes.REPAIR_COST)
|
||||
{
|
||||
return (T)(Integer)0;
|
||||
}
|
||||
return original;
|
||||
}
|
||||
}
|
||||
@@ -63,6 +63,10 @@ public class EnchantmentMixin
|
||||
@Unique
|
||||
private int getPowerLevel(int level)
|
||||
{
|
||||
if (!CUSTOM_LEVELS_IN_LOOT_TABLE)
|
||||
{
|
||||
return level;
|
||||
}
|
||||
int newMax = getCustomLevel((Enchantment)(Object)this);
|
||||
if (newMax == 0)
|
||||
{
|
||||
|
||||
@@ -3,6 +3,7 @@ package com.kasetoatz.superenchants.mixin;
|
||||
import net.minecraft.component.DataComponentTypes;
|
||||
import net.minecraft.component.type.ItemEnchantmentsComponent;
|
||||
import net.minecraft.enchantment.Enchantment;
|
||||
import net.minecraft.enchantment.Enchantments;
|
||||
import net.minecraft.entity.passive.MerchantEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.Items;
|
||||
@@ -15,6 +16,7 @@ import org.spongepowered.asm.mixin.injection.ModifyArg;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
import static com.kasetoatz.superenchants.config.Config.CUSTOM_LEVELS_IN_LOOT_TABLE;
|
||||
import static com.kasetoatz.superenchants.config.Config.ONLY_BEST_VILLAGER_TRADES;
|
||||
import static com.kasetoatz.superenchants.util.Util.getCustomLevel;
|
||||
|
||||
@@ -37,12 +39,16 @@ public class MerchantEntityMixin
|
||||
{
|
||||
return obj;
|
||||
}
|
||||
int level = getCustomLevel(entry.get().value());
|
||||
int level = CUSTOM_LEVELS_IN_LOOT_TABLE ? getCustomLevel(entry.get().value()) : entry.get().value().definition().maxLevel();
|
||||
if (level == 0)
|
||||
{
|
||||
level = entry.get().value().definition().maxLevel();
|
||||
}
|
||||
int price = 5 + 3 * (Math.clamp((int)Math.round(level / (level / (double)entry.get().value().definition().maxLevel())), 1, 5) - 1);
|
||||
if (entry.get().matchesKey(Enchantments.MENDING) || entry.get().matchesKey(Enchantments.FROST_WALKER))
|
||||
{
|
||||
price *= 2;
|
||||
}
|
||||
stack.addEnchantment(entry.get(), level);
|
||||
return new TradeOffer(
|
||||
new TradedItem(Items.EMERALD, price),
|
||||
|
||||
@@ -4,14 +4,15 @@
|
||||
"package": "com.kasetoatz.superenchants.mixin",
|
||||
"compatibilityLevel": "JAVA_21",
|
||||
"mixins": [
|
||||
"ComponentHolderMixin",
|
||||
"BowItemMixin",
|
||||
"ChangeItemDamageEnchantmentEffectMixin",
|
||||
"CrossbowItemMixin",
|
||||
"EnchantmentMixin",
|
||||
"MerchantEntityMixin",
|
||||
"PersistentProjectileMixin",
|
||||
"TridentEntityMixin",
|
||||
"TridentItemMixin",
|
||||
"MerchantEntityMixin",
|
||||
"WeatherCheckLootConditionMixin"
|
||||
],
|
||||
"client": [
|
||||
|
||||
Reference in New Issue
Block a user