Presentation is loading. Please wait.

Presentation is loading. Please wait.

Copyright © 2013-2015 Curt Hill Sounds, Resource Packs, JSON What more would you want?

Similar presentations


Presentation on theme: "Copyright © 2013-2015 Curt Hill Sounds, Resource Packs, JSON What more would you want?"— Presentation transcript:

1 Copyright © 2013-2015 Curt Hill Sounds, Resource Packs, JSON What more would you want?

2 Introduction A resource pack allows replacement of a series of textures, sounds or music to be installed instead of the standard Minecraft versions In order to add new sounds we will put them in a resource pack –Then figure out how to use them We will need JSON as well –That is where we will start Copyright © 2013-2015 Curt Hill

3 What is JSON? JavaScript Object Notation A language for data interchange –Derived from JavaScript (ECMA standard) –Alternative to XML in that respect Both easy for people to read and easy for machines to parse Consists of sequences and attribute- value pairs It is an open standard Copyright © 2013-2015 Curt Hill

4 Simple Types Does not have many Number –A floating point type String –Enclosed in double quotes –Uses UNICODE characters Boolean –May be true or false null –Indicates an empty value Copyright © 2013-2015 Curt Hill

5 Structured Types Only two structuring types Object –Similar to a group, record, or struct, depending on language –Unordered, comma separated list of name value pairs enclosed in braces { } –The key is separated from the value by a colon Array –An ordered, comma separated list of values enclosed in brackets [ ] Copyright © 2013-2015 Curt Hill

6 Commentary White space may be interspersed for readability without changing meaning Hardly any programming language lacks these features –Most have a JSON interface Keys are merely strings –Enclosed in double quotes Copyright © 2013-2015 Curt Hill

7 Example A simple object to contain a name: { “first”:”Bill”, “lastname”: “Smith” } An array of names inside an object: { “employees” : [ {“first”:”Bill”, “last”:“Sam” }, {“first”:”John”, “last”:“Doe” }, {“first”:”Curt”, “last”:“Hill” } ] } We will see two examples in resource packs Copyright © 2013-2015 Curt Hill

8 BSON Binary JSON also exists This is a binary encoded serialization of JSON objects These should be more compact and faster to parse This we will not use in this class Copyright © 2013-2015 Curt Hill

9 Resource Packs A resource pack is a zip file containing a directory tree Various parts of this tree contain the resources that Minecraft will replace its native resources We need to look at several parts of this tree –Starting at the root Copyright © 2013-2015 Curt Hill

10 The root directory Contains three things: An assets directory The pack.mcdata file –The first of our two JSON files in this presentation A pack.png file –For display Copyright © 2013-2015 Curt Hill

11 pack.mcdata A JSON file that identifies the resource pack There may be several things in it, but the required information is the name and format of the pack See the next slide for an example Copyright © 2013-2015 Curt Hill

