23
23
import com .solegendary .reignofnether .orthoview .OrthoviewClientEvents ;
24
24
import com .solegendary .reignofnether .player .PlayerClientEvents ;
25
25
import com .solegendary .reignofnether .research .ResearchClient ;
26
- import com .solegendary .reignofnether .resources .ResourceName ;
27
- import com .solegendary .reignofnether .resources .ResourceSources ;
28
- import com .solegendary .reignofnether .resources .Resources ;
29
- import com .solegendary .reignofnether .resources .ResourcesClientEvents ;
26
+ import com .solegendary .reignofnether .resources .*;
30
27
import com .solegendary .reignofnether .sandbox .SandboxActionButtons ;
31
28
import com .solegendary .reignofnether .sandbox .SandboxClientEvents ;
32
29
import com .solegendary .reignofnether .sandbox .SandboxMenuType ;
55
52
import net .minecraft .client .model .Model ;
56
53
import net .minecraft .client .resources .language .I18n ;
57
54
import net .minecraft .core .BlockPos ;
55
+ import net .minecraft .network .chat .Component ;
58
56
import net .minecraft .network .chat .Style ;
59
57
import net .minecraft .resources .ResourceLocation ;
60
58
import net .minecraft .util .FormattedCharSequence ;
61
59
import net .minecraft .world .entity .Entity ;
62
60
import net .minecraft .world .entity .EquipmentSlot ;
63
61
import net .minecraft .world .entity .LivingEntity ;
64
62
import net .minecraft .world .entity .Mob ;
63
+ import net .minecraft .world .entity .animal .Animal ;
65
64
import net .minecraft .world .item .BannerItem ;
66
65
import net .minecraft .world .item .ItemStack ;
67
66
import net .minecraftforge .client .event .RenderLivingEvent ;
76
75
import static com .solegendary .reignofnether .hud .buttons .HelperButtons .*;
77
76
import static com .solegendary .reignofnether .tutorial .TutorialClientEvents .helpButton ;
78
77
import static com .solegendary .reignofnether .unit .UnitClientEvents .*;
78
+ import static com .solegendary .reignofnether .util .MiscUtil .capitaliseAndSpace ;
79
79
import static com .solegendary .reignofnether .util .MiscUtil .fcs ;
80
80
81
81
public class HudClientEvents {
@@ -167,14 +167,17 @@ public static String getSimpleEntityName(Entity entity) {
167
167
.replace (".none" , "" );
168
168
}
169
169
} else {
170
- return entity .getName ().getString ();
170
+ return entity .getName ().getString (). toLowerCase () ;
171
171
}
172
172
}
173
173
174
174
// not to be used for resource paths
175
175
public static String getModifiedEntityName (Entity entity ) {
176
176
String name = getSimpleEntityName (entity );
177
177
178
+ if (!(entity instanceof Unit ))
179
+ return name .toLowerCase ();
180
+
178
181
ItemStack itemStack = ((LivingEntity ) entity ).getItemBySlot (EquipmentSlot .HEAD );
179
182
180
183
if (itemStack .getItem () instanceof BannerItem ) {
@@ -619,12 +622,7 @@ else if (hudSelectedEntity != null && portraitRendererUnit.model != null
619
622
int totalRes = Resources .getTotalResourcesFromItems (unit .getItems ()).getTotalValue ();
620
623
621
624
if (hudSelectedEntity instanceof Mob mob && mob .canPickUpLoot () && totalRes > 0 ) {
622
- hudZones .add (portraitRendererUnit .renderResourcesHeld (evt .getGuiGraphics (),
623
- nameCap ,
624
- blitX ,
625
- blitY ,
626
- unit
627
- ));
625
+ hudZones .add (portraitRendererUnit .renderResourcesHeld (evt .getGuiGraphics (), blitX , blitY , unit ));
628
626
629
627
// return button
630
628
if (getPlayerToEntityRelationship (hudSelectedEntity ) == Relationship .OWNED ) {
@@ -645,7 +643,11 @@ else if (hudSelectedEntity != null && portraitRendererUnit.model != null
645
643
renderedButtons .add (returnButton );
646
644
}
647
645
}
646
+ } else if (ResourceSources .isHuntableAnimal (hudSelectedEntity )) {
647
+ hudZones .add (portraitRendererUnit .renderResourcesHeld (evt .getGuiGraphics (), blitX , blitY , (Animal ) hudSelectedEntity ));
648
+ blitX += portraitRendererUnit .statsWidth ;
648
649
}
650
+
649
651
if (hudSelectedEntity instanceof Unit unit
650
652
&& Resources .getTotalResourcesFromItems (unit .getItems ()).getTotalValue () > 0 ) {
651
653
blitX += portraitRendererUnit .statsWidth + 5 ;
@@ -661,7 +663,7 @@ else if (hudSelectedEntity != null && portraitRendererUnit.model != null
661
663
blitY = screenHeight - iconFrameSize * 2 - 10 ;
662
664
663
665
for (LivingEntity unit : selUnits ) {
664
- if (getPlayerToEntityRelationship (unit ) == Relationship .OWNED && unitButtons .size () < (buttonsPerRow * 2 )) {
666
+ if (( getPlayerToEntityRelationship (unit ) == Relationship .OWNED || NonUnitClientEvents . canControlNonUnits ()) && unitButtons .size () < (buttonsPerRow * 2 )) {
665
667
// mob head icon
666
668
String unitName = getSimpleEntityName (unit );
667
669
String buttonImagePath ;
@@ -690,7 +692,7 @@ else if (hudSelectedEntity != null && portraitRendererUnit.model != null
690
692
}
691
693
},
692
694
null ,
693
- null
695
+ List . of ( fcs ( capitaliseAndSpace ( getModifiedEntityName ( unit ))))
694
696
);
695
697
if (unit .isVehicle ()) {
696
698
String passengerName = getSimpleEntityName (unit .getFirstPassenger ());
@@ -739,17 +741,17 @@ else if (hudSelectedEntity != null && portraitRendererUnit.model != null
739
741
for (int i = selUnits .size () - numExtraUnits ; i < selUnits .size (); i ++) {
740
742
741
743
LivingEntity unit = selUnits .get (i );
742
- LivingEntity nextUnit = null ;
743
- String unitName = HudClientEvents .getSimpleEntityName (unit );
744
+ LivingEntity nextUnit ;
745
+ String unitName = HudClientEvents .getModifiedEntityName (unit );
744
746
String nextUnitName = null ;
745
747
numUnits += 1 ;
746
748
747
749
if (i < selUnits .size () - 1 ) {
748
750
nextUnit = selUnits .get (i + 1 );
749
- nextUnitName = HudClientEvents .getSimpleEntityName (nextUnit );
751
+ nextUnitName = HudClientEvents .getModifiedEntityName (nextUnit );
750
752
}
751
753
if (!unitName .equals (nextUnitName )) {
752
- tooltipLines .add (FormattedCharSequence .forward ("x" + numUnits + " " + I18n . get (unitName ),
754
+ tooltipLines .add (FormattedCharSequence .forward ("x" + numUnits + " " + capitaliseAndSpace (unitName ),
753
755
Style .EMPTY
754
756
));
755
757
numUnits = 0 ;
0 commit comments