Class MerchantScreen

All Implemented Interfaces:
ContainerEventHandler, GuiEventListener, Renderable, TabOrderedElement, MenuAccess<MerchantMenu>

public class MerchantScreen extends AbstractContainerScreen<MerchantMenu>
  • Field Details

    • OUT_OF_STOCK_SPRITE

      private static final ResourceLocation OUT_OF_STOCK_SPRITE
    • EXPERIENCE_BAR_BACKGROUND_SPRITE

      private static final ResourceLocation EXPERIENCE_BAR_BACKGROUND_SPRITE
    • EXPERIENCE_BAR_CURRENT_SPRITE

      private static final ResourceLocation EXPERIENCE_BAR_CURRENT_SPRITE
    • EXPERIENCE_BAR_RESULT_SPRITE

      private static final ResourceLocation EXPERIENCE_BAR_RESULT_SPRITE
    • SCROLLER_SPRITE

      private static final ResourceLocation SCROLLER_SPRITE
    • SCROLLER_DISABLED_SPRITE

      private static final ResourceLocation SCROLLER_DISABLED_SPRITE
    • TRADE_ARROW_OUT_OF_STOCK_SPRITE

      private static final ResourceLocation TRADE_ARROW_OUT_OF_STOCK_SPRITE
    • TRADE_ARROW_SPRITE

      private static final ResourceLocation TRADE_ARROW_SPRITE
    • DISCOUNT_STRIKETHRUOGH_SPRITE

      private static final ResourceLocation DISCOUNT_STRIKETHRUOGH_SPRITE
    • VILLAGER_LOCATION

      private static final ResourceLocation VILLAGER_LOCATION
      The GUI texture for the villager merchant GUI.
    • TEXTURE_WIDTH

      private static final int TEXTURE_WIDTH
      See Also:
    • TEXTURE_HEIGHT

      private static final int TEXTURE_HEIGHT
      See Also:
    • MERCHANT_MENU_PART_X

      private static final int MERCHANT_MENU_PART_X
      See Also:
    • PROGRESS_BAR_X

      private static final int PROGRESS_BAR_X
      See Also:
    • PROGRESS_BAR_Y

      private static final int PROGRESS_BAR_Y
      See Also:
    • SELL_ITEM_1_X

      private static final int SELL_ITEM_1_X
      See Also:
    • SELL_ITEM_2_X

      private static final int SELL_ITEM_2_X
      See Also:
    • BUY_ITEM_X

      private static final int BUY_ITEM_X
      See Also:
    • LABEL_Y

      private static final int LABEL_Y
      See Also:
    • NUMBER_OF_OFFER_BUTTONS

      private static final int NUMBER_OF_OFFER_BUTTONS
      See Also:
    • TRADE_BUTTON_X

      private static final int TRADE_BUTTON_X
      See Also:
    • TRADE_BUTTON_HEIGHT

      private static final int TRADE_BUTTON_HEIGHT
      See Also:
    • TRADE_BUTTON_WIDTH

      private static final int TRADE_BUTTON_WIDTH
      See Also:
    • SCROLLER_HEIGHT

      private static final int SCROLLER_HEIGHT
      See Also:
    • SCROLLER_WIDTH

      private static final int SCROLLER_WIDTH
      See Also:
    • SCROLL_BAR_HEIGHT

      private static final int SCROLL_BAR_HEIGHT
      See Also:
    • SCROLL_BAR_TOP_POS_Y

      private static final int SCROLL_BAR_TOP_POS_Y
      See Also:
    • SCROLL_BAR_START_X

      private static final int SCROLL_BAR_START_X
      See Also:
    • TRADES_LABEL

      private static final Component TRADES_LABEL
    • DEPRECATED_TOOLTIP

      private static final Component DEPRECATED_TOOLTIP
    • shopItem

      private int shopItem
      The integer value corresponding to the currently selected merchant recipe.
    • tradeOfferButtons

      private final MerchantScreen.TradeOfferButton[] tradeOfferButtons
    • scrollOff

      int scrollOff
    • isDragging

      private boolean isDragging
  • Constructor Details

  • Method Details

    • postButtonClick

      private void postButtonClick()
    • init

      protected void init()
      Overrides:
      init in class AbstractContainerScreen<MerchantMenu>
    • renderLabels

      protected void renderLabels(GuiGraphics pGuiGraphics, int pMouseX, int pMouseY)
      Overrides:
      renderLabels in class AbstractContainerScreen<MerchantMenu>
    • renderBg

      protected void renderBg(GuiGraphics pGuiGraphics, float pPartialTick, int pMouseX, int pMouseY)
      Specified by:
      renderBg in class AbstractContainerScreen<MerchantMenu>
    • renderProgressBar

      private void renderProgressBar(GuiGraphics pGuiGraphics, int pPosX, int pPosY, MerchantOffer pMerchantOffer)
    • renderScroller

      private void renderScroller(GuiGraphics pGuiGraphics, int pPosX, int pPosY, MerchantOffers pMerchantOffers)
    • render

      public void render(GuiGraphics pGuiGraphics, int pMouseX, int pMouseY, float pPartialTick)
      Renders the graphical user interface (GUI) element.
      Specified by:
      render in interface Renderable
      Overrides:
      render in class AbstractContainerScreen<MerchantMenu>
      Parameters:
      pGuiGraphics - the GuiGraphics object used for rendering.
      pMouseX - the x-coordinate of the mouse cursor.
      pMouseY - the y-coordinate of the mouse cursor.
      pPartialTick - the partial tick time.
    • renderButtonArrows

      private void renderButtonArrows(GuiGraphics pGuiGraphics, MerchantOffer pMerchantOffers, int pPosX, int pPosY)
    • renderAndDecorateCostA

      private void renderAndDecorateCostA(GuiGraphics pGuiGraphics, ItemStack pRealCost, ItemStack pBaseCost, int pX, int pY)
    • canScroll

      private boolean canScroll(int pNumOffers)
    • mouseScrolled

      public boolean mouseScrolled(double pMouseX, double pMouseY, double pScrollX, double pScrollY)
    • mouseDragged

      public boolean mouseDragged(double pMouseX, double pMouseY, int pButton, double pDragX, double pDragY)
      Called when the mouse is dragged within the GUI element.

      Specified by:
      mouseDragged in interface ContainerEventHandler
      Specified by:
      mouseDragged in interface GuiEventListener
      Overrides:
      mouseDragged in class AbstractContainerScreen<MerchantMenu>
      Parameters:
      pMouseX - the X coordinate of the mouse.
      pMouseY - the Y coordinate of the mouse.
      pButton - the button that is being dragged.
      pDragX - the X distance of the drag.
      pDragY - the Y distance of the drag.
      Returns:
      true if the event is consumed, false otherwise.
    • mouseClicked

      public boolean mouseClicked(double pMouseX, double pMouseY, int pButton)
      Called when a mouse button is clicked within the GUI element.

      Specified by:
      mouseClicked in interface ContainerEventHandler
      Specified by:
      mouseClicked in interface GuiEventListener
      Overrides:
      mouseClicked in class AbstractContainerScreen<MerchantMenu>
      Parameters:
      pMouseX - the X coordinate of the mouse.
      pMouseY - the Y coordinate of the mouse.
      pButton - the button that was clicked.
      Returns:
      true if the event is consumed, false otherwise.