Java Code Examples for net.minecraft.util.SoundEvent

The following examples show how to use net.minecraft.util.SoundEvent. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may want to check out the right sidebar which shows the related API usage.
Example 1
Source Project: AdvancedRocketry   Source File: BlockElectricMushroom.java    License: MIT License 5 votes vote down vote up
@Override
public void onBlockDestroyedByPlayer(World world, BlockPos pos,
		IBlockState state) {
	super.onBlockDestroyedByPlayer(world, pos, state);
	
	if(world.isRemote) {
		FxSystemElectricArc.spawnArc(world, pos.getX() + 0.5f, pos.getY() + 0.5f, pos.getZ() + 0.5f, .3, 7);
		
		world.playSound(pos.getX(), pos.getY(), pos.getZ(), new SoundEvent( new ResourceLocation("advancedrocketry:ElectricShockSmall")), SoundCategory.BLOCKS, .7f,  0.975f + world.rand.nextFloat()*0.05f, false);
	}
}
 
Example 2
@Override
public SoundEvent getBreakSound() {
	return blockSound.getSound(BlockProperty.BlockSound.BlockSoundTrigger.BREAK)
		.map(sound -> (sound.domain.isEmpty() && !sound.name.contains(".")) ? "dig." + sound.name : sound.getID())
		.map(soundID -> SoundEvent.REGISTRY.getObject(new ResourceLocation(soundID)))
		.orElseGet(super::getBreakSound);
}
 
Example 3
Source Project: CommunityMod   Source File: RegUtil.java    License: GNU Lesser General Public License v2.1 5 votes vote down vote up
public static SoundEvent registerSound(IForgeRegistry<SoundEvent> reg, ResourceLocation name) {
	SoundEvent event = new SoundEvent(name);
	event.setRegistryName(name);

	reg.register(event);

	return event;
}
 
Example 4
public BlockSound(String name, SoundEvent sound) {
    super(Material.ROCK);
    this.setCreativeTab(CommunityGlobals.TAB);
    this.setSoundType(new SoundType(2.0F, 1.0F, sound, sound, sound, sound, sound));
    this.setRegistryName(name);
    this.setTranslationKey(getRegistryName().toString());
}
 
Example 5
@SubscribeEvent
public static void registerSounds(RegistryEvent.Register<SoundEvent> event)
{
	IForgeRegistry<SoundEvent> registry = event.getRegistry();
	
	GNOME_SPEAK = registerSoundEvent(registry, "mob.gnome.say");
	GNOME_DEATH = registerSoundEvent(registry, "mob.gnome.death");
}
 
Example 6
private static SoundEvent registerSoundEvent(IForgeRegistry<SoundEvent> registry, String location)
{
	ResourceLocation rl = new ResourceLocation(CommunityGlobals.MOD_ID, location);
	SoundEvent sound = new SoundEvent(rl);
	sound.setRegistryName(rl);
	registry.register(sound);
	return sound;
}
 
Example 7
Source Project: Production-Line   Source File: ItemPLRecord.java    License: MIT License 5 votes vote down vote up
public ItemPLRecord(String name, SoundEvent soundEvent) {
    super(name, soundEvent);
    this.name = name;
    this.setCreativeTab(ProductionLine.creativeTabPL);
    this.setUnlocalizedName(MOD_ID + "." + name);
    GameRegistry.<Item>register(this, new ResourceLocation(MOD_ID, name));
}
 
Example 8
Source Project: ForgeHax   Source File: WorldListener.java    License: MIT License 5 votes vote down vote up
@Override
public void playSoundToAllNearExcept(
    EntityPlayer player,
    SoundEvent soundIn,
    SoundCategory category,
    double x,
    double y,
    double z,
    float volume,
    float pitch) {
}
 
Example 9
@Override
public SoundEvent deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException
{
    ResourceLocation key = context.deserialize(json, ResourceLocation.class);
    SoundEvent event = SoundEvent.REGISTRY.getObject(key);

    return event;
}
 
Example 10
@Test
public void fromString()
{
    Map<String, SoundEvent> map = gson.fromJson("{ \"sound\": \"item.armor.equip_gold\" }", new TypeToken<Map<String, SoundEvent>>() {}.getType());

    SoundEvent sound = map.get("sound");
    assertNotNull(sound);
    assertSame(SoundEvents.ITEM_ARMOR_EQUIP_GOLD, sound);
}
 
Example 11
@Override
public SoundEvent getPlaceSound() {
	return blockSound.getSound(BlockProperty.BlockSound.BlockSoundTrigger.PLACE)
		.map(sound -> sound.domain.isEmpty() ? "step." + sound.name : sound.getID())
		.map(soundID -> SoundEvent.REGISTRY.getObject(new ResourceLocation(soundID)))
		.orElseGet(super::getPlaceSound);
}
 
Example 12
@Override
public SoundEvent getStepSound() {
	return blockSound.getSound(BlockProperty.BlockSound.BlockSoundTrigger.WALK)
		.map(sound -> (sound.domain.isEmpty() && !sound.name.contains(".")) ? "step." + sound.name : sound.getID())
		.map(soundID -> SoundEvent.REGISTRY.getObject(new ResourceLocation(soundID)))
		.orElseGet(super::getBreakSound);
}
 
