Package journeymap.api.v2.client.util
Class PolygonHelper
java.lang.Object
journeymap.api.v2.client.util.PolygonHelper
Utility class related to Polygons.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic List<MapPolygonWithHoles> classifyAndGroup(List<MapPolygon> polygons) Given an arbitrary list of polygons, determine which are hulls and holes and which holes are associated with which hulls.static MapPolygoncreateBlockRect(net.minecraft.core.BlockPos corner1, net.minecraft.core.BlockPos corner2) Creates a polygon for the block coords, starting with the lower-left (southwest) corner and going counter-clockwise.static MapPolygoncreateChunkPolygon(int chunkX, int y, int chunkZ) Creates a polygon for the chunk coords, starting with the lower-left (southwest) corner and going counter-clockwise.static MapPolygoncreateChunkPolygonForWorldCoords(int x, int y, int z) Creates a polygon for the chunk containing worldCoords, starting with the lower-left (southwest) corner and going counter-clockwise.static AreacreateChunksArea(Collection<net.minecraft.world.level.ChunkPos> chunks) Given a collection of chunks, creates anAreathat covers them.static List<MapPolygonWithHoles> createChunksPolygon(Collection<net.minecraft.world.level.ChunkPos> chunks, int y) Given a collection of chunks, creates one or moreMapPolygonWithHolesthat covers them.static List<MapPolygonWithHoles> createPolygonFromArea(Area area, int y) Creates a set ofMapPolygonWithHolesfrom the givenArea(XZ block coords) and the given Y coord.static AreatoArea(MapPolygon polygon) Converts aMapPolygoninto anArea(keeping XZ coords only).
-
Constructor Details
-
PolygonHelper
public PolygonHelper()
-
-
Method Details
-
createChunkPolygonForWorldCoords
Creates a polygon for the chunk containing worldCoords, starting with the lower-left (southwest) corner and going counter-clockwise.- Parameters:
x- world Xy- world Yz- world Z- Returns:
- a polygon for the surrounding chunk
-
createChunkPolygon
Creates a polygon for the chunk coords, starting with the lower-left (southwest) corner and going counter-clockwise.- Parameters:
chunkX- chunk xy- block ychunkZ- chunk z- Returns:
- polygon
-
createBlockRect
public static MapPolygon createBlockRect(net.minecraft.core.BlockPos corner1, net.minecraft.core.BlockPos corner2) Creates a polygon for the block coords, starting with the lower-left (southwest) corner and going counter-clockwise. The supplied coordinates don't need to be in order, just opposite.- Parameters:
corner1- One corner of the desired rectanglecorner2- The opposite corner- Returns:
- polygon
-
createChunksArea
@Nonnull public static Area createChunksArea(@Nonnull Collection<net.minecraft.world.level.ChunkPos> chunks) Given a collection of chunks, creates anAreathat covers them.- Parameters:
chunks- The set of chunks.- Returns:
- An Area of the corresponding block coordinates.
-
createChunksPolygon
@Nonnull public static List<MapPolygonWithHoles> createChunksPolygon(@Nonnull Collection<net.minecraft.world.level.ChunkPos> chunks, int y) Given a collection of chunks, creates one or moreMapPolygonWithHolesthat covers them. (Just a convenience wrapper for theArea-based methods.)- Parameters:
chunks- The set of chunks.y- The y-coordinate for the resulting polygons.- Returns:
- One or more polygons that cover the specified chunks.
-
toArea
Converts aMapPolygoninto anArea(keeping XZ coords only).- Parameters:
polygon- The polygon.- Returns:
- The corresponding area.
-
createPolygonFromArea
Creates a set ofMapPolygonWithHolesfrom the givenArea(XZ block coords) and the given Y coord.Note that this includes some point-simplification that currently only works if the area is only made up of rectangular subregions -- i.e. all lines are perfectly horizontal or vertical. If you do have diagonal lines this is mostly harmless; just might leave more points than are strictly required.
- Parameters:
area- The area to cover.y- The y-coordinate.- Returns:
- The polygons.
-
classifyAndGroup
@Nonnull public static List<MapPolygonWithHoles> classifyAndGroup(@Nonnull List<MapPolygon> polygons) Given an arbitrary list of polygons, determine which are hulls and holes and which holes are associated with which hulls.Assumes that hulls use CCW point winding and holes use CW point winding, which seems to be consistent with
createPolygonFromArea(java.awt.geom.Area, int).- Parameters:
polygons- The input list ofMapPolygons.- Returns:
- The resulting list of
MapPolygonWithHoles.
-