11package com .cleanroommc .modularui .factory ;
22
3- import com .cleanroommc .modularui .ModularUI ;
43import com .cleanroommc .modularui .api .JeiSettings ;
54import com .cleanroommc .modularui .api .UIFactory ;
5+ import com .cleanroommc .modularui .holoui .HoloScreenEntity ;
66import com .cleanroommc .modularui .holoui .HoloUI ;
77import com .cleanroommc .modularui .holoui .ScreenEntityRender ;
88import com .cleanroommc .modularui .network .NetworkHandler ;
99import com .cleanroommc .modularui .network .packets .OpenGuiPacket ;
10- import com .cleanroommc .modularui .network .packets .SyncHoloPacket ;
1110import com .cleanroommc .modularui .screen .*;
1211import com .cleanroommc .modularui .value .sync .PanelSyncManager ;
1312import com .cleanroommc .modularui .widget .WidgetTree ;
2928import io .netty .buffer .Unpooled ;
3029import org .jetbrains .annotations .NotNull ;
3130
31+ import java .util .List ;
32+
3233public class HoloGuiManager extends GuiManager {
3334
3435
@@ -40,23 +41,27 @@ public static <T extends GuiData> void open(@NotNull UIFactory<T> factory, @NotN
4041 guiData .setJeiSettings (JeiSettings .DUMMY );
4142 PanelSyncManager syncManager = new PanelSyncManager ();
4243 ModularPanel panel = factory .createPanel (guiData , syncManager );
43- if (HoloUI .isOpen (panel )) {
44- HoloUI .builder ()
44+ List <HoloScreenEntity > screens = player .world .getEntities (HoloScreenEntity .class , entity -> entity .isName (panel .getName ()));
45+ if (!screens .isEmpty ()) {
46+ for (HoloScreenEntity screen : screens ) {
47+ screen .setDead ();
48+ }
49+ /*HoloUI.builder()
4550 .inFrontOf(player, 5, true)
46- .reposition (panel . getName (), player );
51+ .reposition(player, screens );
4752 NetworkHandler.sendToPlayer(new SyncHoloPacket(panel.getName()), player);
4853 ModularUI.LOGGER.warn("reposition the holo, sync to client");
49- return ;
54+ return;*/
5055 }
5156 WidgetTree .collectSyncValues (syncManager , panel );
52- ModularContainer container = new ModularContainer (null );
57+ ModularContainer container = new ModularContainer (player , syncManager , panel . getName () );
5358 HoloUI .builder ()
5459 .screenScale (0.5f )
5560 .inFrontOf (player , 5 , true )
5661 .open (screen -> {
5762 screen .setContainer (container );
5863 screen .setPanel (panel );
59- HoloUI .registerSyncedHoloUI (panel , screen );
64+ // HoloUI.registerSyncedHoloUI(panel, screen);
6065 }, player .getEntityWorld ());
6166 // sync to client
6267// player.getNextWindowId();
@@ -83,7 +88,7 @@ public static <T extends GuiData> void open(int windowId, @NotNull UIFactory<T>
8388 WidgetTree .collectSyncValues (syncManager , panel );
8489 ModularScreen screen = factory .createScreen (guiData , panel );
8590 screen .getContext ().setJeiSettings (jeiSettings );
86- GuiScreenWrapper guiScreenWrapper = new GuiScreenWrapper (new ModularContainer (null ), screen );
91+ GuiScreenWrapper guiScreenWrapper = new GuiScreenWrapper (new ModularContainer (player , syncManager , panel . getName () ), screen );
8792 guiScreenWrapper .inventorySlots .windowId = windowId ;
8893 HoloUI .builder ()
8994// .screenScale(0.25f)
@@ -92,15 +97,15 @@ public static <T extends GuiData> void open(int windowId, @NotNull UIFactory<T>
9297 .open (screen1 -> {
9398 screen1 .setPanel (panel );
9499 screen1 .setWrapper (guiScreenWrapper );
95- HoloUI .registerSyncedHoloUI (panel , screen1 );
100+ // HoloUI.registerSyncedHoloUI(panel, screen1);
96101 }, player .getEntityWorld ());
97102 }
98103
99104 public static void reposition (String panel , EntityPlayer player ) {
100105 HoloUI .builder ()
101106// .screenScale(0.25f)
102107 .inFrontOf (player , 5 , true )
103- .reposition (panel , player );
108+ .reposition (player , player . world . getEntities ( HoloScreenEntity . class , entity -> entity . isName ( panel )) );
104109 }
105110
106111 //todo make this a mixin instead of using event to cancel arm animation stuff
0 commit comments