Coder Social home page Coder Social logo

huskyui-plugin's Introduction

HuskyUI

A simple, lightweight UI system for, as of right now, chest GUIs.

Java Docs

Forum Topic

HuskyUI Wiki

Implementation Examples

Hotbar Compass using ElementRegistry

RunnableAction testAction = new RunnableAction(registry, ActionType.NONE,"");
testAction.setRunnable(context -> {
    StateContainer container = new StateContainer();
    Page testPage = Page.builder()
            .setTitle(Text.of(TextColors.GOLD,"Navigator"))
            .setAutoPaging(true)
            .addElement(new Element(
                    ItemStack.builder()
                        .itemType(ItemTypes.DIAMOND)
                        .add(Keys.DISPLAY_NAME,Text.of(TextColors.BLUE,"Diamond Rush"))
                        .build()
                    ))
            .addElement(new Element(
                    ItemStack.builder()
                            .itemType(ItemTypes.FIREWORKS)
                            .add(Keys.DISPLAY_NAME,Text.of(TextColors.RED,"Fireworks Palooza"))
                            .build()
            ))
            .addElement(new Element(
                    ItemStack.builder()
                            .itemType(ItemTypes.MINECART)
                            .add(Keys.DISPLAY_NAME,Text.of(TextColors.GRAY,"Roller Coasters"))
                            .build()
            ))
            .build("testpage");
    container.setInitialState(testPage);
    container.launchFor(context.getObserver());
});
ActionableElement testElement = new ActionableElement(
                                    testAction,
                                    ItemStack.builder()
                                            .itemType(ItemTypes.COMPASS)
                                            .add(Keys.DISPLAY_NAME, Text.of(TextColors.GOLD,"Navigator"))
                                            .build());

HuskyUI.getElementRegistry().registerAutoElement(4,testElement);
ItemStack litMC = ItemStack.builder()
        .itemType(ItemTypes.REDSTONE_TORCH)
        .add(Keys.DISPLAY_NAME,Text.of(TextColors.RED,"LitMC"))
        .build();
HuskyUI.getElementRegistry().registerAutoElement(0,new Element(litMC));
HuskyUI.getElementRegistry().registerAutoElement(8,new Element(litMC));

HuskyUI.getElementRegistry().registerAutoElement(new Element(ItemStack.builder().itemType(ItemTypes.MINECART).add(Keys.DISPLAY_NAME,Text.of("movable 1")).build()));
HuskyUI.getElementRegistry().registerAutoElement(new Element(ItemStack.builder().itemType(ItemTypes.MINECART).add(Keys.DISPLAY_NAME,Text.of("movable 2")).build()));
HuskyUI.getElementRegistry().registerAutoElement(new Element(ItemStack.builder().itemType(ItemTypes.MINECART).add(Keys.DISPLAY_NAME,Text.of("movable 3")).build()));

Result (with some movement of the movable carts.)

img

Generic Example

StateContainer container = new StateContainer();
container.addState(
    Page.builder()
        .setUpdatable(true)
        .setUpdater(page -> {
            int count = 0;
            for(Inventory slot: page.getPageView().slots()){

                if(!slot.peek().isPresent() && count == page.getTicks()%page.getPageView().capacity()){
                    slot.set(ItemStack.of(ItemTypes.STAINED_GLASS_PANE,count));
                }else{
                    if(slot.peek().isPresent()) {
                        ItemStack stack = slot.peek().get();
                        if (stack.getType() == ItemTypes.STAINED_GLASS_PANE) {
                            slot.set(ItemStack.empty());
                        }
                    }
                }
                count++;
            }
        })
        .setUpdateTickRate(20)
        .setTitle(Text.of(TextColors.RED,"BLARG"))
            .addElement(new ActionableElement(new Action(container,ActionType.NORMAL,"test2"),ItemStack.builder().
                    itemType(ItemTypes.COOKIE)
                    .build()))
        .build("test")
);
container.addState(
    Page.builder()
        .setUpdatable(false)
        .setTitle(Text.of(TextColors.GREEN,"alt"))
        .addElement(new ActionableElement(new Action(container,ActionType.BACK,"test"),ItemStack.builder().
                itemType(ItemTypes.COOKIE)
                .build()))
        .setParent("test")
        .build("test2")
);
container.launchFor(plr);

huskyui-plugin's People

Contributors

ferusgrim avatar redrield avatar waterpicker avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.