Search in sources :

Example 21 with Skill

use of jackiecrazy.wardance.skill.Skill in project WarDance by Jackiecrazy.

the class SkillSelectionScreen method init.

// private SkillSelectionScreen.SortType sortType = SkillSelectionScreen.SortType.NORMAL;
/*
    there needs to be a skill list widget that lists all castable skills, composed of skill entries, on the very very left, and maybe a search bar as well
    a skill entry is made from the main skill icon, the name, and a smaller assortment of icons representing available variations. They can be kind of generic across every skill
    clicking a skill highlights it and will call the main screen to display text down the middle to describe the skill
    A little panel at the bottom is reserved for displaying variation descriptions, to show the base and variation effects in a single screen.
    On the right is the skill octagon and four slots to click skills into
    these slots can be tinted blue if it is selected, grey if it's selectable, orange if it's not selectable, yellow if they share a parent skill, and red if the two skills are incompatible (such as breathing fire while chanting a spell).
    Upon closing, the octagon is sent to the server, double checked, and finalized.
     */
@Override
public void init() {
    for (SkillCategory mod : bases) {
        listWidth = Math.max(listWidth, getFontRenderer().width(mod.name().getString()) + 20);
    }
    listWidth = Math.max(Math.min(listWidth, width / 5), 100);
    listWidth += listWidth % numButtons != 0 ? (numButtons - listWidth % numButtons) : 0;
    int skillCircleWidth = 150;
    int infoWidth = this.width - this.listWidth - skillCircleWidth - (PADDING * 4);
    int doneButtonWidth = Math.min(infoWidth, 200);
    int y = this.height - 20 - PADDING;
    this.addButton(new Button(((listWidth + PADDING + this.width - doneButtonWidth) / 2), y, doneButtonWidth, 20, new TranslationTextComponent("gui.done"), b -> SkillSelectionScreen.this.onClose()));
    // y -= 20 + PADDING;
    // y -= 14 + PADDING + 1;
    search = new TextFieldWidget(getFontRenderer(), PADDING + 1, y, listWidth - 2, 14, new TranslationTextComponent("fml.menu.mods.search"));
    int fullButtonHeight = PADDING + 20 + PADDING;
    this.skillList = new SkillListWidget(this, listWidth, PADDING, search.y - getFontRenderer().lineHeight - PADDING);
    this.skillList.setLeftPos(PADDING);
    int split = (this.height - PADDING * 2 - fullButtonHeight) * 2 / 3;
    this.skillInfo = new InfoPanel(this.minecraft, infoWidth, split, PADDING);
    this.variationList = new VariationListWidget(this, infoWidth - 9, split + PADDING * 2, search.y - getFontRenderer().lineHeight - PADDING);
    this.variationList.setLeftPos(PADDING * 2 + listWidth);
    List<Skill> oldList = CasterData.getCap(Minecraft.getInstance().player).getEquippedSkills();
    for (int d = 0; d < skillPie.length; d++) {
        skillPie[d] = new SkillSliceButton(this, width - skillCircleWidth, PADDING / 2, skillCircleWidth, fixedU[d], fixedV[d], radial, d);
        skillPie[d].setSkill(oldList.get(d));
        children.add(skillPie[d]);
    }
    for (int d = 0; d < passives.length; d++) {
        passives[d] = new PassiveButton(this, width - skillCircleWidth + d * (31), PADDING + skillCircleWidth, 23, d);
        passives[d].setSkill(oldList.get(d + skillPie.length));
        children.add(passives[d]);
    }
    children.add(search);
    children.add(skillList);
    children.add(variationList);
    children.add(skillInfo);
    search.setFocus(false);
    search.setCanLoseFocus(true);
    // final int width = listWidth / numButtons;
    // int x = PADDING;
    // addButton(AdvancedData.NORMAL.button = new Button(x, PADDING, width - buttonMargin, 20, AdvancedData.NORMAL.getButtonText(), b -> resortMods(AdvancedData.NORMAL)));
    // x += width + buttonMargin;
    // addButton(AdvancedData.A_TO_Z.button = new Button(x, PADDING, width - buttonMargin, 20, AdvancedData.A_TO_Z.getButtonText(), b -> resortMods(AdvancedData.A_TO_Z)));
    // x += width + buttonMargin;
    // addButton(AdvancedData.Z_TO_A.button = new Button(x, PADDING, width - buttonMargin, 20, AdvancedData.Z_TO_A.getButtonText(), b -> resortMods(AdvancedData.Z_TO_A)));
    resortMods(AdvancedData.NORMAL);
    updateCache();
    setInitialFocus(skillList);
}
Also used : net.minecraft.util.text(net.minecraft.util.text) ForgeHooks(net.minecraftforge.common.ForgeHooks) SkillCategory(jackiecrazy.wardance.skill.SkillCategory) CasterData(jackiecrazy.wardance.capability.skill.CasterData) UpdateSkillSelectionPacket(jackiecrazy.wardance.networking.UpdateSkillSelectionPacket) IReorderingProcessor(net.minecraft.util.IReorderingProcessor) Function(java.util.function.Function) ArrayList(java.util.ArrayList) Minecraft(net.minecraft.client.Minecraft) TextFieldWidget(net.minecraft.client.gui.widget.TextFieldWidget) Button(net.minecraft.client.gui.widget.button.Button) MatrixStack(com.mojang.blaze3d.matrix.MatrixStack) Skill(jackiecrazy.wardance.skill.Skill) StringUtils(net.minecraftforge.fml.loading.StringUtils) GuiUtils(net.minecraftforge.fml.client.gui.GuiUtils) ExtendedList(net.minecraft.client.gui.widget.list.ExtendedList) CombatChannel(jackiecrazy.wardance.networking.CombatChannel) Collectors(java.util.stream.Collectors) Consumer(java.util.function.Consumer) List(java.util.List) Screen(net.minecraft.client.gui.screen.Screen) FontRenderer(net.minecraft.client.gui.FontRenderer) Tessellator(net.minecraft.client.renderer.Tessellator) ScrollPanel(net.minecraftforge.client.gui.ScrollPanel) RenderSystem(com.mojang.blaze3d.systems.RenderSystem) ResourceLocation(net.minecraft.util.ResourceLocation) WarDance(jackiecrazy.wardance.WarDance) Comparator(java.util.Comparator) Collections(java.util.Collections) SkillCategory(jackiecrazy.wardance.skill.SkillCategory) Skill(jackiecrazy.wardance.skill.Skill) Button(net.minecraft.client.gui.widget.button.Button) TextFieldWidget(net.minecraft.client.gui.widget.TextFieldWidget)

Example 22 with Skill

use of jackiecrazy.wardance.skill.Skill in project WarDance by Jackiecrazy.

the class SkillArgument method parse.

@Override
public Skill parse(StringReader reader) throws CommandSyntaxException {
    final int start = reader.getCursor();
    final ResourceLocation skill = ResourceLocation.read(reader);
    final Skill result = Skill.getSkill(skill);
    if (result == null) {
        reader.setCursor(start);
        throw CommandSyntaxException.BUILT_IN_EXCEPTIONS.dispatcherUnknownArgument().createWithContext(reader);
    }
    return result;
}
Also used : Skill(jackiecrazy.wardance.skill.Skill) ResourceLocation(net.minecraft.util.ResourceLocation)

Example 23 with Skill

use of jackiecrazy.wardance.skill.Skill in project WarDance by Jackiecrazy.

the class SkillEventHandler method dropse.

@SubscribeEvent(priority = EventPriority.LOWEST)
public static void dropse(LootingLevelEvent e) {
    if (e.getEntityLiving() != null && !e.getEntityLiving().isEffectiveAi())
        return;
    if (e.getDamageSource().getEntity() instanceof LivingEntity) {
        LivingEntity attacker = (LivingEntity) e.getDamageSource().getEntity();
        ISkillCapability isc = CasterData.getCap(attacker);
        for (Skill s : isc.getEquippedSkills()) {
            isc.getSkillData(s).ifPresent(d -> s.onProc(attacker, e, d.getState(), d, e.getEntityLiving()));
        }
    }
    ISkillCapability isc = CasterData.getCap(e.getEntityLiving());
    for (Skill s : isc.getEquippedSkills()) {
        isc.getSkillData(s).ifPresent(d -> s.onProc(e.getEntityLiving(), e, d.getState(), d, null));
    }
}
Also used : LivingEntity(net.minecraft.entity.LivingEntity) Skill(jackiecrazy.wardance.skill.Skill) ISkillCapability(jackiecrazy.wardance.capability.skill.ISkillCapability) SubscribeEvent(net.minecraftforge.eventbus.api.SubscribeEvent)

Example 24 with Skill

use of jackiecrazy.wardance.skill.Skill in project WarDance by Jackiecrazy.

the class SkillEventHandler method parryFlags.

@SubscribeEvent(priority = EventPriority.HIGHEST)
public static void parryFlags(ParryEvent e) {
    if (!e.getEntityLiving().isEffectiveAi())
        return;
    if (e.getAttacker() != null) {
        LivingEntity attacker = e.getAttacker();
        ISkillCapability isc = CasterData.getCap(attacker);
        for (Skill s : isc.getEquippedSkills()) {
            isc.getSkillData(s).ifPresent(d -> s.onProc(attacker, e, d.getState(), d, e.getEntityLiving()));
        }
    }
    ISkillCapability isc = CasterData.getCap(e.getEntityLiving());
    for (Skill s : isc.getEquippedSkills()) {
        isc.getSkillData(s).ifPresent(d -> s.onProc(e.getEntityLiving(), e, d.getState(), d, e.getAttacker()));
    }
}
Also used : LivingEntity(net.minecraft.entity.LivingEntity) Skill(jackiecrazy.wardance.skill.Skill) ISkillCapability(jackiecrazy.wardance.capability.skill.ISkillCapability) SubscribeEvent(net.minecraftforge.eventbus.api.SubscribeEvent)

Example 25 with Skill

use of jackiecrazy.wardance.skill.Skill in project WarDance by Jackiecrazy.

the class SkillEventHandler method deathFlag.

@SubscribeEvent(priority = EventPriority.HIGHEST)
public static void deathFlag(LivingDeathEvent e) {
    if (!e.getEntityLiving().isEffectiveAi())
        return;
    if (e.getSource().getEntity() instanceof LivingEntity) {
        LivingEntity attacker = (LivingEntity) e.getSource().getEntity();
        ISkillCapability isc = CasterData.getCap(attacker);
        for (Skill s : isc.getEquippedSkills()) {
            isc.getSkillData(s).ifPresent(d -> s.onProc(attacker, e, d.getState(), d, e.getEntityLiving()));
        }
    }
    ISkillCapability isc = CasterData.getCap(e.getEntityLiving());
    for (Skill s : isc.getEquippedSkills()) {
        isc.getSkillData(s).ifPresent(d -> s.onProc(e.getEntityLiving(), e, d.getState(), d, null));
    }
}
Also used : LivingEntity(net.minecraft.entity.LivingEntity) Skill(jackiecrazy.wardance.skill.Skill) ISkillCapability(jackiecrazy.wardance.capability.skill.ISkillCapability) SubscribeEvent(net.minecraftforge.eventbus.api.SubscribeEvent)

Aggregations

Skill (jackiecrazy.wardance.skill.Skill)32 ISkillCapability (jackiecrazy.wardance.capability.skill.ISkillCapability)23 SubscribeEvent (net.minecraftforge.eventbus.api.SubscribeEvent)23 LivingEntity (net.minecraft.entity.LivingEntity)21 MatrixStack (com.mojang.blaze3d.matrix.MatrixStack)3 ICombatCapability (jackiecrazy.wardance.capability.resources.ICombatCapability)3 SkillData (jackiecrazy.wardance.skill.SkillData)3 ArrayList (java.util.ArrayList)3 List (java.util.List)3 Minecraft (net.minecraft.client.Minecraft)3 PlayerEntity (net.minecraft.entity.player.PlayerEntity)3 ResourceLocation (net.minecraft.util.ResourceLocation)3 TranslationTextComponent (net.minecraft.util.text.TranslationTextComponent)3 RenderSystem (com.mojang.blaze3d.systems.RenderSystem)2 WarDance (jackiecrazy.wardance.WarDance)2 CasterData (jackiecrazy.wardance.capability.skill.CasterData)2 CombatChannel (jackiecrazy.wardance.networking.CombatChannel)2 UpdateSkillSelectionPacket (jackiecrazy.wardance.networking.UpdateSkillSelectionPacket)2 Screen (net.minecraft.client.gui.screen.Screen)2 Tessellator (net.minecraft.client.renderer.Tessellator)2