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);
}
}
}
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();
}
Aggregations