Search in sources :

Example 6 with ModuleInstanceModifier

use of com.teamwizardry.wizardry.api.spell.module.ModuleInstanceModifier in project Wizardry by TeamWizardry.

the class TableModule method drawComponent.

@Override
public void drawComponent(@NotNull Vec2d mousePos, float partialTicks) {
    super.drawComponent(mousePos, partialTicks);
    GlStateManager.color(1f, 1f, 1f, 1f);
    GlStateManager.enableAlpha();
    GlStateManager.enableTexture2D();
    Sprite plate;
    plate = isErrored() ? PLATE_HIGHLIGHTED_ERROR : (worktable.selectedModule == this ? PLATE_HIGHLIGHTED : PLATE);
    Vec2d pos = Vec2d.ZERO;
    GlStateManager.translate(0, 0, -20);
    if (hasTag("connecting")) {
        drawWire(pos.add(getSize().getX() / 2.0, getSize().getY() / 2.0), mousePos, getColorForModule(module.getModuleType()), Color.WHITE);
    }
    if (linksTo != null) {
        Vec2d posTo = linksTo.thisPosToOtherContext(this);
        drawWire(pos.add(getSize().getX() / 2.0, getSize().getY() / 2.0), posTo.add(getSize().getX() / 2.0, getSize().getY() / 2.0), getColorForModule(module.getModuleType()), getColorForModule(linksTo.getModule().getModuleType()));
    }
    GlStateManager.translate(0, 0, 20);
    if (isErrored() || worktable.selectedModule == this || (!benign && !worktable.animationPlaying && getMouseOver() && !hasTag("connecting"))) {
        GlStateManager.translate(0, 0, 80);
    }
    plate.bind();
    plate.draw(0, 0, 0, getSize().getXf(), getSize().getYf());
    float shrink = 4;
    icon.bind();
    icon.draw(0, shrink / 2.0f, shrink / 2.0f, getSize().getXf() - shrink, getSize().getYf() - shrink);
    HashMap<ModuleInstanceModifier, Integer> modifiers = new HashMap<>();
    List<ModuleInstanceModifier> modifierList = new ArrayList<>();
    for (ModuleInstance module : ModuleRegistry.INSTANCE.getModules(ModuleType.MODIFIER)) {
        if (!(module instanceof ModuleInstanceModifier))
            continue;
        if (!hasData(Integer.class, module.getNBTKey()))
            continue;
        modifiers.put((ModuleInstanceModifier) module, getData(Integer.class, module.getNBTKey()));
        modifierList.add((ModuleInstanceModifier) module);
    }
    int count = modifierList.size();
    for (int i = 0; i < count; i++) {
        ModuleInstanceModifier modifier = modifierList.get(i);
        Vec2d modSize = getSize().mul(0.75f);
        float angle = (float) (i * Math.PI * 2.0 / count);
        // RENDER PLATE
        {
            float x = (getSize().getXf() / 2f - modSize.getXf() / 2f) + MathHelper.cos(angle) * radius;
            float y = (getSize().getYf() / 2f - modSize.getYf() / 2f) + MathHelper.sin(angle) * radius;
            GlStateManager.pushMatrix();
            GlStateManager.translate(x, y, -10);
            plate.bind();
            plate.draw(0, 0, 0, modSize.getXf(), modSize.getYf());
            float modShrink = 4;
            Sprite modICon = new Sprite(new ResourceLocation(Wizardry.MODID, "textures/gui/worktable/icons/" + modifier.getNBTKey() + ".png"));
            modICon.bind();
            modICon.draw(0, modShrink / 2.0f, modShrink / 2.0f, modSize.getXf() - modShrink, modSize.getYf() - modShrink);
            GlStateManager.translate(-x, -y, 10);
            GlStateManager.popMatrix();
        }
        // RENDER TEXT
        {
            FontRenderer font = Minecraft.getMinecraft().fontRenderer;
            String txt = "x" + modifiers.get(modifier);
            float txtWidth = font.getStringWidth(txt);
            float txtHeight = font.FONT_HEIGHT;
            float x = (getSize().getXf() / 2f - txtWidth / 2f) + MathHelper.cos(angle) * textRadius;
            float y = (getSize().getYf() / 2f - txtHeight / 2f) + MathHelper.sin(angle) * textRadius;
            GlStateManager.pushMatrix();
            GlStateManager.translate(x, y, -15);
            font.drawString(txt, 0, 0, 0x000000);
            GlStateManager.color(1f, 1f, 1f, 1f);
            GlStateManager.translate(-x, -y, 15);
            GlStateManager.popMatrix();
        }
    }
    if (isErrored() || worktable.selectedModule == this || (!benign && !worktable.animationPlaying && getMouseOver() && !hasTag("connecting"))) {
        GlStateManager.translate(0, 0, -80);
    }
}
Also used : Sprite(com.teamwizardry.librarianlib.features.sprite.Sprite) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) Vec2d(com.teamwizardry.librarianlib.features.math.Vec2d) ModuleInstanceModifier(com.teamwizardry.wizardry.api.spell.module.ModuleInstanceModifier) ResourceLocation(net.minecraft.util.ResourceLocation) FontRenderer(net.minecraft.client.gui.FontRenderer) ModuleInstance(com.teamwizardry.wizardry.api.spell.module.ModuleInstance)