12 Required Example Copyright © 2013-2015 Curt Hill { "pack": { "description": "Curt's Minecraft Resources", "pack_format": 1 }

13 Other things There may be other things in this file as well The template resource pack contains numerous language types Copyright © 2013-2015 Curt Hill

14 Directory Structure Copyright © 2013-2015 Curt Hill

15 Moving Down The assets directory is rooted in the top level directory It only contains the minecraft directory Inside the minecraft directory are several resource directories There is also the sounds.json file Copyright © 2013-2015 Curt Hill

16 Minecraft directory Contains as many of the following subdirectories as you want to use: –icons –music –records –sounds –textures Today we are only interested in sounds Copyright © 2013-2015 Curt Hill

17 Sounds Directory May contain 15 or more subdirectories Again, these depend on what you want to replace These include: –Damage –Dig –Fire –Mob –Music –Step –Among others Copyright © 2013-2015 Curt Hill

18 Example: Step Directory This contains the noise made when an entity steps on a particular type of block Usually there are several alternatives so the exact same noise is not used for every step In the template there are 4 cloth, 6 grass, 4 gravel etc. Copyright © 2013-2015 Curt Hill

19 Built ins and not Most of the sounds are built-in –Their presence in the correct directory is all that is needed Should you add something another file is needed: sound.json Yet another JSON file that gives additional control information to the game Sounds that are not standard need an entry in this file Copyright © 2013-2015 Curt Hill

20 The sounds.json file First recall that this file is in the assets/minecraft directory It has one or more entries that give a name to a sound and then describe its location –Possibly other things as well Copyright © 2013-2015 Curt Hill

21 Minimal Example File Copyright © 2013-2015 Curt Hill { "lightblock": { "category": "neutral", "sounds": [ "step/lightblock" ] }, "step.lightblock": { "category": "neutral", "sounds": [ "step/lightblock" ] }

22 Commentary This file gave two names for the same file –This is done in two entries First entry is the name –This identifies an object The object may contain two or more entries –Only two were shown: category and sounds Copyright © 2013-2015 Curt Hill

23 Object entries Category determines the volume controls Several options here: –ambient –weather –player –neutral –block –record –Among others Copyright © 2013-2015 Curt Hill

24 Volume Controls Copyright © 2013-2015 Curt Hill

25 Testing Once we have established a named sound in: –The resource pack –sounds.json We should be able to use it In the client we should be able to type: /playsound soundname @p –The sound should play or the console record the error Copyright © 2013-2015 Curt Hill

26 Playing Copyright © 2013-2015 Curt Hill

27 Played Copyright © 2013-2015 Curt Hill

28 Commentary The screen said it was played, but what he really means is that he tried to play it The console will have a complaint if it tried to play it but could not find it Later we will consider the Java code to play it Before that we continue with the resource pack Copyright © 2013-2015 Curt Hill

29 Template Pack A template resource pack is at: http://hypixel.net/threads/official- resource-pack-template.7540/ http://hypixel.net/threads/official- resource-pack-template.7540/ This is the basis of what I have used Download and extract it to a directory –Not your minecraft directory Then modify it to suit Copyright © 2013-2015 Curt Hill

30 Modification Modify the pack.mcdata and pack.png –Only the name of the resource pack Create and edit the new sounds Add these new sounds to whichever directory seems appropriate Create and add the sounds.json file to the minecraft directory Rezip it and copy to the correct directory Copyright © 2013-2015 Curt Hill

31 Rezip There are several zip utilities The built-in in Windows Explorer is the easiest Enter the top level directory Select all of these –assets directory –pack.mcdata –pack.png Right click and choose Send to compressed file Rename it to your own name Copyright © 2013-2015 Curt Hill

32 Getting Minecraft to use it The resource file needs to be in a particular directory This can be easily found by clicking the options and resource buttons Then click on Open Resource Pack folder –This will open a Windows Explorer in the right directory Copyright © 2013-2015 Curt Hill

33 Selected Resource Packs Copyright © 2013-2015 Curt Hill

34 Finding location Copyright © 2013-2015 Curt Hill

35 Selection Once Minecraft knows it is available it should be in the left column Move to right column Make it first Now it should be available when you play Next we consider sounds and playing them at appropriate times Copyright © 2013-2015 Curt Hill

36 Sounds We have already seen the Block method setStepSound It takes as a parameter a Block.SoundType class Up to now we have used one of the constant sounds: –soundTypeAnvil, soundTypeCloth, soundTypeGlass, soundTypeGrass, soundTypeGravel, soundTypeMetal, soundTypeSand, etc. Now we want more Copyright © 2013-2015 Curt Hill

37 Block.SoundType A class in its own right Has three properties: –float frequency –String soundName –float volume The constructor takes all three –Name, frequency, volume Copyright © 2013-2015 Curt Hill

38 Constructor Again The frequency is more like playback speed 1.0F means normal –Less than one means slow it down –More than one speeds it up The volume should be between 0-1 –Moderated by sliders The name is the name in sounds.json This is usually used inside the setStepSound or similar method Copyright © 2013-2015 Curt Hill

39 Ways to play sound Blocks contain the setStepSound –Strangely, there is no setDigSound method The other way is playSound –This is a method in Entity Copyright © 2013-2015 Curt Hill

40 setStepSound We have seen this using a constant sound Here is the example using a new sound: setStepSound( new Block.SoundType ("lightblock",1.0F,1.0F)); The lightblock is in the sounds.json file Copyright © 2013-2015 Curt Hill

41 playSound This one is somewhat different It is a member of Entity The signature is: void playSound(String name, float freq, float vol); – Where Freq is the playback speed Vol is the volume Copyright © 2013-2015 Curt Hill

42 Where? The playSound method may be used in anything with access to an Entity In particular this is usually in event handlers: –onEntityWalking –onEntityCollidedWithBlock These both have a parameter that gives the entity that did the action Copyright © 2013-2015 Curt Hill

43 Finally Now we know about using sounds –Putting them in resource packs –Construction JSON files that describe Time for the demo Copyright © 2013-2015 Curt Hill


Download ppt "Copyright © 2013-2015 Curt Hill Sounds, Resource Packs, JSON What more would you want?"

Similar presentations


Ads by Google