- 25
- 1
- 0
Предмет:
package ru.qlcreations.exile_z.items.medic;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.MobEffects;
import net.minecraft.init.SoundEvents;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.potion.PotionEffect;
import net.minecraft.util.ActionResult;
import net.minecraft.util.EnumActionResult;
import net.minecraft.util.EnumHand;
import net.minecraft.util.SoundCategory;
import net.minecraft.world.World;
import ru.qlcreations.exile_z.Sounds;
public class FirstAidKit extends Item {
public FirstAidKit(String name){
this.setRegistryName(name);
this.setUnlocalizedName(name);
}
public void FirstAidUsed(World worldIn, EntityPlayer player) {
player.setHealth(player.getHealth() + 4);
player.addPotionEffect(new PotionEffect(MobEffects.REGENERATION, 120));
}
public ActionResult<ItemStack> onItemRightClick(World worldIn, EntityPlayer playerIn, EnumHand handIn)
{
ItemStack itemStack = playerIn.getHeldItem(handIn);
itemStack.setCount(itemStack.getCount() - 1);
playerIn.getCooldownTracker().setCooldown(this, 60);
worldIn.playSound(playerIn.posX, playerIn.posZ, playerIn.posY, Sounds.FIRST_AID_USE_SOUND, SoundCategory.PLAYERS, 1.0F, 1.0F, false);
FirstAidUsed(worldIn, playerIn);
return new ActionResult<ItemStack>(EnumActionResult.PASS, playerIn.getHeldItem(handIn));
}
}
Класс Sounds:
package ru.qlcreations.exile_z;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.SoundEvent;
import net.minecraftforge.event.RegistryEvent;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
@Mod.EventBusSubscriber(modid = ExileZ.MODID)
public class Sounds {
public static final SoundEvent FIRST_AID_USE_SOUND = registry("first_aid_use_sound");
@SubscribeEvent
public static void registerSounds(RegistryEvent.Register<SoundEvent> event) {
event.getRegistry().register(FIRST_AID_USE_SOUND);
}
private static SoundEvent registry(String name) {
ResourceLocation uniqueName = new ResourceLocation(ExileZ.MODID, name);
SoundEvent soundEvent = new SoundEvent(uniqueName);
soundEvent.setRegistryName(uniqueName);
return soundEvent;
}
}
ClientProxy:
package ru.qlcreations.exile_z.proxy;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
import net.minecraftforge.fml.common.event.FMLPostInitializationEvent;
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
import ru.qlcreations.exile_z.Sounds;
public class ClientProxy extends CommonProxy{
@Override
public void preInit(FMLPreInitializationEvent event)
{
super.preInit(event);
}
@Override
public void init(FMLInitializationEvent event)
{
super.init(event);
MinecraftForge.EVENT_BUS.register(new Sounds());
}
@Override
public void postInit(FMLPostInitializationEvent event)
{
super.postInit(event);
}
}
sounds.json:
{
"first_aid_use_sound": {
"category": "player",
"sounds": [
{
"name": "exile_z:first_aid_use_sound",
"stream": true,
"volume": 1.0,
"pitch": 1.0,
"weight": 1
}
]
}
Сижу, пробую различные способы решения, ничего не помогает. Воспроизводится стандартный звук какой - то левый)