1010import net .minecraft .loot .context .LootContext ;
1111import net .minecraft .loot .function .SetNameLootFunction ;
1212import net .minecraft .text .Text ;
13+ import net .minecraft .util .JsonHelper ;
14+ import org .jetbrains .annotations .Nullable ;
1315
1416public class SetCustomNameEntityModifier implements EntityModifier {
1517 private final Text customName ;
18+ private final @ Nullable Boolean visible ;
1619
17- public SetCustomNameEntityModifier (Text customName ) {
20+ public SetCustomNameEntityModifier (Text customName , @ Nullable Boolean visible ) {
1821 this .customName = customName ;
22+ this .visible = visible ;
1923 }
2024
2125 @ Override
@@ -28,6 +32,9 @@ public Entity apply(Entity entity, LootContext lootContext) {
2832 if (this .customName != null ) {
2933 entity .setCustomName (SetNameLootFunction .applySourceEntity (lootContext , LootContext .EntityTarget .THIS ).apply (this .customName ));
3034 }
35+ if (this .visible != null ) {
36+ entity .setCustomNameVisible (this .visible );
37+ }
3138 return entity ;
3239 }
3340
@@ -42,7 +49,8 @@ public void toJson(JsonObject json, SetCustomNameEntityModifier object, JsonSeri
4249 @ Override
4350 public SetCustomNameEntityModifier fromJson (JsonObject json , JsonDeserializationContext context ) {
4451 Text customName = Text .Serializer .fromJson (json .get ("name" ));
45- return new SetCustomNameEntityModifier (customName );
52+ @ Nullable Boolean visible = json .has ("visible" ) ? JsonHelper .getBoolean (json , "visible" ) : null ;
53+ return new SetCustomNameEntityModifier (customName , visible );
4654 }
4755 }
4856}
0 commit comments