Config fixes

This commit is contained in:
2025-09-18 14:06:13 +02:00
parent acdf1d5747
commit 5fac94e868
4 changed files with 25 additions and 17 deletions

View File

@@ -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.0
mod_version=1.1
maven_group=com.kasetoatz
archives_base_name=SuperEnchants
# Dependencies

View File

@@ -21,12 +21,12 @@ public class Config
public static boolean ARMOR_ENCHANTS_UNNERF = true;
public static boolean TOOL_ENCHANTS_UNNERF = true;
public static boolean ENABLE_CHANNELING_2 = true;
public static boolean ENABLE_LOYALTY_VOID_PROTECTION = true; // todo
public static boolean LOYALTY_VOID_PROTECTION = true;
public static boolean DISABLE_SOUL_SPEED_DAMAGE = true;
public static boolean DISABLE_THORNS_DAMAGE = true;
public static boolean ENABLE_INFINITY_WITHOUT_ARROW = true;
public static boolean ENABLE_CROSSBOW_INFINITY = true;
public static boolean LOYALTY_RETURN_TO_SAME_SLOT = true; // todo
public static boolean TRIDENT_RETURN_TO_SAME_SLOT = true;
public static boolean ENABLE_CUSTOM_ENCHANT_LEVELS = true;
public static Map<Identifier, Integer> LEVELS = new HashMap<>(Map.ofEntries(
@@ -98,9 +98,9 @@ public class Config
{
ENABLE_CHANNELING_2 = data.get("enable-channeling-2").getAsBoolean();
}
if (data.has("enable-loyalty-void-protection"))
if (data.has("loyalty-void-protection"))
{
ENABLE_LOYALTY_VOID_PROTECTION = data.get("enable-loyalty-void-protection").getAsBoolean();
LOYALTY_VOID_PROTECTION = data.get("loyalty-void-protection").getAsBoolean();
}
if (data.has("disable-soul-speed-damage"))
{
@@ -118,9 +118,9 @@ public class Config
{
ENABLE_CROSSBOW_INFINITY = data.get("enable-crossbow-infinity").getAsBoolean();
}
if (data.has("loyalty-return-to-same-slot"))
if (data.has("trident-return-to-same-slot"))
{
LOYALTY_RETURN_TO_SAME_SLOT = data.get("loyalty-return-to-same-slot").getAsBoolean();
TRIDENT_RETURN_TO_SAME_SLOT = data.get("loyalty-return-to-same-slot").getAsBoolean();
}
if (data.has("enable-custom-enchant-levels"))
{
@@ -149,12 +149,12 @@ public class Config
data.addProperty("armor-enchants-unnerf", ARMOR_ENCHANTS_UNNERF);
data.addProperty("tool-enchants-unnerf", TOOL_ENCHANTS_UNNERF);
data.addProperty("enable-channeling-2", ENABLE_CHANNELING_2);
data.addProperty("enable-loyalty-void-protection", ENABLE_LOYALTY_VOID_PROTECTION);
data.addProperty("loyalty-void-protection", LOYALTY_VOID_PROTECTION);
data.addProperty("disable-soul-speed-damage", DISABLE_SOUL_SPEED_DAMAGE);
data.addProperty("disable-thorns-damage", DISABLE_THORNS_DAMAGE);
data.addProperty("enable-infinity-without-arrow", ENABLE_INFINITY_WITHOUT_ARROW);
data.addProperty("enable-crossbow-infinity", ENABLE_CROSSBOW_INFINITY);
data.addProperty("loyalty-return-to-same-slot", LOYALTY_RETURN_TO_SAME_SLOT);
data.addProperty("trident-return-to-same-slot", TRIDENT_RETURN_TO_SAME_SLOT);
data.addProperty("enable-custom-enchant-levels", ENABLE_CUSTOM_ENCHANT_LEVELS);
JsonObject levels = new JsonObject();
LEVELS.forEach((id, level) -> levels.addProperty(id.toString(), level));

View File

@@ -9,15 +9,21 @@ 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.config.Config.TRIDENT_RETURN_TO_SAME_SLOT;
@Mixin(PersistentProjectileEntity.class)
public class PersistentProjectileMixin
{
@Redirect(method="tryPickup", at= @At(value = "INVOKE", target = "Lnet/minecraft/entity/player/PlayerInventory;insertStack(Lnet/minecraft/item/ItemStack;)Z"))
public boolean tryPickup(PlayerInventory inventory, ItemStack stack)
{
if (TRIDENT_RETURN_TO_SAME_SLOT)
{
if ((Object)this instanceof TridentEntity trident)
{
int slot = trident.get(DataComponentTypes.CUSTOM_DATA).copyNbt().getInt("slot", -1);
if (slot != -1 && inventory.getStack(slot).isEmpty())
{
if (slot == PlayerInventory.OFF_HAND_SLOT)
{
inventory.setStack(slot, stack);
@@ -25,6 +31,8 @@ public class PersistentProjectileMixin
}
return inventory.insertStack(slot, stack);
}
}
}
return inventory.insertStack(stack);
}
}

View File

@@ -9,7 +9,7 @@ import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import static com.kasetoatz.superenchants.config.Config.ENABLE_LOYALTY_VOID_PROTECTION;
import static com.kasetoatz.superenchants.config.Config.LOYALTY_VOID_PROTECTION;
@Mixin(TridentEntity.class)
public abstract class TridentEntityMixin
@@ -21,7 +21,7 @@ public abstract class TridentEntityMixin
public void tick(CallbackInfo ci)
{
TridentEntity trident = ((TridentEntity)(Object)this);
if (ENABLE_LOYALTY_VOID_PROTECTION && trident.getDataTracker().get(LOYALTY) > 0 && trident.getY() <= trident.getWorld().getBottomY())
if (LOYALTY_VOID_PROTECTION && trident.getDataTracker().get(LOYALTY) > 0 && trident.getY() <= trident.getWorld().getBottomY())
{
dealtDamage = true;
trident.setVelocity(0, 0, 0);