#HOW DO I CAN NAME ITEMS

7 messages · Page 1 of 1 (latest)

rose mist
#

I'm new at modding for mc and it says this shi
"The method setCustomName(MutableText) is undefined for the type ItemStack"

private static int giveHearts(ServerPlayerEntity executor, int amount) {
UUID uuid = executor.getUuid();
int heartCount = PlayerDataManager.getPlayerHeartCount(uuid);

    if (heartCount <= amount) {
        executor.sendMessage(Text.literal("§cYeterli kalbiniz yok! En az " + (amount + 1) + " kalp olmalı."), true);
        return 0;
    }

    PlayerDataManager.setPlayerHeartCount(uuid, heartCount - amount);

    double newMaxHealth = (heartCount - amount) * 2.0;
    executor.getAttributeInstance(EntityAttributes.MAX_HEALTH).setBaseValue(newMaxHealth);
    executor.setHealth((float) Math.min(executor.getHealth(), newMaxHealth));

    for (int i = 0; i < amount; i++) {
        ItemStack heartItem = new ItemStack(Items.NETHER_STAR);
        // Use setCustomName for 1.21.10
      **  heartItem.setCustomName(Text.literal("§c❤️ Kalp"));**
        executor.getInventory().offerOrDrop(heartItem);
    }

    executor.sendMessage(Text.literal("§c❤ " + amount + " kalbinizi verdiniz! Kalan kalp sayınız: " + (heartCount - amount)), true);
    return 1;
}

i'm trying to make mod like lifestealsmp for playing with my friends i did ask to ai and it stuck.
Can someone help me

pearl siren
#

!!code

severe yewBOT
#

You can use codeblocks in discord as shown below:
```java
code
```

You can also specify the syntax highlighting to use by specifying the language after the last backtick (`) on the top.

rose mist
#

?????

runic zodiac
#

custom name is controlled by a data component

rose mist
#

can u send me a example

runic zodiac
#

check how the anvil works?