Item Based Skill tree

Started by EliteDangerGamer on

Topic category: Troubleshooting, bugs, and solutions

Joined Apr 2024
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Item Based Skill tree
Mon, 08/18/2025 - 00:13 (edited)

So I've been creating a mod which is basically a manhunt, with a skill tree, and one of the upgrades is a health one, but for some reason it's taking the items without increasing the health, I can't figure out to attach images (help with that please)

package net.mcreator.hackermanhuntskilltree.procedures;

/* imports omitted */

public class HHU2Procedure {

    public static void execute(Entity entity) {

        if (entity == null)

            return;

        if (64 >= getAmountInGUISlot(entity, 0)) {

            if (32 >= getAmountInGUISlot(entity, 1)) {

                if (16 >= getAmountInGUISlot(entity, 2)) {

                    if (entity instanceof Player _player) {

                        ItemStack _stktoremove = new ItemStack(Items.IRON_INGOT);

                        _player.getInventory().clearOrCountMatchingItems(p -> _stktoremove.getItem() == p.getItem(), 64, _player.inventoryMenu.getCraftSlots());

                    }

                    if (entity instanceof Player _player) {

                        ItemStack _stktoremove = new ItemStack(Items.GOLD_INGOT);

                        _player.getInventory().clearOrCountMatchingItems(p -> _stktoremove.getItem() == p.getItem(), 32, _player.inventoryMenu.getCraftSlots());

                    }

                    if (entity instanceof Player _player) {

                        ItemStack _stktoremove = new ItemStack(Items.DIAMOND);

                        _player.getInventory().clearOrCountMatchingItems(p -> _stktoremove.getItem() == p.getItem(), 16, _player.inventoryMenu.getCraftSlots());

                    }

                    {

                        Entity _ent = entity;

                        if (!_ent.level().isClientSide() && _ent.getServer() != null) {

                            _ent.getServer().getCommands().performPrefixedCommand(new CommandSourceStack(CommandSource.NULL, _ent.position(), _ent.getRotationVector(), _ent.level() instanceof ServerLevel ? (ServerLevel) _ent.level() : null, 4,

                                    _ent.getName().getString(), _ent.getDisplayName(), _ent.level().getServer(), _ent), "attribute @s minecraft:max_health base set 40");

                        }

                    }

                }

            }

        }

    }



    private static int getAmountInGUISlot(Entity entity, int sltid) {

        if (entity instanceof Player player && player.containerMenu instanceof HackerManhuntSkillTreeModMenus.MenuAccessor menuAccessor) {

            ItemStack stack = menuAccessor.getSlots().get(sltid).getItem();

            if (stack != null)

                return stack.getCount();

        }

        return 0;

    }

}
Edited by EliteDangerGamer on Mon, 08/18/2025 - 00:13
Joined Apr 2024
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
I'm using the Execute…
Sun, 08/17/2025 - 23:19

I'm using the Execute command /attribute @s minecraft:max_health base set 40 in the name of event/target entity