diff --git a/src/main/java/net/ugi/sculk_depths/portal/GenerateStructureAPI.java b/src/main/java/net/ugi/sculk_depths/portal/GenerateStructureAPI.java index 7348a56e..fec2a3ad 100644 --- a/src/main/java/net/ugi/sculk_depths/portal/GenerateStructureAPI.java +++ b/src/main/java/net/ugi/sculk_depths/portal/GenerateStructureAPI.java @@ -40,33 +40,10 @@ public static boolean generateStructure(World originalWorld, RegistryKey GenerateStructureAPI.generateStructure(originalWorld, ModDimensions.SCULK_DEPTHS_LEVEL_KEY, structure_, pos); });*/ } - public static boolean generateStructure(World originalWorld, RegistryKey targetWorldKey, RegistryKey structure, BlockPos pos){ - if(originalWorld.isClient)return false; - Optional> structureReference = originalWorld.getRegistryManager().get(RegistryKeys.STRUCTURE).getEntry(structure); - if(structureReference.isEmpty()) return false; - ServerWorld serverWorld = originalWorld.getServer().getWorld(targetWorldKey); - StructureStart structureStart = structureStart(originalWorld, targetWorldKey, structure, pos); - if(structureStart == null)return false; - BlockBox blockBox = structureStart.getBoundingBox(); - ChunkPos chunkPos = new ChunkPos(ChunkSectionPos.getSectionCoord(blockBox.getMinX()), ChunkSectionPos.getSectionCoord(blockBox.getMinZ())); - ChunkPos chunkPos2 = new ChunkPos(ChunkSectionPos.getSectionCoord(blockBox.getMaxX()), ChunkSectionPos.getSectionCoord(blockBox.getMaxZ())); - ChunkPos[] chunkPosArray = ChunkPos.stream(chunkPos, chunkPos2).toArray(ChunkPos[]::new); - return generate(serverWorld, structureStart, chunkPosArray); + return generateStructure(originalWorld, targetWorldKey, structure.getValue(), pos); } - public static boolean generateStructure(World originalWorld, RegistryKey targetWorldKey, RegistryKey structure, StructureStart structureStart){ - if(originalWorld.isClient)return false; - if(structureStart == null)return false; - Optional> structureReference = originalWorld.getRegistryManager().get(RegistryKeys.STRUCTURE).getEntry(structure); - if(structureReference.isEmpty()) return false; - ServerWorld serverWorld = originalWorld.getServer().getWorld(targetWorldKey); - BlockBox blockBox = structureStart.getBoundingBox(); - ChunkPos chunkPos = new ChunkPos(ChunkSectionPos.getSectionCoord(blockBox.getMinX()), ChunkSectionPos.getSectionCoord(blockBox.getMinZ())); - ChunkPos chunkPos2 = new ChunkPos(ChunkSectionPos.getSectionCoord(blockBox.getMaxX()), ChunkSectionPos.getSectionCoord(blockBox.getMaxZ())); - ChunkPos[] chunkPosArray = ChunkPos.stream(chunkPos, chunkPos2).toArray(ChunkPos[]::new); - return generate(serverWorld, structureStart, chunkPosArray); - } public static boolean generateStructure(World originalWorld, RegistryKey targetWorldKey, Identifier structure, StructureStart structureStart){ if(originalWorld.isClient)return false; @@ -80,47 +57,22 @@ public static boolean generateStructure(World originalWorld, RegistryKey ChunkPos[] chunkPosArray = ChunkPos.stream(chunkPos, chunkPos2).toArray(ChunkPos[]::new); return generate(serverWorld, structureStart, chunkPosArray); } - - public static boolean generateStructurePartial(World originalWorld, RegistryKey targetWorldKey, RegistryKey structure, StructureStart structureStart, ChunkPos[] chunkPosArray){ - if(originalWorld.isClient)return false; - if(structureStart == null)return false; - Optional> structureReference = originalWorld.getRegistryManager().get(RegistryKeys.STRUCTURE).getEntry(structure); - if(structureReference.isEmpty()) return false; - ServerWorld serverWorld = originalWorld.getServer().getWorld(targetWorldKey); - return generate(serverWorld, structureStart, chunkPosArray); + public static boolean generateStructure(World originalWorld, RegistryKey targetWorldKey, RegistryKey structure, StructureStart structureStart){ + return generateStructure(originalWorld, targetWorldKey, structure.getValue(), structureStart); } + + public static boolean generateStructurePartial(World originalWorld, RegistryKey targetWorldKey, Identifier structure, StructureStart structureStart, ChunkPos[] chunkPosArray){ if(originalWorld.isClient)return false; if(structureStart == null)return false; Optional> structureReference = originalWorld.getRegistryManager().get(RegistryKeys.STRUCTURE).getEntry(structure); if(structureReference.isEmpty()) return false; ServerWorld serverWorld = originalWorld.getServer().getWorld(targetWorldKey); - ChunkGenerator chunkGenerator = serverWorld.getChunkManager().getChunkGenerator(); return generate( serverWorld, structureStart, chunkPosArray); } - - - public static StructureStart structureStart (World originalWorld, RegistryKey targetWorldKey, RegistryKey structureKey, BlockPos pos){ - if(originalWorld.isClient)return null; - RegistryEntry.Reference structure = originalWorld.getRegistryManager().get(RegistryKeys.STRUCTURE).getEntry(structureKey).get(); - System.out.println("1"); - ServerWorld serverWorld = originalWorld.getServer().getWorld(targetWorldKey); - ChunkGenerator chunkGenerator = serverWorld.getChunkManager().getChunkGenerator(); - Structure structure2 = structure.value(); - StructureStart structureStart = structure2.createStructureStart( - originalWorld.getRegistryManager(), - chunkGenerator, - chunkGenerator.getBiomeSource(), - serverWorld.getChunkManager().getNoiseConfig(), - serverWorld.getStructureTemplateManager(), - originalWorld.getServer().getWorld(World.OVERWORLD).getSeed(),//maybe fix rotation - new ChunkPos(pos), - 0, - serverWorld, - biome -> true - ); - return structureStart; + public static boolean generateStructurePartial(World originalWorld, RegistryKey targetWorldKey, RegistryKey structure, StructureStart structureStart, ChunkPos[] chunkPosArray){ + return generateStructurePartial(originalWorld, targetWorldKey, structure.getValue(), structureStart, chunkPosArray); } public static StructureStart structureStart (World originalWorld, RegistryKey targetWorldKey, Identifier structureKey, BlockPos pos){ @@ -144,6 +96,9 @@ public static StructureStart structureStart (World originalWorld, RegistryKey targetWorldKey, RegistryKey structureKey, BlockPos pos){ + return structureStart (originalWorld,targetWorldKey,structureKey.getValue(),pos);; + } private static boolean generate(ServerWorld serverWorld, StructureStart structureStart, ChunkPos[] chunkPosArray){ ChunkGenerator chunkGenerator = serverWorld.getChunkManager().getChunkGenerator(); @@ -157,7 +112,7 @@ private static boolean generate(ServerWorld serverWorld, StructureStart structur return false; }*/ for (ChunkPos chunkPosx : chunkPosArray) { - structureStart.place( + structureStart.place( serverWorld, serverWorld.getStructureAccessor(), chunkGenerator, @@ -188,4 +143,4 @@ private static void unloadNearbyChunks(ChunkPos[] chunkPosArray, ServerWorld wor world.setChunkForced(chunkPos.x, chunkPos.z, true); } } -} +} \ No newline at end of file