diff --git a/gradle.properties b/gradle.properties index 2e05d75..fd21abc 100644 --- a/gradle.properties +++ b/gradle.properties @@ -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 diff --git a/src/main/java/com/kasetoatz/superenchants/config/Config.java b/src/main/java/com/kasetoatz/superenchants/config/Config.java index 2b3a31a..99a28fd 100644 --- a/src/main/java/com/kasetoatz/superenchants/config/Config.java +++ b/src/main/java/com/kasetoatz/superenchants/config/Config.java @@ -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 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)); diff --git a/src/main/java/com/kasetoatz/superenchants/mixin/PersistentProjectileMixin.java b/src/main/java/com/kasetoatz/superenchants/mixin/PersistentProjectileMixin.java index eb7748b..ce24115 100644 --- a/src/main/java/com/kasetoatz/superenchants/mixin/PersistentProjectileMixin.java +++ b/src/main/java/com/kasetoatz/superenchants/mixin/PersistentProjectileMixin.java @@ -9,21 +9,29 @@ 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 ((Object)this instanceof TridentEntity trident) + if (TRIDENT_RETURN_TO_SAME_SLOT) { - int slot = trident.get(DataComponentTypes.CUSTOM_DATA).copyNbt().getInt("slot", -1); - if (slot == PlayerInventory.OFF_HAND_SLOT) + if ((Object)this instanceof TridentEntity trident) { - inventory.setStack(slot, stack); - return true; + 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); + return true; + } + return inventory.insertStack(slot, stack); + } } - return inventory.insertStack(slot, stack); } return inventory.insertStack(stack); } diff --git a/src/main/java/com/kasetoatz/superenchants/mixin/TridentEntityMixin.java b/src/main/java/com/kasetoatz/superenchants/mixin/TridentEntityMixin.java index d206f71..ec34fda 100644 --- a/src/main/java/com/kasetoatz/superenchants/mixin/TridentEntityMixin.java +++ b/src/main/java/com/kasetoatz/superenchants/mixin/TridentEntityMixin.java @@ -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);