@@ -42,11 +42,12 @@ protected void addGuiElements() {
4242 itemNameField .setCanLoseFocus (false );
4343 itemNameField .setTextColor (-1 );
4444 itemNameField .setTextColorUneditable (-1 );
45+ itemNameField .setBordered (false );
4546 itemNameField .setBackground (BackgroundType .NONE );
4647 itemNameField .setMaxLength (50 );
4748 itemNameField .setResponder (this ::onNameChanged );
49+ itemNameField .setEditable (menu .getSlot (0 ).hasItem ());
4850 setInitialFocus (itemNameField );
49- itemNameField .setEditable (false );
5051 menu .removeSlotListener (this );
5152 menu .addSlotListener (this );
5253 }
@@ -64,8 +65,9 @@ private void onNameChanged(String newText) {
6465 if (slot .hasItem () && !slot .getItem ().has (DataComponents .CUSTOM_NAME ) && newText .equals (slot .getItem ().getHoverName ().getString ())) {
6566 newText = "" ;
6667 }
67- menu .setItemName (newText );
68- getMinecraft ().player .connection .send (new ServerboundRenameItemPacket (newText ));
68+ if (menu .setItemName (newText )) {
69+ getMinecraft ().player .connection .send (new ServerboundRenameItemPacket (newText ));
70+ }
6971 }
7072 }
7173
@@ -81,21 +83,20 @@ protected void drawForegroundText(@NotNull GuiGraphics guiGraphics, int mouseX,
8183 int maximumCost = menu .getCost ();
8284 if (maximumCost > 0 ) {
8385 int k = 0x80FF20 ;
84- boolean flag = true ;
8586 Component component = MekanismLang .REPAIR_COST .translate (maximumCost );
86- if (maximumCost >= 40 && !getMinecraft ().player .isCreative () ) {
87+ if (maximumCost >= 40 && !getMinecraft ().player .getAbilities (). instabuild ) {
8788 component = MekanismLang .REPAIR_EXPENSIVE .translate ();
8889 k = 0xFF6060 ;
8990 } else {
9091 Slot slot = menu .getSlot (2 );
9192 if (!slot .hasItem ()) {
92- flag = false ;
93+ component = null ;
9394 } else if (!slot .mayPickup (player )) {
9495 k = 0xFF6060 ;
9596 }
9697 }
9798
98- if (flag ) {
99+ if (component != null ) {
99100 int width = imageWidth - 8 - getStringWidth (component ) - 2 ;
100101 guiGraphics .fill (width - 2 , 67 , imageWidth - 8 , 79 , 0x4F000000 );
101102 guiGraphics .drawString (getFont (), component , width , 69 , k );
0 commit comments