Refresh and then it should be linked is it going to work hey everyone welcome back to another episode of Code with me wow it’s been a while since I’ve posted a video about the series I was out for most of December I was in Hong Kong which was Really fun but also I didn’t get much of a chance to code in 4.0 as you can see in my world right here I have some ticket machines because I was testing the different mechanisms for it and signs as well Signs Now function properly which is pretty Cool so today what I want to show you is not related to the ticket machines or signs although those are pretty cool as well what I want to show you here is something that has existed in the older versions of the game but I haven’t added Back to 4.0 yet and that is elevators or lifts so let me show you what our existing behavior is I haven’t finished coding all of this by the way so this is going to be incomplete so right now we have the lift track and the lift floor track which is already in the Existing version version so let me Place those down real quick and then we have the refresher as well so I right click and my lift appears and then if I click it again you can modify different parameters and stuff like that so that all works and that’s good wait did that Work okay I think that worked I’m not sure okay and then we have the buttons which we can link I haven’t coded the display of the buttons onto here yet so let’s just pretend that the buttons are rendered here so then if I click the button I should request the lift and That goes up okay what I want to show you in this video is something that it’s that has been requested from other members for a little while now I’m not sure how long which is different directions of the lifts in real life sometimes you might have some diagonal lifts or even Horizontal moving lifts so I’ve added just that these are horizontal tracks and I can place them like so and let’s put down some buttons as well and Link them to here I haven’t actually tested this myself so I don’t know if this is going to work oh I have to refresh this first First refresh and then it should be linked is it going to work if this doesn’t work then I’m going to have to look into the code again if I request this it comes down is it going to come up no okay let’s see what the code is looking like Actually before I dive into the code I think I figured out a way to make it work so for some reason when I refresh the path again it’s not getting updated in the lift so instead if I break the floor of the existing path then the lift Disappears and I place down the floor again and refresh it again the lift appears down there and then this time when I press the buttons the lift successfully comes to the floor I requested all right and then if I press on this floor the lift comes over here Oh I saw that little bounce still moving a little bit the movement of the lift is still a bit glitchy as you can tell but I’m working on it so while I’m also wondering if I can offset the values here H that didn’t do anything oh now that did Something just so that the lift doesn’t clip into the wall okay that works I also have encoded in the door opening and stuff so it might look a little weird yeah there you go let’s try something else so if let’s say my lift is going to come back up here To this flooor right here I’ve made another track called the corner track so this is the horizontal track the vertical track the corner track and the floor track so we have the corner as well let’s put that down so the corner depending on what part of the block you Click it’s going to face a different way like that so if I do this this this and so on and then I’m going to just break the path and then re redo this and put the buttons down and redo that and refresh the whole thing and let me request the Lift oh that looks so funny at least it works though now I can request the lift over here h The Bouncing is kind of funny I might have to look into that later but it works so one thing to note though is if you make tracks like this let me break This it’s going to take the shortest distance to get to the destination so it’s not going to so it’s going to take a weird diagonal line the shortest distance between the two floors instead of accurately following your path you set up in your world so for example if I Make a track that looks like this the lift is going to just cut diagonally across instead of following the zigzag directly so let me show you what I mean if I press the button watch this last part it’s just going to take a smooth diagonal to your destination I don’t Know if that’s what you want but that’s that’s how I coded it in so far so I guess maybe way points will be useful if you want to make more accurate paths but for now this will do and I’m happy with the result like that like This so I requested it on the bottom floor and then again on this floor so when the door closes the lift is going to come back to this floor all right everything’s working as expected now I’m going to break this I think and what happens if I refresh the Path if I refresh the path the lift doesn’t seem to take on the New Path and it still thinks it’s on the old path oh wait no maybe it’s not registered with this anymore now yeah if I press this button the lift is not going to come Here if I press this the lift will still go over there cool but I press this because I broke the track and I refreshed it it’s no longer going to come here I think what would be useful is if I was holding the refresher the lift would show its Path like as like ghost blocks or something so let me try to code that in okay so back in the code I have this class called render lifts which is quite similar to the other files we’ve been seeing for example render rails and render Vehicles render trains is just rendering everything so it’s Calling render Vehicles render lifts and render rails this should probably be renamed as I mentioned before I just kept the name just for old time sake but it’s not an accurate name for that so I’m back in render lifts and I want to check if yeah let me put a Boolean here Like is holding refresher would be equal to I think I have a utility for that I forgot an I block is holding wait utilities not in utilities H I forgot what the method was called okay so I just decided to use the vanilla method which is dot is Holding and lift refresher so if we’re holding the refresher we want to iterate through the floors and I realize that the methods I have in the lift class doesn’t have any anything that can allow me to do that so I think I need like um like a method for example public void iterate Floors I don’t know I just don’t feel like exposing the floors array because I don’t want people just modifying it so I like to use these iterate methods although if we’re going to draw lines between them you know what let’s just do it consumer of lift Floor and then we just do floors dot for each consumer just like that and then now we have to build it which will automatically copy it into this project and then we can see our new method okay I think the build is finished so let’s see iterate floors there’s our method And okay for starters let’s just try to render some I don’t know what to render render a shape what should we do a circle what what do we have available for us so to render something we can schedule it identifier I’m kind of coding blind here Because I forgot how to do a lot of things so mod ID I don’t know uh textures block uh what textures do we have exit I don’t know lift. PNG I don’t know if that’s even a real texture but let’s just try that no priority render layer I think light We want it full brightness it’ll be okay and then there’s our call back with the graphics holder and then what would this this would be the offset draw H draw texture in world I think so we can use that H so this takes in what does it take it Takes in float values I don’t want to necessarily use float values the reason is because if I how do I say this if the coordinates are too high and we use float values we’re going to get jittering just like what we saw in the existing versions of the mod So instead we’re going to have to do some translations yeah that takes in a double so that’s going to be better so ah I need to review how to do this all this okay I decided to go with making a model in instead an entity model so maybe that would be easier to Render I just thought of doing that so I guess we need to make a static thing here private static final model small cube model small cube and our texture would be um let’s just do like redstone block or something I don’t even know if that’s the right path for the Minecraft Redstone block texture but we’ll see okay so instead of this scheduling render we will have our model render so stored Matrix Transformations would be similar to what we do up here and then we need to add some transforms which is the lift floor translate lift floor do Position uh do we already have position defined somewhere oh and why is it the wrong type okay position dox position doy and position doz so when we render we can just put our storage Matrix Transformation light we need the constant from IGI which is the max light glowing I just like it glowing so that at night time when we’re debugging we can see it pretty easily okay so let’s test that that should render our little cubes on each floor okay let’s test it I’m going to Refresh and there we go our little Redstone indicators are showing up so let me try one more thing when I connect this track and refresh all right so this one shows up too so it’s part of the track so I press this oh the lift does come over here I Wonder why it wasn’t working earlier H that’s weird let me do one more thing is to make like big lines to connect them so that I can see what’s going on like how the floors are being connected together okay so this is what I have I stored the previous lift floor Here in this variable and then if it’s not null then I’m going to render a line from between these two positions yeah okay let’s see what that looks like all right let’s see it refresh and there we go the lines are all connected and we can See the path of the lift which is really cool so let’s say I want to put a floor here and I refresh there we go the the path updates accordingly and if I break this and refresh a second oh did the second lift spawn a second lift spawned supposed to Be just these two tracks and then H the weird thing happened it’s because it still thinks that that that lift is connecting all of these so I guess that’s the issue when we refresh it and the path is shorten then it doesn’t work right yeah so we’re going to have to Break this and then do it again now it registers the shorter path and then if I do this then it registers that path all right I guess that’s a bug to fix for another time unfortunately I don’t have too much time to work on this today I still have a lot around the House to do so I can’t just keep coding right now H now there’s two lifts in this area I break that both of them goes away refresh there we go all right let me Demo this one more time for those of you who like to skip the video to the Interesting Parts I guess skip the parts where I’m coding so lifts now support diagonal tracks and horizontal tracks so this is how I’ve been building my tracks with the horizontal track vertical track floor track as well as the corner track the corner track can be placed in any of These four orientations depending on where on the Block you point at and I haven’t coded in the button rendering yet so you’re going to have to imagine that they have up and down buttons so if I click on it the lift will be requested and come to the Specified floor and if I’m holding the refresher it’ll also show me like the path of the lift so if you’re trying to debug it it’s not going to be too difficult so I requested this floor the lift is going to come to this floor and down here and Oh that was weird the movement is still a bit glitchy but you get the idea so going to go down to that floor and go up cuz I press this one so still some bugs to fix but I’m excited about this update and if in case you’re wondering how come you’re adding More new features rather than just getting 4.0 out the door my answer to that is I needed to rewrite the lift code anyway as part of the new backend so I might as well Implement horizontal lines horizontal tracks because that’s not much more effort it’s still the main Lift logic so the hard part is coding the back end and the logic and how the lift moves and all of that it has nothing much to do with adding horizontal or vertical tracks so that’s why I chose to add it because I know some of you suggest it on the Discord And thank you for that now it’s going to be implemented in 4.0 and it’s going to be really fun so thank you so much for watching unfortunately I don’t have that much time to code today and please remember to like the video if you’re excited for the 4.0 Update subscribe to the channel so that you can get future updates and thank you so much for watching I’ll see you next time time bye Video Information
This video, titled ‘Elevators are Even Crazier in 4.0.0? – Minecraft Transit Railway’, was uploaded by Jonathan Ho on 2024-01-07 11:00:01. It has garnered 2646 views and 115 likes. The duration of the video is 00:21:39 or 1299 seconds.
Elevators can go up and down… and more! Thank you Patreon members for your continuous support. Please consider subscribing if you are able!
https://www.patreon.com/minecraft_transit_railway
Timestamps 0:00 Intro 1:21 Existing Elevator Blocks and Items 2:16 New Elevator Tracks 1 4:54 New Elevator Tracks 2 8:21 Code With Me – Adding a Path Preview 18:51 Final Result – Crazy Elevators!
Minecraft Transit Railway is a Minecraft mod based on Hong Kong’s MTR, the London Underground, and the New York Subway. It adds trains, boats, cable cars, and planes to the game along with other miscellaneous blocks and items. With this mod, it is possible to build a fully functional railway system in your world!
Useful Links Mod Download: https://www.curseforge.com/minecraft/mc-mods/minecraft-transit-railway Get 25% off server hosting on Shockbyte: Use code MTRMOD https://partners.shockbyte.com/minecrafttransitrailway Mod Wiki: https://wiki.minecrafttransitrailway.com/start Be part of the community; join our Discord! https://discord.gg/PVZ2nfUaTW Support my work! https://www.patreon.com/minecraft_transit_railway Help translate the mod! https://crwd.in/minecraft-transit-railway
Social https://www.instagram.com/minecraft.transit.railway/ https://www.facebook.com/Minecraft-Transit-Railway-102713049454897 https://twitter.com/MTRMinecraft
#minecrafttransitrailway #minecraftmods #minecraftmtr #mtrmod #mtr #minecraft #transit #railway #trains #railway #transport #subway #londonunderground #london #underground #nyc #newyorksubway #nycsubway #cablecar #airplane #airlines #aeroplane #plane
#update #spoiler #preview