Search in sources :

Example 1 with FluidSlot

use of logisticspipes.utils.gui.FluidSlot in project LogisticsPipes by RS485.

the class DummyContainerSlotClick method processPacket.

@Override
public void processPacket(EntityPlayer player) {
    if (player instanceof EntityPlayerMP && ((EntityPlayerMP) player).openContainer instanceof DummyContainer) {
        DummyContainer container = (DummyContainer) ((EntityPlayerMP) player).openContainer;
        Slot slot = container.inventorySlots.get(slotId);
        if (slot instanceof DummySlot || slot instanceof ColorSlot || slot instanceof FluidSlot) {
            container.handleDummyClick(slot, slotId, stack, button, ClickType.PICKUP, player);
        }
    }
}
Also used : DummyContainer(logisticspipes.utils.gui.DummyContainer) ColorSlot(logisticspipes.utils.gui.ColorSlot) DummySlot(logisticspipes.utils.gui.DummySlot) FluidSlot(logisticspipes.utils.gui.FluidSlot) ColorSlot(logisticspipes.utils.gui.ColorSlot) Slot(net.minecraft.inventory.Slot) DummySlot(logisticspipes.utils.gui.DummySlot) EntityPlayerMP(net.minecraft.entity.player.EntityPlayerMP) FluidSlot(logisticspipes.utils.gui.FluidSlot)

Example 2 with FluidSlot

use of logisticspipes.utils.gui.FluidSlot in project LogisticsPipes by RS485.

the class GhostIngredientHandler method getTargets.

@Nonnull
@Override
public <I> List<Target<I>> getTargets(@Nonnull LogisticsBaseGuiScreen gui, @Nonnull I ingredient, boolean doStart) {
    if (ingredient instanceof ItemStack) {
        Stream<Target<I>> slotStream = gui.inventorySlots.inventorySlots.stream().filter(it -> it instanceof DummySlot).map(it -> (DummySlot) it).map(it -> new Target<I>() {

            @Nonnull
            @Override
            public Rectangle getArea() {
                return new Rectangle(gui.getGuiLeft() + it.xPos, gui.getGuiTop() + it.yPos, 17, 17);
            }

            @Override
            public void accept(@Nonnull I ingredient) {
                it.putStack((ItemStack) ingredient);
                MainProxy.sendPacketToServer(PacketHandler.getPacket(SetGhostItemPacket.class).setInteger(it.slotNumber).setStack((ItemStack) ingredient));
            }
        });
        if (FluidIdentifier.get((ItemStack) ingredient) != null) {
            Stream<Target<I>> fluidStream = gui.inventorySlots.inventorySlots.stream().filter(it -> it instanceof FluidSlot).map(it -> (FluidSlot) it).map(it -> new Target<I>() {

                @Nonnull
                @Override
                public Rectangle getArea() {
                    return new Rectangle(gui.getGuiLeft() + it.xPos, gui.getGuiTop() + it.yPos, 17, 17);
                }

                @Override
                public void accept(@Nonnull I ingredient) {
                    FluidIdentifier ident = FluidIdentifier.get((ItemStack) ingredient);
                    if (ident != null) {
                        ItemStack stack = ident.getItemIdentifier().unsafeMakeNormalStack(1);
                        it.putStack(stack);
                        MainProxy.sendPacketToServer(PacketHandler.getPacket(SetGhostItemPacket.class).setInteger(it.slotNumber).setStack(stack));
                    }
                }
            });
            slotStream = Stream.concat(slotStream, fluidStream);
        }
        return slotStream.collect(Collectors.toList());
    } else if (ingredient instanceof FluidStack) {
        return gui.inventorySlots.inventorySlots.stream().filter(it -> it instanceof FluidSlot).map(it -> (FluidSlot) it).map(it -> new Target<I>() {

            @Nonnull
            @Override
            public Rectangle getArea() {
                return new Rectangle(gui.getGuiLeft() + it.xPos, gui.getGuiTop() + it.yPos, 17, 17);
            }

            @Override
            public void accept(@Nonnull I ingredient) {
                FluidIdentifier ident = FluidIdentifier.get((FluidStack) ingredient);
                if (ident != null) {
                    ItemStack stack = ident.getItemIdentifier().unsafeMakeNormalStack(1);
                    it.putStack(stack);
                    MainProxy.sendPacketToServer(PacketHandler.getPacket(SetGhostItemPacket.class).setInteger(it.slotNumber).setStack(stack));
                }
            }
        }).collect(Collectors.toList());
    }
    return Collections.emptyList();
}
Also used : Rectangle(java.awt.Rectangle) FluidSlot(logisticspipes.utils.gui.FluidSlot) PacketHandler(logisticspipes.network.PacketHandler) MainProxy(logisticspipes.proxy.MainProxy) Collectors(java.util.stream.Collectors) LogisticsBaseGuiScreen(logisticspipes.utils.gui.LogisticsBaseGuiScreen) ItemStack(net.minecraft.item.ItemStack) List(java.util.List) SetGhostItemPacket(logisticspipes.network.packets.SetGhostItemPacket) FluidIdentifier(logisticspipes.utils.FluidIdentifier) Stream(java.util.stream.Stream) FluidStack(net.minecraftforge.fluids.FluidStack) IGhostIngredientHandler(mezz.jei.api.gui.IGhostIngredientHandler) Collections(java.util.Collections) Nonnull(javax.annotation.Nonnull) DummySlot(logisticspipes.utils.gui.DummySlot) Nonnull(javax.annotation.Nonnull) FluidStack(net.minecraftforge.fluids.FluidStack) DummySlot(logisticspipes.utils.gui.DummySlot) Rectangle(java.awt.Rectangle) FluidSlot(logisticspipes.utils.gui.FluidSlot) FluidIdentifier(logisticspipes.utils.FluidIdentifier) ItemStack(net.minecraft.item.ItemStack) Nonnull(javax.annotation.Nonnull)

Aggregations

DummySlot (logisticspipes.utils.gui.DummySlot)2 FluidSlot (logisticspipes.utils.gui.FluidSlot)2 Rectangle (java.awt.Rectangle)1 Collections (java.util.Collections)1 List (java.util.List)1 Collectors (java.util.stream.Collectors)1 Stream (java.util.stream.Stream)1 Nonnull (javax.annotation.Nonnull)1 PacketHandler (logisticspipes.network.PacketHandler)1 SetGhostItemPacket (logisticspipes.network.packets.SetGhostItemPacket)1 MainProxy (logisticspipes.proxy.MainProxy)1 FluidIdentifier (logisticspipes.utils.FluidIdentifier)1 ColorSlot (logisticspipes.utils.gui.ColorSlot)1 DummyContainer (logisticspipes.utils.gui.DummyContainer)1 LogisticsBaseGuiScreen (logisticspipes.utils.gui.LogisticsBaseGuiScreen)1 IGhostIngredientHandler (mezz.jei.api.gui.IGhostIngredientHandler)1 EntityPlayerMP (net.minecraft.entity.player.EntityPlayerMP)1 Slot (net.minecraft.inventory.Slot)1 ItemStack (net.minecraft.item.ItemStack)1 FluidStack (net.minecraftforge.fluids.FluidStack)1