Example 13
Source Project: GokiStats   Source File: GokiSounds.java    License: MIT License 5 votes vote down vote up
@SubscribeEvent
public void registerSounds(RegistryEvent.Register<SoundEvent> event) {
    event.getRegistry().registerAll(
            new SoundEvent(new ResourceLocation(MODID, "treasure")),
            new SoundEvent(new ResourceLocation(MODID, "magician")),
            new SoundEvent(new ResourceLocation(MODID, "reaper"))
    );
}
 
Example 14
Source Project: TofuCraftReload   Source File: TofuSounds.java    License: MIT License 4 votes vote down vote up
private static SoundEvent createEvent(String name) {
    SoundEvent sound = new SoundEvent(new ResourceLocation(TofuMain.MODID, name));
    sound.setRegistryName(new ResourceLocation(TofuMain.MODID, name));
    return sound;
}
 
Example 15
Source Project: TofuCraftReload   Source File: TofuSounds.java    License: MIT License 4 votes vote down vote up
@SubscribeEvent
public static void registerSounds(RegistryEvent.Register<SoundEvent> evt) {
    evt.getRegistry().register(TOFUNIAN_YES);
    evt.getRegistry().register(TOFUNIAN_AMBIENT);
    evt.getRegistry().register(TOFUBUGLE);
}
 
Example 16
Source Project: AdvancedRocketry   Source File: TileLathe.java    License: MIT License 4 votes vote down vote up
@Override
public SoundEvent getSound() {
	return AudioRegistry.lathe;
}
 
Example 17
Source Project: TofuCraftReload   Source File: EntityTofuGandlem.java    License: MIT License 4 votes vote down vote up
protected SoundEvent getSpellPrepareSound() {
    return SoundEvents.ENTITY_ZOMBIE_VILLAGER_CONVERTED;
}
 
Example 18
Source Project: TofuCraftReload   Source File: EntityTofuGandlem.java    License: MIT License 4 votes vote down vote up
protected SoundEvent getSpellPrepareSound() {
    return SoundEvents.EVOCATION_ILLAGER_PREPARE_SUMMON;
}
 
Example 19
Source Project: TofuCraftReload   Source File: EntityTofuGandlem.java    License: MIT License 4 votes vote down vote up
@Nullable
protected abstract SoundEvent getSpellPrepareSound();
 
Example 20
Source Project: AdvancedRocketry   Source File: TileAtmosphereTerraformer.java    License: MIT License 4 votes vote down vote up
@Override
protected void playMachineSound(SoundEvent event) {
	world.playSound(getPos().getX(), getPos().getY() + 7, getPos().getZ(), event, SoundCategory.BLOCKS, Minecraft.getMinecraft().gameSettings.getSoundLevel(SoundCategory.BLOCKS),  0.975f + world.rand.nextFloat()*0.05f, false);
}
 
Example 21
Source Project: TofuCraftReload   Source File: EntityTofunian.java    License: MIT License 4 votes vote down vote up
@Override
protected SoundEvent getAmbientSound() {

    return TofuSounds.TOFUNIAN_AMBIENT;
}
 
Example 22
Source Project: AdvancedRocketry   Source File: TileChemicalReactor.java    License: MIT License 4 votes vote down vote up
@Override
public SoundEvent getSound() {
	return AudioRegistry.rollingMachine;
}
 
Example 23
Source Project: TofuCraftReload   Source File: EntityTofunian.java    License: MIT License 4 votes vote down vote up
@Override
protected SoundEvent getHurtSound(DamageSource damageSource) {

    return null;
}
 
Example 24
Source Project: AdvancedRocketry   Source File: TileGravityController.java    License: MIT License 4 votes vote down vote up
@Override
public SoundEvent getSound() {
	return AudioRegistry.gravityOhhh;
}
 
Example 25
Source Project: Sakura_mod   Source File: EntitySamuraiIllager.java    License: MIT License 4 votes vote down vote up
protected SoundEvent getDeathSound() {
    return SoundEvents.VINDICATION_ILLAGER_DEATH;
}
 
Example 26
Source Project: Sakura_mod   Source File: CommonProxy.java    License: MIT License 4 votes vote down vote up
@SubscribeEvent
public static void onSoundEvenrRegistration(RegistryEvent.Register<SoundEvent> event) {
    event.getRegistry().register(TAIKO.setRegistryName(new ResourceLocation(SakuraMain.MODID, "taiko")));
}
 
Example 27
Source Project: CommunityMod   Source File: GnuLinux.java    License: GNU Lesser General Public License v2.1 4 votes vote down vote up
@SubscribeEvent
public static void onRegisterSounds(RegistryEvent.Register<SoundEvent> event) {
    GNU_LINUX = RegUtil.registerSound(event.getRegistry(), new ResourceLocation(CommunityGlobals.MOD_ID, "gnu_linux"));
}
 
Example 28
@SubscribeEvent
public static void registerSoundEvents(RegistryEvent.Register<SoundEvent> event) {
    event.getRegistry().registerAll(E_SOUND, BRUH_2_SOUND);
}
 
Example 29
protected SoundEvent getAmbientSound()
{
    return SoundEvents.ENTITY_CHICKEN_AMBIENT;
}
 
Example 30
protected SoundEvent getHurtSound(DamageSource damageSourceIn)
{
    return SoundEvents.ENTITY_CHICKEN_HURT;
}