@@ -65,6 +65,8 @@ public GraphWidget(String registryID, String registryKey, String modId, Anchor a
65
65
this .showGrid = showGrid ;
66
66
this .gridLines = gridLines ;
67
67
this .label = label ;
68
+ this .setMinValue (minValue );
69
+ this .setMaxValue (maxValue );
68
70
69
71
internal_init ();
70
72
@@ -74,8 +76,6 @@ public GraphWidget(String registryID, String registryKey, String modId, Anchor a
74
76
private void internal_init (){
75
77
Validate .isTrue (maxDataPoints > 2 , "MaxDataPoints should be more than 2." );
76
78
this .dataPoints = new float [maxDataPoints ];
77
- this .setMinValue (minValue );
78
- this .setMaxValue (maxValue );
79
79
this .label = label .trim ();
80
80
this .widgetBox = new WidgetBox (x , y , (int ) width , (int ) height );
81
81
@@ -259,6 +259,7 @@ public void renderWidget(DrawContext context, int mouseX, int mouseY) {
259
259
DrawHelper .drawVerticalLine (matrix , xPos , y , height , 0.5f , 0x4DFFFFFF );
260
260
}
261
261
}
262
+
262
263
// Draw interpolated graph curve
263
264
List <float []> points = getInterpolatedPoints ();
264
265
drawInterpolatedCurve (matrix , points , graphColor .getRGB (), lineThickness );
@@ -276,8 +277,9 @@ public void renderWidget(DrawContext context, int mouseX, int mouseY) {
276
277
1.0f , 0.8f , 1.0f , 0.05f , true
277
278
);
278
279
280
+
279
281
// Draw axes
280
- DrawHelper .drawHorizontalLine (matrix , x , width , y + height , 1.0f , 0xFFFFFFFF ); // X-axis
282
+ DrawHelper .drawHorizontalLine (matrix , x , width , y + height - 1 , 1.0f , 0xFFFFFFFF ); // X-axis
281
283
DrawHelper .drawVerticalLine (matrix , x , y , height , 1.0f , 0xFFFFFFFF ); // Y-axis
282
284
283
285
// Draw min and max value labels with formatted values
@@ -345,25 +347,6 @@ public void createMenu() {
345
347
);
346
348
}
347
349
348
- @ Override
349
- public void readFromTag (NbtCompound tag ) {
350
- super .readFromTag (tag );
351
- this .width = tag .getFloat ("width" );
352
- this .height = tag .getFloat ("height" );
353
- this .maxDataPoints = tag .getInt ("maxDataPoints" );
354
- this .minValue = tag .getFloat ("minValue" );
355
- this .maxValue = tag .getFloat ("maxValue" );
356
- this .graphColor = new Color (tag .getInt ("graphColor" ));
357
- this .backgroundColor = new Color (tag .getInt ("backgroundColor" ));
358
- this .lineThickness = tag .getFloat ("lineThickness" );
359
- this .showGrid = tag .getBoolean ("showGrid" );
360
- this .gridLines = tag .getInt ("gridLines" );
361
- this .label = tag .getString ("label" );
362
-
363
- internal_init ();
364
- createMenu ();
365
- }
366
-
367
350
public float getMinValue () {
368
351
return minValue ;
369
352
}
@@ -484,6 +467,29 @@ public void writeToTag(NbtCompound tag) {
484
467
tag .putBoolean ("showGrid" , showGrid );
485
468
tag .putInt ("gridLines" , gridLines );
486
469
tag .putString ("label" , label );
470
+ tag .putBoolean ("autoUpdateRange" , autoUpdateRange );
471
+ }
472
+
473
+ @ Override
474
+ public void readFromTag (NbtCompound tag ) {
475
+ super .readFromTag (tag );
476
+ this .width = tag .getFloat ("width" );
477
+ this .height = tag .getFloat ("height" );
478
+ this .maxDataPoints = tag .getInt ("maxDataPoints" );
479
+ this .minValue = tag .getFloat ("minValue" );
480
+ this .maxValue = tag .getFloat ("maxValue" );
481
+ this .graphColor = new Color (tag .getInt ("graphColor" ));
482
+ this .backgroundColor = new Color (tag .getInt ("backgroundColor" ));
483
+ this .lineThickness = tag .getFloat ("lineThickness" );
484
+ this .showGrid = tag .getBoolean ("showGrid" );
485
+ this .gridLines = tag .getInt ("gridLines" );
486
+ this .label = tag .getString ("label" );
487
+ this .autoUpdateRange = tag .getBoolean ("autoUpdateRange" );
488
+ this .setMinValue (minValue );
489
+ this .setMaxValue (maxValue );
490
+
491
+ internal_init ();
492
+ createMenu ();
487
493
}
488
494
489
495
@ Override
0 commit comments