Search in sources :

Example 1 with LivingEntity

use of net.minecraft.world.entity.LivingEntity in project MinecraftForge by MinecraftForge.

the class ForgeIngameGui method renderHealthMount.

protected void renderHealthMount(int width, int height, PoseStack mStack) {
    Player player = (Player) minecraft.getCameraEntity();
    Entity tmp = player.getVehicle();
    if (!(tmp instanceof LivingEntity))
        return;
    bind(GUI_ICONS_LOCATION);
    boolean unused = false;
    int left_align = width / 2 + 91;
    minecraft.getProfiler().popPush("mountHealth");
    RenderSystem.enableBlend();
    LivingEntity mount = (LivingEntity) tmp;
    int health = (int) Math.ceil((double) mount.getHealth());
    float healthMax = mount.getMaxHealth();
    int hearts = (int) (healthMax + 0.5F) / 2;
    if (hearts > 30)
        hearts = 30;
    final int MARGIN = 52;
    final int BACKGROUND = MARGIN + (unused ? 1 : 0);
    final int HALF = MARGIN + 45;
    final int FULL = MARGIN + 36;
    for (int heart = 0; hearts > 0; heart += 20) {
        int top = height - right_height;
        int rowCount = Math.min(hearts, 10);
        hearts -= rowCount;
        for (int i = 0; i < rowCount; ++i) {
            int x = left_align - i * 8 - 9;
            blit(mStack, x, top, BACKGROUND, 9, 9, 9);
            if (i * 2 + 1 + heart < health)
                blit(mStack, x, top, FULL, 9, 9, 9);
            else if (i * 2 + 1 + heart == health)
                blit(mStack, x, top, HALF, 9, 9, 9);
        }
        right_height += 10;
    }
    RenderSystem.disableBlend();
}
Also used : LivingEntity(net.minecraft.world.entity.LivingEntity) LivingEntity(net.minecraft.world.entity.LivingEntity) Entity(net.minecraft.world.entity.Entity) Player(net.minecraft.world.entity.player.Player)

Example 2 with LivingEntity

use of net.minecraft.world.entity.LivingEntity in project MinecraftForge by MinecraftForge.

the class IBlockRenderProperties method getFogColor.

/**
 * NOT CURRENTLY IMPLEMENTED
 * <p>
 * Use this to change the fog color used when the entity is "inside" a material.
 * Vec3d is used here as "r/g/b" 0 - 1 values.
 *
 * @param Level         The Level.
 * @param pos           The position at the entity viewport.
 * @param state         The state at the entity viewport.
 * @param entity        the entity
 * @param originalColor The current fog color, You are not expected to use this, Return as the default if applicable.
 * @return The new fog color.
 */
default Vector3d getFogColor(BlockState state, LevelReader Level, BlockPos pos, Entity entity, Vector3d originalColor, float partialTicks) {
    if (state.getMaterial() == Material.WATER) {
        float f12 = 0.0F;
        if (entity instanceof LivingEntity) {
            LivingEntity ent = (LivingEntity) entity;
            f12 = (float) EnchantmentHelper.getRespiration(ent) * 0.2F;
            if (ent.hasEffect(MobEffects.WATER_BREATHING)) {
                f12 = f12 * 0.3F + 0.6F;
            }
        }
        return new Vector3d(0.02F + f12, 0.02F + f12, 0.2F + f12);
    } else if (state.getMaterial() == Material.LAVA) {
        return new Vector3d(0.6F, 0.1F, 0.0F);
    }
    return originalColor;
}
Also used : LivingEntity(net.minecraft.world.entity.LivingEntity) Vector3d(com.mojang.math.Vector3d)

Example 3 with LivingEntity

use of net.minecraft.world.entity.LivingEntity in project MyPet by xXKeyleXx.

the class EntityRegistry method registerEntityType.

protected void registerEntityType(MyPetType petType, String key, DefaultedRegistry<EntityType<?>> entityRegistry) {
    EntityDimensions size = entityRegistry.get(new ResourceLocation(key.toLowerCase())).getDimensions();
    entityTypes.put(petType, Registry.register(entityRegistry, "mypet_" + key.toLowerCase(), EntityType.Builder.createNothing(MobCategory.CREATURE).noSave().noSummon().sized(size.width, size.height).build(key)));
    EntityType<? extends LivingEntity> types = (EntityType<? extends LivingEntity>) entityRegistry.get(new ResourceLocation(key));
    registerDefaultAttributes(entityTypes.get(petType), types);
    overwriteEntityID(entityTypes.get(petType), getEntityTypeId(petType, entityRegistry), entityRegistry);
}
Also used : EntityType(net.minecraft.world.entity.EntityType) LivingEntity(net.minecraft.world.entity.LivingEntity) EntityDimensions(net.minecraft.world.entity.EntityDimensions) ResourceLocation(net.minecraft.resources.ResourceLocation)

