Search in sources :

Example 1 with Ability

use of com.lying.variousoddities.species.abilities.Ability in project VariousOddities by Lyinginbedmon.

the class ScreenSelectSpecies method render.

public void render(MatrixStack matrixStack, int mouseX, int mouseY, float partialTicks) {
    renderDirtBackground(0);
    this.speciesList.render(matrixStack, mouseX, mouseY, partialTicks);
    this.abilityList.render(matrixStack, mouseX, mouseY, partialTicks);
    renderBackgroundLayer(matrixStack, partialTicks);
    hideListEdge();
    drawListBorder(matrixStack, this.speciesList, this.height, 0, 180, 6, TEXTURE);
    int yPos = 20;
    drawCenteredString(matrixStack, this.font, this.title, this.width / 2, 12, 16777215);
    yPos += 15;
    if (selectableSpecies.isEmpty())
        return;
    // Draw species display name
    Species currentSpecies = getCurrentSpecies();
    this.selectButton.setMessage(currentSpecies.getDisplayName());
    yPos += this.font.FONT_HEIGHT + 12;
    // Render stars of appropriate colour for power
    drawStars(matrixStack, yPos, currentSpecies.getPower());
    yPos += this.font.FONT_HEIGHT + 3;
    // Display types
    int health = 20;
    if (currentSpecies.hasTypes()) {
        ITextComponent typesHeader = currentSpecies.getTypes().toHeader();
        drawCenteredString(matrixStack, this.font, typesHeader, this.width / 2, yPos, -1);
        health = (int) currentSpecies.getTypes().getPlayerHealth();
    }
    // Health and armour
    yPos += this.font.FONT_HEIGHT + 3;
    double armour = 0;
    List<Ability> abilities = currentSpecies.getFullAbilities();
    if (!abilities.isEmpty())
        for (Ability ability : abilities) {
            if (ability.getRegistryName().equals(AbilityNaturalArmour.REGISTRY_NAME))
                armour += ((AbilityNaturalArmour) ability).amount();
            if (ability.getRegistryName().equals(AbilityModifierCon.REGISTRY_NAME))
                health += ((AbilityModifier) ability).amount();
        }
    ;
    drawHealthAndArmour(matrixStack, this.font, this.width / 2, yPos, health, (int) armour);
    // Display abilities
    yPos += this.font.FONT_HEIGHT + 3;
    this.abilityList.setTop(yPos);
    super.render(matrixStack, mouseX, mouseY, partialTicks);
}
Also used : Ability(com.lying.variousoddities.species.abilities.Ability) ITextComponent(net.minecraft.util.text.ITextComponent) Species(com.lying.variousoddities.species.Species)

Example 2 with Ability

use of com.lying.variousoddities.species.abilities.Ability in project VariousOddities by Lyinginbedmon.

the class ScreenSelectTemplates method displayBaseStats.