Example 7 with ModuleInstanceModifier

use of com.teamwizardry.wizardry.api.spell.module.ModuleInstanceModifier in project Wizardry by TeamWizardry.

the class WorktableGui method syncToServer.

public void syncToServer() {
    Set<CommonWorktableModule> commonModules = new HashSet<>();
    for (TableModule head : getSpellHeads()) {
        TableModule lastModule = head;
        CommonWorktableModule lastCommonModule = new CommonWorktableModule(lastModule.hashCode(), lastModule.getModule(), lastModule.getPos(), null, new HashMap<>());
        commonModules.add(lastCommonModule);
        while (lastModule != null) {
            if (lastModule != head) {
                CommonWorktableModule commonModule = new CommonWorktableModule(lastModule.hashCode(), lastModule.getModule(), lastModule.getPos(), null, new HashMap<>());
                lastCommonModule.setLinksTo(commonModule);
                lastCommonModule = commonModule;
            }
            for (ModuleInstance module : ModuleRegistry.INSTANCE.getModules(ModuleType.MODIFIER)) {
                if (!(module instanceof ModuleInstanceModifier))
                    continue;
                if (!lastModule.hasData(Integer.class, module.getNBTKey()))
                    continue;
                int count = lastModule.getData(Integer.class, module.getNBTKey());
                lastCommonModule.addModifier((ModuleInstanceModifier) module, count);
            }
            lastModule = lastModule.getLinksTo();
        }
    }
    int dim = Minecraft.getMinecraft().world.provider.getDimension();
    PacketHandler.NETWORK.sendToServer(new PacketSyncWorktable(dim, pos, commonModules));
}
Also used : PacketSyncWorktable(com.teamwizardry.wizardry.common.network.PacketSyncWorktable) CommonWorktableModule(com.teamwizardry.wizardry.api.spell.CommonWorktableModule) ModuleInstance(com.teamwizardry.wizardry.api.spell.module.ModuleInstance) ModuleInstanceModifier(com.teamwizardry.wizardry.api.spell.module.ModuleInstanceModifier)

Example 8 with ModuleInstanceModifier

use of com.teamwizardry.wizardry.api.spell.module.ModuleInstanceModifier in project Wizardry by TeamWizardry.

the class WorktableGui method playLoadAnimation.

