Okay so this train 391 delay again oh I guess this is showing the train behind it not this train which is weird it’s supposed to show the train right here hey everyone and welcome back to another episode of Code with me in this series we are going to be working on This mod and showing you some upcoming features of 4.0 so last time we talked about some of the these hit boxes on the vehicle that you can set and you can make it as complex as you want although there’s like a few small bugs with it but I will fix that in the Future and so you notice that I’m on an mlr train that’s also new I’ve been working on converting more of these trains into the resource pack format which is how vehicles are going to be loaded into the mod from here on out so there’ll be no more hardcoded trains So if you don’t know Java you can still contribute to the project by making pull requests and stuff like that and this is just an example of another train that I just added the mlr so as we mentioned last time like because of these hit boxes you wouldn’t be able to walk Through the seats like you see I just get thrown into this part and I I can’t walk past the doors I can’t walk past the seats yeah and also performance is kind of not great right now I’m not sure if it’s because of all the hitbox checking or Just CU there’s so many Trains being rendered right now so yeah if you want to know what’s coming up in 4.0 you’re in the right place so today let me get off this train real quick I would like to work on a feature that is very important to this mod and It’ll tell us when the trains arrive and you can probably guess it is the passenger information display systems so there’s a lot of those in the mod right now 1 2 3 4 5 6 78 there’s at least eight different types of Passenger information display systems my personal Favorite I think it’s still this one because it shows three arrivals it’s nice and clean but the problem is it doesn’t work right now see it’s showing nothing because there’s no code for it yet so that’s what we’re going to do today so all these trains and stuff Recently I’ve been putting a lot of work into it but I think it’s time to move on to some of the other mod functionalities such as the passenger information display system this weekend like for the past couple of days I’ve been spending way too much time of trying to get the train Riding movement smooth because sometimes when you’re riding the train is going to Jitter when the train is being rendered it looks like it’s jittering and we don’t want that so I’ve been spending a lot of time trying to get the train movement to look smooth Okay so I’m going to come over here for now just to do development over here because there are fewer Trains being rendered here and so the game will be smoother in terms of FPS okay so we’re back in the code and we’ve got nothing here right now in this render class render Pids this is where our code to render the passenger information display system will go so first of all we have to add some code that allows us to to detect where the nearest platform is so that’s not going to be an easy task okay um let’s take a look at what Types of PS blocks we have because I know there’s a vertical type and the horizontal type so where are my blocks we have uh PS base horizontal and vertical right so horizontal contains the facing block State and the vertical also contains the facing block state but it also has the Half block state so the horizontal piece is composed of two identical blocks but with opposite facing orientations and then the vertical ones has a facing value but two halves kind of like the door in my Minecraft all right so the first thing we have to do is To detect where the platform is when we place it down detect the nearest platform I know existing Behavior allows you to select which platform you want but we don’t need to do that right now right now let’s just get it to work by autod detecting the nearest platform So this is all client side code this render method is going to be run client site so I can access client Data instance platforms because there’s not very many platforms it only shows the nearby platforms to the player I think it’s okay to iterate through this every render tick it wouldn’t consume too much processing power if we Loop through all the platforms because again the client only knows about nearby Platforms in the world and not all the Platforms in the whole world all right I just created a simple stream here where I’m going through all the platforms and finding if our block entity is close to it and with a radius check of five so the issue is this if you have a Curved platform is going to check if it’s anywhere within the shadow of the curve so let me show you what I mean let me open up paint real quick oh wow they really updated paint look at that in Windows 11 okay so if my platform is like this Then the area that’s being checked is going to be this so if my oh if my passenger information display system is here it’s still going to register with this platform whereas if I have a straight platform it’s going to try to detect in this Area so the problem is if I try to put a display right here where this Orange Box is it’s going to detect to be under this curve platform rather than this one like if I’m intending it to register with this one that’s why having the ability to select what platform you want is Quite important instead of relying on this Auto detection another thing we could do is we can just trace this curve and have detection boxes like this all the way along the platform have like better bounding boxes to detect but that also takes more computing power and more coding which I Don’t really want to get into right now so just for Simplicity and getting this video out I’m just going to take the big box okay it’s going to work for our one single platform in the world anyway because that’s that platforms relatively straight and there’s no other platforms nearby all right So that now that we have our platform here this if present means that if there’s a platform close to it then give us the platform in the Lambda and then we can use it however we want so the next part is to get the endpoint to work we can’t just request arrivals like We’ve done before because the data is no longer stored on the Minecraft server so we have to send a request to the actual to the actual server so to the actual simulation that’s running in the back right now our packet to handle data only supports this wait let’s see I changed this code A little bit recently yeah it only supports this data endpoint with the integration seret operation which is hardcoded to just be update get delete generate clear and list and we currently don’t have a method to return arrivals so maybe I feel like maybe it’ll make sense To add another one in here like generate clear but we add another one to fetch arrivals so this is my Transportation simulation core project let’s see where our operation is yeah so here if we add added another one arrivals like that and then add another case in the switch Statement and then just basically copy what we have yeah we’re not going to have any rail node modif ification so we don’t need a position call back and we also won’t be caring about any signal Changes okay so this this code is TBD we only want to check for platforms okay so what else do we need here do we need a switch state I don’t think so yeah for the clear method that’s all we have so I think the code will just jump down to here automatically Okay so if existing data is instant of a platform then we would want to pull arrivals from there so I forgot if the H I forgot if I can just fetch arrivals directly from the platform I guess maybe not I need to find where I wrote the Code for the one bus away stuff remember one bus away is the app that can be integrated with the back end here if you didn’t see that video go check out the first video of the series and I demonstrate the functionality of using the one bus away app with the Mod okay so the thing I want is this one get Oba arrivals and departure elements with trips used so somehow I have to access the siding in which I can pass in the platform and yeah so so the format that I return will probably be in the form of the one bus Away end point that’s why I feel like this might not fit in this integration serlet because the way everything returns in this integration serlet is of a specifically defined type and eventually I’ll probably want to convert all of these payloads and stuff into Json objects kind of serialized like these Json files On the left here it’s much more clean than just relying on accessing string values like Json object add or like Json object get like look at this I’m hardcoding all these strings into here but if all the Json can be loaded and parsed through a predefined schema That’s going to make the code much cleaner and less prone to mistakes but for now okay let’s try to access the sidings so somehow we have to get the roots that are serving this platform and then from The Roots we can probably grab the siding from There so then for the sidings we have to get the arrival and departure elements which will give us the payload right how is this being used like that okay yeah so platform we access the roots and then Roots we access the depot which okay so I can basically copy this actually And then our results will end up in this arrivals and departures array all right let’s just give it a try we can always change the code later yeah okay so we have our platform here I don’t really care about the current Millies Yeah eventually I’ll probably not want to return a one bus away format and then the milliseconds before I would probably do zero cuz I don’t want to show any arrivals that already departed and then Millies after let’s say we want to grab arrivals up to 10 minutes after so 10 * mli Per sure let’s just do 1 hour why not so that’s the number of milliseconds of arrivals that we want to see and then trips used array I I don’t really need that well H maybe it’ll be useful I don’t know you know I’m also wondering why I’m Doing this putting it in the integration serlet actually thinking about it I don’t think that’s the best idea so let me undo all that yeah I don’t want to do it in the integration serlet because we’re already have it in this Oba thing so if I come back To my packets I might as well just create a new packet that just lets me request the data request the arrival data directly I feel like that’ll be the cleaner solution so I’m going to call this fetch arrivals and I forgot how to write a packet Class okay let me split this so that I can see it side by side and we extend packet Handler and we need private long platform ID that’s what we’re going to be sending back and forth and then once’s coming back would be a Json object so we need a Constructor packet fetch arrival A Constructor with a packet buffer in it and then this will read our platform ID like that and then another Constructor of just creating this object in the first place okay now we need the right and run server overloads H I wonder why this is deprecated but it’s something to do with my mappings that’s marking this as deprecated I think because 1.20 now returns packet buffer as this part of This method call so we can ignore the deprecated right now but overall when you’re using the mappings don’t ignore the deprecated all right why are these yellow as well hm do we not have The annotation not n by default oh I guess we don’t have this packet package info thing okay this is Basically some information for the code to say use this annotation for all the classes in this package for the packet so now we have to treat all variables treat all parameters as non-null annotation basically applied to each of these files so I don’t have to type it To annotate it in each of these classes that’s what that does okay so now on the server I would want to send I made a static method in the packet data send HTTP request and that is going to be in the format of let’s see cuz it’s a bit different from the Rest of the stuff let’s take a look at my no not the socket Handler my main where I register everything it would be slash Oba API yeah so this is already hardcoded to MTR API so this needs to move here this is my overload for sending this and then make sure that this One so I added a method to set time so this needs to be prefix with MTR API since I’m I’m moving it out of this method okay yeah MTR API misk so instead of that that’ll be op Oba API wear okay MTR API data right okay so this will be Oba API where that’s just the format of the one bu away method calls so I’m just following this and then get arrivals and departures from for stop that’s one I’m using and then I think how does it get the platform ID data what is data here data is okay set Here you know let’s pull up the documentation because that’s what I’ve been following so this is the official one bu away document ation which works for this case because I coded it in accordance with this so it looks like we have just SL platform ID and then we’ll Be getting the Json so we won’t do XML but I think it works just without as well so we’re do slash plus platform ID just like that I think that would work and if it doesn’t then yeah we’ll figure it out so I don’t have anything to send to the Endpoint right so I’ll just do that cuz I don’t think I can pass in null to here that’s going to error out cuz by default we’re sending post requests okay so this is the response that’s going to come back to us so I don’t need this anymore more I’ll put this back here and then the packet data when we send something we have a consumer which gets run let’s see so the consumer that yeah we’re going to broadcast this to the player that requested it all right Should I do iterate players do I want all the players to have this information that’s a question or maybe I should only send it to the player that is that requested it so if I want to do that that would just be server player entity uh registry send packet to client server player Entity new packet fetch arrivals data that’s it I think although oh oh I see when we’re sending it back we’re going to need to send it as Json okay let’s just add it here doesn’t matter and then we can have two different Constructors we can send the platform ID back that’s no big Deal so when the response comes back from the server we’ll just set the we’ll just set the platform ID again and here we want packet buffer right string Json object to string just like that and there we go so up here when we’re parsing stuff we would want to try to parse the Json object is there a parse here I’m pretty sure I wrote a method to tryparse a Json somewhere here is it this read string oh wait no not that parse Json this should probably be public right cuz this is basically use it everywhere how many instances do I have of this parse String yeah well this is caught in a try Okay anyway let’s just make this public at least so I like to order my methods with like public and then protect it in private it’s optional of course but it just looks neater I think so just read String do I need to specify the max length here I don’t know oh it’s a static method that I added all right so that should do it so so this is my packet for sending stuff now so next we have to register the packet and I just do it in alphabetical Order packet fetch arrivals let’s see where else is this being called just in knit right just a knit too Reg it I think so so now we can use the packet to send stuff okay so the next step H I think we’re going to need some caching because we can’t possibly be Requesting data all the time and sending requests to the server so instead we need some sort of cool down so I’m thinking in packet no client data that would be a good place to do it I think so if we add um oh I just noticed that there’s no public static final Fields okay doesn’t matter okay public we’ll create a map that’s going to store our cached request so this will be long to object probably AVL tree map is fine and then string so oh no Json object and then this will Be oh we probably need an expiry date as well so object to Long object long immutable pair so what I’m doing here is is caching the request and setting an expiry time to it as well so let me show you after I add this bit of code in all right So when I request an arrival I’m going to call this method with the platform ID I’m going to see if there’s any cach arrival request so when I get that I’m going to get the arrival data if there’s nothing in the cache which when arrival data is null or if The long value is less than the current Millies minus the cash request Millies which I set at 3 seconds so every 3 seconds it’s going to invalidate the cach and grab the data again so if that’s the case then we’re going to try to fetch more arrivals And return a Json object while we’re waiting otherwise we’ll fetch the actual data actually I think a better no never mind I’ll just stick with this I was just going to say because as we fetch more data in the world the map will just grow longer and Longer so we need a way to clear the previous entries out maybe when we do a sync maybe when we do a Sync here we can do a Ral request clear that would clear it periodically and flush the the cach okay so you notice right now the code That when the data comes back from the simulator it’s not going to update this map so we need to add that functionality here one run client CU right Yeah so run client cued will be when the packet comes back from the server good thing we passed the platform ID back we’re going to need that okay so client data we need a way to write to that oh where’s my client data class so I might well I might as well Just write a method here to write to the cache all right pretty simple method here write arrival requests we have the platform ID Json object we’ll just put the platform ID with the actual Json object with the expiry date which is going to be 3 seconds after the current time actually Here we don’t even need to do this minus anymore so as long as the right value is less than the current time then we can fetch it again okay so in our packet we’re going to write arrival request platform ID and Json object there we go pretty simple Now in the render pids that’s where we’re going to fetch everything client data um instant wait this arrival request I I was not intending to make this Public that’s why I had all those methods okay so if I do that then we’re going to get a list of arrivals so let me store that as a Json Object okay H that should be good and I do want to print it out but it’s going to spam the console yeah maybe we’ll just cut straight to the rendering code now I’m going to look back at my old project and see the how I how I actually render all the text Because there’s going to be a lot of translation rotation all that okay let me show you what I have here so I copied a bunch of code existing from the current versions of the Minecraft Transit Railway mod including all these final fields of the class which get set from this Constructor here these are just like parameters like the positioning and the width and stuff like that the text color so the important part is down here so remember here if present we have the platform and we’re going to grab the response and the response also includes The current time let me show you an example of a response it includes the current time here and includes a data chunk that contains all the all the arrivals and these arrivals contain a predicted arrival time and a scheduled arrival time so if the vehicle is not Tracked in real time it’s going to show up as null in the predicted arrival time rather we will have to use the scheduled arrival time so in the code I will grab this arrivals array and go through each element and then add this arrival class which I just made real Quick which will grab the predicted arrival time and if that is null then we will get the scheduled arrival time instead and store it into this field here maybe I should rename this to just arrival Time like that and I also included a compare so that we can sort the arrivals by arrival time all right and then we also stored the destination and then here we will draw the text on the pids okay let’s see how that looks I don’t I have no idea of this Code is going to work we’ll just have to see there’s no formatting of any sort there’s no columns is just getting the Rival data from the server and showing it in the world it might be off offc centered who knows let’s see all right the moment of truth and Nothing all right so that’s okay because yeah probably whoa what is with this lag let’s take a look oh that’s not good okay nothing is rendering not because not necessarily because it’s shifted wrong or anything but it looks like we have some issues with the code So yeah maybe this response is empty or something oh yeah we have to check for that y so response we already have a try statement maybe I don’t don’t make a print the error so then it won’t lag it up like that okay now the thing we have to investigate is Why Json object is null right here yeah so for some reason this Json Object yeah there’s no way why this is null because this always just gets set unless it’s set here and the data coming back is null that’s weird I am sending the right requests right Oba API where arrivals and departures for stop SL platform ID do I need oh H do I need Json is that it let’s just try that and then if not if that doesn’t work I’m going to open up Postman to try again all right let’s see here still Nothing and there’s still a lot of lag oh yeah we’re still getting issues here oh wait I was supposed to check it with Postman before I quit the game so why is this Json object null so the data coming back is null that’s the only reason I can see why that’s the case Oh parsing is null oh this just automatically grabs the data oh wait there is a data though huh okay I I shouldn’t have quit the game so early I should have maybe put a breakpoint there or something also it’s going to be time for church soon so maybe I’ll continue the video Another time but my wife is not feeling well today because she got the flu shot and the co shot yesterday both at the same time I don’t know why the doctors thought that would be a good idea but don’t know how she’s feeling in terms of going out today So maybe she’ll just stay at home to rest all right so in the game let’s put a breako right here so that’s our platform and the result not found interesting okay okay no wonder when we get the data it comes back as null why is it null though okay So there’s actually a method to wait where’s the documentation there’s actually a method to to wait where what rest API there we go so there’s actually a method to get stops for location so maybe there I can see my stop IDs my platform IDs and how those will Look so let me open up Postman Postman is an application that I probably showed in the past and it can basically create some dummy request so we need to do sloba SL apiw stops for Location what does that give Us okay oh we need to specify what what do we need to specify lat and long oh not commas we need to do and this is like actual URL formatting okay so I guess my platform IDs are in HEX format no wonder it didn’t work okay so let’s pause Here my platform ID was this let me copy that first so this didn’t work let me try removing the Json that’s confusing okay now I need to go to my calculator and convert that to hex so in Windows if you didn’t know this in this calculator you can go to Programmer and then basically put in your number and then it can generate the hex value for you oh I think did I mess it up okay so I’m going to resume the program and then send this there we go there is our arrivals yeah so we just had to convert That to a hex value all right all right let me quit Minecraft so that it doesn’t keep spamming the console and then in the render when we fetch the arrivals here where are we fetching the arrivals request arrivals instead of platform idid I guess we’ll do it in the packet So when we’re sending this we actually don’t need the Json and then I wonder if I have a utility to do that number to padded hex string okay I think I I can just do that and how much is this padding 16 yeah how am I padding These just have to make sure I guess I’m just directly plugging it into this method so it should be okay okay let’s try it and see if that gives us something oh actually let me stop this first I just realize that if the response comes back Uh where’s my packet data yeah if the response comes back already with the data pulled out then it’s not going to have the Millies showing like remember our response I was trying to get the current time here so if the result already parses it within this data section it’s only going to return Me entry arrivals and departures and so on it’s not going to show me the current time so I have to unwrap this in this method here and then pull this out to here this Consumer so if I put the get data down here then I wouldn’t have to do it up here yeah like that so this is basically a shortcut method to calling this which is just for API data request and with the predefined operation en num so if we’re calling those kind of Requests we can just directly grab the data piece from the response whereas for any other response for example fetching arrivals yeah we would only want the results directly I don’t know if I’m making any sense yeah one other place that we’re using that method directly is to set Time so recently I added some code where the game can constantly be setting time to the back end which is important because if you change the time in Minecraft you want that to be reflected in the simulator as well you don’t want the time to be out of sync or else your Departures will be a bit messed up so every 25 seconds I feel like that’s a good interval the game sends a time like the current ingame time to the server all right so we’re firing up Minecraft and I’m hoping that the text renders this time if not I’m going to Set break points again to try to take a look at what’s going on come on please work still nothing and still a lot of lag what’s going on now string too big okay I see I see that will definitely be an issue so I think what we can Do wow look how many characters over we are okay we can handle this on the packet side because I think the issue is coming from when we send this data from the server to the client right I think that’s what it is so we need to trim this down a little Bit maybe I can even do the processing here yeah I think that’s what I’ll do I might have to reshape the Json as well H let me think okay let me show you what I did here so before we run we before we send the packet to the Client I’m converting this data piece into like a simplified Json so we grab the current Millies save that actually maybe we can inline this as Well so I create a new list for the arrivals and then for each entry we are processing it using this arrival object that I created and then sorting it and then I guess this I can put down here creating a new object creating a new array and then I am putting in at Most 10 elements inside there so at most 10 arrivals and then adding it to the new array and then returning it in this new object and then on the client here we are doing the same thing requesting the arrivals getting the current Millies getting the data this Time is just data we don’t have to drill into the Oba format like data entry arrivals and departures I just put it all under data so each element we’re adding it to this new arrivals list as well and then here we’re also limiting that again to the max arrivals shown on the PID PS okay so for each arrival we’re grabbing it and then showing the destination and then the arrival time okay pretty simple I think the only issue that I can foresee is huh that it’s not going to be a live update within the 3 seconds because the current Millies won’t Change and if we do this math current Millies minus the arrival time it’s just going to stay stuck at one number but let’s see let’s just see if if this works in the first place and then we can change the code to improve on it please work let’s see still Nothing why are there so many problems here let’s see again is it all stop stop scrolling cannot get as long Okay so data get current mes is null so let’s see what the data looks like oh it says current time not current Millies ah silly mistakes like that will mess up the Code let’s just change it to current time just to be consistent and then where is my render pids let’s go oh my wife says it’s time to go but let me check this one little thing current time yep okay good okay we’re in the world oh I thought The it is just a breako I thought it didn’t work oh it still doesn’t work let’s see oh there’s no errors though okay I’ll check this in a second I’ll be back all right I just came back from dropping off my wife at church the church service that she’s Going to is related to an internship that she wants to do so I’m not going to that one the church service that we’re going to later together will be at 2:00 p.m. so not right now I just had to make a small change to my arrivals Class where is that it just jumped to another file just now so yeah when I create a new arrival there’s two types of parsing that I want to do so this one generates a reduced Json which is how we convert the one bus away payload to the reduced Json and I Added another one from reduced which will directly just grab the arrival times and destinations so like that we can kind of specify what kind of parsing of the Json we want that’s why it wasn’t working because on the render side when we did this it was parsing assuming that it was An Oba instead of assuming that it was a reduced Json okay so I also have to fix it here like that so incoming stuff from the endpoint will be in one bus away format whereas incoming stuff from the Minecraft server will be already converted to the reduce Format that’s why each of these when converting the Json into the arrival class each of these has to be parsed differently that’s why I made two separate static methods to parse parse them separately I can’t make two separate Constructors because they both have the same signature so I have to use Static methods to create two two different methods that call the common Constructor which is private so hopefully this works all right still nothing on here oh it’s here spoke too soon I think is this counting down at all it’s flashing though I don’t know why it’s flashing oh it’s because for that one Split Second when it returns a new Json object yeah so where’s client data so in this Split Second when we’re trying to fetch the data it returns new Json new Json object but we can also do if this is null first return new Json object otherwise we also want to Return the normal cach so that while the data is being fetched it can return the cash so I’m glad that this is showing up here and we have to fix the time wait I’m wondering are these actually returning it in seconds or milliseconds that’s why there’s such a Big negative value but anyway let’s fix the let’s fix the rendering offset first I feel like that’s the first thing we should fix so the issue with scheduling the render is that the offset is weird and it’s not rendering with respect to where the block Is okay so I think I know what to do first right I okay so we need to translate it oh we already have a translate statement so so offset get X yeah we need to offset the actually no we need to get the position x minus the offset X and Then same thing for the Y and Z Coordinates so let’s see if this works oh I also realized that this is backwards so let me let me stop this build first so the arrival time theoretically should be higher than the current time because it’s sometime in the future so and then I also want to divide this by 1,000 because this is in milliseconds this is in milliseconds and we want to show it in seconds so then I would divide it by 1,00 to get seconds or I guess if I’m feeling fancy I could do Millies where is it so wait if I Implement utility then I can Get the static constants that I have there so like mli per second it’s a predefined number while that’s building I also had another idea so if we did and if we put an offset in here like hey let me test it first yeah I was saying if I put a put an offset Here then we can store that offset like Millie’s offset will be an offset that when we fetch something from the Server then we will know the offset okay there we go it’s rendering at the correct location now what is this 1249 I don’t understand and it’s still flashing so something’s wrong there this should be returning is there anything in the console nope H I have no idea why it’s flashing still And yeah the reason why it’s showing both Test 2 and test one is because is showing the terminating arrivals as well as well as the destination of this one so 1 12 49 seconds that’s not right and it’s not even counting down all right let’s fix those things First H so earlier my idea was we have a Millie’s offset field so every time we get data from the server we will write to this offset based on the time that we see versus the time getting like that we get from the server because one of the issues we have with The existing version of The Mod is that if the server and the client computer times are out of sync then weird things are going to happen with the passenger information displays so if we take the responses maybe we can do it here as well like if we take the response here like The current time and then calculate the offset yeah let’s just do it in here why not not so private we should make a static so that the value doesn’t change if we create new packet objects private static long Millies offset so by default it’s going to be Zero but here we’re going to do Final Long current Millies Equals we don’t even need to add this property here in this case we just need to store the offset that’s it so offset M offset I’ll just do it here directly Millie offset equals this one minus system current time Millies so maybe I put this up at the top so then when we get our object this is private right and then we do from Oba all the arrival times can be offset by Millie’s offset but in this case this will probably be a very low number anyway Because I’m running this as on the local server on here anyway so the system time is the same so let me check my math just one more time so if we minus that that would mean I don’t know I always confuse myself with this kind of math Like this is the milliseconds so if the server is 10 10 seconds faster then 10 milliseconds faster then this will be 10 and then the time minus okay I think I think that’s right I don’t know so let’s just do that and then instead of minus the current Millies Because this field won’t exist anymore we’ll do system current time mil so now it will countown in real time now okay so the next thing I want to see is why the arrival time doesn’t show up properly so maybe if I launch it I can get a better Idea why is showing like 1,000 something it’s not supposed to be 1,000 something it should be just like up to a minute at most yeah I don’t know what’s going On pretty sure these are in milliseconds all right so you can see it counting down but it jumps back to 49 so it’s 1,200 seconds which is 2 minutes right 2 minutes 46 seconds actually no that’s probably yeah I don’t know and it’s still FL crashing I wonder if this is sorted Backwards as well okay let’s see let’s see so we put a break point here and let’s look at the arrival copy this value current mes this is 1121 so that’s a vehicle 21 minutes away so I also think maybe we’re sorting sorting the values wrong so I should switch this but I’m not sure exactly so I switch this the list will be in backwards order of what it is currently Okay so just to verify I want to put a break point well I guess I can do it here as well so if I put a breakpoint right here I can see my list of arrivals we have 10 that is correct so let’s see if these are sorted in order or not 21213 7 wait 13 7415 yeah so they’re sorted backwards so this needs to be reversed I don’t know why there are so many with the same Tim Stamp I want to check it on my phone to see what that looks like I know you can’t see it because I’m not showing it on camera okay I think I know why because there’s some scheduled arrivals and there’s also some realtime arrivals so maybe we have to filter those out as Well um if there are no let’s see see yeah we want to skip out we want to skip those that don’t have uh predicted arrival time meaning the trains are not shown in real time so just scheduled ones so how do we do that um Let me pause this for a second all right did some refactoring of the code uh make when we’re requesting an arrival I made it right to the cache as well so that you’re not constantly requesting before the first response comes in so meaning like when we see oh the request has Expired while we’re waiting for the response from the server we’re also continuing to check for if the cash is expired so it’s going to stay expired until the new response comes in but while that’s still expired it’s going to keep spamming those requests so here I’m manually writing a Blank arrival request well it’s going to be blank unless there’s something already in the in the cache then I’m going to write it but otherwise we’re just going to write in some dummy data or existing data and that will prevent us from trying to fetch until either the Response comes back or three more seconds has elapsed so here I also refactored this part a little bit so basically if there is an arrival time element if there’s a predicted arrival time add it to the list otherwise just skip it so now this should only show actual tracked Vehicles now So yeah hopefully we can see just the track arrivals and not the scheduled arrivals and hopefully it’ll be accurate whoa that’s a big negative number and they’re all the same value so that’s not right either what’s going on well the train is here so what’s it going to show and it’s flashing still H that’s really weird it’s not supposed to Flash come on maybe for this for now this try statement I want to print out print out the stack Trace just so that I can debug this easier like if there’s some sometimes it doesn’t show that’s so weird like right now the console isn’t Showing any errors so if there’s some parsing errors I want it to show so each arrival why is the arrival time zero okay no wonder it’s weird like that did I do the logic wrong down here so get the the predicted arrival time if it’s not null write it in Okay and when are we using the offsets here oh there’s actually a 38 millisecond offset that we’re applying I’m so confused I know I forgot the offset here but doesn’t matter for now H okay wait oh I know why because we should be checking predicted false rather than predicted arrival time cuz That’s zero it’s not going to be null yeah so probably checking this predicted field is going to be more more reliable so [Applause] predicted Boolean so we want to filter it by that then here we can do that like that so let me stop the game does that look right I think that Looks right all right let’s try it okay that looks a little bit more promising although I don’t know why it’s counting down with the negative is it still showing even if the train is departed okay so we’re also getting an error message here which is good because I do want to debug This so get S Json array is null so sometimes there’s no data chunk being returned yeah that’s what I thought it was oh that train just left I should probably be watching okay so the next one’s coming in I see what’s happening so I think if I filter out the Arrivals using these URL query parameters and force the minutes before to zero and 10 minutes after to basically a whole day actually let me just do 24 * 60 uh yeah 24 24 hours per day times 60 Minutes I don’t have a constant for that hours per day times 60 Minutes per hour so that would be total number of minutes in a day so I’ll just grab those arrivals and then go from there and then here instead of returning just this Json object I want to make sure that there’s a data piece in it so H yeah let’s See so in this part where we’re returning turning that new Json object I’m going to make sure that there’s at least a data field with an empty Json array in here and then here yeah we limited the minutes before and after so hopefully it won’t show the already departed Vehicles It’s okay to show a vehicle before it has left the station though yeah I think that’s acceptable all right so it’s stuck at six oh it’s still flashing oh 12 seconds now let’s watch this train come in to see if that’s accurate yep and it should theoretically stay Below zero yep cuz the departure time hasn’t hit yet so there’s two Fields currently in the payload one is the vehicle like the predicted arrival time and there’s also another field for the predicted departure time so if there’s a dwell time like the train here of 10 seconds So the predicted departure time should be 10 seconds after the arrival time it’s still showing like it’s still flashing though well now it’s not because of the error wow the server’s overloaded that’s wait 11:30 26 that’s pretty recent so that’s not good something is lagging up the Server I don’t understand why this is still flashing though see another can’t keep up I can’t tell why that’s the case I think maybe going minutes after for so long is a bit overboard so maybe just 60 Minutes Or 120 minutes is fine and then maybe if there’s no responses that come Back we can fet a higher value but I think 120 is a more reasonable number to get or even just 60 yeah fetch all the arrivals for the next hour instead of just all of them okay now what I’m still not satisfied because it’s flashing and and that means There’s a problem with the logic H so when we request arrivals we shouldn’t really hit this part after we said it the first time oh it’s because when we syn it we clear it let me try not doing that and see what happens doesn’t matter if we rack up the memory Here yeah maybe that’s why and also I noticed that the arrivals are all the same time we actually only make one small change before I start up Minecraft so if I want let’s just save this value Long arrival seconds would be this so let’s just do arrival seconds math uh do it here math. Max zero so I make sure that this number is not negative at all times and then here maybe we can do like blank does Java let me do that if the question Mark I have a string here and then I have a long value here okay well yeah this logic here is going to be used for more places later so while Minecraft is loading up I guess just for fun let me just show the deviation I feel like that would be pretty interesting to Show because if like in the future I would like to make I know epic puppy has told me this on Discord where it would be great to have modular passenger information display systems where you can configure what types of data you want to show on there so how delayed the Train is is probably something that people would want to show on here so that means we have an extra field here and um yeah let’s just do that and then we’ll add it in here as well to reduce Json deviation this all this can actually be converted into a Json schema and Autogenerated this class could be autogenerated but I’m holding off on doing that just in case I want to change the format of this and the way data is displayed so in the future this will be an autogenerated class which will make it easier to work with and less prone to Mistakes as I mentioned earlier and so we need something here so as I said there’s a predicted field and there’s a scheduled field so I want to do scheduled so the predicted time minus the scheduled time this will be basically delay let’s rename that to Delay yeah so that would be a bit more clear what we’re doing here and meanwhile Minecraft is launching let me load into the world real quick and then here we also need to okay here it should be already be here and then arrival. delay then we can see how many seconds Delay the train is let me make it here Actually uh we don’t want to clamp it to anything so just like that is fine okay the next time we restart Minecraft it should show 2 1 Zer there’s the train no more flashing yep good no more flashing yeah my I’m puzzled as to why this third arrival is also the same time As the rest so I’m curious if we go back to our earlier station where all the lag is because all the trains will all of a sudden render okay so if I put this here okay so this is correct so for some reason it’s not showing this train that’s currently here Because I guess it’s already pass is departure time and then the next train is just right behind it and it’s like delayed as well well it’s moving slowly on the platform because it’s not supposed to do that if it’s keeping on schedule the reason for that is because when a train Starts from speed of zero and it’s moving on the platform it’ll maintain a speed of 20 while if the train is just coming in normally it’ll keep the speed of the previous rail that’s why it’s coming in so slowly and messing up the time yeah this is so confusing Like it’s not showing the right times this one should be showing the right times at least 7 6 5 4 3 2 one and good enough yeah okay let’s try it with the delay value because I’m kind of excited to see what that would look like in theory all these trains should be Delayed because they’re stuck like that and then after that we can try clearing the trains from the siding and see if the delay still shows all right take a look at this I put so this is the station name d for delay and a for arriving so oh why isn’t the train showing Up ah sometimes it’s like this I don’t know why okay so the arrival is zero right now the delay on this train is 391 seconds so that’s not good so after this train leaves the next one is 385 seconds delayed 376 seconds delayed 379 seconds delayed and it’s Predicted in 6 seconds which is not true because that train is just about to leave I guess it’s jammed by that train okay now it’s 391 394 even more delayed than that other one oh 404 now that’s the delay okay I’m going to go over to that other Station as well and show you what that looks like but before I do that I would just like to thank all the patreons and server supporters that have been supporting me so far I know City skylines 2 just dropped and I’m really excited to play it but the problem is It’s quite expensive right now and I don’t I didn’t buy the game I’m probably going to wait for a sale I do have the original City skylines although I don’t have City skylines too so if you feel compelled to support me you can feel free to buy me steam Gift cards I guess or yeah just support the patreon you’ll be supporting the channel the mod okay so this train 391 delay again oh I guess this is showing the train behind it not this train which is weird it’s supposed to show the train right here the arrivals are still like really Low because the trains are stuck behind each other and then you can see the delays gradually increasing because the trains that are waiting back here are not are supposed to be here already theoretically okay now I’m going to try clearing all the trains so if I refresh that’s basically clearing It so there’s no predicted arrivals right now so if I did enable these to show the scheduled arrivals as well then that will show it okay you notice that the next scheduled arrival is actually the same train as this one but it’s offset by 1,200 seconds which is 20 minutes right Wait yeah 20 minutes so 20 minutes is what one day in Minecraft is so every 20 minutes the schedule loops around itself oh wa Why did the the train just snap into place there that weird this train is 9 seconds early okay so there’s no delay theoretically for this train Yep and then that train that’s just left is going to loop back in 170 seconds which is 20 minutes but since the world time is constantly getting set right now the daylight cycle is false so it’s going to keep resetting so you can just ignore this this time Right now because the schedule is going to constantly be updating regenerating because because the daylight cycle is false so the way the the backend simulation sets the schedule is a bit different from before so it’s going to compile all your frequencies set on the dashboard and It’s going to compile that all into real time like real time stamps okay so this train is starting to be delayed because they’re getting stuck behind each other now so this train is supposed to be here already let’s take a look at the other side this trains with a delay of 34 is Supposed to be arriving in about 20 seconds now let’s see if it does arrive on time or not 17 16 15 14 13 12 is it coming yet there it is 4 3 2 one all right and this next train with a delay of 66 seconds will arrive in 40 seconds all Right I’m not going to wait for that train necessarily but you get the idea so thank you so much for watching this is probably just going to be part one of the passenger information display system update there’s still a lot of exciting things that I can add to this but I’m Also keeping in mind the release timeline like I don’t want to be adding too many features that make the 4.0 release slower as well so I’m just going to release the required stuff like at least showing a basic countdown here and then additional functionality for the passenger information display systems can come Later in newer updates for the 4 point after the first 4.0 has come out so this is really exciting we can show the delay as well as other information on here as well if you enjoyed this video please make sure to like And subscribe to the channel it Really helps me out a lot and please consider supporting me on patreon as well this has really taken me a long time for example the past two days I was working non-stop on just riding the vehicle and rendering the train so it doesn’t shake when you’re riding it Thank you so much for watching there’s also going to be a part two of the from the previous video where I was talking about the train movement inside the train like all the bounds and stuff like these boxes right here I’m probably going to show a demo of Like a double decker bus so that you can see what it looks like if you have stairs inside your vehicle and you need to climb up to the upper deck how that’s going to look all right lots of exciting changes coming up make sure you’re subscribed and stay tuned for more all right Bye Video Information
This video, titled ‘4.0.0 Customizable Passenger Information Display Systems (Part 1) – Minecraft Transit Railway’, was uploaded by Jonathan Ho on 2023-11-06 07:00:08. It has garnered 2011 views and 84 likes. The duration of the video is 01:35:51 or 5751 seconds.
More data can now be displayed on Passenger Information Display Systems (PIDS)! 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 3:34 Watch Me Add the PIDS 1:19:18 Showing Arrivals 1:28:41 Final Result at the First Station – Showing Arrivals and Vehicle Delay! 1:29:54 Final Result at the Second Station – Showing Arrivals and Vehicle Delay!
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