@@ -16,6 +16,12 @@ import { BlockPlace } from "./BlockPlace.js";
1616import { DistanceBasedFog } from "./DistanceBasedFog.js" ;
1717import { EventHandler } from "./EventHandler.js" ;
1818
19+ const dimNamesInt = {
20+ "-1" : "minecraft:nether" ,
21+ 0 : "minecraft:overworld" ,
22+ 1 : "minecraft:end" ,
23+ } ;
24+
1925class Game {
2026 constructor ( ) {
2127 var _this = this ;
@@ -49,6 +55,9 @@ class Game {
4955 "minecraft:overworld" : [ 165 / 255 , 192 / 255 , 254 / 255 ] ,
5056 "minecraft:the_end" : [ 1 / 255 , 20 / 255 , 51 / 255 ] ,
5157 "minecraft:the_nether" : [ 133 / 255 , 40 / 255 , 15 / 255 ] ,
58+
59+ "minecraft:end" : [ 1 / 255 , 20 / 255 , 51 / 255 ] ,
60+ "minecraft:nether" : [ 133 / 255 , 40 / 255 , 15 / 255 ] ,
5261 } ;
5362 this . camera = new THREE . PerspectiveCamera ( this . fov , 2 , 0.1 , 1000 ) ;
5463 this . camera . rotation . order = "YXZ" ;
@@ -101,12 +110,25 @@ class Game {
101110 _this . camera . rotation . y = yaw ;
102111 _this . camera . rotation . x = pitch ;
103112 } ) ;
104- this . socket . on ( "dimension" , function ( dim ) {
113+ this . socket . on ( "dimension" , function ( dim , format ) {
114+ switch ( format ) {
115+ case "int" :
116+ dim = dimNamesInt [ dim ] ;
117+ break ;
118+
119+ case "world" :
120+ // idk what this is yet
121+ break ;
122+ }
123+
105124 _this . dimension = dim ;
106125 console . log ( `Player dimension has been changed: ${ dim } ` ) ;
107126 _this . world . resetWorld ( ) ;
127+
108128 var bg = _this . dimBg [ dim ] ;
109129 if ( bg === undefined ) {
130+ bg = _this . dimBg [ "minecraft:overworld" ] ;
131+
110132 _this . scene . background = new THREE . Color (
111133 ..._this . dimBg [ "minecraft:overworld" ]
112134 ) ;
@@ -138,7 +160,9 @@ class Game {
138160 _this . chat . log ( msg ) ;
139161 } ) ;
140162 this . socket . on ( "kicked" , function ( reason ) {
141- _this . chat . log ( "You have been kicked! Reason: " + JSON . parse ( reason ) . text ) ;
163+ _this . chat . log (
164+ "You have been kicked! Reason: " + JSON . parse ( reason ) . text
165+ ) ;
142166 } ) ;
143167 this . socket . on ( "xp" , function ( xp ) {
144168 _this . inv_bar . setXp ( xp . level , xp . progress ) ;
0 commit comments