2626 */
2727public class BetterGuiMerchant extends GuiMerchant {
2828
29- private final int addXSize =0 ;
29+ private int xBase =0 ;
3030 private final ItemStack tradeOK , tradeNOK ;
3131 private final int lineHeight =18 ;
3232 private final int titleDistance =20 ;
@@ -38,7 +38,13 @@ public class BetterGuiMerchant extends GuiMerchant {
3838
3939 BetterGuiMerchant (InventoryPlayer inv , GuiMerchant template , World world ) {
4040 super (inv , template .getMerchant (), world );
41- this .xSize +=addXSize ;
41+ if (ConfigurationHandler .showLeft ()) {
42+ xBase =-ConfigurationHandler .leftPixelOffset ();
43+ if (xBase ==0 )
44+ xBase =-this .getXSize ();
45+ }
46+ else
47+ xBase =this .getXSize ()+5 ;
4248 tradeOK =new ItemStack (Item .getItemById (351 ), 1 , 2 );
4349 tradeNOK =new ItemStack (Item .getItemById (351 ), 1 , 1 );
4450 }
@@ -63,7 +69,7 @@ protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY)
6369 return ;
6470 int topAdjust =getTopAdjust (trades .size ());
6571 String s = trades .size ()+" trades" ;
66- this .fontRenderer .drawString (s , this . xSize - addXSize + 5 , -topAdjust , 0xff00ff );
72+ this .fontRenderer .drawString (s , xBase , -topAdjust , 0xff00ff );
6773 // First draw all items, then all tooltips. This is extra effort,
6874 // but we don't want any items in front of any tooltips.
6975 RenderHelper .enableStandardItemLighting ();
@@ -73,9 +79,9 @@ protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY)
7379 ItemStack i1 =trade .getItemToBuy ();
7480 ItemStack i2 =trade .hasSecondItemToBuy () ? trade .getSecondItemToBuy () : null ;
7581 ItemStack o1 =trade .getItemToSell ();
76- drawItem (i1 , this . xSize - addXSize + 5 +firstBuyItemXpos , i *lineHeight -topAdjust +titleDistance );
77- drawItem (i2 , this . xSize - addXSize + 5 +secondBuyItemXpos , i *lineHeight -topAdjust +titleDistance );
78- drawItem (o1 , this . xSize - addXSize + 5 +sellItemXpos , i *lineHeight -topAdjust +titleDistance );
82+ drawItem (i1 , xBase +firstBuyItemXpos , i *lineHeight -topAdjust +titleDistance );
83+ drawItem (i2 , xBase +secondBuyItemXpos , i *lineHeight -topAdjust +titleDistance );
84+ drawItem (o1 , xBase +sellItemXpos , i *lineHeight -topAdjust +titleDistance );
7985
8086 NBTTagList enchantments ;
8187
@@ -100,19 +106,22 @@ protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY)
100106 enchants .append (enchant .getTranslatedName (k ));
101107 }
102108 }
103- fontRenderer .drawString (enchants .toString (), this .xSize -addXSize +textXpos , i *lineHeight -topAdjust +24 , 0xffff00 );
109+ String shownEnchants =enchants .toString ();
110+ if (xBase <0 )
111+ shownEnchants =fontRenderer .trimStringToWidth (shownEnchants , -xBase -textXpos -5 );
112+ fontRenderer .drawString (shownEnchants , xBase +textXpos , i *lineHeight -topAdjust +24 , 0xffff00 );
104113 }
105- drawItem (trade .isRecipeDisabled () ? tradeNOK : tradeOK , xSize - addXSize + 5 +okNokXpos , i *lineHeight -topAdjust +titleDistance );
114+ drawItem (trade .isRecipeDisabled () ? tradeNOK : tradeOK , xBase +okNokXpos , i *lineHeight -topAdjust +titleDistance );
106115 }
107116 RenderHelper .disableStandardItemLighting ();
108117 for (int i =0 ; i <trades .size (); i ++) {
109118 MerchantRecipe trade =trades .get (i );
110119 ItemStack i1 =trade .getItemToBuy ();
111120 ItemStack i2 =trade .hasSecondItemToBuy () ? trade .getSecondItemToBuy () : null ;
112121 ItemStack o1 =trade .getItemToSell ();
113- drawTooltip (i1 , this . xSize - addXSize + 5 +firstBuyItemXpos , i *lineHeight -topAdjust +titleDistance , mouseX , mouseY );
114- drawTooltip (i2 , this . xSize - addXSize + 5 +secondBuyItemXpos , i *lineHeight -topAdjust +titleDistance , mouseX , mouseY );
115- drawTooltip (o1 , this . xSize - addXSize + 5 +sellItemXpos , i *lineHeight -topAdjust +titleDistance , mouseX , mouseY );
122+ drawTooltip (i1 , xBase +firstBuyItemXpos , i *lineHeight -topAdjust +titleDistance , mouseX , mouseY );
123+ drawTooltip (i2 , xBase +secondBuyItemXpos , i *lineHeight -topAdjust +titleDistance , mouseX , mouseY );
124+ drawTooltip (o1 , xBase +sellItemXpos , i *lineHeight -topAdjust +titleDistance , mouseX , mouseY );
116125 }
117126 }
118127
@@ -143,8 +152,8 @@ private void drawTooltip(ItemStack stack, int x, int y, int mousex, int mousey)
143152 protected void mouseClicked (final int mouseX , final int mouseY , final int mouseButton ) throws IOException {
144153 // System.out.println("click at "+mouseX+"/"+mouseY);
145154 if (mouseButton ==0
146- && (mouseX - this .guiLeft ) > this . xSize - addXSize
147- && (mouseX - this .guiLeft ) < this . xSize - addXSize +textXpos
155+ && (mouseX - this .guiLeft ) >= xBase
156+ && (mouseX - this .guiLeft ) <= xBase +textXpos
148157 ) {
149158 MerchantRecipeList trades =getMerchant ().getRecipes (null );
150159 if (trades ==null )
0 commit comments