Monday, December 5, 2022
HomeNewsHow To Make Sonic In Minecraft

How To Make Sonic In Minecraft

A Simple Deterministic State System

Minecraft: How To Make a Sonic Statue “Sonic the Hedgehog” Tutorial

Back in Section 5.6 we discussed why using variables across threads canlead to random behaviour. This stops us from being able to reliablyreproduce code such as this:

## An Example of Non-Deterministic Behaviour## .#### If you run this code you'll notice## that the list that's printed is## not always sorted!a = live_loop :shuffled do  a = a.shuffle  sleep 0.5endlive_loop :sorted do  a = a.sort  sleep 0.5  puts "sorted: ", aend

Lets take a look at how this might look using get and set:

## An Example of Deterministic Behaviour## ## using Sonic Pi's new Time State system.#### When this code is executed, the list that's## printed is always sorted!set :a, live_loop :shuffled do  set :a, get.shuffle  sleep 0.5endlive_loop :sorted do  set :a, get.sort  sleep 0.5  puts "sorted: ", getend

Notice how this code is pretty much identical to the version usinga variable before it. However when you run the code, it behaves as youwould expect with any typical Sonic Pi code – it does the same thingevery time in this case thanks to the Time State system.

Therefore, when sharing information across live loops and threads, useget and set instead of variables for deterministic, reproduciblebehaviour.

Setting The Position Of The User

Now, lets try a little magic. Lets teleport ourselves somewhere! Trythe following:

mc_teleport 50, 50, 50

When you hit Run – boom! Youre instantantly transported to a newplace. Most likely it was somewhere in the sky and you fell down eitherto dry land or into water. Now, what are those numbers: 50, 50, 50?Theyre the coordinates of the location youre trying to teleportto. Lets take a brief moment to explore what coordinates are and howthey work because theyre really, really important for programmingMinecraft.

Dont Make It Too Complicated

Most of the power in the tick system isnt useful when you getstarted. Dont try and learn everything in this section. Just focus onticking through a single ring. Thatll give you most of the joy andsimplicity of ticking through rings in your live_loops.

Take a look at the documentation for tick where there are many usefulexamples and happy ticking!

Don’t Miss: How To Build A Door In Minecraft

Receiving From External Machines

For security reasons, by default Sonic Pi does not let remote machinessend it OSC messages. However, you can enable support for remotemachines in Preferences->IO->Network->Receive Remote OSC Messages. Onceyouve enabled this, you can receive OSC messages from any computer onyour network. Typically the sending machine will need to know your IPaddress . You can discover the IPaddress of your computer by looking at the IO section of the preferencespane. .

Note, some programs such as TouchOSC for iPhone and Android supportsending OSC as a standard feature. So, once youre listening to remotemachines and know your IP address you can instantly start sendingmessages from apps like TouchOSC which enable you to build your owncustom touch controls with sliders, buttons, dials etc. This can provideyou with an enormous range of input options.

Sending Osc To Other Programs

Minecraft Tutorial Ep.3: How To Make Sonic

Of course, sending OSC messages to ourselves may be fun but its notthat useful. The real benefit starts when we send messages to otherprograms:

use_osc "localhost", 123456osc "/hello/world"

In this case were assuming theres another program on the same machinelistening to port 123456. If there is, then it will receive a”/hello/world OSC message with which it can do what it wants.

If our program is running on another machine, we need to know its IPaddress which we use instead of “localhost”:

use_osc "", 123456osc "/hello/world"

Now we can send OSC messages to any device reachable to us via our localnetworks and even the internet!

Don’t Miss: How Many People Have Bought Minecraft

Finding Your Current Coordinates

Lets have a play with coordinates. Navigate to a nice place in theMinecraft map and then switch over to Sonic Pi. Now enter the following:

puts mc_location

When you hit the Run button youll see the coordinates of your currentposition displayed in the log window. Take a note of them, then moveforward in the world and try again. Notice how the coordinates changed!Now, I recommend you spend some time repeating exactly this – move a bitin the world, take a look at the coordinates and repeat. Do this untilyou start to get a feel for how the coordinates change when youmove. Once youve understood how coordinates work, programming with theMinecraft API will be a complete breeze.

Specifying Start And Finish

Of course, we can combine these two to play arbitrary segments of theaudio file. How about only a small section in the middle:

sample :loop_amen, start: 0.4, finish: 0.6

What happens if we choose a start position after the finish position?

sample :loop_amen, start: 0.6, finish: 0.4

Cool! It plays it backwards!

Don’t Miss: How To Train A Fox In Minecraft

Passing Values Into The Future

In the example above we set :foo to 1 which we did nothing with. Wecan actually get this value from the thread calling sync:

in_thread do  amp = sync :foo  sample :ambi_lunar_land, amp: ampendsleep 2set :foo, 0.5

Note that values that are passed through set and cue must be threadsafe – i.e. immutable rings, numbers, symbols or frozen strings. SonicPi will throw an error if the value you are attempting to store in theTime State is not valid.

A Simple Explanation Of Sample Rate

Minecraft Tutorial: How To Make A Sonic Themed House

A useful way to think of samples is as springs. Playback rate is likesquashing and stretching the spring. If you play the sample at rate 2,youre squashing the spring to half its normal length. The sampletherefore takes half the amount of time to play as its shorter. If youplay the sample at half rate, youre stretching the spring to doubleits length. The sample therefore takes twice the amount of time to playas its longer. The more you squash , the shorter it gets,the more you stretch , the longer it gets.

Compressing a spring increases its density – this is similar to the sample sounding higher pitched. Stretchingthe spring decreases its density and is similar to the sound having alower pitch.

Also Check: How To Find Apples In Minecraft

Designed To Be Live Coded

The Minecraft Pi API has been designed to work seamlessly withinlive_loops. This means its possible to synchronise modifications inyour Minecraft Pi worlds with modifications in your Sonic Pisounds. Instant Minecraft-based music videos! Note however thatMinecraft Pi is alpha software and is known to be slightly buggy. If youencounter any problems simply restart Minecraft Pi and carry on asbefore. Sonic Pis automatic connection functionality will take care ofthings for you.

Minecraft Free Sonic Mod

Get Sonic, Knuckles, Tails, Amy, and all other Sonic stuff through the free mod.

By Mehrdad Khayyat

If you are a Minecraft player, you have probably heard about the new Sonic DLC that went live yesterday. Although its a paid DLC, theres still a free option to get your own Sonic-themed event in Minecraft. The only thing you need to do is installing the Sonic mod.

Prior to the launch of the official Sonic DLC on Minecraft, there was already a free mod available for the game, allowing players to install all Sonic-related blocks and create their very own Sonic world in Minecraft.

  • GUIDE: Scarlet Nexus Expected Release Time For Xbox, PlayStation, and PC

Although the official DLC might seem like a more complete bundle for Sonic fans, the free mod that we are going to introduce you to here has all the iconic elements of the Sonic series.

Sonic x Minecraft DLC: Official Trailer

Also Check: How To Make Hardened Clay In Minecraft

Sonic The Hedgehog Appears To Be Coming To Minecraft

  • 0

Earlier this week, Sega held the first ever ‘Sonic Central‘ broadcast. During the live stream, it announced the return of Sonic Colors, Sonic Origins, and a brand new game from the Sonic Team, arriving in 2022.

In between all of this, there were a few smaller teasers, but one you might have missed is the announcement of a collaboration between Sonic the Hedgehog and Minecraft. You can see this at around the 3:48 mark in the broadcast.

Apart from the brief clip showing a giant block build of Sonic, you can also hear and see a Minecraft chicken at the bottom of the shot. According to the voice-over, this collab is one of many that we should be hearing more about throughout the year:

“Stay tuned for more information on future collaborations throughout the year.”

While nothing else has been shown or mentioned about this so far, it’s likely to be a skin pack or various other Sonic-themed content for Mojang’s insane popular survival crafting game. It could perhaps be similar to what we saw with the Super Mario mash-up pack.

You can read more about some of the smaller announcements during Sonic Central in our previous post. Did you catch this Minecraft X Sonic tease during the broadcast? Leave a comment down below.

See Also

The Maths Behind Sample Rate


As we saw above, a sample is represented by a big long list of numbersrepresenting where the speaker should be through time. We can take thislist of numbers and use it to draw a graph which would look similar tothis:

