Search in sources :

Example 11 with TameableEntity

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;
}
Also used : TameableEntity(net.minecraft.entity.passive.TameableEntity) HorseBaseEntity(net.minecraft.entity.passive.HorseBaseEntity)

Example 12 with TameableEntity

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);
}
Also used : Entity(net.minecraft.entity.Entity) PlayerEntity(net.minecraft.entity.player.PlayerEntity) ServerPlayerEntity(net.minecraft.server.network.ServerPlayerEntity) TameableEntity(net.minecraft.entity.passive.TameableEntity) TameableEntity(net.minecraft.entity.passive.TameableEntity) HasIFF(net.sistr.littlemaidrebirth.entity.iff.HasIFF)

Aggregations

TameableEntity (net.minecraft.entity.passive.TameableEntity)12 Entity (net.minecraft.entity.Entity)8 PlayerEntity (net.minecraft.entity.player.PlayerEntity)7 UUID (java.util.UUID)4 LivingEntity (net.minecraft.entity.LivingEntity)4 ServerPlayerEntity (net.minecraft.entity.player.ServerPlayerEntity)4 HorseBaseEntity (net.minecraft.entity.passive.HorseBaseEntity)3 Inject (org.spongepowered.asm.mixin.injection.Inject)3 LivingEntityBridge (io.izzel.arclight.common.bridge.entity.LivingEntityBridge)2 Optional (java.util.Optional)2 EventHandler (meteordevelopment.orbit.EventHandler)2 ProjectileEntity (net.minecraft.entity.projectile.ProjectileEntity)2 Vector3d (net.minecraft.util.math.vector.Vector3d)2 Function (com.google.common.base.Function)1 MobEntityBridge (io.izzel.arclight.common.bridge.entity.MobEntityBridge)1 ServerPlayerEntityBridge (io.izzel.arclight.common.bridge.entity.player.ServerPlayerEntityBridge)1 WorldBridge (io.izzel.arclight.common.bridge.world.WorldBridge)1 Unpooled (io.netty.buffer.Unpooled)1 Collection (java.util.Collection)1 List (java.util.List)1