use of net.minecraft.entity.passive.TameableEntity in project BleachHack by BleachDrinker420.
the class Nametags method getAnimalLines.
public List<Text> getAnimalLines(LivingEntity animal) {
List<Text> lines = new ArrayList<>();
if (animal instanceof HorseBaseEntity || animal instanceof TameableEntity) {
boolean tame = animal instanceof HorseBaseEntity ? ((HorseBaseEntity) animal).isTame() : ((TameableEntity) animal).isTamed();
UUID ownerUUID = animal instanceof HorseBaseEntity ? ((HorseBaseEntity) animal).getOwnerUuid() : ((TameableEntity) animal).getOwnerUuid();
if (getSetting(2).asToggle().getChild(4).asToggle().getState() && !animal.isBaby() && (getSetting(2).asToggle().getChild(4).asToggle().getChild(0).asMode().getMode() != 1 || tame)) {
lines.add(0, new LiteralText(tame ? "Tamed: Yes" : "Tamed: No").formatted(tame ? Formatting.GREEN : Formatting.RED));
}
if (getSetting(2).asToggle().getChild(5).asToggle().getState() && ownerUUID != null) {
if (uuidCache.containsKey(ownerUUID)) {
lines.add(0, new LiteralText("Owner: " + uuidCache.get(ownerUUID)).formatted(Formatting.GREEN));
} else if (failedUUIDs.contains(ownerUUID)) {
lines.add(0, new LiteralText("Owner: " + Formatting.GRAY + "Invalid UUID!").formatted(Formatting.GREEN));
} else {
// Try to see if the owner is online on the server before calling the mojang api
Optional<GameProfile> owner = mc.player.networkHandler.getPlayerList().stream().map(PlayerListEntry::getProfile).filter(profile -> profile != null && ownerUUID.equals(profile.getId()) && profile.getName() != null).findFirst();
if (owner.isPresent()) {
uuidCache.put(ownerUUID, owner.get().getName());
} else if (!uuidQueue.contains(ownerUUID) && !uuidFutures.containsKey(ownerUUID)) {
uuidQueue.add(ownerUUID);
}
lines.add(0, new LiteralText("Owner: " + Formatting.GRAY + "Loading...").formatted(Formatting.GREEN));
}
}
if (getSetting(2).asToggle().getChild(6).asToggle().getState() && animal instanceof HorseBaseEntity) {
HorseBaseEntity he = (HorseBaseEntity) animal;
lines.add(0, new LiteralText(CmdEntityStats.getSpeed(he) + " m/s" + Formatting.GRAY + " | " + Formatting.RESET + CmdEntityStats.getJumpHeight(he) + " Jump").formatted(Formatting.GREEN));
}
}
List<Text> mainText = new ArrayList<>();
if (getSetting(2).asToggle().getChild(2).asToggle().getState()) {
// Name
mainText.add(((MutableText) animal.getName()).formatted(Formatting.GREEN));
}
if (getSetting(2).asToggle().getChild(3).asToggle().getState()) {
// Health
if (getSetting(0).asMode().getMode() == 2) {
lines.add(0, getHealthText(animal));
} else {
mainText.add(getHealthText(animal));
}
}
if (!mainText.isEmpty())
lines.add(Texts.join(mainText, new LiteralText(" ")));
return lines;
}
use of net.minecraft.entity.passive.TameableEntity in project LittleMaidReBirth-Fabric by SistrScarlet.
the class OpenIFFScreenPacket method openIFFScreen.
private static void openIFFScreen(int id, PlayerEntity player) {
Entity entity = player.world.getEntityById(id);
if (!(entity instanceof HasIFF) || (entity instanceof TameableEntity && !player.getUuid().equals(((TameableEntity) entity).getOwnerUuid()))) {
return;
}
sendS2CPacket(entity, ((HasIFF) entity).getIFFs(), player);
}
Aggregations