Search in sources :

Example 1 with ProjectileEntityAccessor

use of mathax.client.mixin.ProjectileEntityAccessor in project Client by MatHax.

the class EntityOwner method onRender2D.

@EventHandler
private void onRender2D(Render2DEvent event) {
    for (Entity entity : mc.world.getEntities()) {
        UUID ownerUuid;
        if (entity instanceof TameableEntity)
            ownerUuid = ((TameableEntity) entity).getOwnerUuid();
        else if (entity instanceof HorseBaseEntity)
            ownerUuid = ((HorseBaseEntity) entity).getOwnerUuid();
        else if (entity instanceof ProjectileEntity && projectiles.get())
            ownerUuid = ((ProjectileEntityAccessor) entity).getOwnerUuid();
        else
            continue;
        if (ownerUuid != null) {
            pos.set(entity, event.tickDelta);
            pos.add(0, entity.getEyeHeight(entity.getPose()) + 0.75, 0);
            if (NametagUtils.to2D(pos, scale.get())) {
                renderNametag(getOwnerName(ownerUuid));
            }
        }
    }
}
Also used : Entity(net.minecraft.entity.Entity) PlayerEntity(net.minecraft.entity.player.PlayerEntity) ProjectileEntity(net.minecraft.entity.projectile.ProjectileEntity) HorseBaseEntity(net.minecraft.entity.passive.HorseBaseEntity) TameableEntity(net.minecraft.entity.passive.TameableEntity) ProjectileEntity(net.minecraft.entity.projectile.ProjectileEntity) TameableEntity(net.minecraft.entity.passive.TameableEntity) UUID(java.util.UUID) HorseBaseEntity(net.minecraft.entity.passive.HorseBaseEntity) ProjectileEntityAccessor(mathax.client.mixin.ProjectileEntityAccessor) EventHandler(mathax.client.eventbus.EventHandler)

Aggregations

UUID (java.util.UUID)1 EventHandler (mathax.client.eventbus.EventHandler)1 ProjectileEntityAccessor (mathax.client.mixin.ProjectileEntityAccessor)1 Entity (net.minecraft.entity.Entity)1 HorseBaseEntity (net.minecraft.entity.passive.HorseBaseEntity)1 TameableEntity (net.minecraft.entity.passive.TameableEntity)1 PlayerEntity (net.minecraft.entity.player.PlayerEntity)1 ProjectileEntity (net.minecraft.entity.projectile.ProjectileEntity)1