129129import java .util .Objects ;
130130import java .util .Optional ;
131131import java .util .OptionalInt ;
132- import java .util .function .IntSupplier ;
133132import java .util .function .ToIntBiFunction ;
134133import java .util .stream .IntStream ;
135134import java .util .stream .Stream ;
@@ -181,8 +180,10 @@ public class SeedMapScreen extends Screen {
181180 private static final int HORIZONTAL_PADDING = 50 ;
182181 private static final int VERTICAL_PADDING = 50 ;
183182
184- public static final int MIN_PIXELS_PER_BIOME = 1 ;
185- public static final int MAX_PIXELS_PER_BIOME = 100 ;
183+ public static final double MIN_PIXELS_PER_BIOME = 0.01D ;
184+ public static final double DEFAULT_MIN_PIXELS_PER_BIOME = 1.0D ;
185+ public static final double MAX_PIXELS_PER_BIOME = 100.0D ;
186+ private static final double ZOOM_SCROLL_SENSITIVITY = 0.2D ;
186187
187188 private static final int HORIZONTAL_FEATURE_TOGGLE_SPACING = 5 ;
188189 private static final int VERTICAL_FEATURE_TOGGLE_SPACING = 1 ;
@@ -191,7 +192,9 @@ public class SeedMapScreen extends Screen {
191192 private static final int TELEPORT_FIELD_WIDTH = 70 ;
192193 private static final int WAYPOINT_NAME_FIELD_WIDTH = 100 ;
193194
194- private static final IntSupplier TILE_SIZE_PIXELS = () -> TilePos .TILE_SIZE_CHUNKS * SCALED_CHUNK_SIZE * Configs .PixelsPerBiome ;
195+ private static double tileSizePixels () {
196+ return TilePos .TILE_SIZE_CHUNKS * SCALED_CHUNK_SIZE * Configs .PixelsPerBiome ;
197+ }
195198
196199 private static final Object2ObjectMap <WorldIdentifier , Object2ObjectMap <TilePos , int []>> biomeDataCache = new Object2ObjectOpenHashMap <>();
197200 private static final Object2ObjectMap <WorldIdentifier , Object2ObjectMap <ChunkPos , ChunkStructureData >> structureDataCache = new Object2ObjectOpenHashMap <>();
@@ -363,7 +366,7 @@ protected void init() {
363366 this .centerX = this .width / 2 ;
364367 this .centerY = this .height / 2 ;
365368
366- this .seedMapWidth = 2 * (this .centerX - HORIZONTAL_PADDING );
369+ this .seedMapWidth = computeSeedMapWidth (this .width );
367370 this .seedMapHeight = 2 * (this .centerY - VERTICAL_PADDING );
368371
369372 this .createFeatureToggles ();
@@ -389,11 +392,11 @@ public void render(GuiGraphics guiGraphics, int mouseX, int mouseY, float partia
389392 private void drawTile (GuiGraphics guiGraphics , Tile tile ) {
390393 TilePos tilePos = tile .pos ();
391394 QuartPos2f relTileQuart = QuartPos2f .fromQuartPos (QuartPos2 .fromTilePos (tilePos )).subtract (this .centerQuart );
392- int tileSizePixels = TILE_SIZE_PIXELS . getAsInt ();
393- int minX = this .centerX + Mth . floor ( Configs .PixelsPerBiome * relTileQuart .x () );
394- int minY = this .centerY + Mth . floor ( Configs .PixelsPerBiome * relTileQuart .z () );
395- int maxX = minX + tileSizePixels ;
396- int maxY = minY + tileSizePixels ;
395+ double tileSizePixels = tileSizePixels ();
396+ double minX = this .centerX + Configs .PixelsPerBiome * relTileQuart .x ();
397+ double minY = this .centerY + Configs .PixelsPerBiome * relTileQuart .z ();
398+ double maxX = minX + tileSizePixels ;
399+ double maxY = minY + tileSizePixels ;
397400
398401 if (maxX < HORIZONTAL_PADDING || minX > HORIZONTAL_PADDING + this .seedMapWidth ) {
399402 return ;
@@ -402,25 +405,25 @@ private void drawTile(GuiGraphics guiGraphics, Tile tile) {
402405 return ;
403406 }
404407
405- float u0 , u1 , v0 , v1 ;
406- if ( minX < HORIZONTAL_PADDING ) {
407- u0 = ( float ) ( HORIZONTAL_PADDING - minX ) / tileSizePixels ;
408- minX = HORIZONTAL_PADDING ;
409- } else u0 = 0 ;
410- if ( maxX > HORIZONTAL_PADDING + this . seedMapWidth ) {
411- u1 = 1 - (( float ) ( maxX - HORIZONTAL_PADDING - this . seedMapWidth ) / tileSizePixels );
412- maxX = HORIZONTAL_PADDING + this . seedMapWidth ;
413- } else u1 = 1 ;
414- if ( minY < VERTICAL_PADDING ) {
415- v0 = (float ) (VERTICAL_PADDING - minY ) / tileSizePixels ;
416- minY = VERTICAL_PADDING ;
417- } else v0 = 0 ;
418- if ( maxY > VERTICAL_PADDING + this . seedMapHeight ) {
419- v1 = 1 - (( float ) ( maxY - VERTICAL_PADDING - this . seedMapHeight ) / tileSizePixels );
420- maxY = VERTICAL_PADDING + this . seedMapHeight ;
421- } else v1 = 1 ;
408+ double clampedMinX = Math . max ( minX , HORIZONTAL_PADDING ) ;
409+ double clampedMaxX = Math . min ( maxX , HORIZONTAL_PADDING + this . seedMapWidth );
410+ double clampedMinY = Math . max ( minY , VERTICAL_PADDING ) ;
411+ double clampedMaxY = Math . min ( maxY , VERTICAL_PADDING + this . seedMapHeight ) ;
412+ if ( clampedMinX >= clampedMaxX || clampedMinY >= clampedMaxY ) {
413+ return ;
414+ }
415+
416+ float u0 = ( float ) (( clampedMinX - minX ) / tileSizePixels ) ;
417+ float u1 = ( float ) (( clampedMaxX - minX ) / tileSizePixels );
418+ float v0 = (float ) (( clampedMinY - minY ) / tileSizePixels ) ;
419+ float v1 = ( float ) (( clampedMaxY - minY ) / tileSizePixels ) ;
420+
421+ int drawMinX = ( int ) Math . floor ( clampedMinX );
422+ int drawMaxX = ( int ) Math . ceil ( clampedMaxX );
423+ int drawMinY = ( int ) Math . floor ( clampedMinY ) ;
424+ int drawMaxY = ( int ) Math . ceil ( clampedMaxY ) ;
422425
423- guiGraphics .submitBlit (RenderPipelines .GUI_TEXTURED , tile .texture ().getTextureView (), tile .texture ().getSampler (), minX , minY , maxX , maxY , u0 , u1 , v0 , v1 , this .getMapBackgroundTint ());
426+ guiGraphics .submitBlit (RenderPipelines .GUI_TEXTURED , tile .texture ().getTextureView (), tile .texture ().getSampler (), drawMinX , drawMinY , drawMaxX , drawMaxY , u0 , u1 , v0 , v1 , this .getMapBackgroundTint ());
424427 }
425428
426429 private Tile createBiomeTile (TilePos tilePos , int [] biomeData ) {
@@ -1317,10 +1320,12 @@ public boolean mouseScrolled(double mouseX, double mouseY, double scrollX, doubl
13171320 return true ;
13181321 }
13191322
1320- float currentScroll = Mth .clamp ((float ) Configs .PixelsPerBiome / MAX_PIXELS_PER_BIOME , 0.0F , 1.0F );
1321- currentScroll = Mth .clamp (currentScroll - (float ) (-scrollY / MAX_PIXELS_PER_BIOME ), 0.0F , 1.0F );
1322-
1323- int newPixels = Math .max ((int ) (currentScroll * MAX_PIXELS_PER_BIOME + 0.5 ), MIN_PIXELS_PER_BIOME );
1323+ double minPixels = Math .max (MIN_PIXELS_PER_BIOME , Configs .SeedMapMinPixelsPerBiome );
1324+ double scale = Math .pow (2.0D , scrollY * ZOOM_SCROLL_SENSITIVITY );
1325+ double newPixels = Math .clamp (Configs .PixelsPerBiome * scale , minPixels , MAX_PIXELS_PER_BIOME );
1326+ if (Math .abs (newPixels - Configs .PixelsPerBiome ) < 1.0E-6D ) {
1327+ return false ;
1328+ }
13241329 // use setter so all feature/widget positions are updated when zooming
13251330 this .setPixelsPerBiome (newPixels );
13261331 return true ;
@@ -2258,9 +2263,9 @@ protected void renderSeedMap(GuiGraphics guiGraphics, int mouseX, int mouseY, fl
22582263 Component seedComponent = Component .translatable ("seedMap.seedAndVersion" , accent (Long .toString (this .seed )), Cubiomes .mc2str (this .version ).getString (0 ));
22592264 guiGraphics .drawString (this .font , seedComponent , HORIZONTAL_PADDING , VERTICAL_PADDING - this .font .lineHeight - 1 , -1 );
22602265
2261- int tileSizePixels = TILE_SIZE_PIXELS . getAsInt ();
2262- int horTileRadius = Math .ceilDiv (this .seedMapWidth , tileSizePixels ) + 1 ;
2263- int verTileRadius = Math .ceilDiv (this .seedMapHeight , tileSizePixels ) + 1 ;
2266+ double tileSizePixels = tileSizePixels ();
2267+ int horTileRadius = ( int ) Math .ceil (this .seedMapWidth / tileSizePixels ) + 1 ;
2268+ int verTileRadius = ( int ) Math .ceil (this .seedMapHeight / tileSizePixels ) + 1 ;
22642269
22652270 TilePos centerTile = TilePos .fromQuartPos (QuartPos2 .fromQuartPos2f (this .centerQuart ));
22662271 for (int relTileX = -horTileRadius ; relTileX <= horTileRadius ; relTileX ++) {
@@ -2287,8 +2292,8 @@ protected void renderSeedMap(GuiGraphics guiGraphics, int mouseX, int mouseY, fl
22872292
22882293 guiGraphics .nextStratum ();
22892294
2290- int horChunkRadius = Math .ceilDiv ( this .seedMapWidth / 2 , SCALED_CHUNK_SIZE * Configs .PixelsPerBiome );
2291- int verChunkRadius = Math .ceilDiv ( this .seedMapHeight / 2 , SCALED_CHUNK_SIZE * Configs .PixelsPerBiome );
2295+ int horChunkRadius = ( int ) Math .ceil (( this .seedMapWidth / 2.0D ) / ( SCALED_CHUNK_SIZE * Configs .PixelsPerBiome ) );
2296+ int verChunkRadius = ( int ) Math .ceil (( this .seedMapHeight / 2.0D ) / ( SCALED_CHUNK_SIZE * Configs .PixelsPerBiome ) );
22922297
22932298 // compute structures
22942299 Configs .ToggledFeatures .stream ()
@@ -2528,7 +2533,8 @@ protected double getPixelsPerBiome() {
25282533 }
25292534
25302535 protected void setPixelsPerBiome (double pixelsPerBiome ) {
2531- int p = (int ) Math .round (Math .max (MIN_PIXELS_PER_BIOME , Math .min (MAX_PIXELS_PER_BIOME , pixelsPerBiome )));
2536+ double min = Math .max (MIN_PIXELS_PER_BIOME , Configs .SeedMapMinPixelsPerBiome );
2537+ double p = Math .clamp (pixelsPerBiome , min , MAX_PIXELS_PER_BIOME );
25322538 Configs .PixelsPerBiome = p ;
25332539 // update widget positions so icons move when zoom changes
25342540 try {
@@ -2552,4 +2558,8 @@ protected void updateAllFeatureWidgetPositions() {
25522558 protected boolean showCoordinateOverlay () { return true ; }
25532559 protected boolean showFeatureToggleTooltips () { return true ; }
25542560 protected boolean showSeedLabel () { return true ; }
2555- }
2561+
2562+ public static int computeSeedMapWidth (int screenWidth ) {
2563+ return Math .max (1 , screenWidth - 2 * HORIZONTAL_PADDING );
2564+ }
2565+ }
0 commit comments