11package mekanism .client .gui ;
22
3- import java .util .Set ;
4- import mekanism .api .inventory .IInventorySlot ;
53import mekanism .api .security .IBlockSecurityUtils ;
6- import mekanism .api .text .EnumColor ;
74import mekanism .client .gui .element .tab .GuiRedstoneControlTab ;
85import mekanism .client .gui .element .tab .GuiSecurityTab ;
96import mekanism .client .gui .element .tab .window .GuiUpgradeWindowTab ;
10- import mekanism .common .MekanismLang ;
11- import mekanism .common .inventory .container .slot .InventoryContainerSlot ;
127import mekanism .common .inventory .container .tile .MekanismTileContainer ;
13- import mekanism .common .item .ItemConfigurator ;
14- import mekanism .common .lib .transmitter .TransmissionType ;
158import mekanism .common .tile .base .TileEntityMekanism ;
16- import mekanism .common .tile .component .config .ConfigInfo ;
17- import mekanism .common .tile .component .config .DataType ;
18- import mekanism .common .tile .component .config .slot .ISlotInfo ;
19- import mekanism .common .tile .component .config .slot .InventorySlotInfo ;
20- import mekanism .common .tile .interfaces .ISideConfiguration ;
21- import net .minecraft .client .gui .GuiGraphics ;
22- import net .minecraft .client .gui .components .Tooltip ;
23- import net .minecraft .client .gui .navigation .ScreenAxis ;
24- import net .minecraft .client .gui .navigation .ScreenRectangle ;
259import net .minecraft .network .chat .Component ;
2610import net .minecraft .world .entity .player .Inventory ;
27- import net .minecraft .world .inventory .Slot ;
28- import net .minecraft .world .item .ItemStack ;
29- import org .jetbrains .annotations .NotNull ;
3011import org .jetbrains .annotations .Nullable ;
3112
3213public abstract class GuiMekanismTile <TILE extends TileEntityMekanism , CONTAINER extends MekanismTileContainer <TILE >> extends GuiMekanism <CONTAINER > {
@@ -38,11 +19,6 @@ public abstract class GuiMekanismTile<TILE extends TileEntityMekanism, CONTAINER
3819 @ Nullable
3920 private GuiUpgradeWindowTab upgradeWindowTab ;
4021
41- @ Nullable
42- private Component lastInfo = null ;
43- @ Nullable
44- private Tooltip lastTooltip ;
45-
4622 protected GuiMekanismTile (CONTAINER container , Inventory inv , Component title ) {
4723 super (container , inv , title );
4824 tile = container .getTileEntity ();
@@ -74,53 +50,4 @@ protected void addGenericTabs() {
7450 protected void addSecurityTab () {
7551 addRenderableWidget (new GuiSecurityTab (this , tile ));
7652 }
77-
78- @ Override
79- protected void renderTooltip (@ NotNull GuiGraphics guiGraphics , int mouseX , int mouseY ) {
80- super .renderTooltip (guiGraphics , mouseX , mouseY );
81- //TODO: Can we move this into GuiSlot#updateTooltip to mirror how we do it for GuiGauge?
82- // would potentially let us have an even more accurate screen rectangle, especially for sawmill output
83- if (tile instanceof ISideConfiguration ) {
84- ItemStack stack = getCarriedItem ();
85- if (!stack .isEmpty () && stack .getItem () instanceof ItemConfigurator ) {
86- Slot slot = getSlotUnderMouse ();
87- if (slot != null ) {
88- DataType data = getFromSlot (slot );
89- if (data != null ) {
90- EnumColor color = data .getColor ();
91- Component info = MekanismLang .GENERIC_WITH_PARENTHESIS .translateColored (color , data , color .getName ());
92- if (!info .equals (lastInfo )) {
93- lastInfo = info ;
94- lastTooltip = Tooltip .create (info );
95- }
96- if (lastTooltip != null ) {
97- lastTooltip .refreshTooltipForNextRenderPass (true , true ,
98- ScreenRectangle .of (ScreenAxis .HORIZONTAL , slot .x , slot .y , 16 , 16 ));
99- return ;
100- }
101- }
102- }
103- }
104- }
105- lastInfo = null ;
106- lastTooltip = null ;
107- }
108-
109- private DataType getFromSlot (Slot slot ) {
110- if (slot .index < tile .getSlots () && slot instanceof InventoryContainerSlot containerSlot ) {
111- ISideConfiguration config = (ISideConfiguration ) tile ;
112- ConfigInfo info = config .getConfig ().getConfig (TransmissionType .ITEM );
113- if (info != null ) {
114- Set <DataType > supportedDataTypes = info .getSupportedDataTypes ();
115- IInventorySlot inventorySlot = containerSlot .getInventorySlot ();
116- for (DataType type : supportedDataTypes ) {
117- ISlotInfo slotInfo = info .getSlotInfo (type );
118- if (slotInfo instanceof InventorySlotInfo inventorySlotInfo && inventorySlotInfo .hasSlot (inventorySlot )) {
119- return type ;
120- }
121- }
122- }
123- }
124- return null ;
125- }
12653}
0 commit comments