Search in sources :

Example 1 with ExchangeScreen

use of com.almuradev.almura.feature.exchange.client.gui.ExchangeScreen in project Almura by AlmuraDev.

the class ClientExchangeManager method handleExchangeSpecificOffer.

public void handleExchangeSpecificOffer(final String id) {
    checkNotNull(id);
    final GuiScreen currentScreen = Minecraft.getMinecraft().currentScreen;
    if (!(currentScreen instanceof ExchangeScreen)) {
        return;
    }
    final Exchange axs = this.getExchange(id);
    if (axs == null) {
        ((ExchangeScreen) currentScreen).close();
        return;
    }
    final ExchangeScreen axsScreen = (ExchangeScreen) currentScreen;
    new ExchangeOfferScreen(axsScreen, axs, axsScreen.listItemList.getItems().stream().filter(item -> !item.getForSaleItem().isPresent()).map(item -> new BasicVanillaStack(item.asRealStack())).collect(Collectors.toList()), axsScreen.limit).display();
}
Also used : Exchange(com.almuradev.almura.feature.exchange.Exchange) ExchangeModifyType(com.almuradev.almura.feature.exchange.ExchangeModifyType) FMLNetworkEvent(net.minecraftforge.fml.common.network.FMLNetworkEvent) Almura(com.almuradev.almura.Almura) ClientboundListItemsSaleStatusPacket(com.almuradev.almura.feature.exchange.network.ClientboundListItemsSaleStatusPacket) ServerboundModifyForSaleItemListStatusRequestPacket(com.almuradev.almura.feature.exchange.network.ServerboundModifyForSaleItemListStatusRequestPacket) ServerboundTransactionRequestPacket(com.almuradev.almura.feature.exchange.network.ServerboundTransactionRequestPacket) ListStatusType(com.almuradev.almura.feature.exchange.ListStatusType) Singleton(javax.inject.Singleton) ForSaleItem(com.almuradev.almura.feature.exchange.listing.ForSaleItem) ListItem(com.almuradev.almura.feature.exchange.listing.ListItem) ArrayList(java.util.ArrayList) Inject(javax.inject.Inject) BigDecimal(java.math.BigDecimal) Minecraft(net.minecraft.client.Minecraft) Side(net.minecraftforge.fml.relauncher.Side) BasicForSaleItem(com.almuradev.almura.feature.exchange.basic.listing.BasicForSaleItem) ExchangeModule(com.almuradev.almura.feature.exchange.ExchangeModule) ServerboundModifyExchangePacket(com.almuradev.almura.feature.exchange.network.ServerboundModifyExchangePacket) ExchangeOfferScreen(com.almuradev.almura.feature.exchange.client.gui.ExchangeOfferScreen) ExchangeScreen(com.almuradev.almura.feature.exchange.client.gui.ExchangeScreen) BasicListItem(com.almuradev.almura.feature.exchange.basic.listing.BasicListItem) EntityPlayerSP(net.minecraft.client.entity.EntityPlayerSP) SideOnly(net.minecraftforge.fml.relauncher.SideOnly) Nullable(javax.annotation.Nullable) Exchange(com.almuradev.almura.feature.exchange.Exchange) ExchangeManagementScreen(com.almuradev.almura.feature.exchange.client.gui.ExchangeManagementScreen) SoundEvents(net.minecraft.init.SoundEvents) ServerboundListItemsRequestPacket(com.almuradev.almura.feature.exchange.network.ServerboundListItemsRequestPacket) InventoryAction(com.almuradev.almura.feature.exchange.InventoryAction) Preconditions.checkNotNull(com.google.common.base.Preconditions.checkNotNull) ServerboundForSaleFilterResponsePacket(com.almuradev.almura.feature.exchange.network.ServerboundForSaleFilterResponsePacket) FeatureConstants(com.almuradev.almura.shared.feature.FeatureConstants) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) Set(java.util.Set) NetworkConfig(com.almuradev.almura.shared.network.NetworkConfig) BasicVanillaStack(com.almuradev.almura.shared.item.BasicVanillaStack) Collectors(java.util.stream.Collectors) Preconditions.checkState(com.google.common.base.Preconditions.checkState) ChannelBinding(org.spongepowered.api.network.ChannelBinding) GuiScreen(net.minecraft.client.gui.GuiScreen) List(java.util.List) Witness(com.almuradev.core.event.Witness) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent) ChannelId(org.spongepowered.api.network.ChannelId) ServerboundExchangeSpecificOfferRequestPacket(com.almuradev.almura.feature.exchange.network.ServerboundExchangeSpecificOfferRequestPacket) ExchangeOfferScreen(com.almuradev.almura.feature.exchange.client.gui.ExchangeOfferScreen) GuiScreen(net.minecraft.client.gui.GuiScreen) BasicVanillaStack(com.almuradev.almura.shared.item.BasicVanillaStack) ExchangeScreen(com.almuradev.almura.feature.exchange.client.gui.ExchangeScreen)

Example 2 with ExchangeScreen

