#hello i m trying to set custom effects
1 messages · Page 1 of 1 (latest)
your if statement is bad
I got rid of the lore n displayname
works for every apple which has no lore and no name
@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
the enchanted golden apple's durability is 1, and the regular one is 0
i'm 100% sure that default golden apple has no itemmeta
if you do getItemMeta() it will return null
aight lemme try it
didn't work
no errors
you tried with both apples?
yep
and got no message
no
well then lEgAcY
probably itemmeta is not null
in 1.12
strange tho
method for checking if it's not null already exists
should I try the durability
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