@@ -85,9 +85,9 @@ public static void register(CommandDispatcher<FabricClientCommandSource> dispatc
8585 .then (argument ("item" , itemAndEnchantments ())
8686 .executes (ctx -> submit (() -> locateLoot (CustomClientCommandSource .of (ctx .getSource ()), getInteger (ctx , "amount" ), getItemAndEnchantments (ctx , "item" )))))))
8787 .then (literal ("slimechunk" )
88- .executes (ctx -> submit (() -> locateSlimeChunk (CustomClientCommandSource .of (ctx .getSource () )))))
88+ .executes (ctx -> locateSlimeChunk (CustomClientCommandSource .of (ctx .getSource ()))))
8989 .then (literal ("spawn" )
90- .executes (ctx -> submit (() -> locateSpawn (CustomClientCommandSource .of (ctx .getSource () )))))
90+ .executes (ctx -> locateSpawn (CustomClientCommandSource .of (ctx .getSource ()))))
9191 .then (literal ("orevein" )
9292 .then (literal ("copper" )
9393 .executes (ctx -> submit (() -> locateOreVein (CustomClientCommandSource .of (ctx .getSource ()), true ))))
@@ -116,7 +116,7 @@ private static int locateBiome(CustomClientCommandSource source, int biome) thro
116116 throw CommandExceptions .NO_BIOME_FOUND_EXCEPTION .create (BIOME_SEARCH_RADIUS );
117117 }
118118
119- source .sendFeedback (Component .translatable ("command.locate.biome.foundAt" , ComponentUtils .formatXZ (pos .x (), pos .z ())));
119+ source .getClient (). schedule (() -> source . sendFeedback (Component .translatable ("command.locate.biome.foundAt" , ComponentUtils .formatXZ (pos .x (), pos .z () ))));
120120 return Command .SINGLE_SUCCESS ;
121121 }
122122 }
@@ -177,41 +177,43 @@ private static int locateStructure(CustomClientCommandSource source, StructureAn
177177 throw CommandExceptions .NO_STRUCTURE_FOUND_EXCEPTION .create (Level .MAX_LEVEL_SIZE );
178178 }
179179
180- source .sendFeedback (Component .translatable ("command.locate.feature.structure.foundAt" , ComponentUtils .formatXZ (Pos .x (structurePos ), Pos .z (structurePos ))));
180+ int structureXPos = Pos .x (structurePos );
181+ int structureZPos = Pos .z (structurePos );
182+ source .getClient ().schedule (() -> source .sendFeedback (Component .translatable ("command.locate.feature.structure.foundAt" , ComponentUtils .formatXZ (structureXPos , structureZPos ))));
181183
182184 if (structure == Cubiomes .End_City ()) {
183- int numPieces = Cubiomes .getEndCityPieces (pieces , seed , Pos . x ( structurePos ) >> 4 , Pos . z ( structurePos ) >> 4 );
185+ int numPieces = Cubiomes .getEndCityPieces (pieces , seed , structureXPos >> 4 , structureZPos >> 4 );
184186 IntStream .range (0 , numPieces )
185187 .mapToObj (i -> Piece .asSlice (pieces , i ))
186188 .filter (piece -> Piece .type (piece ) == Cubiomes .END_SHIP ())
187189 .findAny () // only one ship per end city
188190 .map (Piece ::pos )
189191 .map (city -> new BlockPos (Pos3 .x (city ), Pos3 .y (city ) + 60 , Pos3 .z (city )))
190- .ifPresent (city -> source .sendFeedback (Component .literal (" - " )
191- .append (Component .translatable ("command.locate.feature.structure.endCity.hasShip" , ComponentUtils .formatXYZ (city .getX (), city .getY (), city .getZ ())))));
192+ .ifPresent (city -> source .getClient (). schedule (() -> source . sendFeedback (Component .literal (" - " )
193+ .append (Component .translatable ("command.locate.feature.structure.endCity.hasShip" , ComponentUtils .formatXYZ (city .getX (), city .getY (), city .getZ ())))))) ;
192194 } else if (structure == Cubiomes .Fortress ()) {
193- int numPieces = Cubiomes .getFortressPieces (pieces , StructureChecks .MAX_END_CITY_AND_FORTRESS_PIECES , version , seed , Pos . x ( structurePos ) >> 4 , Pos . z ( structurePos ) >> 4 );
195+ int numPieces = Cubiomes .getFortressPieces (pieces , StructureChecks .MAX_END_CITY_AND_FORTRESS_PIECES , version , seed , structureXPos >> 4 , structureZPos >> 4 );
194196 IntStream .range (0 , numPieces )
195197 .mapToObj (i -> Piece .asSlice (pieces , i ))
196198 .filter (piece -> Piece .type (piece ) == Cubiomes .BRIDGE_SPAWNER ())
197199 .map (Piece ::pos )
198200 .map (monsterThrone -> new BlockPos (Pos3 .x (monsterThrone ), Pos3 .y (monsterThrone ) + 10 , Pos3 .z (monsterThrone )))
199- .forEach (spawnerPos -> source .sendFeedback (Component .literal (" - " )
200- .append (Component .translatable ("command.locate.feature.structure.fortress.hasSpawner" , ComponentUtils .formatXYZ (spawnerPos .getX (), spawnerPos .getY (), spawnerPos .getZ ())))));
201+ .forEach (spawnerPos -> source .getClient (). schedule (() -> source . sendFeedback (Component .literal (" - " )
202+ .append (Component .translatable ("command.locate.feature.structure.fortress.hasSpawner" , ComponentUtils .formatXYZ (spawnerPos .getX (), spawnerPos .getY (), spawnerPos .getZ ())))))) ;
201203 }
202204
203205 if (!variantData ) {
204206 return Command .SINGLE_SUCCESS ;
205207 }
206- int biome = Cubiomes .getBiomeAt (generator , 4 , Pos . x ( structurePos ) >> 2 , 320 >> 2 , Pos . z ( structurePos ) >> 2 );
207- Cubiomes .getVariant (structureVariant , structure , version , seed , Pos . x ( structurePos ), Pos . z ( structurePos ) , biome );
208+ int biome = Cubiomes .getBiomeAt (generator , 4 , structureXPos >> 2 , 320 >> 2 , structureZPos >> 2 );
209+ Cubiomes .getVariant (structureVariant , structure , version , seed , structureXPos , structureZPos , biome );
208210
209211 List <Component > components = StructureVariantFeedbackHelper .get (structure , structureVariant );
210212 if (components .isEmpty ()) {
211213 return Command .SINGLE_SUCCESS ;
212214 }
213- source .sendFeedback (Component .translatable ("command.locate.feature.structure.variantData" ));
214- components .forEach (component -> source .sendFeedback (Component .literal (" - " ).append (component )));
215+ source .getClient (). schedule (() -> source . sendFeedback (Component .translatable ("command.locate.feature.structure.variantData" ) ));
216+ components .forEach (component -> source .getClient (). schedule (() -> source . sendFeedback (Component .literal (" - " ).append (component ) )));
215217 return Command .SINGLE_SUCCESS ;
216218 }
217219 }
@@ -231,7 +233,7 @@ private static int locateStronghold(CustomClientCommandSource source) throws Com
231233
232234 BlockPos pos = tree .nearestTo (position .atY (0 ));
233235
234- source .sendFeedback (Component .translatable ("command.locate.feature.stronghold.success" , ComponentUtils .formatXZ (pos .getX (), pos .getZ ())));
236+ source .getClient (). schedule (() -> source . sendFeedback (Component .translatable ("command.locate.feature.stronghold.success" , ComponentUtils .formatXZ (pos .getX (), pos .getZ () ))));
235237 return Command .SINGLE_SUCCESS ;
236238 }
237239
@@ -497,7 +499,7 @@ private static int locateOreVein(CustomClientCommandSource source, boolean wantC
497499 throw CommandExceptions .NO_ORE_VEIN_FOUND_EXCEPTION .create (6400 );
498500 }
499501
500- source .sendFeedback (Component .translatable ("command.locate.oreVein.foundAt" , ComponentUtils .formatXYZ (pos [0 ].getX (), pos [0 ].getY (), pos [0 ].getZ (), Component .translatable ("command.locate.oreVein.copy" ))));
502+ source .getClient (). schedule (() -> source . sendFeedback (Component .translatable ("command.locate.oreVein.foundAt" , ComponentUtils .formatXYZ (pos [0 ].getX (), pos [0 ].getY (), pos [0 ].getZ (), Component .translatable ("command.locate.oreVein.copy" ) ))));
501503
502504 return Command .SINGLE_SUCCESS ;
503505 }
@@ -537,7 +539,7 @@ private static int locateCanyon(CustomClientCommandSource source) throws Command
537539 if (pos == null ) {
538540 throw CommandExceptions .NO_CANYON_FOUND_EXCEPTION .create (6400 );
539541 }
540- source .sendFeedback (Component .translatable ("command.locate.canyon.foundAt" , ComponentUtils .formatXZ (SectionPos .sectionToBlockCoord (pos .x ()), SectionPos .sectionToBlockCoord (pos .z ()), Component .translatable ("command.locate.canyon.copy" ))));
542+ source .getClient (). schedule (() -> source . sendFeedback (Component .translatable ("command.locate.canyon.foundAt" , ComponentUtils .formatXZ (SectionPos .sectionToBlockCoord (pos .x ()), SectionPos .sectionToBlockCoord (pos .z ()), Component .translatable ("command.locate.canyon.copy" ) ))));
541543 return Command .SINGLE_SUCCESS ;
542544 }
543545 }
0 commit comments