Hey everyone so um two years ago i did uh advent of parents where i tried to blog about closure every day of the event last year i did the more popular uh advent of code uh did some youtube videos um where every day i did some streaming and then later Released the videos about solving this advent of code um problems you can find those uh as a playlist on the lambda island profile on youtube um this year i’ll be doing something slightly different i’ve been meaning for a while to make some new videos about witchcraft which is uh our library for Uh doing sort of interactive coding with minecraft and a lot has happened there i have a few videos online about that but a lot has changed a lot has gotten better so let’s dive in so one of the big things since the last video is that we now basically support any bucket based Minecraft servers so minecraft mojang releases their official server and people do all kinds of different ways to mod it but one of the the ways of modding it that’s been around for a long time is these different servers which all implement this common api so so basically these are projects that Modify the mojang official server to sort of add on support for this stable api which is the bucket api um so that you can write your plugins and your code using the bucket api and it sort of works across versions across servers and so that’s what we’ve been targeting From the beginning with glowstone but so now we’ve actually made sure that we’re compatible also with the the most popular other ones which are spigot and paper and i in particular have been enjoying paper so that’s what i’ll be showing you um so paper mc you go to downloads Um this is also an opportune time because uh minecraft 118 just came out we’ve got a bunch of new biomes and stuff and so that’s the other thing besides being compatible just with these different server implementations um we’ve also done some stuff uh to make sure it’s easier for us to support Multiple versions of minecraft on a single code base so the stable version of closed stone still uses the minecraft 112 block types and all of that whereas now we’re already at 118 for the for the other ones um and glosson’s targeting that as well of course with their with their upcoming version um But so that you know we kind of done a couple things and maybe in a future video i can dive into some of the cool tricks we’ve done there to to support all that in this video trying to not to make it too long just kind of want to Show how to get started um another thing that’s new is that we now have a witchcraft plugin so there’s the witchcraft project on github but there’s also the witchcraft plugin project and so this is now the recommended way uh to run the whole thing uh to get you know your enrolled Connection etc so basically if you’ve seen the old videos i would start my minecraft server my glowstone server from a closure rebel i would first start closure and from inside closure run minecraft with the plugin it’s the other way around you run your minecraft server the way you would normally run your Minecraft software server just drop in the plugin and you’re off to the races which definitely for people coming more from the minecraft world is gonna seem more familiar so let’s look at that if you download this you’re gonna get a jar um i’m just gonna clean this up again and Start with that so this is an executable jar that’s how most servers come and so you just executed with java jar i’m using java 117 from openjdk i think 117 is actually or 17 is necessary now uh definitely for the client i think also for the server Um so and then you just say java jar paper uh this is gonna download the official mojang server patch it do some funny stuff with it uh and then run it uh yeah so you see applying patches learning libraries does a bunch of stuff and then it exits And you’ll see at this point that it’s already created a bunch of files is basically why i wanted to run it the first time it’s created this eula.txt which creates or like equals false so oil is the end user license agreement basically it asks you to explicitly say That you’ve read and agreed to mojang’s license so we’re just going to copy over an oil which has oil is true and now we can go ahead and run it again server.properties not super interesting right now but it could be interesting there’s a whole bunch of stuff in here and especially uh There’s should be a seed in here or at least you can configure a seed in here a world seed or a level seed i think it’s called if you want to control how your worlds are generating you can find you know cool seeds online that give you like specific cool generated worlds We’ll just let it pick a random seed so we’ve agreed to the euler um let’s run this again and now even more stuff should be happening it pops up this gui um where you can kind of see you know the load and the the logs that are also showing up here If you pass an extra no gui option to the server that’s not going to be the case which i generally do i don’t really need this so now our server is running it started a bunch of it created a bunch of initial worlds uh gonna close it once more Uh you’ll see now there’s even more stuff going on here and in particular we got a plugins directory so if you go to witchcraft plugin releases and you download the plugin for your server type and server version so in my case that’s paper 118 and then you just drop that into that directory I’m just going to do it from my local build target witchcraft for paper 118 shaded into plugins if your exact server isn’t on here you can try some of the others there’s a good chance that they will actually work um or just ping us maybe leave a github issue Should be relatively easy for us to add builds um for these other servers it really just depends on a different api uh dependency for their specific flavor of the bucket api but since we use so little of it in the plugin itself i think most of the time that’s not Going to be a big deal so let’s start this once more i’m going to also say no gui and so now um once it kind of starts booting up and loading plugins you’ll see here witchcraft enabling witchcraft uh no witchcraft even found creating default no depth eden font creating default loading depths in Uh require long island witchcraft and then we got a bunch of reflection warnings which i probably should try to fix but it seems like we can it more or less boots up fine um so let’s actually see if we can connect to it from minecraft first so i’m using Multi-mc as a launcher i already added the 118 instance here in my configuration where is it edit instance settings you’ll see that i’ve also configured it to make sure it’s using the right java 17 java executable now you can use the vanilla you know mojang launcher that you get when you Download minecraft uh and make sure that you install 118 there that should work too so when it’s running we don’t need this anymore and now we can say multiplayer so i already added the server here so basically let me let me do that again uh yeah delete this add a server I’m gonna call it runs the default port 25565 done connect to that all right and here’s our new world um and we’ve spawned on top of a birch tree it seems uh yeah we’ll have a better look in a second what uh you know what this world gives us um To kind of see where we are but not too much to be seen yet okay anyway um you know we could just start playing minecraft from here but of course we’re here to do some coding so i’m in emacs now so here i’m actually in my my cauldron project so um You can find a bunch of example code in the witchcraft uh repo but a lot of my own tinkering and a lot of this is very messy but it does give you an idea of the kind of things you can do with witchcraft all go into this this So i created a new rebel session here event 2021 and so from here oh yeah and then the other thing if if you switch to your editor and then minecraft does does this that’s kind of annoying so to prevent that you go back to minecraft And you say you hold f3 and then press p it should say debug is disabled and now i can alt tab or however you switch to your editor so from here i’m gonna do just a cider connect so basically whatever your editor does to connect to an apple server uh So that’s running on your localhost so the minecraft is six five the n wrap is five five connect to that uh sure side or whatever just do the thing And uh here we are okay so um can we evaluate stuff we can um so we can for instance say wc player and that returns craft player name sunny plexus so that’s me and now we can do something like get the location of the current player so you know we’re we’re connected um We are you know we’re in business um let me actually maybe also go here and punch the tree so that this thing goes away there you go we punched a tree good job everyone Um yeah let me start with a little bit of a little bit of administration so one thing that i’d like to do here is set game rule do daylight cycle false World so with that it should just stay so time no longer moves forward um because you know when you’re coding and then suddenly it turns night and zombies start attacking and it’s you know that’s not what we’re here for okay um let’s first uh let’s maybe just give ourselves flying um Yeah so you can give it a username which is probably a little bit of a better practice so yeah now we can fly just kind of want to find a slightly more open area so i was thinking how far am i in for today 13 minutes thinking of maybe going up to something Like 20 minutes so i still got time to try to show a little bit of api stuff uh and in particular i was thinking maybe we can oh there’s a huge yeah so this is the caves and cliffs part two and i feel like we’re already seeing some of the results here But um i just wanna find a place that’s a little bit more open that isn’t full of forest yet where i can put a christmas tree uh a sort of first little creative coating thing uh definitely a lot of forest going on maybe just go straight land inwards See if we hit another biome um the other thing i sometimes do here is just kind of randomly teleport to places so let’s see we are going towards positive x actually yeah i can increase my speed set speed no how is it speed speed fly speed Set fly speed oh yeah so this actually i just put a bit of effort into making sure that um the clj dock built works correctly so we can find the same thing here fly speed um and then also set fly speed so these are probably handy to to keep around Not everything has proper doc strings yet but you know we’re getting there i i have tried to put a bit of effort into that but it’s an ongoing thing anyway um so yeah if we say set full high speed well what’s the current fly speed what kind of uh Yeah so what i’ll usually do is have something at the top here definitely um all right so that i can do stuff like that actually maybe also something to so there’s lock which returns you which gives you a map there’s also xyz which just gives you like a three element vector um And most uh witchcraft methods functions which take some kind of location thing can work with either of these or with the actual object from bucket like a location object transparently which is quite nice and i’ll be showing more of that so okay our flying speed is 0.1 so if we just Make it like 0.5 then maybe we can already go a lot faster here to find a nice biome getting some mushrooms here some big trees and what’s this thing called yeah and so okay when you start doing that you do notice that it might start struggling a little bit with keeping up With the rendering but that’s fine we’ll get there eventually more water uh okay all right we got some planes here this is actually what i was looking for just so you know i can kind of see what i’m doing all right how about we just put a nice christmas tree right here so I am looking at facing west towards negative x and my current location that’s my current location let’s just do that so then we roughly know let’s call that the anchor and just go behind it so okay so for instance if we say uh set block uh at the anchor of uh I don’t know let’s say uh spruce block or just spruce no spruce as well spruce the logs which lock i guess we should use yeah all right cool um okay yeah and so here what i will do is um a technique that i’ve used a lot uh basically a list comprehension of for Loop with xyz ranges so let’s say it’s like 15 wide or actually let’s maybe say like from minus minus eight to eight why why is the height so we’re just going to go like 35 high i don’t know and z is the other axis so this this basically gives us a big um Box like sort of a you know extruded rectangle um and now we’re gonna we’re gonna carve that out so let’s say for instance if x and z are zero then it’s sort of uh the the stem you know the the actual trunk of the tree so then we want it to be Uh x y z spruce lock yeah actually let’s do this for now okay so this gives us something like that and now we can say map the witchcraft add this to our anchor um so now it’s sort of offset actually i guess i should swap it around then it should maintain the yes And then we should be able to just pass this to set blocks all right so there’s our trunk oh it’s already pretty high but that’s cool that’s cool um let’s undo that um right now so if right if this is the case then it’s that uh actually let’s make this a card so That’s the stem and then we wanna so based on the height okay so um if y um let’s say the first five well first four actually done good first like the lowest four okay or is that the lowest three something like that um we we just leave blanket and from from There on we kind of want to get this this pointy three going uh tree um so these are all the y’s above four and now what we do is um let’s get the distance right from uh x zero y to zero zero zero so basically this is like to figure out How far from the center of the tree this block is that we’re looking at so so what we’re doing here is basically like looping over every single block in this big box of blocks and then kind of carving out what we want there and so what we’re doing with distance like this Is sort of our trick to get circular things so let’s say if the distance is smaller than so yeah we’re going from -8 to 8 let’s say it’s one of five all right let’s put and um spruce leaves um yeah so now we get some nils here um let’s just say uh What is the idiomatic way to do this uh no that does not work i don’t know i have a key or keyword right yes so we actually want x y z spruce leaves okay so Oh and those leaves immediately start disappearing because they’re too far from the stem that’s interesting but also this is not exactly what i wanted did i get this right so yeah i think this is maybe what i wanted no now we get nothing okay so the distance even though this is X oh x y x z uh the rest that seems right okay yeah so that already starts to look kind of circulary right um yeah i probably don’t want to go quite as high let’s maybe say 25-ish and now we just want to kind of have it slope towards the top um So this 5 here is going to depend on why and we want it to go between okay so how about we divide y by five what does that do yeah so now it’s upside down okay but that’s already uh pretty good um 25 minus y And i guess here this is where the f now the other way around 28 minutes yeah that’s already getting there right let’s maybe go a little more still cool um so there’s the start of our christmas tree and then tomorrow we can maybe put some uh some decoration in it and stuff so Yeah hope you all like that see you tomorrow bye Video Information
This video, titled ‘Advent of Witchcraft – part 1 (Clojure + Minecraft)’, was uploaded by Lambda Island on 2021-12-01 14:09:17. It has garnered 1765 views and 66 likes. The duration of the video is 00:25:31 or 1531 seconds.
Configure a PaperMC server to work with Clojure, connect from our editor, and code up a christmas tree.