Search in sources :

Example 1 with CrateRewardHolder

use of pw.codehusky.huskycrates.crate.config.CrateRewardHolder in project HuskyCrates-Sponge by codeHusky.

the class SpinnerCrateView method updateInv.

private void updateInv(int state) {
    ItemStack border = ItemStack.builder().itemType(ItemTypes.STAINED_GLASS_PANE).add(Keys.DYE_COLOR, DyeColors.BLACK).build();
    border.offer(Keys.DISPLAY_NAME, Text.of(TextStyles.RESET, "HuskyCrates"));
    //border.offer(Keys.ITEM_LORE,lore);
    ItemStack selector = ItemStack.of(ItemTypes.REDSTONE_TORCH, 1);
    selector.offer(Keys.DISPLAY_NAME, Text.of(TextStyles.RESET, "HuskyCrates"));
    //selector.offer(Keys.ITEM_LORE,lore);
    int slotnum = 0;
    for (Inventory e : disp.slots()) {
        if (state == 0 && (slotnum == 4 || slotnum == 22)) {
            e.set(selector);
        } else if (slotnum > 9 && slotnum < 17 && state != 2) {
            //int itemNum = items.size() - 1 - Math.abs(((slotnum - 10) + (clicks)) % items.size());
            int itemNum = Math.abs((clicks + (slotnum - 9) - 3) % items.size());
            //System.out.println(itemNum);
            e.set(((CrateRewardHolder) items.get(itemNum)[1]).getDisplayItem());
            if (slotnum == 13) {
                giveToPlayer = (CrateRewardHolder) items.get(itemNum)[1];
            }
        } else if (slotnum != 13) {
            if (state == 2) {
                e.set(confettiBorder());
            } else if (state == 0) {
                e.set(border);
            }
        } else if (slotnum == 13 && state == 2) {
            e.set(giveToPlayer.getDisplayItem());
        }
        slotnum++;
    }
    if (!ourplr.isViewingInventory()) {
        ourplr.openInventory(disp, plugin.genericCause);
    }
}
Also used : ItemStack(org.spongepowered.api.item.inventory.ItemStack) CrateRewardHolder(pw.codehusky.huskycrates.crate.config.CrateRewardHolder) Inventory(org.spongepowered.api.item.inventory.Inventory)

Aggregations

Inventory (org.spongepowered.api.item.inventory.Inventory)1 ItemStack (org.spongepowered.api.item.inventory.ItemStack)1 CrateRewardHolder (pw.codehusky.huskycrates.crate.config.CrateRewardHolder)1