11package io .github .madis0 ;
22
33import me .shedaniel .autoconfig .AutoConfig ;
4- import net .fabricmc .loader .api .FabricLoader ;
54import net .minecraft .client .Minecraft ;
65import net .minecraft .client .gui .Font ;
7- import net .minecraft .client .gui .GuiGraphics ;
6+ import net .minecraft .client .gui .GuiGraphicsExtractor ;
87import net .minecraft .core .component .DataComponents ;
98import net .minecraft .network .chat .Component ;
109import net .minecraft .resources .ResourceKey ;
@@ -29,7 +28,7 @@ public class OneBarElements {
2928 private final PlayerProperties playerProperties = new PlayerProperties ();
3029 private final Minecraft client = Minecraft .getInstance ();
3130 private final Difficulty difficulty = Objects .requireNonNull (client .getCameraEntity ()).level ().getDifficulty ();
32- private final GuiGraphics drawContext ;
31+ private final GuiGraphicsExtractor drawContext ;
3332 private final Font textRenderer = client .font ;
3433
3534 boolean hasHunger = playerProperties .hasHunger && !config .disableHunger ;
@@ -40,7 +39,7 @@ public class OneBarElements {
4039 float armorBarTotalLength = armorBarBootsLength + playerProperties .bootsMaxArmor ;
4140 float elytraDurability = playerProperties .getArmorElementDurability (Objects .requireNonNull (client .player ), EquipmentSlot .CHEST , 8 ); //8 aka same full width as Diamond/Netherite
4241
43- public OneBarElements (GuiGraphics context ){
42+ public OneBarElements (GuiGraphicsExtractor context ){
4443 drawContext = context ;
4544 }
4645
@@ -402,7 +401,7 @@ private void barText(){
402401 int textX = clientProperties .baseEndW - client .font .width (value );
403402 int textY = clientProperties .baseStartH + 1 ;
404403
405- drawContext .drawString (textRenderer , value , textX , textY , config .textSettings .textColor , false );
404+ drawContext .text (textRenderer , value , textX , textY , config .textSettings .textColor , false );
406405 }
407406
408407 private void xpBar (){
@@ -431,13 +430,13 @@ private void xpBar(){
431430 int edgeAlignedConst = 13 ;
432431
433432 if (playerProperties .xpLevel >= 0 && playerProperties .xpLevel < sizeLimit ){
434- drawContext .drawCenteredString (textRenderer , String .valueOf (playerProperties .xpLevel ), textX , textY , config .otherBars .xpColor );
433+ drawContext .centeredText (textRenderer , String .valueOf (playerProperties .xpLevel ), textX , textY , config .otherBars .xpColor );
435434 }
436435 else if (playerProperties .xpLevel >= sizeLimit ){
437436 if (client .options .mainHand ().get () == HumanoidArm .RIGHT )
438- drawContext .drawString (textRenderer , String .valueOf (playerProperties .xpLevel ), textX - edgeAlignedConst , textY , config .otherBars .xpColor );
437+ drawContext .text (textRenderer , String .valueOf (playerProperties .xpLevel ), textX - edgeAlignedConst , textY , config .otherBars .xpColor );
439438 else if (client .options .mainHand ().get () == HumanoidArm .LEFT )
440- drawContext .drawString (textRenderer , String .valueOf (playerProperties .xpLevel ), textX + edgeAlignedConst - client .font .width (String .valueOf (playerProperties .xpLevel )), textY , config .otherBars .xpColor );
439+ drawContext .text (textRenderer , String .valueOf (playerProperties .xpLevel ), textX + edgeAlignedConst - client .font .width (String .valueOf (playerProperties .xpLevel )), textY , config .otherBars .xpColor );
441440 }
442441
443442 var lapisTextX = clientProperties .xpEndW + 1 ;
@@ -449,11 +448,11 @@ else if(client.options.mainHand().get() == HumanoidArm.LEFT)
449448 }
450449
451450 if (config .otherBars .lapisCounter ){
452- drawContext .drawString (textRenderer , lapisText , lapisTextX , lapisTextY , config .otherBars .lapisColor );
451+ drawContext .text (textRenderer , lapisText , lapisTextX , lapisTextY , config .otherBars .lapisColor );
453452 }
454453
455454 if (config .otherBars .mendingIndicator && playerProperties .isMendingAnything ){
456- drawContext .drawCenteredString (textRenderer , Calculations .emojiOrText ("text.onebar.mendingEmoji" , "text.onebar.mending" , false ), textX , mendingTextY , config .otherBars .mendingColor );
455+ drawContext .centeredText (textRenderer , Calculations .emojiOrText ("text.onebar.mendingEmoji" , "text.onebar.mending" , false ), textX , mendingTextY , config .otherBars .mendingColor );
457456 }
458457 }
459458 if (!config .otherBars .adaptiveXpBar || playerProperties .xp > 0 ){
@@ -494,7 +493,7 @@ public void jumpBar(){
494493 int textY = clientProperties .jumpEndH - 10 ;
495494
496495 if (config .textSettings .showText && config .entity .showMountJumpText )
497- drawContext .drawString (textRenderer , roundedHeightInBlocks , textX , textY , config .textSettings .textColor , false );
496+ drawContext .text (textRenderer , roundedHeightInBlocks , textX , textY , config .textSettings .textColor , false );
498497 }
499498
500499 public void dashBar (){
@@ -522,7 +521,7 @@ public void dashBar(){
522521 String roundedDistanceInBlocks = Calculations .getSubscriptNumber (Double .parseDouble (String .format (Locale .US , "%,.1f" ,(distanceInBlocks ))));
523522 int textX = clientProperties .dashEndW - client .font .width (roundedDistanceInBlocks );
524523 int textY = clientProperties .dashEndH - 9 ;
525- drawContext .drawString (textRenderer , roundedDistanceInBlocks , textX , textY , config .textSettings .textColor , false );
524+ drawContext .text (textRenderer , roundedDistanceInBlocks , textX , textY , config .textSettings .textColor , false );
526525 }
527526 }
528527 }
@@ -536,7 +535,7 @@ private void dashCooldownBar(int relativeEndW, int cooldownTimer){
536535 String text = Calculations .getSubscriptNumber (-1 - cooldownTimer );
537536 int textX = clientProperties .dashEndW - client .font .width (text );
538537 int textY = clientProperties .dashEndH - 9 ;
539- drawContext .drawString (textRenderer , text , textX , textY , config .textSettings .textColor , false );
538+ drawContext .text (textRenderer , text , textX , textY , config .textSettings .textColor , false );
540539 }
541540 }
542541 }
@@ -570,7 +569,7 @@ public void mountBar(LivingEntity mountEntity){
570569 renderBar (clientProperties .baseStartW , clientProperties .mountStartH , clientProperties .baseEndW , clientProperties .mountEndH , config .backgroundColor );
571570 renderBar (clientProperties .baseStartW , clientProperties .mountStartH , clientProperties .baseRelativeEndW (Calculations .getPreciseInt (mountRawHealth ), Calculations .getPreciseInt (mountMaxHealth )), clientProperties .mountEndH , config .entity .healthColor );
572571 if (config .armor .showArmorBar ) renderBar (clientProperties .baseStartW , clientProperties .mountStartH - 1 , clientProperties .baseRelativeEndW (mountArmor , mountMaxArmor ), clientProperties .mountStartH , config .armor .armorColor );
573- if (config .textSettings .showText ) drawContext .drawString (textRenderer , value , textX , textY , config .textSettings .textColor , false );
572+ if (config .textSettings .showText ) drawContext .text (textRenderer , value , textX , textY , config .textSettings .textColor , false );
574573
575574 if (mountEntity instanceof Camel ){
576575 long standingUpMax = 52 ;
@@ -585,6 +584,6 @@ public void mountBar(LivingEntity mountEntity){
585584 }
586585
587586 private void debugText (String value ){
588- drawContext .drawString (textRenderer , value , clientProperties .baseEndW + 15 , clientProperties .baseStartH + 1 , config .textSettings .textColor );
587+ drawContext .text (textRenderer , value , clientProperties .baseEndW + 15 , clientProperties .baseStartH + 1 , config .textSettings .textColor );
589588 }
590589}
0 commit comments