Skip to content

Adding Animation Sound(s)

LopyMine edited this page Sep 22, 2024 · 3 revisions

And finally, let's try to add our own sound for custom animation. Actually, there is nothing new if you ever added custom sounds to game with resource packs.

Converting Sound From .mp3 to .ogg

  1. First, we will need to get our sound. For example, I downloaded the piston activation sound from Internet, but it's .mp3 which is wrong us.
showcase
  1. Because we will need to convert our sound from .mp3 to .ogg. For it, you can use any online converter. You cannot just rename file!
showcase
  1. Good, now we have the right sound. All that remains is to register this sound.

Registering Sound

  1. First, we need to put this sound to assets/namespace/sounds/ folder (for us namespace will be patpat folder). Second, we need to create file at assets/namespace/sounds.json and register our sound in it. You can read this wiki to know more about this file.
showcase

Here is a simple example of this file content:

sounds.json

{
	"here_you_must_write_unique_sound_id": {
		"sounds": [
			"namespace:here_you_must_write_your_sound_name_from_sounds_folder"
		]
	}
}
  1. Let's edit it for us:

sounds.json

{
	"patpat_piston_sound_id": {
		"sounds": [
			"patpat:piston_sound"
		]
	}
}
  1. Finally, let's tell PatPat Mod, which sound we want to play with animation. For it, we need to edit animated_piston.json5. Also, we will specify min/max pitch, and volume for our sound.

Here is what we want to add:

animated_piston.json5

{
	// ...
	"animation": {
		// ...
		"sound": {
			"id": "patpat:patpat_piston_sound_id",
			"min_pitch": 0.5,
			"max_pitch": 1.5,
			"volume": 0.8
		},
		// ...
	}
	// ...
}
See Full File

animated_piston.json5

{
	"version": "1.0.0",
	"animation": {
		"texture": "patpat:textures/animated_piston.png",
		"duration": 300,

		"sound": {
			"id": "patpat:patpat_piston_sound_id",
			"min_pitch": 0.5,
			"max_pitch": 1.5,
			"volume": 0.8
		},

		"frame": {
			"totalFrames": 5,

			"scaleX": 1,
			"scaleY": 1,

			"offsetX": 0,
			"offsetY": 0,
			"offsetZ": 0
		}
	},
	"entities": [
		"minecraft:zombie"
	]
}
  1. So, let's test our ready-to-use resource pack!

Youtube Video (click here to open it)


Previous Next