1
1
package pro .mikey .kubeutils .kubejs .modules ;
2
2
3
- import dev .latvian .mods .kubejs .level .ServerLevelJS ;
4
3
import net .minecraft .core .BlockPos ;
5
4
import net .minecraft .core .Registry ;
6
5
import net .minecraft .core .Vec3i ;
11
10
import net .minecraft .world .entity .LivingEntity ;
12
11
import net .minecraft .world .level .block .Block ;
13
12
import net .minecraft .world .level .block .state .BlockState ;
14
- import net .minecraft .world .level .levelgen .feature .ConfiguredStructureFeature ;
15
13
import net .minecraft .world .level .levelgen .structure .BoundingBox ;
14
+ import net .minecraft .world .level .levelgen .structure .Structure ;
16
15
import net .minecraft .world .level .levelgen .structure .templatesystem .StructurePlaceSettings ;
17
16
import net .minecraft .world .level .levelgen .structure .templatesystem .StructureTemplate ;
18
17
import net .minecraft .world .phys .AABB ;
18
+ import net .minecraftforge .registries .ForgeRegistries ;
19
19
import pro .mikey .kubeutils .KubeUtils ;
20
20
21
21
import javax .annotation .Nullable ;
@@ -26,8 +26,8 @@ public class LevelUtils {
26
26
private static final ResourceLocation UNKNOWN = new ResourceLocation (KubeUtils .getId (), "unknown" );
27
27
private final ServerLevel level ;
28
28
29
- public LevelUtils (ServerLevelJS level ) {
30
- this .level = level .getMinecraftLevel ();
29
+ public LevelUtils (ServerLevel level ) {
30
+ this .level = level .getLevel ();
31
31
}
32
32
33
33
/**
@@ -62,7 +62,7 @@ public List<LivingEntity> findEntitiesWithinRadius(ResourceLocation entityId, Bl
62
62
continue ;
63
63
}
64
64
65
- ResourceLocation registryName = current .getType (). getRegistryName ( );
65
+ ResourceLocation registryName = ForgeRegistries . ENTITY_TYPES . getKey ( current .getType ());
66
66
if (registryName == null || !registryName .equals (entityId )) {
67
67
continue ;
68
68
}
@@ -178,29 +178,28 @@ public List<BlockPos> seekCollectionOfBlocks(BlockPos startingPos, int range, Pr
178
178
* @return if the structure is there.
179
179
*/
180
180
public boolean isStructureAtLocation (BlockPos pos , ResourceLocation structureId ) {
181
- ConfiguredStructureFeature <?, ?> configuredStructureFeature = level .getServer ().registryAccess ().registryOrThrow (Registry .CONFIGURED_STRUCTURE_FEATURE_REGISTRY ).get (structureId );
182
- if (configuredStructureFeature == null ) {
181
+ Structure structure = level .getServer ().registryAccess ().registryOrThrow (Registry .STRUCTURE_REGISTRY ).get (structureId );
182
+ if (structure == null ) {
183
183
return false ;
184
184
}
185
185
186
- return level .structureFeatureManager ().getStructureAt (pos , configuredStructureFeature ).isValid ();
186
+ return level .structureManager ().getStructureAt (pos , structure ).isValid ();
187
187
}
188
188
189
189
/**
190
190
* Gets all the structures at a given block location
191
191
*
192
- * @param pos the block location you want to check
193
- *
192
+ * @param pos the block location you want to check
194
193
* @return a list (set) of the structures at that location
195
194
*/
196
- public Set <ConfiguredStructureFeature <?, ?> > getStructuresAtLocation (BlockPos pos ) {
197
- return level .structureFeatureManager ().getAllStructuresAt (pos ).keySet ();
195
+ public Set <Structure > getStructuresAtLocation (BlockPos pos ) {
196
+ return level .structureManager ().getAllStructuresAt (pos ).keySet ();
198
197
}
199
198
200
199
/**
201
200
* Gets all the structure ids at a given location, just like {@link #getRandomLocation(BlockPos, int, int)}
202
201
*/
203
202
public List <ResourceLocation > getStructureIdsAtLocation (BlockPos pos ) {
204
- return getStructuresAtLocation (pos ).stream ().map (e -> e . feature . getRegistryName () == null ? UNKNOWN : e . feature . getRegistryName ( )).toList ();
203
+ return getStructuresAtLocation (pos ).stream ().map (e -> Registry . STRUCTURE_TYPES . getKey ( e . type () )).toList ();
205
204
}
206
205
}
0 commit comments