Example 4 with LivingEntity

use of net.minecraft.world.entity.LivingEntity in project MyPet by xXKeyleXx.

the class Sprint method shouldStart.

@Override
public boolean shouldStart() {
    if (!myPet.getSkills().isActive(SprintImpl.class)) {
        return false;
    }
    if (petEntity.getMyPet().getDamage() <= 0) {
        return false;
    }
    if (!this.petEntity.hasTarget()) {
        return false;
    }
    LivingEntity targetEntity = ((CraftLivingEntity) this.petEntity.getMyPetTarget()).getHandle();
    if (!targetEntity.isAlive()) {
        return false;
    }
    if (lastTarget == targetEntity) {
        return false;
    }
    if (petEntity.getMyPet().getRangedDamage() > 0 && this.petEntity.distanceToSqr(targetEntity) >= 16) {
        return false;
    }
    this.lastTarget = targetEntity;
    return true;
}
Also used : LivingEntity(net.minecraft.world.entity.LivingEntity) CraftLivingEntity(org.bukkit.craftbukkit.v1_17_R1.entity.CraftLivingEntity) SprintImpl(de.Keyle.MyPet.skill.skills.SprintImpl) CraftLivingEntity(org.bukkit.craftbukkit.v1_17_R1.entity.CraftLivingEntity)

Example 5 with LivingEntity

use of net.minecraft.world.entity.LivingEntity in project MyPet by xXKeyleXx.

the class EntityRegistry method registerEntityType.

protected void registerEntityType(MyPetType petType, String key, DefaultedRegistry<EntityType<?>> entityRegistry) {
    EntityDimensions size = entityRegistry.get(new ResourceLocation(key.toLowerCase())).getDimensions();
    entityTypes.put(petType, Registry.register(entityRegistry, "mypet_" + key.toLowerCase(), EntityType.Builder.createNothing(MobCategory.CREATURE).noSave().noSummon().sized(size.width, size.height).build(key)));
    EntityType<? extends LivingEntity> types = (EntityType<? extends LivingEntity>) entityRegistry.get(new ResourceLocation(key));
    registerDefaultAttributes(entityTypes.get(petType), types);
    overwriteEntityID(entityTypes.get(petType), getEntityTypeId(petType, entityRegistry), entityRegistry);
}
Also used : EntityType(net.minecraft.world.entity.EntityType) LivingEntity(net.minecraft.world.entity.LivingEntity) EntityDimensions(net.minecraft.world.entity.EntityDimensions) ResourceLocation(net.minecraft.resources.ResourceLocation)

Aggregations

LivingEntity (net.minecraft.world.entity.LivingEntity)32 Entity (net.minecraft.world.entity.Entity)15 Player (net.minecraft.world.entity.player.Player)11 DamageSource (net.minecraft.world.damagesource.DamageSource)10 ResourceLocation (net.minecraft.resources.ResourceLocation)9 ArrayList (java.util.ArrayList)8 BlockPos (net.minecraft.core.BlockPos)7 EquipmentSlot (net.minecraft.world.entity.EquipmentSlot)7 CauseStackManager (org.spongepowered.api.event.CauseStackManager)7 Overwrite (org.spongepowered.asm.mixin.Overwrite)7 List (java.util.List)6 Cause (org.spongepowered.api.event.Cause)6 DamageFunction (org.spongepowered.api.event.cause.entity.damage.DamageFunction)6 ItemStackSnapshot (org.spongepowered.api.item.inventory.ItemStackSnapshot)6 ServerWorld (org.spongepowered.api.world.server.ServerWorld)6 ItemStackUtil (org.spongepowered.common.item.util.ItemStackUtil)6 Collection (java.util.Collection)5 ServerLevel (net.minecraft.server.level.ServerLevel)5 ServerPlayer (net.minecraft.server.level.ServerPlayer)5 MobType (net.minecraft.world.entity.MobType)5