2323import net .roboxgamer .modernutils .network .RedstoneModePayload ;
2424import net .roboxgamer .modernutils .network .RemainItemTogglePayload ;
2525import net .roboxgamer .modernutils .network .SlotStatePayload ;
26+ import net .roboxgamer .modernutils .util .AddonClientManager ;
2627import net .roboxgamer .modernutils .util .AddonManager ;
2728import net .roboxgamer .modernutils .util .Constants ;
2829import net .roboxgamer .modernutils .util .RedstoneManager ;
@@ -74,6 +75,7 @@ public class MechanicalCrafterScreen extends AbstractContainerScreen<MechanicalC
7475 private float lastProgress = 0f ;
7576 private float visualProgress = 0f ;
7677 private AddonManager addonManager ;
78+ private AddonClientManager addonClientManager ;
7779
7880 public MechanicalCrafterScreen (MechanicalCrafterMenu menu , Inventory playerInv , Component title ) {
7981 super (menu , playerInv , title );
@@ -101,6 +103,7 @@ protected void init() {
101103 this .blockEntity = mcbe ;
102104 this .redstoneManager = this .blockEntity .getRedstoneManager ();
103105 this .addonManager = this .blockEntity .getAddonManager ();
106+ this .addonClientManager = new AddonClientManager (this .addonManager );
104107
105108 } else {
106109 ModernUtilsMod .LOGGER .error ("Mechanical Crafter Screen: BlockEntity is not a MechanicalCrafterBlockEntity!" );
@@ -142,9 +145,10 @@ public void renderWidget(@NotNull GuiGraphics guiGraphics, int mouseX, int mouse
142145 92 , 92 , Component .empty (), ExtendedButton .WidgetPosition .BOTTOM_LEFT );
143146 addRenderableWidget (SideConfigTab );
144147
145- this .addonManager .createAddonTab (this .player , this );
146- addRenderableWidget (this .addonManager .getAddonTab ());
147- addRenderableWidget (this .addonManager .getAddonConfigButton ());
148+ // Create addon tab and button using the client manager
149+ this .addonClientManager .createAddonTab (this .player , this );
150+ addRenderableWidget (this .addonClientManager .getAddonTab ());
151+ addRenderableWidget (this .addonClientManager .getAddonConfigButton ());
148152
149153 this .sideConfigBtn = new ExtendedButton (
150154 "Config_Btn" ,
@@ -309,13 +313,6 @@ private void renderScreen(GuiGraphics guiGraphics, int mouseX, int mouseY, float
309313 guiGraphics .blit (TEXTURE , this .leftPos , this .topPos , 0 , 0 , this .imageWidth , this .imageHeight );
310314 }
311315
312- // private void renderWidgets(GuiGraphics guiGraphics, int mouseX, int mouseY,
313- // float partialTick) {
314- // for (Renderable renderable : this.renderables) {
315- // renderable.render(guiGraphics, mouseX, mouseY, partialTick);
316- // }
317- // }
318-
319316 private void renderMyLabels (GuiGraphics guiGraphics , int mouseX , int mouseY ) {
320317 guiGraphics .drawString (this .font , Component .literal ("Input" ), this .leftPos + 8 , this .topPos + 80 , 0x404040 , false );
321318 guiGraphics .drawString (this .font , Component .literal ("Output" ), this .leftPos + 8 , this .topPos + 112 , 0x404040 ,
@@ -329,40 +326,23 @@ protected void renderBg(@NotNull GuiGraphics guiGraphics, float partialTick, int
329326
330327 public void render (@ NotNull GuiGraphics guiGraphics , int mouseX , int mouseY , float partialTick ) {
331328 super .render (guiGraphics , mouseX , mouseY , partialTick );
332- // renderTransparentBackground(guiGraphics);
333- // this.renderScreen(guiGraphics, mouseX, mouseY, partialTick);
334- // this.renderWidgets(guiGraphics, mouseX, mouseY, partialTick);
335329
336330 this .renderProgressBar (guiGraphics , partialTick ); // Render the progress bar with partialTick
337331 this .renderMyLabels (guiGraphics , mouseX , mouseY );
338332 this .renderTooltip (guiGraphics , mouseX , mouseY );
339-
340- // ModernUtils.LOGGER.debug("Mouse X: {}, Mouse Y: {}", mouseX, mouseY);
341-
342- if (this .hoveredSlot instanceof OutputSlotItemHandler
343- && !this .menu .isSlotDisabled (this .hoveredSlot .getSlotIndex ())
344- && this .menu .getCarried ().isEmpty ()
345- && !this .hoveredSlot .hasItem ()
346- && !this .player .isSpectator ()) {
347- guiGraphics .renderTooltip (this .font , DISABLED_SLOT_TOOLTIP , mouseX , mouseY );
348- }
349333 }
350334
351335 @ Override
352336 public void renderSlot (@ NotNull GuiGraphics guiGraphics , @ NotNull Slot slot ) {
353337 // Define the range of slot indices for addon slots
354- int addonStartIndex = MechanicalCrafterMenu .INPUT_SLOTS_COUNT + MechanicalCrafterMenu .OUTPUT_SLOTS_COUNT + 10 ; // 10
355- // is
356- // for
357- // crafting
358- // slots
338+ int addonStartIndex = MechanicalCrafterMenu .INPUT_SLOTS_COUNT + MechanicalCrafterMenu .OUTPUT_SLOTS_COUNT + 10 ; // 10 is for crafting slots
359339 int addonEndIndex = addonStartIndex + this .addonManager .ADDON_SLOTS_COUNT ;
360340
361341 // Check if this slot is an addon slot
362342 if (slot .index >= addonStartIndex && slot .index < addonEndIndex ) {
363343 // Only render addon slots when both the tab is open and the slot is active
364- if (this .addonManager .getAddonTab ().isOpen () && slot .isActive ()) {
365- this .addonManager .renderAddonSlot (guiGraphics , slot );
344+ if (this .addonClientManager .getAddonTab ().isOpen () && slot .isActive ()) {
345+ this .addonClientManager .renderAddonSlot (guiGraphics , slot );
366346 super .renderSlot (guiGraphics , slot );
367347 }
368348 }
@@ -468,12 +448,15 @@ private void renderProgressBar(GuiGraphics guiGraphics, float partialTick) {
468448 this .leftPos + this .imageWidth - BORDER_THICKNESS , BAR_Y_POS + BAR_HEIGHT - BORDER_THICKNESS ,
469449 0xFF000000 ); // Black background
470450
471- // Only draw the progress fill if there is any progress
451+ // Draw progress (blue progress bar)
472452 if (progressWidth > 0 ) {
473- // Draw progress fill (white fill) with the interpolated width
474453 guiGraphics .fill (this .leftPos + BORDER_THICKNESS , BAR_Y_POS + BORDER_THICKNESS ,
475454 this .leftPos + BORDER_THICKNESS + progressWidth , BAR_Y_POS + BAR_HEIGHT - BORDER_THICKNESS ,
476- 0xFFFFFFFF ); // White fill
455+ 0xFF0088FF ); // Blue progress
477456 }
478457 }
458+
459+ public AddonClientManager getAddonManager () {
460+ return this .addonClientManager ;
461+ }
479462}
0 commit comments