@SuppressWarnings("deprecation")
private void displayBaseStats(MatrixStack matrixStack, int mouseX, int mouseY, int xPos) {
    // Describe base creature
    RenderSystem.color4f(1.0F, 1.0F, 1.0F, 1.0F);
    Minecraft.getInstance().getTextureManager().bindTexture(TEXTURES);
    int yPos = 20 + this.font.FONT_HEIGHT;
    this.blit(matrixStack, xPos - 100, 20 + this.font.FONT_HEIGHT, 0, 65, 100, 120);
    xPos -= 8;
    yPos += 10;
    drawString(matrixStack, this.font, this.baseSpecies.getDisplayName().getString(), xPos - this.font.getStringWidth(this.baseSpecies.getDisplayName().getString()) - 2, yPos, 16777215);
    yPos += this.font.FONT_HEIGHT + 8;
    int basePower = this.baseSpecies.getPower();
    int totalStars = Math.max(1, Math.abs(basePower));
    while (totalStars > 0) {
        int stars = Math.min(5, totalStars);
        ScreenSelectSpecies.drawStars(matrixStack, Math.min(5, basePower), xPos - (stars * 9), yPos);
        totalStars -= stars;
        yPos += this.font.FONT_HEIGHT;
    }
    yPos += 1;
    Types baseTypes = new Types(getBaseTypes());
    ITextComponent baseTypesText = baseTypes.toHeader();
    if (baseTypesText.getString().length() > 15)
        baseTypesText = new StringTextComponent(baseTypesText.getString().substring(0, 15) + "...");
    drawString(matrixStack, this.font, baseTypesText, xPos - this.font.getStringWidth(baseTypesText.getString()), yPos, 16777215);
    yPos += this.font.FONT_HEIGHT + 5;
    Map<ResourceLocation, Ability> baseAbilities = getBaseAbilities();
    double health = baseTypes.getPlayerHealth();
    double armour = 0D;
    if (!baseAbilities.isEmpty())
        for (Ability ability : baseAbilities.values()) {
            if (ability.getRegistryName().equals(AbilityNaturalArmour.REGISTRY_NAME))
                armour += ((AbilityNaturalArmour) ability).amount();
            if (ability.getRegistryName().equals(AbilityModifierCon.REGISTRY_NAME))
                health += ((AbilityModifier) ability).amount();
        }
    ;
    int hudWidth = 10 + this.font.getStringWidth(String.valueOf((int) health)) + 5 + 10 + this.font.getStringWidth(String.valueOf((int) armour));
    drawHealthAndArmour(matrixStack, xPos - hudWidth, yPos, (int) health, (int) armour);
    yPos += this.font.FONT_HEIGHT + 5;
    ITextComponent abilityCount = new TranslationTextComponent("gui." + Reference.ModInfo.MOD_ID + ".templates_select.ability_tally", baseAbilities.size());
    drawString(matrixStack, this.font, abilityCount, xPos - this.font.getStringWidth(abilityCount.getString()), yPos, 16777215);
    if (mouseX <= xPos && mouseY <= (yPos + font.FONT_HEIGHT) && mouseY >= 29)
        renderCharacterSummary(matrixStack, mouseX, mouseY, baseTypes, baseAbilities);
}
Also used : Ability(com.lying.variousoddities.species.abilities.Ability) Types(com.lying.variousoddities.species.types.Types) ResourceLocation(net.minecraft.util.ResourceLocation) ITextComponent(net.minecraft.util.text.ITextComponent) TranslationTextComponent(net.minecraft.util.text.TranslationTextComponent) StringTextComponent(net.minecraft.util.text.StringTextComponent)

Example 3 with Ability

use of com.lying.variousoddities.species.abilities.Ability in project VariousOddities by Lyinginbedmon.

the class CommandAbilities method listAbilities.

private static int listAbilities(Entity entity, CommandSource source) throws CommandSyntaxException {
    if (entity instanceof LivingEntity) {
        LivingEntity living = (LivingEntity) entity;
        Map<ResourceLocation, Ability> abilityMap = AbilityRegistry.getCreatureAbilities(living);
        source.sendFeedback(new TranslationTextComponent(translationSlug + "list", living.getDisplayName(), abilityMap.size()), true);
        List<Ability> abilities = Lists.newArrayList(abilityMap.values());
        Collections.sort(abilities, Ability.SORT_ABILITY);
        for (Ability ability : abilities) source.sendFeedback(new StringTextComponent("  ").append(getAbilityWithEdit(ability, living)), false);
    } else
        throw INVALID_ENTITY_EXCEPTION.create();
    return 15;
}
Also used : LivingEntity(net.minecraft.entity.LivingEntity) Ability(com.lying.variousoddities.species.abilities.Ability) ResourceLocation(net.minecraft.util.ResourceLocation) TranslationTextComponent(net.minecraft.util.text.TranslationTextComponent) StringTextComponent(net.minecraft.util.text.StringTextComponent)

Example 4 with Ability

use of com.lying.variousoddities.species.abilities.Ability in project VariousOddities by Lyinginbedmon.

the class ElytraMixin method canElytraFly.

