Skip to content

Commit

Permalink
Add Rabbit Type and Painting Variants to Entity Variant Info Line.
Browse files Browse the repository at this point in the history
  • Loading branch information
sakura-ryoko committed Dec 6, 2024
1 parent 2028f1f commit dae363b
Show file tree
Hide file tree
Showing 5 changed files with 80 additions and 1 deletion.
63 changes: 63 additions & 0 deletions src/main/java/fi/dy/masa/minihud/event/RenderHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@
import net.minecraft.entity.attribute.AttributeContainer;
import net.minecraft.entity.attribute.EntityAttributeInstance;
import net.minecraft.entity.attribute.EntityAttributes;
import net.minecraft.entity.decoration.painting.PaintingEntity;
import net.minecraft.entity.decoration.painting.PaintingVariant;
import net.minecraft.entity.effect.StatusEffect;
import net.minecraft.entity.effect.StatusEffectInstance;
import net.minecraft.entity.mob.SkeletonEntity;
Expand All @@ -62,7 +64,9 @@
import net.minecraft.server.world.OptionalChunk;
import net.minecraft.server.world.ServerChunkManager;
import net.minecraft.server.world.ServerWorld;
import net.minecraft.text.Text;
import net.minecraft.util.DyeColor;
import net.minecraft.util.Formatting;
import net.minecraft.util.Identifier;
import net.minecraft.util.Util;
import net.minecraft.util.collection.DefaultedList;
Expand Down Expand Up @@ -1290,6 +1294,29 @@ else if (entityType.equals(EntityType.HORSE))
this.addLineI18n("minihud.info_line.entity_variant.horse", horsePair.getLeft().asString(), horsePair.getRight().name().toLowerCase());
}
}
else if (entityType.equals(EntityType.PAINTING))
{
Pair<Direction, PaintingVariant> paintingPair = EntityUtils.getPaintingDataFromNbt(nbt, world.getRegistryManager());

if (paintingPair.getRight() != null)
{
Optional<Text> title = paintingPair.getRight().title();
Optional<Text> author = paintingPair.getRight().author();

if (title.isPresent() && author.isPresent())
{
this.addLineI18n("minihud.info_line.entity_variant.painting.both", title.get().getString(), author.get().getString());
}
else if (title.isPresent())
{
this.addLineI18n("minihud.info_line.entity_variant.painting.title_only", title.get().getString());
}
else if (author.isPresent())
{
this.addLineI18n("minihud.info_line.entity_variant.painting.author_only", author.get().getString());
}
}
}
else if (entityType.equals(EntityType.PARROT))
{
ParrotEntity.Variant variant = EntityUtils.getParrotVariantFromNbt(nbt);
Expand All @@ -1299,6 +1326,15 @@ else if (entityType.equals(EntityType.PARROT))
this.addLineI18n("minihud.info_line.entity_variant.parrot", variant.asString());
}
}
else if (entityType.equals(EntityType.RABBIT))
{
RabbitEntity.RabbitType rabbitType = EntityUtils.getRabbitTypeFromNbt(nbt);

if (rabbitType != null)
{
this.addLineI18n("minihud.info_line.entity_variant.rabbit", rabbitType.asString());
}
}
else if (entityType.equals(EntityType.SHEEP))
{
DyeColor color = EntityUtils.getSheepColorFromNbt(nbt);
Expand Down Expand Up @@ -1345,10 +1381,37 @@ else if (pair.getLeft() instanceof HorseEntity horse)
{
this.addLineI18n("minihud.info_line.entity_variant.horse", horse.getVariant().asString(), horse.getMarking().name().toLowerCase());
}
else if (pair.getLeft() instanceof PaintingEntity painting)
{
PaintingVariant paintingVariant = painting.getVariant().value();

if (paintingVariant != null)
{
Optional<Text> title = paintingVariant.title();
Optional<Text> author = paintingVariant.author();

if (title.isPresent() && author.isPresent())
{
this.addLineI18n("minihud.info_line.entity_variant.painting.both", title.get().getString(), author.get().getString());
}
else if (title.isPresent())
{
this.addLineI18n("minihud.info_line.entity_variant.painting.title_only", title.get().getString());
}
else if (author.isPresent())
{
this.addLineI18n("minihud.info_line.entity_variant.painting.author_only", author.get().getString());
}
}
}
else if (pair.getLeft() instanceof ParrotEntity parrot)
{
this.addLineI18n("minihud.info_line.entity_variant.parrot", parrot.getVariant().asString());
}
else if (pair.getLeft() instanceof RabbitEntity rabbit)
{
this.addLineI18n("minihud.info_line.entity_variant.rabbit", rabbit.getVariant().asString());
}
else if (pair.getLeft() instanceof SheepEntity sheep)
{
this.addLineI18n("minihud.info_line.entity_variant.sheep", sheep.getColor().getName());
Expand Down
4 changes: 4 additions & 0 deletions src/main/resources/assets/minihud/lang/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -994,7 +994,11 @@
"minihud.info_line.entity_variant.cat": "Cat Variant: §b%s§r (%s collar)",
"minihud.info_line.entity_variant.frog": "Frog Variant: §b%s§r",
"minihud.info_line.entity_variant.horse": "Horse Variant: §b%s / %s§r",
"minihud.info_line.entity_variant.painting.both": "Painting Variant: §b%s§r by §e%s§r",
"minihud.info_line.entity_variant.painting.title_only": "Painting Variant: §b%s§r",
"minihud.info_line.entity_variant.painting.author_only": "Painting Variant: by §e%s§r",
"minihud.info_line.entity_variant.parrot": "Parrot Variant: §b%s§r",
"minihud.info_line.entity_variant.rabbit": "Rabbit Variant: §b%s§r",
"minihud.info_line.entity_variant.sheep": "Sheep Color: §b%s§r",
"minihud.info_line.entity_variant.tropical_fish": "Tropical Fish Variant: §b%s§r",
"minihud.info_line.entity_variant.wolf": "Wolf Variant: §b%s§r (%s collar)",
Expand Down
6 changes: 5 additions & 1 deletion src/main/resources/assets/minihud/lang/ko_kr.json
Original file line number Diff line number Diff line change
Expand Up @@ -929,12 +929,16 @@
"minihud.info_line.entity_variant.cat": "고양이 유형: §b%s§r (%s 색)",
"minihud.info_line.entity_variant.frog": "개구리 유형: §b%s§r",
"minihud.info_line.entity_variant.horse": "말 유형: §b%s / %s§r",
"minihud.info_line.entity_variant.painting.both": "Painting Variant: §b%s§r by §e%s§r",
"minihud.info_line.entity_variant.painting.title_only": "Painting Variant: §b%s§r",
"minihud.info_line.entity_variant.painting.author_only": "Painting Variant: by §e%s§r",
"minihud.info_line.entity_variant.parrot": "앵무새 유형: §b%s§r",
"minihud.info_line.entity_variant.rabbit": "Rabbit Variant: §b%s§r",
"minihud.info_line.entity_variant.sheep": "양 색상: §b%s§r",
"minihud.info_line.entity_variant.tropical_fish": "열대어 유형: §b%s§r",
"minihud.info_line.entity_variant.wolf": "늑대 유형: §b%s§r (%s 색)",
"minihud.info_line.zombie_conversion": "%s 변환: %s",
"minihud.info_line.entity_reg_name": "엔티티 레지스트리명: %s",
"minihud.info_line.looking_at_block": "대상 블록 좌표: %d, %d, %d",
"minihud.info_line.looking_at_block_chunk": "블록: %d, %d, %d 서브-청크: %d, %d, %d"
}
}
4 changes: 4 additions & 0 deletions src/main/resources/assets/minihud/lang/zh_cn.json
Original file line number Diff line number Diff line change
Expand Up @@ -929,7 +929,11 @@
"minihud.info_line.entity_variant.cat": "Cat Variant: §b%s§r (%s collar)",
"minihud.info_line.entity_variant.frog": "Frog Variant: §b%s§r",
"minihud.info_line.entity_variant.horse": "Horse Variant: §b%s / %s§r",
"minihud.info_line.entity_variant.painting.both": "Painting Variant: §b%s§r by §e%s§r",
"minihud.info_line.entity_variant.painting.title_only": "Painting Variant: §b%s§r",
"minihud.info_line.entity_variant.painting.author_only": "Painting Variant: by §e%s§r",
"minihud.info_line.entity_variant.parrot": "Parrot Variant: §b%s§r",
"minihud.info_line.entity_variant.rabbit": "Rabbit Variant: §b%s§r",
"minihud.info_line.entity_variant.sheep": "Sheep Color: §b%s§r",
"minihud.info_line.entity_variant.tropical_fish": "Tropical Fish Variant: §b%s§r",
"minihud.info_line.entity_variant.wolf": "Wolf Variant: §b%s§r (%s collar)",
Expand Down
4 changes: 4 additions & 0 deletions src/main/resources/assets/minihud/lang/zh_tw.json
Original file line number Diff line number Diff line change
Expand Up @@ -929,7 +929,11 @@
"minihud.info_line.entity_variant.cat": "Cat Variant: §b%s§r (%s collar)",
"minihud.info_line.entity_variant.frog": "Frog Variant: §b%s§r",
"minihud.info_line.entity_variant.horse": "Horse Variant: §b%s / %s§r",
"minihud.info_line.entity_variant.painting.both": "Painting Variant: §b%s§r by §e%s§r",
"minihud.info_line.entity_variant.painting.title_only": "Painting Variant: §b%s§r",
"minihud.info_line.entity_variant.painting.author_only": "Painting Variant: by §e%s§r",
"minihud.info_line.entity_variant.parrot": "Parrot Variant: §b%s§r",
"minihud.info_line.entity_variant.rabbit": "Rabbit Variant: §b%s§r",
"minihud.info_line.entity_variant.sheep": "Sheep Color: §b%s§r",
"minihud.info_line.entity_variant.tropical_fish": "Tropical Fish Variant: §b%s§r",
"minihud.info_line.entity_variant.wolf": "Wolf Variant: §b%s§r (%s collar)",
Expand Down

0 comments on commit dae363b

Please sign in to comment.