Skip to content

Commit

Permalink
fix: bugs and issues
Browse files Browse the repository at this point in the history
  • Loading branch information
Senior-S committed Oct 18, 2024
1 parent 8c6bceb commit 6f31454
Show file tree
Hide file tree
Showing 9 changed files with 22 additions and 50 deletions.
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.1.5
1.1.6
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public static void register(CommandDispatcher<CommandSourceStack> 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")))
)
)
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -24,5 +25,5 @@ public class HandlerConvergenceItemsConfig {

@SerialEntry(comment = "Convergence skill convergence item list")
@ListGroup(controllerFactory = StringListGroup.class, valueFactory = StringListGroup.class)
public List<String> convergenceItemList = List.of();
public List<String> 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");
}
Original file line number Diff line number Diff line change
@@ -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<Void> 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);
}
}
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
public class CommonConfigSyncCP {

private final int aptitudeFirstCostLevel;
private final boolean closeCraftingMenu;
private final boolean dropLockedItems;
private final boolean displayTitlesAsPrefix;

Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -284,7 +280,6 @@ public void handle(Supplier<NetworkEvent.Context> 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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<String> 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 -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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> 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();
Expand Down

0 comments on commit 6f31454

Please sign in to comment.