#hello i m trying to set custom effects

1 messages · Page 1 of 1 (latest)

mint anchor
#

@stark scarab could we do it here?

onyx steeple
#

your if statement is bad

mint anchor
#

I got rid of the lore n displayname

onyx steeple
#

works for every apple which has no lore and no name

mint anchor
#

i was testing some random stuff

#

so?

onyx steeple
#
@EventHandler
public void onItemConsume(PlayerItemConsumeEvent e) {
    ItemStack item = e.getItem();
    if (item.getType() != Material.GOLDEN_APPLE) return;
    if (!item.hasItemMeta()) return;
    e.setCancelled(true);
    Player player = e.getPlayer();
    player.getInventory().removeItem(item);
    player.sendMessage("It worked");
    // apply potion
}```

try this ig
#

idk if enchanted golden apple follows ItemMeta rule

#

you can just debug rn

mint anchor
#

the enchanted golden apple's durability is 1, and the regular one is 0

onyx steeple
#

i'm 100% sure that default golden apple has no itemmeta

#

if you do getItemMeta() it will return null

mint anchor
#

aight lemme try it

onyx steeple
#

you tried with both apples?

mint anchor
#

yep

onyx steeple
#

and got no message

mint anchor
#

no

onyx steeple
#

well then lEgAcY

#

probably itemmeta is not null

#

in 1.12

#

strange tho

#

method for checking if it's not null already exists

mint anchor
#

should I try the durability

onyx steeple
#

you can comment the hasItemMeta check for now

#

and test

mint anchor
#

aight

#

its working for both now

#

Yo

#
    @EventHandler
    public void onItemConsume(PlayerItemConsumeEvent e) {
        ItemStack item = new ItemStack(Material.GOLDEN_APPLE, 1, (short) 1);
        if (item.getDurability() != 1) return;
        // if (!item.hasItemMeta()) return;
        e.setCancelled(true);
        Player player = e.getPlayer();
        player.getInventory().removeItem(item);
        player.sendMessage("It worked");
        player.addPotionEffect(new PotionEffect(PotionEffectType.SPEED, 200, 10));
    }

I got something weird to happen

#

now when I consume a normal gapple it removes the enchanted apple from my inventory

#

but it still gives me the effects n stuff

#

and i tried moving them around in my hotbar and it still doesnt matter, it keeps on removing the enchanted ones and it ignores the regular ones

#

there's something wrong and I can't see it, i've been awake for way too long