Advertisement
Guest User

CapCompScreen

a guest
Oct 27th, 2020
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.43 KB | None | 0 0
  1. public class CapCompScreen extends ContainerScreen<CapCompContainer> implements IHasContainer<CapCompContainer> {
  2. private static final ResourceLocation BUTTON_RIGHT_TEXTURE = Main.getId("textures/gui/container/right.png");
  3. private static final ResourceLocation BUTTON_LEFT_TEXTURE = Main.getId("textures/gui/container/left.png");
  4. private final int containerID;
  5. private final int containerInd;
  6. private final int xLeft;
  7. private final int yTop;
  8. private int newContainerInd;
  9.  
  10. public static void register() {
  11. ScreenManager.registerFactory(ModContainerTypes.MULTI_9X3.get(), CapCompScreen::new);
  12. }
  13.  
  14. /** The ResourceLocation containing the chest GUI texture. */
  15. private static final ResourceLocation CHEST_GUI_TEXTURE = Main.getId("textures/gui/container/multi_27_default.png");
  16.  
  17. public CapCompScreen(CapCompContainer p_i51095_1_, PlayerInventory p_i51095_2_, ITextComponent p_i51095_3_) {
  18. super(p_i51095_1_, p_i51095_2_, p_i51095_3_);
  19.  
  20. this.field_230711_n_ = false;
  21. this.guiLeft = 0;
  22. this.guiTop = 0;
  23. this.xSize = 176;
  24. this.ySize = 186;
  25. this.xLeft = this.guiLeft + this.xSize;
  26. this.yTop = this.guiTop + this.ySize;
  27.  
  28. this.field_238742_p_ = 8; //xTitle
  29. this.field_238743_q_ = 8; //yTitle
  30. this.field_238744_r_ = 8; //xInventory
  31. this.field_238745_s_ = 93; //yInventory
  32.  
  33. //this.container = p_i51095_1_;
  34. this.containerInd = p_i51095_1_.getInvInd();
  35. this.newContainerInd = this.containerInd;
  36. this.containerID = p_i51095_1_.getID();
  37. }
  38.  
  39. protected void func_231160_c_() {
  40. super.func_231160_c_();
  41. this.func_230480_a_(
  42. new ImageButton(this.guiLeft + this.xSize - 20, this.guiTop - 20 - 6,
  43. 20, 20,
  44. 0, 0, 21, BUTTON_RIGHT_TEXTURE, (p_214076_1_) -> {
  45. this.newContainerInd++;
  46. if (this.newContainerInd > 15) {
  47. this.newContainerInd = 0;
  48. }
  49. PacketUpdateContainer packet = new PacketUpdateContainer(this.containerID, this.newContainerInd);
  50. PacketHandler.sendToServer(packet);
  51. })
  52. );
  53. this.func_230480_a_(
  54. new ImageButton(this.guiLeft, this.guiTop - 20 - 6,
  55. 20, 20,
  56. 0, 0, 21, BUTTON_LEFT_TEXTURE, (p_214076_1_) -> {
  57. this.newContainerInd--;
  58. if (this.newContainerInd < 0) {
  59. this.newContainerInd = 15;
  60. }
  61. PacketUpdateContainer packet = new PacketUpdateContainer(this.containerID, this.newContainerInd);
  62. PacketHandler.sendToServer(packet);
  63. })
  64. );
  65. }
  66.  
  67. public void func_230430_a_(MatrixStack p_230430_1_, int p_230430_2_, int p_230430_3_, float p_230430_4_) {
  68. this.func_230446_a_(p_230430_1_);
  69. super.func_230430_a_(p_230430_1_, p_230430_2_, p_230430_3_, p_230430_4_);
  70. this.func_230459_a_(p_230430_1_, p_230430_2_, p_230430_3_);
  71. }
  72.  
  73. protected void func_230450_a_(MatrixStack p_230450_1_, float p_230450_2_, int p_230450_3_, int p_230450_4_) {
  74. RenderSystem.color4f(1.0F, 1.0F, 1.0F, 1.0F);
  75. this.field_230706_i_.getTextureManager().bindTexture(CHEST_GUI_TEXTURE);
  76. this.func_238474_b_(p_230450_1_, this.guiLeft, this.guiTop, 0, 0, this.xSize, this.ySize);
  77. }
  78. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement