19
19
20
20
package com .sk89q .worldedit .sponge ;
21
21
22
- import com .flowpowered .math .vector .Vector3d ;
23
22
import com .sk89q .worldedit .math .BlockVector3 ;
24
23
import com .sk89q .worldedit .math .Vector3 ;
25
24
import com .sk89q .worldedit .util .Location ;
26
25
import com .sk89q .worldedit .world .World ;
27
26
import com .sk89q .worldedit .world .biome .BiomeType ;
28
27
import com .sk89q .worldedit .world .biome .BiomeTypes ;
28
+ import org .spongepowered .api .CatalogKey ;
29
29
import org .spongepowered .api .Sponge ;
30
30
import org .spongepowered .api .entity .living .player .Player ;
31
+ import org .spongepowered .api .world .server .ServerWorld ;
32
+ import org .spongepowered .math .vector .Vector3d ;
33
+ import org .spongepowered .math .vector .Vector3i ;
31
34
32
35
import static com .google .common .base .Preconditions .checkNotNull ;
33
36
@@ -39,28 +42,13 @@ public class SpongeAdapter {
39
42
private SpongeAdapter () {
40
43
}
41
44
42
- /**
43
- * Create a WorldEdit world from a Sponge extent.
44
- *
45
- * @param world the Sponge extent
46
- * @return a WorldEdit world
47
- */
48
- public static World checkWorld (org .spongepowered .api .world .extent .Extent world ) {
49
- checkNotNull (world );
50
- if (world instanceof org .spongepowered .api .world .World ) {
51
- return adapt ((org .spongepowered .api .world .World ) world );
52
- } else {
53
- throw new IllegalArgumentException ("Extent type is not a world" );
54
- }
55
- }
56
-
57
45
/**
58
46
* Create a WorldEdit world from a Sponge world.
59
47
*
60
48
* @param world the Sponge world
61
49
* @return a WorldEdit world
62
50
*/
63
- public static World adapt (org . spongepowered . api . world . World world ) {
51
+ public static World adapt (ServerWorld world ) {
64
52
checkNotNull (world );
65
53
return SpongeWorldEdit .inst ().getWorld (world );
66
54
}
@@ -91,12 +79,12 @@ public static Player adapt(com.sk89q.worldedit.entity.Player player) {
91
79
* @param world the WorldEdit world
92
80
* @return a Sponge world
93
81
*/
94
- public static org . spongepowered . api . world . World adapt (World world ) {
82
+ public static ServerWorld adapt (World world ) {
95
83
checkNotNull (world );
96
84
if (world instanceof SpongeWorld ) {
97
85
return ((SpongeWorld ) world ).getWorld ();
98
86
} else {
99
- org . spongepowered . api . world . World match = Sponge .getServer ().getWorld (world .getName ()).orElse (null );
87
+ ServerWorld match = Sponge .getServer (). getWorldManager ().getWorld (world .getName ()).orElse (null );
100
88
if (match != null ) {
101
89
return match ;
102
90
} else {
@@ -106,11 +94,11 @@ public static org.spongepowered.api.world.World adapt(World world) {
106
94
}
107
95
108
96
public static BiomeType adapt (org .spongepowered .api .world .biome .BiomeType biomeType ) {
109
- return BiomeTypes .get (biomeType .getId ());
97
+ return BiomeTypes .get (biomeType .getKey (). getFormatted ());
110
98
}
111
99
112
100
public static org .spongepowered .api .world .biome .BiomeType adapt (BiomeType biomeType ) {
113
- return Sponge .getRegistry ().getType ( org .spongepowered .api .world .biome .BiomeType .class , biomeType .getId ()).orElse (null );
101
+ return Sponge .getRegistry ().getCatalogRegistry (). get ( org .spongepowered .api .world .biome .BiomeType .class , CatalogKey . resolve ( biomeType .getId () )).orElse (null );
114
102
}
115
103
116
104
/**
@@ -119,11 +107,11 @@ public static org.spongepowered.api.world.biome.BiomeType adapt(BiomeType biomeT
119
107
* @param location the Sponge location
120
108
* @return a WorldEdit location
121
109
*/
122
- public static Location adapt (org .spongepowered .api .world .Location < org . spongepowered . api . world . World > location , Vector3d rotation ) {
110
+ public static Location adapt (org .spongepowered .api .world .Location location , Vector3d rotation ) {
123
111
checkNotNull (location );
124
112
Vector3 position = asVector (location );
125
113
return new Location (
126
- adapt (location .getExtent ()),
114
+ adapt (location .getWorld ()),
127
115
position ,
128
116
(float ) rotation .getX (),
129
117
(float ) rotation .getY ());
@@ -135,10 +123,10 @@ public static Location adapt(org.spongepowered.api.world.Location<org.spongepowe
135
123
* @param location the WorldEdit location
136
124
* @return a Sponge location
137
125
*/
138
- public static org .spongepowered .api .world .Location < org . spongepowered . api . world . World > adapt (Location location ) {
126
+ public static org .spongepowered .api .world .Location adapt (Location location ) {
139
127
checkNotNull (location );
140
128
Vector3 position = location .toVector ();
141
- return new org .spongepowered .api .world .Location <> (
129
+ return org .spongepowered .api .world .Location . of (
142
130
adapt ((World ) location .getExtent ()),
143
131
position .getX (), position .getY (), position .getZ ());
144
132
}
@@ -160,7 +148,7 @@ public static Vector3d adaptRotation(Location location) {
160
148
* @param location The Bukkit location
161
149
* @return a WorldEdit vector
162
150
*/
163
- public static Vector3 asVector (org .spongepowered .api .world .Location < org . spongepowered . api . world . World > location ) {
151
+ public static Vector3 asVector (org .spongepowered .api .world .Location location ) {
164
152
checkNotNull (location );
165
153
return Vector3 .at (location .getX (), location .getY (), location .getZ ());
166
154
}
@@ -171,8 +159,28 @@ public static Vector3 asVector(org.spongepowered.api.world.Location<org.spongepo
171
159
* @param location The Bukkit location
172
160
* @return a WorldEdit vector
173
161
*/
174
- public static BlockVector3 asBlockVector (org .spongepowered .api .world .Location < org . spongepowered . api . world . World > location ) {
162
+ public static BlockVector3 asBlockVector (org .spongepowered .api .world .Location location ) {
175
163
checkNotNull (location );
176
164
return BlockVector3 .at (location .getX (), location .getY (), location .getZ ());
177
165
}
166
+
167
+ /**
168
+ * Create a WorldEdit BlockVector3 from a Sponge Vector3i.
169
+ *
170
+ * @param vec The Sponge Vector3i
171
+ * @return The WorldEdit BlockVector3
172
+ */
173
+ public static BlockVector3 adapt (Vector3i vec ) {
174
+ return BlockVector3 .at (vec .getX (), vec .getY (), vec .getZ ());
175
+ }
176
+
177
+ /**
178
+ * Create a Sponge Vector3i from a WorldEdit BlockVector3.
179
+ *
180
+ * @param vec The WorldEdit BlockVector3
181
+ * @return The Sponge Vector3i
182
+ */
183
+ public static Vector3i adapt (BlockVector3 vec ) {
184
+ return new Vector3i (vec .getX (), vec .getY (), vec .getZ ());
185
+ }
178
186
}
0 commit comments