You might have seen pictures like this before. Its called thewaveform of a sample. Its just a graph of numbers. Typically awaveform like this will have 44100 points of data per second . So, if the sample lastsfor 2 seconds, the waveform will be represented by 88200 numbers whichwe would feed to the speaker at a rate of 44100 points per second. Ofcourse, we could feed it at double rate which would be 88200 points persecond. This would therefore take only 1 second to play back. We couldalso play it back at half rate which would be 22050 points per secondtaking 4 seconds to play back.

The duration of the sample is affected by the playback rate:

  • Doubling the playback rate halves the playback time,
  • Halving the playback rate doubles the playback time,
  • Using a playback rate of one fourth quadruples the playback time,
  • Using a playback rate of 1/10 makes playback last 10 times longer.

We can represent this with the formula:

new_sample_duration =  * sample_duration 

Recommended Reading: How Do You Make A Potion Of Invisibility In Minecraft

Musical Engines And Notation

The histories of music and computers have been intricately woven togethersince the inception of computing machines, or engines as CharlesBabbages powerful analytical engine was called. Back in 1842 theMathematician Ada Lovelace, who worked very closely with Babbage, sawthe creative potential of these engines. Whilst these first engines hadoriginally been designed to accurately solve hard maths problems, Adadreamt about making music with them:

..the engine might compose elaborate and scientific pieces of music ofany degree of complexity or extent. Ada Lovelace, 1842.

Of course, today in 2019 much of our music, regardless of genre, haseither been composed, produced or mastered with a digitalcomputer. Adas dream came true. It is even possible to trace thehistory back even further. If you see coding as the art of writingsequences of special symbols that instruct a computer to do specificthings, then musical composition is a very similar practice. In Westernmusic, the symbols are black dots positioned on a stave of lines thattell the musician which notes to play and when. Intriguingly, if wetrace the roots of Western music notation back to the ItalianBenedictine monk, Guido dArezzo, we find that the dots and lines systemthat modern orchestras use is just one of a number of notation systemshe worked on. Some of the others were much closer to what we might nowsee as code.

Minecraft Meets Sonic In Awesome New Mashup Pack

In celebration of Sonic the Hedgehog’s 30th anniversary, Sega and Mojang teamed up to produce Sonic x Minecraft downloadable content.

To honor;Sonic the Hedgehog‘s 30th anniversary, Sega and Mojang joined each other;in making way for the previously teased;Sonic x Minecraft DLC pack. Sega kickstarted the ongoing celebrations in late May by hosting a Sonic 30th anniversary stream dedicated to new announcements regarding;the;franchise.

One such reveal officially confirmed the release of;Sonic Colors: Ultimate, a remaster for the;Wii and Nintendo DS exclusive Sonic Colors. Sega’s;celebratory Sonic Central broadcast also unleashed new details about;Olympic Games Tokyo 2020 – The Official Video Game, namely that players will get to dress their Olympic avatars like Sonic. Viewers additionally received;cursory information about the 2022 roll out;of;Sonic Origins, a collection packed with several of the beloved brand’s classic adventures. Of course, the most significant announcement;involved CG;footage of;a brand-new Sonic the Hedgehog game, but a quick tease for Sonic’s Minecraft collaboration absorbed some of the spotlight, as well.

Related:;Sonic the Hedgehog Ran So Fast it Permanently Changed His Appearance

This DLC seems yet another great way to honor;the groundbreaking franchise’s 30th anniversary. Plus, Sonic himself fits surprisingly well in the Minecraft aesthetic. The overt blockiness doesn’t look half bad on;the speedy hedgehog.

You May Like: When Was Creative Mode Added To Minecraft

Keep A Practice Diary

When you are practicing, youll often find your mind is full of newexciting ideas – new musical directions, new sounds to try out, newfunctions to write, etc. These ideas are often so interesting that youmight stop what youre doing and start working on the idea. This isanother form of distraction!

Practice tip #8 – keep a practice diary by your keyboard. When you getan exciting new idea, temporarily pause your practice session, quicklyjot the idea down, then forget about it and carry on practicing. You canthen spend some quality time thinking about and working on your ideasafter youve finished practicing.

About This Content Pack

How To Make a Portal to the SONIC Dimension in Minecraft PE (Sonic Portal in MCPE)

The official Sonic the Hedgehog DLC for Minecraft is packed with familiar faces and places from past games. Heres a brief description of what you can find, courtesy of the Minecraft store:

Sonic the Hedgehog races into Minecraft at supersonic speeds! Sprint, roll, and spring off enemies through iconic zones, with infinite gameplay. Master the thrilling abilities of Sonic, Tails, Knuckles, and more! Compete with friends for high scores! Unlock achievements, characters, new zones, and a challenging Eggman Mode! Includes 24 popular skins.

You dont have to wait to get your hands on the Sonic DLC, its available right now! You can purchase it in the Minecraft Marketplace for 1340 Minecoins. You can purchase this in-game currency on the eShop, where $10 will net you 1720 coins. Now if youll excuse me, mine just finished downloading. Ive got some rings to collect!

Also Check: What Is The Fastest Way To Get Xp In Minecraft

No Need To Import Libraries

The Minecraft Pi integration has been designed to be insanely easy touse. All you need to do is to launch Minecraft Pi and create aworld. Youre then free to use the mc_* fns just like you might useplay and synth. Theres no need to import anything or install anylibraries – its all ready to go and works out of the box.

Functions Are Remembered Across Runs

So far, every time youve pressed the Run button, Sonic Pi has startedfrom a completely blank slate. It knows nothing except for what is inthe buffer. You cant reference code in another buffer or anotherthread. However, functions change that. When you define a function,Sonic Pi remembers it. Lets try it. Delete all the code in yourbuffer and replace it with:


Press the Run button – and hear your function play. Where did the codego? How did Sonic Pi know what to play? Sonic Pi just remembered yourfunction – so even after you deleted it from the buffer, itremembered what you had typed. This behaviour only works with functionscreated using define .

Read Also: Can You Eat Pumpkins In Minecraft

Sending Osc To Sonic Pi

We can send OSC to Sonic Pi from any programming language that has anOSC library. For example, if were sending OSC from Python we might dosomething like this:

from pythonosc import osc_message_builderfrom pythonosc import udp_clientsender = udp_client.SimpleUDPClientsender.send_message

Or, if were sending OSC from Clojure we might do something like this from the REPL:


Bringing It All Together

Minecraft Sonic The Hedgehog

In each of these tutorials, well end with a final example in the formof a new piece of music which draws from all of the ideasintroduced. Read this code and see if you can imagine what itsdoing. Then, copy it into a fresh Sonic Pi buffer and hit Run andactually hear what it sounds like. Finally, change one of the numbers orcomment and uncomment things out. See if you can use this as a startingpoint for a new performance, and most of all have fun! See you nexttime

with_fx :reverb, room: 1 do  live_loop :time do    synth :prophet, release: 8, note: :e1, cutoff: 90, amp: 3    sleep 8  endendlive_loop :machine do  sample :loop_garzul, rate: 0.5, finish: 0.25  sample :loop_industrial, beat_stretch: 4, amp: 1  sleep 4endlive_loop :kik do  sample :bd_haus, amp: 2  sleep 0.5endwith_fx :echo do  live_loop :vortex do    # use_random_seed 800    notes =     16.times do      play notes.choose, release: 0.1, amp: 1.5      sleep 0.125    end  endend

Recommended Reading: What Does Fortune Mean In Minecraft

Warning: Variables And Threads

Whilst variables are great for giving things names and capturing theresults of things, it is important to know that they should typicallyonly be used locally within a thread. For example, dont do this:

a = live_loop :shuffled do  a = a.shuffle  sleep 0.5endlive_loop :sorted do  a = a.sort  sleep 0.5  puts "sorted: ", aend

In the above example we assign a ring of numbers to a variable a andthen used it within two separate live_loops. In the first live loopevery 0.5s we sort the ring ) and thenprint it out to the log. If you run the code, youll find that theprinted list is not always sorted!. This may surprise you – especiallythat sometimes the list is printed as sorted, and sometimes it isnot. This is called non-deterministic behaviour and is the result of arather nasty problem called a race-condition. The problem is due to thefact that the second live loop is also manipulating the list and by the time the list is printed, sometimes it hasjust been sorted and sometimes it has just been shuffled. Both liveloops are racing to do something different to the same variable andevery time round a different loop wins.

There are two solutions to this. Firstly, dont use the same variablein multiple live loops or threads. For example, the following code willalways print a sorted list as each live loop has its own separatevariable:

live_loop :shuffled do  a =   a = a.shuffle  sleep 0.5endlive_loop :sorted do  a =   a = a.sort  sleep 0.5  puts "sorted: ", aend


Most Popular