public void playLoadAnimation(Set<CommonWorktableModule> commonModules, @Nullable Runnable finish) {
    animationPlaying = true;
    resetSelectedModule();
    ComponentVoid bookIconMask = new ComponentVoid(0, -100, 180, 100);
    paper.add(bookIconMask);
    Vec2d bookOrigin = new Vec2d((bookIconMask.getSize().getX() / 2.0) - 8, -(bookIconMask.getSize().getY() / 2.0) - 4);
    Runnable itemsRunnable = () -> {
        // PAPER ITEMS ANIMATION
        {
            for (CommonWorktableModule commonHead : commonModules) {
                CommonWorktableModule commonModule = commonHead;
                TableModule lastModule = new TableModule(this, commonHead.module, true, false);
                lastModule.setPos(commonHead.pos);
                while (commonModule != null) {
                    paper.add(lastModule);
                    DragMixin drag = new DragMixin(lastModule, vec2d -> vec2d);
                    drag.setDragOffset(new Vec2d(6, 6));
                    lastModule.setData(Vec2d.class, "true_pos", commonModule.pos);
                    for (ModuleInstanceModifier modifier : commonModule.modifiers.keySet()) {
                        lastModule.setData(Integer.class, modifier.getNBTKey(), commonModule.modifiers.get(modifier));
                    }
                    lastModule.radius = 0;
                    lastModule.textRadius = 0;
                    if (commonModule.linksTo != null) {
                        TableModule childModule = new TableModule(this, commonModule.linksTo.module, true, false);
                        childModule.setPos(bookOrigin);
                        lastModule.setLinksTo(childModule);
                        lastModule = childModule;
                    }
                    commonModule = commonModule.linksTo;
                }
            }
            for (GuiComponent component : paper.getChildren()) {
                if (!(component instanceof TableModule))
                    continue;
                TableModule module = (TableModule) component;
                Vec2d target = module.getData(Vec2d.class, "true_pos");
                if (target == null) {
                    module.invalidate();
                    continue;
                }
                Vec2d randGen = new Vec2d(RandUtil.nextDouble(-100, 100), RandUtil.nextDouble(-100, 100));
                Vec2d random = bookOrigin.add(randGen);
                float delay = RandUtil.nextFloat(0.2f, 0.3f);
                float dur = RandUtil.nextFloat(70, 100);
                ScheduledEventAnimation animSound1 = new ScheduledEventAnimation(dur * delay, () -> Minecraft.getMinecraft().player.playSound(ModSounds.WHOOSH, 1f, 1f));
                KeyframeAnimation<TableModule> animX = new KeyframeAnimation<>(module, "pos.x");
                animX.setDuration(dur);
                animX.setKeyframes(new Keyframe[] { new Keyframe(delay, bookOrigin.getX(), Easing.easeOutQuint), new Keyframe(0.5f, random.getX(), Easing.easeOutQuint), new Keyframe(0.6f, random.getX(), Easing.easeOutQuint), new Keyframe(1f, target.getX(), Easing.easeOutQuint) });
                KeyframeAnimation<TableModule> animY = new KeyframeAnimation<>(module, "pos.y");
                animY.setDuration(dur);
                animY.setKeyframes(new Keyframe[] { new Keyframe(delay, bookOrigin.getY(), Easing.easeOutQuint), new Keyframe(0.5f, random.getY(), Easing.easeOutQuint), new Keyframe(0.6f, random.getY(), Easing.easeOutQuint), new Keyframe(1f, target.getY(), Easing.easeOutQuint) });
                animY.setCompletion(() -> {
                    BasicAnimation<TableModule> animRadius = new BasicAnimation<>(module, "radius");
                    animRadius.setDuration(20);
                    animRadius.setEasing(Easing.easeOutCubic);
                    animRadius.setTo(10);
                    module.add(animRadius);
                    BasicAnimation<TableModule> animText = new BasicAnimation<>(module, "textRadius");
                    animText.setDuration(40);
                    animText.setEasing(Easing.easeOutCubic);
                    animText.setTo(0);
                    module.add(animText);
                });
                module.add(animX, animY, animSound1);
            }
        }
    };
    Runnable runnable = () -> {
        // GRAY BACKGROUND
        {
            ComponentRect grayBackground = new ComponentRect(0, 0, tableComponent.getSize().getXi(), tableComponent.getSize().getYi());
            grayBackground.getColor().setValue(new Color(0.05f, 0.05f, 0.05f, 0f));
            grayBackground.getTransform().setTranslateZ(200);
            grayBackground.BUS.hook(GuiComponentEvents.ComponentTickEvent.class, event -> {
                grayBackground.getColor().setValue(new Color(0.05f, 0.05f, 0.05f, backgroundAlpha));
            });
            // tableComponent.add(grayBackground);
            KeyframeAnimation<WorktableGui> anim = new KeyframeAnimation<>(this, "backgroundAlpha");
            anim.setDuration(100);
            anim.setKeyframes(new Keyframe[] { new Keyframe(0, 0f, Easing.easeInOutQuint), new Keyframe(0.2f, 0.65f, Easing.easeInOutQuint), new Keyframe(0.7f, 0.65f, Easing.easeInOutQuint), new Keyframe(1f, 0f, Easing.easeInOutQuint) });
            anim.setCompletion(grayBackground::invalidate);
        // getMainComponents().add(anim);
        }
        // BOOK PEAK ANIMATION
        {
            ComponentSprite bookIcon = new ComponentSprite(BOOK_ICON, (int) ((bookIconMask.getSize().getX() / 2.0) - 16), (int) (bookIconMask.getSize().getY() + 50), 32, 32);
            bookIconMask.add(bookIcon);
            bookIcon.getTransform().setTranslateZ(200);
            bookIconMask.clipping.setClipToBounds(true);
            bookIconMask.getTransform().setTranslateZ(250);
            final Vec2d originalPos = bookIcon.getPos();
            KeyframeAnimation<ComponentSprite> anim = new KeyframeAnimation<>(bookIcon, "pos.y");
            anim.setDuration(120);
            anim.setKeyframes(new Keyframe[] { new Keyframe(0, originalPos.getY(), Easing.linear), new Keyframe(0.4f, (bookIconMask.getSize().getY() / 2.0) - 25, Easing.easeInBack), new Keyframe(0.5f, (bookIconMask.getSize().getY() / 2.0) - 10, Easing.easeOutBack), new Keyframe(0.8f, (bookIconMask.getSize().getY() / 2.0) - 10, Easing.easeInBack), new Keyframe(1f, originalPos.getY(), Easing.easeInBack) });
            ScheduledEventAnimation animSound = new ScheduledEventAnimation(120 * 0.4f, () -> {
                Minecraft.getMinecraft().player.playSound(ModSounds.WHOOSH, 1f, 1f);
                itemsRunnable.run();
                ScheduledEventAnimation animFinish = new ScheduledEventAnimation(100, () -> {
                    bookIcon.invalidate();
                    if (finish == null)
                        animationPlaying = false;
                    else {
                        finish.run();
                    }
                });
                getMainComponents().add(animFinish);
            });
            bookIcon.add(anim, animSound);
        }
    };
    if (selectedModule != null) {
        selectedModule = null;
        getMainComponents().add(new ScheduledEventAnimation(5, runnable));
    } else
        runnable.run();
}
Also used : BasicAnimation(com.teamwizardry.librarianlib.features.animator.animations.BasicAnimation) GuiComponentEvents(com.teamwizardry.librarianlib.features.gui.component.GuiComponentEvents) ComponentSprite(com.teamwizardry.librarianlib.features.gui.components.ComponentSprite) ComponentVoid(com.teamwizardry.librarianlib.features.gui.components.ComponentVoid) GuiComponent(com.teamwizardry.librarianlib.features.gui.component.GuiComponent) CommonWorktableModule(com.teamwizardry.wizardry.api.spell.CommonWorktableModule) DragMixin(com.teamwizardry.librarianlib.features.gui.mixin.DragMixin) ScheduledEventAnimation(com.teamwizardry.librarianlib.features.animator.animations.ScheduledEventAnimation) Vec2d(com.teamwizardry.librarianlib.features.math.Vec2d) ModuleInstanceModifier(com.teamwizardry.wizardry.api.spell.module.ModuleInstanceModifier) Keyframe(com.teamwizardry.librarianlib.features.animator.animations.Keyframe) KeyframeAnimation(com.teamwizardry.librarianlib.features.animator.animations.KeyframeAnimation) ComponentRect(com.teamwizardry.librarianlib.features.gui.components.ComponentRect)