private boolean canElytraFly() {
    LivingEntity living = (LivingEntity) (Object) this;
    Map<ResourceLocation, Ability> abilityMap = AbilityRegistry.getCreatureAbilities(living);
    return abilityMap.containsKey(AbilityFlight.REGISTRY_NAME) && ((AbilityFlight) abilityMap.get(AbilityFlight.REGISTRY_NAME)).isActive();
}
Also used : LivingEntity(net.minecraft.entity.LivingEntity) Ability(com.lying.variousoddities.species.abilities.Ability) ResourceLocation(net.minecraft.util.ResourceLocation)

Example 5 with Ability

use of com.lying.variousoddities.species.abilities.Ability in project VariousOddities by Lyinginbedmon.

the class VOBusClient method onLivingJump.

@SubscribeEvent
public static void onLivingJump(LivingUpdateEvent event) {
    if (event.getEntityLiving() == mc.player) {
        ClientPlayerEntity player = (ClientPlayerEntity) event.getEntityLiving();
        LivingData data = LivingData.forEntity(event.getEntityLiving());
        Abilities abilities = data.getAbilities();
        Map<ResourceLocation, Ability> abilityMap = AbilityRegistry.getCreatureAbilities(player);
        if (player.movementInput.jump && abilities.canBonusJump) {
            if (AbilitySwim.isEntitySwimming(player)) {
                if (abilityMap.containsKey(AbilitySwim.REGISTRY_NAME)) {
                    abilities.doWaterJump();
                    PacketHandler.sendToServer(new PacketBonusJump(false));
                }
            } else if (!player.isOnGround()) {
                if (abilityMap.containsKey(AbilityFlight.REGISTRY_NAME) && abilityMap.get(AbilityFlight.REGISTRY_NAME).isActive()) {
                    abilities.doAirJump();
                    player.connection.sendPacket(new CEntityActionPacket(player, CEntityActionPacket.Action.START_FALL_FLYING));
                    PacketHandler.sendToServer(new PacketBonusJump());
                }
            }
        }
    }
}
Also used : Ability(com.lying.variousoddities.species.abilities.Ability) IPhasingAbility(com.lying.variousoddities.species.abilities.IPhasingAbility) Abilities(com.lying.variousoddities.capabilities.Abilities) ResourceLocation(net.minecraft.util.ResourceLocation) LivingData(com.lying.variousoddities.capabilities.LivingData) ClientPlayerEntity(net.minecraft.client.entity.player.ClientPlayerEntity) CEntityActionPacket(net.minecraft.network.play.client.CEntityActionPacket) PacketBonusJump(com.lying.variousoddities.network.PacketBonusJump) SubscribeEvent(net.minecraftforge.eventbus.api.SubscribeEvent)

Aggregations

Ability (com.lying.variousoddities.species.abilities.Ability)35 ResourceLocation (net.minecraft.util.ResourceLocation)21 IBonusJumpAbility (com.lying.variousoddities.species.abilities.IBonusJumpAbility)11 ICompoundAbility (com.lying.variousoddities.species.abilities.ICompoundAbility)11 StringTextComponent (net.minecraft.util.text.StringTextComponent)8 CompoundNBT (net.minecraft.nbt.CompoundNBT)6 TranslationTextComponent (net.minecraft.util.text.TranslationTextComponent)6 EnumCreatureType (com.lying.variousoddities.species.types.EnumCreatureType)5 Types (com.lying.variousoddities.species.types.Types)5 LivingEntity (net.minecraft.entity.LivingEntity)5 ITextComponent (net.minecraft.util.text.ITextComponent)5 Abilities (com.lying.variousoddities.capabilities.Abilities)4 HashMap (java.util.HashMap)4 PlayerEntity (net.minecraft.entity.player.PlayerEntity)4 ListNBT (net.minecraft.nbt.ListNBT)4 AbilityRemoveEvent (com.lying.variousoddities.api.event.AbilityEvent.AbilityRemoveEvent)3 Template (com.lying.variousoddities.species.Template)3 ActivatedAbility (com.lying.variousoddities.species.abilities.ActivatedAbility)3 IPhasingAbility (com.lying.variousoddities.species.abilities.IPhasingAbility)3 Inject (org.spongepowered.asm.mixin.injection.Inject)3