use of com.almuradev.almura.feature.exchange.client.gui.ExchangeScreen in project Almura by AlmuraDev.

the class ClientExchangeManager method handleForSaleItems.

public void handleForSaleItems(final String id, @Nullable final List<ForSaleItem> forSaleItems, int preLimitCount) {
    checkNotNull(id);
    final Exchange axs = this.getExchange(id);
    if (axs == null) {
        return;
    }
    final GuiScreen currentScreen = Minecraft.getMinecraft().currentScreen;
    if (currentScreen instanceof ExchangeScreen) {
        if (axs != ((ExchangeScreen) currentScreen).getExchange()) {
            return;
        }
        if (forSaleItems == null) {
            axs.putForSaleItems(null);
        } else {
            axs.putForSaleItems(forSaleItems.stream().collect(Collectors.groupingBy(k -> k.getListItem().getSeller(), ConcurrentHashMap::new, Collectors.toCollection(ArrayList::new))));
        }
        ((ExchangeScreen) currentScreen).refreshForSaleItemResults(forSaleItems, preLimitCount);
    }
}
Also used : Exchange(com.almuradev.almura.feature.exchange.Exchange) GuiScreen(net.minecraft.client.gui.GuiScreen) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) ExchangeScreen(com.almuradev.almura.feature.exchange.client.gui.ExchangeScreen)

Example 3 with ExchangeScreen

use of com.almuradev.almura.feature.exchange.client.gui.ExchangeScreen in project Almura by AlmuraDev.

the class ClientExchangeManager method handleExchangeSpecific.

public void handleExchangeSpecific(final String id, final int limit) {
    checkState(limit >= FeatureConstants.UNLIMITED);
    final Exchange axs = this.getExchange(id);
    if (axs != null) {
        this.clearFilterCache();
        new ExchangeScreen(axs, limit).display();
    }
}
Also used : Exchange(com.almuradev.almura.feature.exchange.Exchange) ExchangeScreen(com.almuradev.almura.feature.exchange.client.gui.ExchangeScreen)

Example 4 with ExchangeScreen

use of com.almuradev.almura.feature.exchange.client.gui.ExchangeScreen in project Almura by AlmuraDev.

the class ClientExchangeManager method handleListItems.

public void handleListItems(final String id, @Nullable final List<ListItem> listItems) {
    checkNotNull(id);
    final Exchange axs = this.getExchange(id);
    if (axs == null) {
        return;
    }
    final GuiScreen currentScreen = Minecraft.getMinecraft().currentScreen;
    if (currentScreen instanceof ExchangeScreen) {
        if (axs != ((ExchangeScreen) currentScreen).getExchange()) {
            return;
        }
        axs.putListItemsFor(Minecraft.getMinecraft().player.getUniqueID(), listItems);
        ((ExchangeScreen) currentScreen).refreshListItems();
    }
}
Also used : Exchange(com.almuradev.almura.feature.exchange.Exchange) GuiScreen(net.minecraft.client.gui.GuiScreen) ExchangeScreen(com.almuradev.almura.feature.exchange.client.gui.ExchangeScreen)

Aggregations

Exchange (com.almuradev.almura.feature.exchange.Exchange)4 ExchangeScreen (com.almuradev.almura.feature.exchange.client.gui.ExchangeScreen)4 GuiScreen (net.minecraft.client.gui.GuiScreen)3 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)2 Almura (com.almuradev.almura.Almura)1 ExchangeModifyType (com.almuradev.almura.feature.exchange.ExchangeModifyType)1 ExchangeModule (com.almuradev.almura.feature.exchange.ExchangeModule)1 InventoryAction (com.almuradev.almura.feature.exchange.InventoryAction)1 ListStatusType (com.almuradev.almura.feature.exchange.ListStatusType)1 BasicForSaleItem (com.almuradev.almura.feature.exchange.basic.listing.BasicForSaleItem)1 BasicListItem (com.almuradev.almura.feature.exchange.basic.listing.BasicListItem)1 ExchangeManagementScreen (com.almuradev.almura.feature.exchange.client.gui.ExchangeManagementScreen)1 ExchangeOfferScreen (com.almuradev.almura.feature.exchange.client.gui.ExchangeOfferScreen)1 ForSaleItem (com.almuradev.almura.feature.exchange.listing.ForSaleItem)1 ListItem (com.almuradev.almura.feature.exchange.listing.ListItem)1 ClientboundListItemsSaleStatusPacket (com.almuradev.almura.feature.exchange.network.ClientboundListItemsSaleStatusPacket)1 ServerboundExchangeSpecificOfferRequestPacket (com.almuradev.almura.feature.exchange.network.ServerboundExchangeSpecificOfferRequestPacket)1 ServerboundForSaleFilterResponsePacket (com.almuradev.almura.feature.exchange.network.ServerboundForSaleFilterResponsePacket)1 ServerboundListItemsRequestPacket (com.almuradev.almura.feature.exchange.network.ServerboundListItemsRequestPacket)1 ServerboundModifyExchangePacket (com.almuradev.almura.feature.exchange.network.ServerboundModifyExchangePacket)1