Hey, I coded a money drop plugin and I want to show drop's name like this "Gold x2". Help pls. Code (Java): @EventHandler public void moneyEvent(EntityDeathEvent event) { int r = (int) (Math.random() * 100); ItemStack gold = new ItemStack(Material.GOLD_NUGGET); if(r < 50) { gold.setAmount(1); } else if(r < 90) { gold.setAmount(2); } else if(r < 96) { gold.setAmount(3); } else if(r < 99) { gold.setAmount(5); } else if(r < 100) { gold.setAmount(10); } ItemMeta goldmeta = gold.getItemMeta(); goldmeta.setDisplayName("money"); gold.setItemMeta(goldmeta); event.getDrops().add(gold); }
I tried this one already. This one for Player dropping event. We're talking about Entity's death drops.
Code (Text): gold.setCustomNameVisible(true); Here's how I do it. Ignore the data values on the item, I use a texture pack to have actual money (coins and dollars)
same process you just need to change the event to EntityDeathEvent then get the drop object then change the content itemstacks
Not same process u cannot cast an itemstack to entity. Oh I changed code like ur code and Code (Java): @EventHandler public void onPara(EntityDeathEvent event) { int r = (int) (Math.random() * 100); ItemStack gold = new ItemStack(Material.GOLD_NUGGET); if(r < 50) { gold.setAmount(1); } else if(r < 90) { gold.setAmount(2); } else if(r < 96) { gold.setAmount(3); } else if(r < 99) { gold.setAmount(5); } else if(r < 100) { gold.setAmount(10); } ItemMeta goldmeta = gold.getItemMeta(); goldmeta.setDisplayName("money"); gold.setItemMeta(goldmeta); Item item = event.getEntity().getWorld().dropItemNaturally(event.getEntity().getLocation(), gold); item.setCustomName("ยง6Gold x" + altin.getAmount()); item.setCustomNameVisible(true); } and it works! Thanks there! Ur very helpful.
Sorry for the misunderstanding I thought you were getting the items being drop by the entity I get it now that your creating a new item stack then dropping it it on the entities location but still same solution as the link I sent you .setCustomNameVisible(true); Good that you found that answer