use of logisticspipes.utils.gui.SubGuiScreen in project LogisticsPipes by RS485.
the class NewGuiHandler method openGui.
@SideOnly(Side.CLIENT)
public static void openGui(OpenGUIPacket packet, EntityPlayer player) {
int guiID = packet.getGuiID();
GuiProvider provider = NewGuiHandler.guilist.get(guiID).template();
LPDataIOWrapper.provideData(packet.getGuiData(), provider::readData);
if (provider instanceof PopupGuiProvider && packet.getWindowID() == -2) {
if (FMLClientHandler.instance().getClient().currentScreen instanceof LogisticsBaseGuiScreen) {
LogisticsBaseGuiScreen baseGUI = (LogisticsBaseGuiScreen) FMLClientHandler.instance().getClient().currentScreen;
SubGuiScreen newSub;
try {
newSub = (SubGuiScreen) provider.getClientGui(player);
} catch (TargetNotFoundException e) {
throw e;
} catch (Exception e) {
LogisticsPipes.log.error(packet.getClass().getName());
LogisticsPipes.log.error(packet.toString());
throw new RuntimeException(e);
}
if (newSub != null) {
if (!baseGUI.hasSubGui()) {
baseGUI.setSubGui(newSub);
} else {
SubGuiScreen canidate = baseGUI.getSubGui();
while (canidate.hasSubGui()) {
canidate = canidate.getSubGui();
}
canidate.setSubGui(newSub);
}
}
}
} else {
GuiContainer screen;
try {
screen = (GuiContainer) provider.getClientGui(player);
} catch (TargetNotFoundException e) {
throw e;
} catch (Exception e) {
LogisticsPipes.log.error(packet.getClass().getName());
LogisticsPipes.log.error(packet.toString());
throw new RuntimeException(e);
}
screen.inventorySlots.windowId = packet.getWindowID();
FMLCommonHandler.instance().showGuiScreen(screen);
}
}
use of logisticspipes.utils.gui.SubGuiScreen in project LogisticsPipes by RS485.
the class GuiPacket method getGui.
@SideOnly(Side.CLIENT)
protected <T> T getGui(Class<T> guiClass) {
GuiScreen currentScreen = Minecraft.getMinecraft().currentScreen;
if (currentScreen == null) {
return null;
}
if (guiClass.isAssignableFrom(currentScreen.getClass())) {
return (T) currentScreen;
}
SubGuiScreen subScreen = null;
if (currentScreen instanceof LogisticsBaseGuiScreen) {
subScreen = ((LogisticsBaseGuiScreen) currentScreen).getSubGui();
}
while (subScreen != null) {
if (guiClass.isAssignableFrom(subScreen.getClass())) {
return (T) subScreen;
}
subScreen = subScreen.getSubGui();
}
return null;
}
use of logisticspipes.utils.gui.SubGuiScreen in project LogisticsPipes by RS485.
the class NewGuiHandler method openGui.
@SideOnly(Side.CLIENT)
public static void openGui(GUIPacket packet, EntityPlayer player) {
int guiID = packet.getGuiID();
GuiProvider provider = NewGuiHandler.guilist.get(guiID).template();
LPDataIOWrapper.provideData(packet.getGuiData(), provider::readData);
if (provider instanceof PopupGuiProvider && packet.getWindowID() == -2) {
if (FMLClientHandler.instance().getClient().currentScreen instanceof LogisticsBaseGuiScreen) {
LogisticsBaseGuiScreen baseGUI = (LogisticsBaseGuiScreen) FMLClientHandler.instance().getClient().currentScreen;
SubGuiScreen newSub;
try {
newSub = (SubGuiScreen) provider.getClientGui(player);
} catch (TargetNotFoundException e) {
throw e;
} catch (Exception e) {
LogisticsPipes.log.error(packet.getClass().getName());
LogisticsPipes.log.error(packet.toString());
throw new RuntimeException(e);
}
if (newSub != null) {
if (!baseGUI.hasSubGui()) {
baseGUI.setSubGui(newSub);
} else {
SubGuiScreen canidate = baseGUI.getSubGui();
while (canidate.hasSubGui()) {
canidate = canidate.getSubGui();
}
canidate.setSubGui(newSub);
}
}
}
} else {
GuiContainer screen;
try {
screen = (GuiContainer) provider.getClientGui(player);
} catch (TargetNotFoundException e) {
throw e;
} catch (Exception e) {
LogisticsPipes.log.error(packet.getClass().getName());
LogisticsPipes.log.error(packet.toString());
throw new RuntimeException(e);
}
screen.inventorySlots.windowId = packet.getWindowID();
FMLCommonHandler.instance().showGuiScreen(screen);
}
}
use of logisticspipes.utils.gui.SubGuiScreen in project LogisticsPipes by RS485.
the class MostLikelyRecipeComponentsResponse method processPacket.
@Override
@ClientSideOnlyMethodContent
public void processPacket(EntityPlayer player) {
GuiScreen firstGui = Minecraft.getMinecraft().currentScreen;
LogisticsBaseGuiScreen gui;
if (firstGui instanceof GuiLogisticsCraftingTable) {
gui = (GuiLogisticsCraftingTable) firstGui;
} else if (firstGui instanceof GuiRequestTable) {
gui = (GuiRequestTable) firstGui;
} else {
return;
}
GuiRecipeImport importGui = null;
SubGuiScreen sub = gui.getSubGui();
while (sub != null) {
if (sub instanceof GuiRecipeImport) {
importGui = (GuiRecipeImport) sub;
break;
}
sub = sub.getSubGui();
}
if (importGui == null)
return;
importGui.handleProposePacket(response);
}
use of logisticspipes.utils.gui.SubGuiScreen in project LogisticsPipes by RS485.
the class ClientProxy method openFluidSelectGui.
@Override
public void openFluidSelectGui(final int slotId) {
if (Minecraft.getMinecraft().currentScreen instanceof LogisticsBaseGuiScreen) {
final List<ItemIdentifierStack> list = new ArrayList<>();
for (FluidIdentifier fluid : FluidIdentifier.all()) {
if (fluid == null) {
continue;
}
list.add(fluid.getItemIdentifier().makeStack(1));
}
SelectItemOutOfList subGui = new SelectItemOutOfList(list, slot -> {
if (slot == -1)
return;
MainProxy.sendPacketToServer(PacketHandler.getPacket(DummyContainerSlotClick.class).setSlotId(slotId).setStack(list.get(slot).makeNormalStack()).setButton(0));
});
LogisticsBaseGuiScreen gui = (LogisticsBaseGuiScreen) Minecraft.getMinecraft().currentScreen;
if (!gui.hasSubGui()) {
gui.setSubGui(subGui);
} else {
SubGuiScreen nextGui = gui.getSubGui();
while (nextGui.hasSubGui()) {
nextGui = nextGui.getSubGui();
}
nextGui.setSubGui(subGui);
}
} else {
throw new UnsupportedOperationException(String.valueOf(Minecraft.getMinecraft().currentScreen));
}
}
Aggregations