1
1
package ru .nanit .limbo .world ;
2
2
3
+ import net .kyori .adventure .nbt .BinaryTagIO ;
3
4
import net .kyori .adventure .nbt .CompoundBinaryTag ;
4
5
import net .kyori .adventure .nbt .ListBinaryTag ;
6
+ import ru .nanit .limbo .server .LimboServer ;
5
7
import ru .nanit .limbo .util .Logger ;
6
8
9
+ import java .io .IOException ;
10
+ import java .io .InputStream ;
11
+
7
12
public final class DimensionRegistry {
8
13
9
14
private CompoundBinaryTag defaultDimension ;
@@ -33,8 +38,14 @@ public CompoundBinaryTag getNether() {
33
38
return nether ;
34
39
}
35
40
36
- public void load (String def ){
37
- initDimensions ();
41
+ public void load (LimboServer server , String def ) throws IOException {
42
+ InputStream in = server .getClass ().getResourceAsStream ("/dimension_registry.nbt" );
43
+ codec = BinaryTagIO .readCompressedInputStream (in );
44
+ ListBinaryTag dimensions = codec .getCompound ("minecraft:dimension_type" ).getList ("value" );
45
+
46
+ overWorld = (CompoundBinaryTag ) ((CompoundBinaryTag ) dimensions .get (0 )).get ("element" );
47
+ nether = (CompoundBinaryTag ) ((CompoundBinaryTag ) dimensions .get (2 )).get ("element" );
48
+ theEnd = (CompoundBinaryTag ) ((CompoundBinaryTag ) dimensions .get (3 )).get ("element" );
38
49
39
50
switch (def .toLowerCase ()){
40
51
case "overworld" :
@@ -52,120 +63,4 @@ public void load(String def){
52
63
break ;
53
64
}
54
65
}
55
-
56
- private void initDimensions (){
57
- overWorld = CompoundBinaryTag .builder ()
58
- .putString ("name" , "minecraft:overworld" )
59
- .putByte ("piglin_safe" , (byte ) 0 )
60
- .putByte ("natural" , (byte ) 1 )
61
- .putFloat ("ambient_light" , 0.0F )
62
- .putString ("infiniburn" , "minecraft:infiniburn_overworld" )
63
- .putByte ("respawn_anchor_works" , (byte ) 0 )
64
- .putByte ("has_skylight" , (byte ) 1 )
65
- .putByte ("bed_works" , (byte ) 1 )
66
- .putString ("effects" , "minecraft:overworld" )
67
- .putLong ("fixed_time" , 6000L )
68
- .putByte ("has_raids" , (byte ) 1 )
69
- .putInt ("logical_height" , 256 )
70
- .putDouble ("coordinate_scale" , 1.0 )
71
- .putByte ("ultrawarm" , (byte ) 0 )
72
- .putByte ("has_ceiling" , (byte ) 0 )
73
- .build ();
74
-
75
- nether = CompoundBinaryTag .builder ()
76
- .putString ("name" , "minecraft:the_nether" )
77
- .putByte ("piglin_safe" , (byte ) 1 )
78
- .putByte ("natural" , (byte ) 0 )
79
- .putFloat ("ambient_light" , 0.1F )
80
- .putString ("infiniburn" , "minecraft:infiniburn_nether" )
81
- .putByte ("respawn_anchor_works" , (byte ) 1 )
82
- .putByte ("has_skylight" , (byte ) 0 )
83
- .putByte ("bed_works" , (byte ) 0 )
84
- .putString ("effects" , "minecraft:the_nether" )
85
- .putLong ("fixed_time" , 18000L )
86
- .putByte ("has_raids" , (byte ) 0 )
87
- .putInt ("logical_height" , 128 )
88
- .putDouble ("coordinate_scale" , 1.0 )
89
- .putByte ("ultrawarm" , (byte ) 1 )
90
- .putByte ("has_ceiling" , (byte ) 1 )
91
- .build ();
92
-
93
- theEnd = CompoundBinaryTag .builder ()
94
- .putString ("name" , "minecraft:the_end" )
95
- .putByte ("piglin_safe" , (byte ) 0 )
96
- .putByte ("natural" , (byte ) 0 )
97
- .putFloat ("ambient_light" , 0.0F )
98
- .putString ("infiniburn" , "minecraft:infiniburn_end" )
99
- .putByte ("respawn_anchor_works" , (byte ) 0 )
100
- .putByte ("has_skylight" , (byte ) 0 )
101
- .putByte ("bed_works" , (byte ) 0 )
102
- .putString ("effects" , "minecraft:the_end" )
103
- .putLong ("fixed_time" , 6000L )
104
- .putByte ("has_raids" , (byte ) 1 )
105
- .putInt ("logical_height" , 256 )
106
- .putDouble ("coordinate_scale" , 1.0 )
107
- .putByte ("ultrawarm" , (byte ) 0 )
108
- .putByte ("has_ceiling" , (byte ) 0 )
109
- .build ();
110
-
111
- CompoundBinaryTag overWorldData = CompoundBinaryTag .builder ()
112
- .putString ("name" , "minecraft:overworld" )
113
- .putInt ("id" , 0 )
114
- .put ("element" , overWorld )
115
- .build ();
116
-
117
- CompoundBinaryTag netherData = CompoundBinaryTag .builder ()
118
- .putString ("name" , "minecraft:the_nether" )
119
- .putInt ("id" , 1 )
120
- .put ("element" , nether )
121
- .build ();
122
-
123
- CompoundBinaryTag endData = CompoundBinaryTag .builder ()
124
- .putString ("name" , "minecraft:the_end" )
125
- .putInt ("id" , 2 )
126
- .put ("element" , theEnd )
127
- .build ();
128
-
129
- CompoundBinaryTag plains = CompoundBinaryTag .builder ()
130
- .putString ("name" , "minecraft:plains" )
131
- .putInt ("id" , 1 )
132
- .put ("element" , CompoundBinaryTag .builder ()
133
- .putString ("precipitation" , "rain" )
134
- .putFloat ("depth" , 0.125F )
135
- .putFloat ("temperature" , 0.8F )
136
- .putFloat ("scale" , 0.05F )
137
- .putFloat ("downfall" , 0.4F )
138
- .putString ("category" , "plains" )
139
- .put ("effects" , CompoundBinaryTag .builder ()
140
- .putInt ("sky_color" , 7907327 )
141
- .putInt ("water_fog_color" , 329011 )
142
- .putInt ("fog_color" , 12638463 )
143
- .putInt ("water_color" , 4159204 )
144
- .put ("mood_sound" , CompoundBinaryTag .builder ()
145
- .putInt ("tick_delay" , 6000 )
146
- .putFloat ("offset" , 2.0F )
147
- .putString ("sound" , "minecraft:ambient.cave" )
148
- .putInt ("block_search_extent" , 8 )
149
- .build ())
150
- .build ())
151
- .build ())
152
- .build ();
153
-
154
- codec = CompoundBinaryTag .builder ()
155
- .put ("minecraft:dimension_type" , CompoundBinaryTag .builder ()
156
- .putString ("type" , "minecraft:dimension_type" )
157
- .put ("value" , ListBinaryTag .builder ()
158
- .add (overWorldData )
159
- .add (netherData )
160
- .add (endData )
161
- .build ())
162
- .build ())
163
- .put ("minecraft:worldgen/biome" , CompoundBinaryTag .builder ()
164
- .putString ("type" , "minecraft:worldgen/biome" )
165
- .put ("value" , ListBinaryTag .builder ()
166
- .add (plains )
167
- .build ())
168
- .build ())
169
- .build ();
170
- }
171
66
}
0 commit comments