Example 9 with ModuleInstanceModifier

use of com.teamwizardry.wizardry.api.spell.module.ModuleInstanceModifier in project Wizardry by TeamWizardry.

the class ComponentModifiers method set.

public void set() {
    List<GuiComponent> children = new ArrayList<>(getChildren());
    // units: none (modifier)
    int childrenSize = children.size();
    // units: pixels
    float slideInDist = childrenSize * PIXELS_PER_BAR;
    for (int i = 0; i < childrenSize; i++) {
        // units: pixels
        int lengthToTravel = (i + 1) * PIXELS_PER_BAR;
        // units: ticks
        float slideDuration = SLIDE_IN_DURATION * lengthToTravel / slideInDist;
        // units: ticks
        float waitDuration = SLIDE_IN_DURATION - slideDuration;
        GuiComponent bar = children.get(i);
        BasicAnimation<GuiComponent> animPlate = new BasicAnimation<>(bar, "pos.y");
        // Use Easing.easeInOutBack for the sexiest effect. Important: do it for BOTH!
        animPlate.setEasing(Easing.easeInBack);
        // units: pixels
        animPlate.setFrom(lengthToTravel - PIXELS_PER_BAR);
        // units: pixels
        animPlate.setTo(-PIXELS_PER_BAR);
        // units: ticks
        animPlate.setDuration(slideDuration);
        animPlate.setCompletion(bar::invalidate);
        add(new ScheduledEventAnimation(waitDuration, () -> add(animPlate)));
    }
    Runnable begin = () -> {
        TableModule selectedModule = worktable.selectedModule;
        if (selectedModule == null) {
            animationPlaying = false;
            return;
        }
        ModuleInstance module = selectedModule.getModule();
        ModuleInstanceModifier[] applicableModifiers = module.applicableModifiers();
        if (applicableModifiers == null || applicableModifiers.length <= 0) {
            animationPlaying = false;
            return;
        }
        ModuleInstanceModifier[] modifiers = module.applicableModifiers();
        if (modifiers == null) {
            animationPlaying = false;
            return;
        }
        // units: none
        int modifiersSize = modifiers.length;
        // units: pixels
        float slideOutDist = modifiersSize * PIXELS_PER_BAR;
        // units: ticks
        float outDuration = SLIDE_OUT_DURATION * modifiersSize;
        add(new ScheduledEventAnimation(SLIDE_IN_DURATION, () -> animationPlaying = false));
        for (int i = 0; i < modifiers.length; i++) {
            // units: pixels
            int lengthToTravel = (i + 1) * PIXELS_PER_BAR;
            // units: ticks
            float slideDuration = outDuration * lengthToTravel / slideOutDist;
            ModuleInstanceModifier modifier = modifiers[i];
            ComponentRect bar = new ComponentRect(0, 0, getSize().getXi(), PIXELS_PER_BAR);
            bar.getColor().setValue(new Color(0x80000000, true));
            TableModule tableModifier = new TableModule(worktable, modifier, false, true);
            tableModifier.setEnableTooltip(true);
            tableModifier.getTransform().setTranslateZ(80);
            bar.add(tableModifier);
            ComponentText text = new ComponentText(20, 4, ComponentText.TextAlignH.LEFT, ComponentText.TextAlignV.TOP);
            text.getText().setValue(TextFormatting.GREEN + modifier.getShortHandName());
            bar.add(text);
            bar.setVisible(true);
            BasicAnimation<ComponentRect> animPlate = new BasicAnimation<>(bar, "pos.y");
            // Use Easing.easeInOutBack for the sexiest effect. Important: do it for BOTH!
            animPlate.setEasing(Easing.easeOutBack);
            // units: pixels
            animPlate.setFrom(-PIXELS_PER_BAR);
            // units: pixels
            animPlate.setTo(lengthToTravel - PIXELS_PER_BAR);
            // units: ticks
            animPlate.setDuration(slideDuration);
            animPlate.setCompletion(() -> Minecraft.getMinecraft().player.playSound(ModSounds.WHOOSH, 1f, 1f));
            add(animPlate);
            bar.render.getTooltip().func((Function<GuiComponent, List<String>>) t -> {
                List<String> txt = new ArrayList<>();
                if (worktable.animationPlaying || tableModifier.getMouseOver())
                    return txt;
                txt.add(TextFormatting.GOLD + modifier.getReadableName());
                if (GuiScreen.isShiftKeyDown())
                    txt.add(TextFormatting.GRAY + modifier.getDescription());
                else
                    txt.add(TextFormatting.GRAY + LibrarianLib.PROXY.translate("wizardry.misc.sneak"));
                return txt;
            });
            bar.BUS.hook(GuiComponentEvents.MouseInEvent.class, event -> {
                bar.getColor().setValue(new Color(0x66000000, true));
            });
            bar.BUS.hook(GuiComponentEvents.MouseOutEvent.class, event -> {
                bar.getColor().setValue(new Color(0x80000000, true));
            });
            bar.BUS.hook(GuiComponentEvents.MouseDownEvent.class, event -> {
                if (event.component.getMouseOver()) {
                    bar.getColor().setValue(new Color(0x4D000000, true));
                }
            });
            bar.BUS.hook(GuiComponentEvents.MouseUpEvent.class, event -> {
                if (event.component.getMouseOver()) {
                    bar.getColor().setValue(new Color(0x80000000, true));
                }
            });
            bar.BUS.hook(GuiComponentEvents.MouseClickEvent.class, (event) -> {
                if (!event.component.getMouseOver())
                    return;
                if (worktable.selectedModule == null)
                    return;
                int j = worktable.selectedModule.hasData(Integer.class, modifier.getNBTKey()) ? worktable.selectedModule.getData(Integer.class, modifier.getNBTKey()) : 0;
                int status = -1;
                if (event.getButton() == EnumMouseButton.LEFT) {
                    AttributeRange cap = null;
                    for (AttributeRegistry.Attribute modifiersAssigned : worktable.selectedModule.getModule().getAttributeRanges().keySet()) {
                        for (AttributeModifier attribute : modifier.getAttributeModifiers()) {
                            if (modifiersAssigned.getNbtName().equals(attribute.getAttribute().getNbtName())) {
                                cap = worktable.selectedModule.getModule().getAttributeRanges().get(modifiersAssigned);
                                break;
                            }
                        }
                    }
                    if (cap != null && cap.max <= j) {
                        Minecraft.getMinecraft().player.playSound(ModSounds.SPELL_FAIL, 1f, 1f);
                        return;
                    }
                    Minecraft.getMinecraft().player.playSound(ModSounds.POP, 1f, 1f);
                    worktable.selectedModule.setData(Integer.class, modifier.getNBTKey(), ++j);
                    status = 0;
                    worktable.setToastMessage("", Color.GREEN);
                    worktable.syncToServer();
                } else if (event.getButton() == EnumMouseButton.RIGHT) {
                    if (worktable.selectedModule.hasData(Integer.class, modifier.getNBTKey())) {
                        if (j > 0) {
                            Minecraft.getMinecraft().player.playSound(ModSounds.ZOOM, 1f, 1f);
                            worktable.selectedModule.setData(Integer.class, modifier.getNBTKey(), --j);
                            if (j <= 0) {
                                Minecraft.getMinecraft().player.playSound(ModSounds.SPELL_FAIL, 1f, 1f);
                                worktable.selectedModule.removeData(Integer.class, modifier.getNBTKey());
                            }
                            status = 1;
                            worktable.syncToServer();
                        }
                        worktable.setToastMessage("", Color.GREEN);
                    } else
                        Minecraft.getMinecraft().player.playSound(ModSounds.SPELL_FAIL, 1f, 1f);
                }
                if (status == -1)
                    return;
                TableModule fakePlate = new TableModule(worktable, modifier, false, true);
                fakePlate.getTransform().setTranslateZ(80);
                worktable.getMainComponents().add(fakePlate);
                Vec2d from = tableModifier.thisPosToOtherContext(worktable.getMainComponents());
                Vec2d to = worktable.selectedModule.thisPosToOtherContext(worktable.getMainComponents()).add(worktable.selectedModule.getSize().sub(tableModifier.getSize()).mul(0.5f));
                KeyframeAnimation<TableModule> anim = new KeyframeAnimation<>(fakePlate, "pos");
                anim.setDuration(20);
                if (status == 0) {
                    Vec2d rand = from.add(RandUtil.nextDouble(-10, 10), RandUtil.nextDouble(-10, 10));
                    anim.setKeyframes(new Keyframe[] { new Keyframe(0, from, Easing.easeOutQuint), new Keyframe(0.3f, rand, Easing.easeOutQuint), new Keyframe(0.35f, rand, Easing.easeOutQuint), new Keyframe(1f, to, Easing.easeInOutQuint) });
                } else {
                    Vec2d rand = to.add(RandUtil.nextDouble(-10, 10), RandUtil.nextDouble(-10, 10));
                    anim.setKeyframes(new Keyframe[] { new Keyframe(0, to, Easing.easeOutQuint), new Keyframe(0.3f, rand, Easing.easeOutQuint), new Keyframe(0.35f, rand, Easing.easeOutQuint), new Keyframe(1f, from, Easing.easeInOutQuint) });
                }
                anim.setCompletion(fakePlate::invalidate);
                worktable.getMainComponents().add(anim);
                worktable.paper.BUS.fire(new TableModule.ModuleUpdateEvent());
            });
            add(bar);
        }
    };
    if (childrenSize > 0)
        add(new ScheduledEventAnimation(SLIDE_IN_DURATION + SPACER_DURATION, begin));
    else
        begin.run();
}
Also used : ComponentRect(com.teamwizardry.librarianlib.features.gui.components.ComponentRect) ModuleInstanceModifier(com.teamwizardry.wizardry.api.spell.module.ModuleInstanceModifier) LibrarianLib(com.teamwizardry.librarianlib.core.LibrarianLib) Function(java.util.function.Function) ArrayList(java.util.ArrayList) Keyframe(com.teamwizardry.librarianlib.features.animator.animations.Keyframe) Minecraft(net.minecraft.client.Minecraft) ModSounds(com.teamwizardry.wizardry.init.ModSounds) Easing(com.teamwizardry.librarianlib.features.animator.Easing) Nonnull(javax.annotation.Nonnull) ScheduledEventAnimation(com.teamwizardry.librarianlib.features.animator.animations.ScheduledEventAnimation) KeyframeAnimation(com.teamwizardry.librarianlib.features.animator.animations.KeyframeAnimation) TextFormatting(net.minecraft.util.text.TextFormatting) EnumMouseButton(com.teamwizardry.librarianlib.features.gui.EnumMouseButton) AttributeRange(com.teamwizardry.wizardry.api.spell.attribute.AttributeRange) ModuleInstance(com.teamwizardry.wizardry.api.spell.module.ModuleInstance) GuiComponent(com.teamwizardry.librarianlib.features.gui.component.GuiComponent) ModuleInstanceShape(com.teamwizardry.wizardry.api.spell.module.ModuleInstanceShape) java.awt(java.awt) BasicAnimation(com.teamwizardry.librarianlib.features.animator.animations.BasicAnimation) GuiScreen(net.minecraft.client.gui.GuiScreen) List(java.util.List) AttributeRegistry(com.teamwizardry.wizardry.api.spell.attribute.AttributeRegistry) Vec2d(com.teamwizardry.librarianlib.features.math.Vec2d) GuiComponentEvents(com.teamwizardry.librarianlib.features.gui.component.GuiComponentEvents) ComponentText(com.teamwizardry.librarianlib.features.gui.components.ComponentText) RandUtil(com.teamwizardry.wizardry.api.util.RandUtil) AttributeModifier(com.teamwizardry.wizardry.api.spell.attribute.AttributeModifier) ArrayList(java.util.ArrayList) GuiComponent(com.teamwizardry.librarianlib.features.gui.component.GuiComponent) Vec2d(com.teamwizardry.librarianlib.features.math.Vec2d) ModuleInstanceModifier(com.teamwizardry.wizardry.api.spell.module.ModuleInstanceModifier) Function(java.util.function.Function) Keyframe(com.teamwizardry.librarianlib.features.animator.animations.Keyframe) KeyframeAnimation(com.teamwizardry.librarianlib.features.animator.animations.KeyframeAnimation) ModuleInstance(com.teamwizardry.wizardry.api.spell.module.ModuleInstance) BasicAnimation(com.teamwizardry.librarianlib.features.animator.animations.BasicAnimation) ScheduledEventAnimation(com.teamwizardry.librarianlib.features.animator.animations.ScheduledEventAnimation) AttributeModifier(com.teamwizardry.wizardry.api.spell.attribute.AttributeModifier) ComponentRect(com.teamwizardry.librarianlib.features.gui.components.ComponentRect) ComponentText(com.teamwizardry.librarianlib.features.gui.components.ComponentText) AttributeRange(com.teamwizardry.wizardry.api.spell.attribute.AttributeRange)

