@@ -249,103 +249,4 @@ public static List<List<Vector2i>> convertLineSegmentsToOutlines(
249249
250250 return holes ;
251251 }
252-
253- /**
254- * Takes a list of all claims in a level and groups them using BFS. While doing that it measures
255- * all the sides of all the claims that are on a border from claimed territory and wilderness.
256- *
257- * <p>The returned segments are directional.
258- *
259- * <p>As opposed to @see ClaimGrouper#convertClaimsToLineSegmentGroups(), this function also
260- * creates line segments to bridge the gap between the outside outline and any inner holes. This
261- * is need by dymap because dynmap doesn't support holes in markers.
262- *
263- * @param claims A set of vectors that represents the coordinates of a claim (@see
264- * ClaimGrouper#separateClaimsByLevel())
265- * @return A list of edges. The edges are returned as a map where the entries represent one
266- * corner of a claim and the values are other corners in connects too. The list has either
267- * one or two elements.
268- */
269- public static List <Map <Vector2i , Vector2i []>> convertClaimsToLineSegmentGroupsWithoutHoles (
270- Set <Vector2i > claims ) {
271- Set <Vector2i > remaining_claims = new HashSet <>(claims );
272- Queue <Vector2i > queue = new LinkedList <>();
273- List <Map <Vector2i , Vector2i []>> groups = new ArrayList <>();
274-
275- while (!remaining_claims .isEmpty ()) {
276- Iterator <Vector2i > iter = remaining_claims .iterator ();
277- Vector2i item = iter .next ();
278- queue .add (item );
279- remaining_claims .remove (item );
280-
281- Map <Vector2i , Vector2i []> lines = new HashMap <>();
282-
283- while (!queue .isEmpty ()) {
284- Vector2i claim = queue .remove ();
285-
286- for (Vector2i dir :
287- new Vector2i [] {
288- new Vector2i (1 , 0 ),
289- new Vector2i (-1 , 0 ),
290- new Vector2i (0 , 1 ),
291- new Vector2i (0 , -1 )
292- }) {
293- Vector2i new_claim = claim .add (dir );
294- // The BFS part
295- if (remaining_claims .contains (new_claim )) {
296- queue .add (new_claim );
297- remaining_claims .remove (new_claim );
298- } else {
299- Vector2i start ; // both of these are in block coordinates
300- Vector2i end ;
301-
302- if (dir .getX () == 0 ) {
303- // the y component is being used as the x component so that the
304- // direction is correct
305- start = claim .mul (16 ).add (new Vector2i (dir .getY (), dir .getY ()).mul (8 ));
306- end = claim .mul (16 ).add (new Vector2i (-dir .getY (), dir .getY ()).mul (8 ));
307- } else {
308- start = claim .mul (16 ).add (new Vector2i (dir .getX (), -dir .getX ()).mul (8 ));
309- end = claim .mul (16 ).add (new Vector2i (dir .getX (), dir .getX ()).mul (8 ));
310- }
311-
312- start =
313- start .add (
314- new Vector2i (
315- 8 ,
316- 8 )); // offset to match how minecraft converts chunk
317- // coords to block coords
318- end = end .add (new Vector2i (8 , 8 ));
319-
320- boolean has_opposite_line = false ;
321-
322- if (lines .containsKey (end )) {
323- for (Vector2i possible_start : lines .get (end )) {
324- if (possible_start .equals (start )) {
325- has_opposite_line = true ;
326- }
327- }
328- }
329-
330- if (!has_opposite_line
331- && claims .contains (new_claim )
332- && !(queue .contains (new_claim )
333- || remaining_claims .contains (new_claim ))) {
334- continue ;
335- }
336-
337- if (lines .containsKey (start )) {
338- lines .put (start , new Vector2i [] {lines .get (start )[0 ], end });
339- } else {
340- lines .put (start , new Vector2i [] {end });
341- }
342- }
343- }
344- }
345-
346- groups .add (lines );
347- }
348-
349- return groups ;
350- }
351252}
0 commit comments