- 1,031
- 19
- 87
Создал такой метод в классе предмета, но почему-то срабытывает дважды: при клике дважды воспроизводится звук и дважды отправляется сообщение.
Java:
@SideOnly(Side.CLIENT)
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, EnumHand hand) {
ItemStack itemstack = player.getHeldItem(hand);
world.playSound((EntityPlayer)null, player.posX, player.posY, player.posZ, SoundEvents.BLOCK_ENCHANTMENT_TABLE_USE, SoundCategory.NEUTRAL, 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F));
player.addStat(StatList.getObjectUseStats(this));
player.sendMessage(new TextComponentString("Your strong, %s".replace("%s", player.getName())));
return new ActionResult<ItemStack>(EnumActionResult.SUCCESS, itemstack);
}