Search in sources :

Example 1 with StoreScreen

use of com.almuradev.almura.feature.store.client.gui.StoreScreen in project Almura by AlmuraDev.

the class ClientStoreManager method handleBuyingItems.

public void handleBuyingItems(final String id, @Nullable final List<BuyingItem> items) {
    checkNotNull(id);
    // Ensure we have the store screen open
    final GuiScreen currentScreen = Minecraft.getMinecraft().currentScreen;
    if (!(currentScreen instanceof StoreScreen)) {
        return;
    }
    // Update our local store
    final Store store = this.stores.stream().filter(s -> s.getId().equals(id)).findAny().orElse(null);
    if (store != null) {
        // Clear existing items
        store.getBuyingItems().clear();
        if (items != null) {
            // Add new items
            store.getBuyingItems().addAll(items);
        }
        // Refresh the screen and create controls
        ((StoreScreen) currentScreen).refresh(true);
    } else {
        // Refresh the screen
        ((StoreScreen) currentScreen).refresh(false);
    }
}
Also used : StoreScreen(com.almuradev.almura.feature.store.client.gui.StoreScreen) Store(com.almuradev.almura.feature.store.Store) GuiScreen(net.minecraft.client.gui.GuiScreen)

Example 2 with StoreScreen

use of com.almuradev.almura.feature.store.client.gui.StoreScreen in project Almura by AlmuraDev.

the class ClientStoreManager method handleSellingItems.

public void handleSellingItems(final String id, @Nullable final List<SellingItem> items) {
    checkNotNull(id);
    // Ensure we have the store screen open
    final GuiScreen currentScreen = Minecraft.getMinecraft().currentScreen;
    if (!(currentScreen instanceof StoreScreen)) {
        return;
    }
    // Update our local store
    final Store store = this.stores.stream().filter(s -> s.getId().equals(id)).findAny().orElse(null);
    if (store != null) {
        // Clear existing items
        store.getSellingItems().clear();
        if (items != null) {
            // Add new items
            store.getSellingItems().addAll(items);
        }
        // Refresh the screen and create controls
        ((StoreScreen) currentScreen).refresh(true);
    } else {
        // Refresh the screen
        ((StoreScreen) currentScreen).refresh(false);
    }
}
Also used : StoreScreen(com.almuradev.almura.feature.store.client.gui.StoreScreen) Store(com.almuradev.almura.feature.store.Store) GuiScreen(net.minecraft.client.gui.GuiScreen)

Aggregations

Store (com.almuradev.almura.feature.store.Store)2 StoreScreen (com.almuradev.almura.feature.store.client.gui.StoreScreen)2 GuiScreen (net.minecraft.client.gui.GuiScreen)2