net.minecraft.util.SoundEvent Java Examples

The following examples show how to use net.minecraft.util.SoundEvent. 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 check out the related API usage on the sidebar.
Example #1
Source File: SoundEventDeserializer.java    From customstuff4 with GNU General Public License v3.0 5 votes vote down vote up
@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 #2
Source File: BlockElectricMushroom.java    From AdvancedRocketry with 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 #3
Source File: GokiSounds.java    From GokiStats with 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 #4
Source File: FWBlockSound.java    From NOVA-Core with GNU Lesser General Public License v3.0 5 votes vote down vote up
@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 #5
Source File: RegUtil.java    From CommunityMod with 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 #6
Source File: BlockSound.java    From CommunityMod with GNU Lesser General Public License v2.1 5 votes vote down vote up
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 #7
Source File: SubmodGnomes.java    From CommunityMod with GNU Lesser General Public License v2.1 5 votes vote down vote up
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 #8
Source File: FWBlockSound.java    From NOVA-Core with GNU Lesser General Public License v3.0 5 votes vote down vote up
@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 #9
Source File: WorldListener.java    From ForgeHax with 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 #10
Source File: FWBlockSound.java    From NOVA-Core with GNU Lesser General Public License v3.0 5 votes vote down vote up
@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 #11
Source File: ItemPLRecord.java    From Production-Line with 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 #12
Source File: SoundEventDeserializerTest.java    From customstuff4 with GNU General Public License v3.0 5 votes vote down vote up
@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 #13
Source File: SubmodGnomes.java    From CommunityMod with GNU Lesser General Public License v2.1 5 votes vote down vote up
@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 #14
Source File: TileRollingMachine.java    From AdvancedRocketry with MIT License 4 votes vote down vote up
@Override
public SoundEvent getSound() {
	return AudioRegistry.rollingMachine;
}
 
Example #15
Source File: EntityToroNpc.java    From ToroQuest with GNU General Public License v3.0 4 votes vote down vote up
protected SoundEvent getHurtSound() {
	return SoundEvents.ENTITY_HOSTILE_HURT;
}
 
Example #16
Source File: EntityMage.java    From ToroQuest with GNU General Public License v3.0 4 votes vote down vote up
protected SoundEvent getHurtSound() {
	return SoundEvents.ENTITY_WITCH_HURT;
}
 
Example #17
Source File: EntityMage.java    From ToroQuest with GNU General Public License v3.0 4 votes vote down vote up
protected SoundEvent getAmbientSound() {
	return SoundEvents.ENTITY_WITCH_AMBIENT;
}
 
Example #18
Source File: EntityMonolithEye.java    From ToroQuest with GNU General Public License v3.0 4 votes vote down vote up
protected SoundEvent getDeathSound() {
	return SoundEvents.ENTITY_WITCH_DEATH;
}
 
Example #19
Source File: EntityMonolithEye.java    From ToroQuest with GNU General Public License v3.0 4 votes vote down vote up
protected SoundEvent getHurtSound() {
	return SoundEvents.ENTITY_WITCH_HURT;
}
 
Example #20
Source File: EntityMonolithEye.java    From ToroQuest with GNU General Public License v3.0 4 votes vote down vote up
protected SoundEvent getAmbientSound() {
	return SoundEvents.ENTITY_WITCH_AMBIENT;
}
 
Example #21
Source File: EntityVampireBat.java    From ToroQuest with GNU General Public License v3.0 4 votes vote down vote up
protected SoundEvent getDeathSound() {
	return SoundEvents.ENTITY_BAT_DEATH;
}
 
Example #22
Source File: EntityVampireBat.java    From ToroQuest with GNU General Public License v3.0 4 votes vote down vote up
protected SoundEvent getHurtSound() {
	return SoundEvents.ENTITY_BAT_HURT;
}
 
Example #23
Source File: EntityVampireBat.java    From ToroQuest with GNU General Public License v3.0 4 votes vote down vote up
@Nullable
protected SoundEvent getAmbientSound() {
	return this.rand.nextInt(4) != 0 ? null : SoundEvents.ENTITY_BAT_AMBIENT;
}
 
Example #24
Source File: EntityBackupZombie.java    From Wizardry with GNU Lesser General Public License v3.0 4 votes vote down vote up
protected SoundEvent getStepSound() {
	return SoundEvents.ENTITY_ZOMBIE_STEP;
}
 
Example #25
Source File: EntityBackupZombie.java    From Wizardry with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Override
protected SoundEvent getDeathSound() {
	return SoundEvents.ENTITY_ZOMBIE_DEATH;
}
 
Example #26
Source File: EntityBackupZombie.java    From Wizardry with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Override
protected SoundEvent getAmbientSound() {
	return SoundEvents.ENTITY_ZOMBIE_AMBIENT;
}
 
Example #27
Source File: EntityRemovalListener.java    From GriefPrevention with MIT License 4 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 #28
Source File: EntityRemovalListener.java    From GriefPrevention with MIT License 4 votes vote down vote up
@Override
public void playRecord(SoundEvent soundIn, BlockPos pos) {
}
 
Example #29
Source File: TofuSounds.java    From TofuCraftReload with 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 #30
Source File: SoundRocketEngine.java    From AdvancedRocketry with MIT License 4 votes vote down vote up
public SoundRocketEngine(SoundEvent soundIn, SoundCategory categoryIn, EntityRocket rocket) {
	super(soundIn, categoryIn);
	this.rocket = rocket;
	this.repeat = true;
}