Example 10 with ModuleInstanceModifier

use of com.teamwizardry.wizardry.api.spell.module.ModuleInstanceModifier in project Wizardry by TeamWizardry.

the class CommandDebug method execute.

@Override
public void execute(@NotNull MinecraftServer server, @NotNull ICommandSender sender, @NotNull String[] args) throws WrongUsageException {
    if (args.length < 2)
        throw new WrongUsageException(getUsage(sender));
    ModuleInstance module = ModuleRegistry.INSTANCE.getModule(args[1]);
    if (module == null) {
        notifyCommandListener(sender, this, "wizardry.command." + getName() + ".module_not_found");
        return;
    }
    notifyCommandListener(sender, this, TextFormatting.YELLOW + " ________________________________________________\\\\");
    notifyCommandListener(sender, this, TextFormatting.YELLOW + " | " + TextFormatting.GRAY + "Module " + module.getReadableName() + ":");
    notifyCommandListener(sender, this, TextFormatting.YELLOW + " |  |_ " + TextFormatting.GREEN + "Description           " + TextFormatting.GRAY + " | " + TextFormatting.GRAY + module.getDescription());
    notifyCommandListener(sender, this, TextFormatting.YELLOW + " |  |_ " + TextFormatting.GREEN + "Item Stack            " + TextFormatting.GRAY + " | " + TextFormatting.GRAY + module.getItemStack().getDisplayName());
    notifyCommandListener(sender, this, TextFormatting.YELLOW + " |  |_ " + TextFormatting.GREEN + "Burnout Fill          " + TextFormatting.GRAY + " | " + TextFormatting.GRAY + module.getBurnoutFill());
    notifyCommandListener(sender, this, TextFormatting.YELLOW + " |  |  |_ " + TextFormatting.DARK_GREEN + "Burnout Multiplier" + TextFormatting.GRAY + " | " + TextFormatting.GRAY + module.getBurnoutMultiplier());
    notifyCommandListener(sender, this, TextFormatting.YELLOW + " |  |_ " + TextFormatting.GREEN + "Mana Drain           " + TextFormatting.GRAY + " | " + TextFormatting.GRAY + module.getManaDrain());
    notifyCommandListener(sender, this, TextFormatting.YELLOW + " |  |  |_" + TextFormatting.DARK_GREEN + "Mana Multiplier     " + TextFormatting.GRAY + " | " + TextFormatting.GRAY + module.getManaMultiplier());
    notifyCommandListener(sender, this, TextFormatting.YELLOW + " |  |_ " + TextFormatting.GREEN + "Power Multiplier     " + TextFormatting.GRAY + " | " + TextFormatting.GRAY + module.getPowerMultiplier());
    notifyCommandListener(sender, this, TextFormatting.YELLOW + " |  |_ " + TextFormatting.GREEN + "Charge Up Time      " + TextFormatting.GRAY + " | " + TextFormatting.GRAY + module.getChargeupTime());
    notifyCommandListener(sender, this, TextFormatting.YELLOW + " |  |_ " + TextFormatting.GREEN + "Cooldown Time        " + TextFormatting.GRAY + " | " + TextFormatting.GRAY + module.getCooldownTime());
    notifyCommandListener(sender, this, TextFormatting.YELLOW + " |  |_ " + TextFormatting.GREEN + "Primary Color        " + TextFormatting.GRAY + " | " + TextFormatting.RED + module.getPrimaryColor().getRed() + TextFormatting.GRAY + ", " + TextFormatting.GREEN + module.getPrimaryColor().getGreen() + TextFormatting.GRAY + ", " + TextFormatting.BLUE + module.getPrimaryColor().getBlue());
    notifyCommandListener(sender, this, TextFormatting.YELLOW + " |  |_ " + TextFormatting.GREEN + "Secondary Color    " + TextFormatting.GRAY + " | " + TextFormatting.RED + module.getSecondaryColor().getRed() + TextFormatting.GRAY + ", " + TextFormatting.GREEN + module.getSecondaryColor().getGreen() + TextFormatting.GRAY + ", " + TextFormatting.BLUE + module.getSecondaryColor().getBlue());
    if (!module.getAttributeModifiers().isEmpty())
        notifyCommandListener(sender, this, TextFormatting.YELLOW + " |  |_ " + TextFormatting.GREEN + "Default AttributeRegistry");
    for (AttributeModifier attributeModifier : module.getAttributeModifiers()) notifyCommandListener(sender, this, TextFormatting.YELLOW + " |  |  |_ " + TextFormatting.GRAY + attributeModifier.toString());
    ModuleInstanceModifier[] modifierList = module.applicableModifiers();
    if (modifierList != null) {
        notifyCommandListener(sender, this, TextFormatting.YELLOW + " |  |_ " + TextFormatting.GREEN + "Applicable Modifiers ");
        for (ModuleInstanceModifier modifier : modifierList) notifyCommandListener(sender, this, TextFormatting.YELLOW + " |     |_ " + TextFormatting.DARK_GREEN + modifier.getNBTKey());
    }
    notifyCommandListener(sender, this, TextFormatting.YELLOW + " |________________________________________________//");
}
Also used : WrongUsageException(net.minecraft.command.WrongUsageException) AttributeModifier(com.teamwizardry.wizardry.api.spell.attribute.AttributeModifier) ModuleInstance(com.teamwizardry.wizardry.api.spell.module.ModuleInstance) ModuleInstanceModifier(com.teamwizardry.wizardry.api.spell.module.ModuleInstanceModifier)

