diff --git a/VERSION b/VERSION index 314c3d7..ab67981 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.1.5 \ No newline at end of file +1.1.6 \ No newline at end of file diff --git a/gradle.properties b/gradle.properties index f657585..aeb2c03 100644 --- a/gradle.properties +++ b/gradle.properties @@ -52,7 +52,7 @@ mod_name=JustLevelingFork # The license of the mod. Review your options at https://choosealicense.com/. All Rights Reserved is the default. mod_license=APACHE # The mod version. See https://semver.org/ -mod_version=1.1.5 +mod_version=1.1.6 # The group ID for the mod. It is only important when publishing as an artifact to a Maven repository. # This should match the base package used for the mod sources. # See https://maven.apache.org/guides/mini/guide-naming-conventions.html diff --git a/src/main/java/com/seniors/justlevelingfork/common/command/AptitudeLevelCommand.java b/src/main/java/com/seniors/justlevelingfork/common/command/AptitudeLevelCommand.java index a4fd4d8..712832a 100644 --- a/src/main/java/com/seniors/justlevelingfork/common/command/AptitudeLevelCommand.java +++ b/src/main/java/com/seniors/justlevelingfork/common/command/AptitudeLevelCommand.java @@ -38,7 +38,7 @@ public static void register(CommandDispatcher dispatcher) { ) .then(Commands.literal(("subtract")) .then(Commands.argument("level", IntegerArgumentType.integer(1, HandlerCommonConfig.HANDLER.instance().aptitudeMaxLevel)) - .executes(source -> addAptitude(source, EntityArgument.getPlayer(source, "player"), source.getArgument("aptitude", String.class), IntegerArgumentType.getInteger(source, "level"))) + .executes(source -> subtractAptitude(source, EntityArgument.getPlayer(source, "player"), source.getArgument("aptitude", String.class), IntegerArgumentType.getInteger(source, "level"))) ) ) ) diff --git a/src/main/java/com/seniors/justlevelingfork/handler/HandlerCommonConfig.java b/src/main/java/com/seniors/justlevelingfork/handler/HandlerCommonConfig.java index 0f3367f..01e55fd 100644 --- a/src/main/java/com/seniors/justlevelingfork/handler/HandlerCommonConfig.java +++ b/src/main/java/com/seniors/justlevelingfork/handler/HandlerCommonConfig.java @@ -51,10 +51,6 @@ public class HandlerCommonConfig { @AutoGen(category = "common", group = "general") @Boolean(formatter = Boolean.Formatter.ON_OFF) public boolean showPotionsHud = true; - @SerialEntry(comment = "If true, when trying to craft a non unlocked item, it will close the crafting the menu") - @AutoGen(category = "common", group = "general") - @Boolean(formatter = Boolean.Formatter.ON_OFF) - public boolean closeCraftingMenu = true; @SerialEntry(comment = "If true, locked items will be automatically dropped from player hands") @AutoGen(category = "common", group = "general") diff --git a/src/main/java/com/seniors/justlevelingfork/handler/HandlerConvergenceItemsConfig.java b/src/main/java/com/seniors/justlevelingfork/handler/HandlerConvergenceItemsConfig.java index 3ac3b85..8f3a307 100644 --- a/src/main/java/com/seniors/justlevelingfork/handler/HandlerConvergenceItemsConfig.java +++ b/src/main/java/com/seniors/justlevelingfork/handler/HandlerConvergenceItemsConfig.java @@ -10,6 +10,7 @@ import dev.isxander.yacl3.config.v2.api.serializer.GsonConfigSerializerBuilder; import net.minecraft.resources.ResourceLocation; +import java.util.Arrays; import java.util.List; public class HandlerConvergenceItemsConfig { @@ -24,5 +25,5 @@ public class HandlerConvergenceItemsConfig { @SerialEntry(comment = "Convergence skill convergence item list") @ListGroup(controllerFactory = StringListGroup.class, valueFactory = StringListGroup.class) - public List convergenceItemList = List.of(); + public List convergenceItemList = Arrays.asList("minecraft:iron_sword#minecraft:iron_ingot", "minecraft:iron_pickaxe#minecraft:iron_ingot", "minecraft:iron_axe#minecraft:iron_ingot", "minecraft:iron_shovel#minecraft:iron_nugget", "minecraft:iron_hoe#minecraft:iron_ingot", "minecraft:golden_sword#minecraft:gold_ingot", "minecraft:golden_pickaxe#minecraft:gold_ingot", "minecraft:golden_axe#minecraft:gold_ingot", "minecraft:golden_shovel#minecraft:gold_ingot", "minecraft:golden_hoe#minecraft:gold_ingot", "minecraft:diamond_sword#minecraft:diamond", "minecraft:diamond_pickaxe#minecraft:diamond", "minecraft:diamond_axe#minecraft:diamond", "minecraft:chainmail_helmet#minecraft:iron_nugget", "minecraft:chainmail_chestplate#minecraft:iron_nugget", "minecraft:chainmail_leggings#minecraft:iron_nugget", "minecraft:chainmail_boots#minecraft:iron_nugget", "minecraft:iron_helmet#minecraft:iron_ingot", "minecraft:iron_chestplate#minecraft:iron_ingot", "minecraft:iron_leggings#minecraft:iron_ingot", "minecraft:iron_boots#minecraft:iron_ingot", "minecraft:golden_helmet#minecraft:gold_ingot", "minecraft:golden_chestplate#minecraft:gold_ingot", "minecraft:golden_leggings#minecraft:gold_ingot", "minecraft:golden_boots#minecraft:gold_ingot", "minecraft:diamond_helmet#minecraft:diamond", "minecraft:diamond_chestplate#minecraft:diamond", "minecraft:diamond_leggings#minecraft:diamond", "minecraft:diamond_boots#minecraft:diamond", "minecraft:netherite_upgrade_smithing_template#minecraft:diamond", "minecraft:sentry_armor_trim_smithing_template#minecraft:diamond", "minecraft:vex_armor_trim_smithing_template#minecraft:diamond", "minecraft:wild_armor_trim_smithing_template#minecraft:diamond", "minecraft:coast_armor_trim_smithing_template#minecraft:diamond", "minecraft:dune_armor_trim_smithing_template#minecraft:diamond", "minecraft:wayfinder_armor_trim_smithing_template#minecraft:diamond", "minecraft:raiser_armor_trim_smithing_template#minecraft:diamond", "minecraft:shaper_armor_trim_smithing_template#minecraft:diamond", "minecraft:host_armor_trim_smithing_template#minecraft:diamond", "minecraft:ward_armor_trim_smithing_template#minecraft:diamond", "minecraft:silence_armor_trim_smithing_template#minecraft:diamond", "minecraft:tide_armor_trim_smithing_template#minecraft:diamond", "minecraft:snout_armor_trim_smithing_template#minecraft:diamond", "minecraft:rib_armor_trim_smithing_template#minecraft:diamond", "minecraft:eye_armor_trim_smithing_template#minecraft:diamond", "minecraft:spire_armor_trim_smithing_template#minecraft:diamond"); } diff --git a/src/main/java/com/seniors/justlevelingfork/mixin/MixCraftingMenu.java b/src/main/java/com/seniors/justlevelingfork/mixin/MixCraftingMenu.java index 3866c79..2917dbb 100644 --- a/src/main/java/com/seniors/justlevelingfork/mixin/MixCraftingMenu.java +++ b/src/main/java/com/seniors/justlevelingfork/mixin/MixCraftingMenu.java @@ -1,39 +1,32 @@ package com.seniors.justlevelingfork.mixin; +import com.llamalad7.mixinextras.injector.wrapoperation.Operation; +import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation; +import com.llamalad7.mixinextras.sugar.Local; import com.seniors.justlevelingfork.common.capability.AptitudeCapability; -import com.seniors.justlevelingfork.handler.HandlerCommonConfig; import net.minecraft.server.level.ServerPlayer; import net.minecraft.world.entity.player.Player; -import net.minecraft.world.inventory.AbstractContainerMenu; import net.minecraft.world.inventory.CraftingContainer; import net.minecraft.world.inventory.CraftingMenu; import net.minecraft.world.inventory.ResultContainer; import net.minecraft.world.item.ItemStack; -import net.minecraft.world.level.Level; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; @Mixin(CraftingMenu.class) -public class MixCraftingMenu { - - @Inject(at = @At("TAIL"), method = "slotChangedCraftingGrid") - private static void slotChangedCraftingGrid(AbstractContainerMenu pMenu, Level level, Player player, CraftingContainer container, ResultContainer resultContainer, CallbackInfo ci){ +public abstract class MixCraftingMenu { + @WrapOperation(method = "slotChangedCraftingGrid", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/inventory/ResultContainer;setItem(ILnet/minecraft/world/item/ItemStack;)V")) + private static void slotChangedCraftingGrid(ResultContainer container, int slotIndex, ItemStack stack, Operation original, @Local(argsOnly = true, index = 2) Player player, @Local(argsOnly = true, index = 3) CraftingContainer craftingInventory) { if (player instanceof ServerPlayer serverPlayer){ - ItemStack itemStack = resultContainer.getItem(0); - if (!serverPlayer.isCreative()) { AptitudeCapability provider = AptitudeCapability.get(player); - if (!provider.canUseItem(serverPlayer, itemStack)){ - resultContainer.setItem(0, ItemStack.EMPTY); - if (HandlerCommonConfig.HANDLER.instance().closeCraftingMenu){ - serverPlayer.closeContainer(); - } + if (provider != null && !provider.canUseItem(serverPlayer, stack)){ + stack = ItemStack.EMPTY; + + original.call(container, slotIndex, stack); } } } } - } diff --git a/src/main/java/com/seniors/justlevelingfork/network/packet/client/CommonConfigSyncCP.java b/src/main/java/com/seniors/justlevelingfork/network/packet/client/CommonConfigSyncCP.java index 3bc2bc1..9ca20ef 100644 --- a/src/main/java/com/seniors/justlevelingfork/network/packet/client/CommonConfigSyncCP.java +++ b/src/main/java/com/seniors/justlevelingfork/network/packet/client/CommonConfigSyncCP.java @@ -23,7 +23,6 @@ public class CommonConfigSyncCP { private final int aptitudeFirstCostLevel; - private final boolean closeCraftingMenu; private final boolean dropLockedItems; private final boolean displayTitlesAsPrefix; @@ -78,7 +77,6 @@ public class CommonConfigSyncCP { public CommonConfigSyncCP() { aptitudeFirstCostLevel = HandlerCommonConfig.HANDLER.instance().aptitudeFirstCostLevel; - closeCraftingMenu = HandlerCommonConfig.HANDLER.instance().closeCraftingMenu; dropLockedItems = HandlerCommonConfig.HANDLER.instance().dropLockedItems; displayTitlesAsPrefix = HandlerCommonConfig.HANDLER.instance().displayTitlesAsPrefix; attackDamageValue = HandlerCommonConfig.HANDLER.instance().attackDamageValue; @@ -131,7 +129,6 @@ public CommonConfigSyncCP() { @SuppressWarnings("unchecked") public CommonConfigSyncCP(FriendlyByteBuf buffer) { aptitudeFirstCostLevel = buffer.readInt(); - closeCraftingMenu = buffer.readBoolean(); dropLockedItems = buffer.readBoolean(); displayTitlesAsPrefix = buffer.readBoolean(); attackDamageValue = buffer.readFloat(); @@ -208,7 +205,6 @@ public CommonConfigSyncCP(FriendlyByteBuf buffer) { public void toBytes(FriendlyByteBuf buffer) { buffer.writeInt(this.aptitudeFirstCostLevel); - buffer.writeBoolean(this.closeCraftingMenu); buffer.writeBoolean(this.dropLockedItems); buffer.writeBoolean(this.displayTitlesAsPrefix); buffer.writeFloat(this.attackDamageValue); @@ -284,7 +280,6 @@ public void handle(Supplier supplier) { LocalPlayer localPlayer = (Minecraft.getInstance()).player; if(localPlayer != null){ HandlerCommonConfig.HANDLER.instance().aptitudeFirstCostLevel = this.aptitudeFirstCostLevel; - HandlerCommonConfig.HANDLER.instance().closeCraftingMenu = this.closeCraftingMenu; HandlerCommonConfig.HANDLER.instance().dropLockedItems = this.dropLockedItems; HandlerCommonConfig.HANDLER.instance().displayTitlesAsPrefix = displayTitlesAsPrefix; HandlerCommonConfig.HANDLER.instance().attackDamageValue = this.attackDamageValue; diff --git a/src/main/java/com/seniors/justlevelingfork/registry/RegistryCommonEvents.java b/src/main/java/com/seniors/justlevelingfork/registry/RegistryCommonEvents.java index f4edf82..a82a2d2 100644 --- a/src/main/java/com/seniors/justlevelingfork/registry/RegistryCommonEvents.java +++ b/src/main/java/com/seniors/justlevelingfork/registry/RegistryCommonEvents.java @@ -499,24 +499,6 @@ public void onAttackEntity(LivingHurtEvent event) { LivingEntity livingEntity1 = event.getEntity(); if (livingEntity1 instanceof ServerPlayer player) { AptitudeCapability provider = AptitudeCapability.get(player); - if (!player.isCreative() && provider != null) { - ItemStack item = player.getMainHandItem(); - - ResourceLocation location = Objects.requireNonNull(ForgeRegistries.ITEMS.getKey(item.getItem())); - if (ModList.get().isLoaded("tetra") && TetraIntegration.TetraItems.contains(location.toString())) { - List extractedTypes = TetraIntegration.GetItemTypes(item); - if (!extractedTypes.isEmpty()) { - for (String tetraItem : extractedTypes) { - if (!provider.canUseSpecificID(player, tetraItem)) { - event.setCanceled(true); - } - } - } - } - else if (!provider.canUseItem(player, item)) { - event.setCanceled(true); - } - } if (provider != null && !event.isCanceled() && RegistrySkills.COUNTER_ATTACK != null && RegistrySkills.COUNTER_ATTACK.get().isEnabled(player)) { player.getCapability(RegistryCapabilities.APTITUDE).ifPresent(aptitudeCapability -> { diff --git a/src/main/java/com/seniors/justlevelingfork/registry/skills/ConvergenceSkill.java b/src/main/java/com/seniors/justlevelingfork/registry/skills/ConvergenceSkill.java index 35cfd34..4cb4fb7 100644 --- a/src/main/java/com/seniors/justlevelingfork/registry/skills/ConvergenceSkill.java +++ b/src/main/java/com/seniors/justlevelingfork/registry/skills/ConvergenceSkill.java @@ -16,8 +16,13 @@ public class ConvergenceSkill { public static ItemStack drop(ItemStack getCrafting) { ItemStack stack = null; - for (int i = 0; i < getItems().size(); i++) { - ItemDrops drops = getItems().get(i); + ArrayList itemDrops = getItems(); + + if (itemDrops == null || itemDrops.isEmpty()){ + return stack; + } + + for (ItemDrops drops : itemDrops) { if (drops.getCraftingItem != null && drops.getConvergenceItem != null && getCrafting.is(drops.getCraftingItem)) { stack = drops.getConvergenceItem.getDefaultInstance();