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();
}
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;
}
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);
}
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;
}
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);
}
Aggregations