Aggregations

ModuleInstanceModifier (com.teamwizardry.wizardry.api.spell.module.ModuleInstanceModifier)10 ModuleInstance (com.teamwizardry.wizardry.api.spell.module.ModuleInstance)7 Vec2d (com.teamwizardry.librarianlib.features.math.Vec2d)5 CommonWorktableModule (com.teamwizardry.wizardry.api.spell.CommonWorktableModule)3 BasicAnimation (com.teamwizardry.librarianlib.features.animator.animations.BasicAnimation)2 Keyframe (com.teamwizardry.librarianlib.features.animator.animations.Keyframe)2 KeyframeAnimation (com.teamwizardry.librarianlib.features.animator.animations.KeyframeAnimation)2 ScheduledEventAnimation (com.teamwizardry.librarianlib.features.animator.animations.ScheduledEventAnimation)2 GuiComponent (com.teamwizardry.librarianlib.features.gui.component.GuiComponent)2 GuiComponentEvents (com.teamwizardry.librarianlib.features.gui.component.GuiComponentEvents)2 ComponentRect (com.teamwizardry.librarianlib.features.gui.components.ComponentRect)2 DragMixin (com.teamwizardry.librarianlib.features.gui.mixin.DragMixin)2 AttributeModifier (com.teamwizardry.wizardry.api.spell.attribute.AttributeModifier)2 ArrayList (java.util.ArrayList)2 List (java.util.List)2 NBTTagList (net.minecraft.nbt.NBTTagList)2 LibrarianLib (com.teamwizardry.librarianlib.core.LibrarianLib)1 Easing (com.teamwizardry.librarianlib.features.animator.Easing)1 EnumMouseButton (com.teamwizardry.librarianlib.features.gui.EnumMouseButton)1 ComponentSprite (com.teamwizardry.librarianlib.features.gui.components.ComponentSprite)1