11package wraith .fwaystones .util ;
22
33import com .mojang .datafixers .util .Pair ;
4+ import net .fabricmc .loader .api .FabricLoader ;
45import net .minecraft .entity .player .PlayerEntity ;
56import net .minecraft .entity .player .PlayerInventory ;
67import net .minecraft .item .Item ;
78import net .minecraft .item .ItemStack ;
89import net .minecraft .registry .Registries ;
910import net .minecraft .registry .RegistryKey ;
1011import net .minecraft .registry .RegistryKeys ;
11- import net .minecraft .registry .entry .RegistryEntry ;
1212import net .minecraft .server .MinecraftServer ;
1313import net .minecraft .structure .pool .StructurePool ;
1414import net .minecraft .structure .pool .StructurePoolElement ;
2020import net .minecraft .world .World ;
2121import org .jetbrains .annotations .Nullable ;
2222import wraith .fwaystones .FabricWaystones ;
23+ import wraith .fwaystones .integration .lithostitched .LithostitchedPlugin ;
2324import wraith .fwaystones .item .LocalVoidItem ;
2425import wraith .fwaystones .mixin .StructurePoolAccessor ;
2526import wraith .fwaystones .screen .AbyssScreenHandler ;
@@ -84,11 +85,6 @@ private static String generateUniqueId() {
8485 }
8586
8687 public static void addToStructurePool (MinecraftServer server , Identifier village , Identifier waystone , int weight ) {
87-
88- RegistryEntry <StructureProcessorList > emptyProcessorList = server .getRegistryManager ()
89- .get (RegistryKeys .PROCESSOR_LIST )
90- .entryOf (EMPTY_PROCESSOR_LIST_KEY );
91-
9288 var poolGetter = server .getRegistryManager ()
9389 .get (RegistryKeys .TEMPLATE_POOL )
9490 .getOrEmpty (village );
@@ -99,15 +95,25 @@ public static void addToStructurePool(MinecraftServer server, Identifier village
9995 }
10096 var pool = poolGetter .get ();
10197
102- var pieceList = ((StructurePoolAccessor ) pool ).getElements ();
103- var piece = StructurePoolElement .ofProcessedSingle (waystone .toString (), emptyProcessorList ).apply (StructurePool .Projection .RIGID );
98+ if (FabricLoader .getInstance ().isModLoaded ("lithostitched" )) {
99+ var pieces = LithostitchedPlugin .createPieces (waystone .toString ());
100+ for (StructurePoolElement piece : pieces ) {
101+ addPieceToPool (piece , ((StructurePoolAccessor )pool ), weight );
102+ }
103+ } else {
104+ var piece = StructurePoolElement .ofSingle (waystone .toString ()).apply (StructurePool .Projection .RIGID );
105+ addPieceToPool (piece , ((StructurePoolAccessor )pool ), weight );
106+ }
107+ }
104108
105- var list = new ArrayList <>(((StructurePoolAccessor ) pool ).getElementCounts ());
106- list .add (Pair .of (piece , weight ));
107- ((StructurePoolAccessor ) pool ).setElementCounts (list );
109+ private static void addPieceToPool (StructurePoolElement element , StructurePoolAccessor accessor , int weight ) {
110+ var pieceList = accessor .getElements ();
111+ var list = new ArrayList <>(accessor .getElementCounts ());
112+ list .add (Pair .of (element , weight ));
113+ accessor .setElementCounts (list );
108114
109115 for (int i = 0 ; i < weight ; ++i ) {
110- pieceList .add (piece );
116+ pieceList .add (element );
111117 }
112118 }
113119
0 commit comments