Jump to content

Hyrancood

Members
  • Posts

    9
  • Joined

  • Last visited

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

Hyrancood's Achievements

Tree Puncher

Tree Puncher (2/8)

0

Reputation

  1. My code: https://github.com/Hyrancood/HyraRPG/tree/main/src/main/java/com/hyrancood/hyrarpg (I use 1.16.5) I create capability, but I ran into a problem. When I use my capa, values are set and output property, but each time they are called, they are reset.
  2. Because I use Mcreator to base my code. It works, so I haven't paid much attention to it. I searched visible field in ImageButton constructors, but I still don't know where I'm supposed to put it.
  3. public class ShopGuiWindow extends ContainerScreen<ShopGui.GuiContainerMod> { private World world; private int x, y, z; private PlayerEntity entity; private final static HashMap guistate = ShopGui.guistate; public ShopGuiWindow(ShopGui.GuiContainerMod container, PlayerInventory inventory, ITextComponent text) { super(container, inventory, text); this.world = container.world; this.x = container.x; this.y = container.y; this.z = container.z; this.entity = container.entity; this.xSize = 190; this.ySize = 166; } private static final ResourceLocation texture = new ResourceLocation("hyrabw:textures/shop.png"); private static final ResourceLocation BUTTONS = new ResourceLocation("hyrabw:textures/shop_buttons1.png"); private static final ResourceLocation BUTTONS2 = new ResourceLocation("hyrabw:textures/shop_buttons2.png"); public boolean visible = false; @Override public void render(MatrixStack ms, int mouseX, int mouseY, float partialTicks) { this.renderBackground(ms); super.render(ms, mouseX, mouseY, partialTicks); this.renderHoveredTooltip(ms, mouseX, mouseY); } @Override protected void drawGuiContainerBackgroundLayer(MatrixStack ms, float partialTicks, int gx, int gy) { RenderSystem.color4f(1, 1, 1, 1); RenderSystem.enableBlend(); RenderSystem.defaultBlendFunc(); Minecraft.getInstance().getTextureManager().bindTexture(texture); int k = (this.width - this.xSize) / 2; int l = (this.height - this.ySize) / 2; this.blit(ms, k, l, 0, 0, this.xSize, this.ySize, this.xSize, this.ySize); RenderSystem.disableBlend(); } @Override public boolean keyPressed(int key, int b, int c) { if (key == 256) { this.minecraft.player.closeScreen(); return true; } return super.keyPressed(key, b, c); } @Override public void tick() { super.tick(); } @Override protected void drawGuiContainerForegroundLayer(MatrixStack ms, int mouseX, int mouseY) { } @Override public void onClose() { super.onClose(); Minecraft.getInstance().keyboardListener.enableRepeatEvents(false); } @Override public void init(Minecraft minecraft, int width, int height) { super.init(minecraft, width, height); minecraft.keyboardListener.enableRepeatEvents(true); this.addButton(new ImageButton(this.guiLeft + 4, this.guiTop + 4, 32, 32, 0, 0, 128, BUTTONS2, e -> { if (((entity.getCapability(HyrabwModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new HyrabwModVariables.PlayerVariables())).team) .equals("red")) { HyrabwMod.PACKET_HANDLER.sendToServer(new ShopGui.ButtonPressedMessage(0, x, y, z)); ShopGui.handleButtonAction(entity, 0, x, y, z); } }) { @Override public void render(MatrixStack ms, int gx, int gy, float ticks) { if (((entity.getCapability(HyrabwModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new HyrabwModVariables.PlayerVariables())).team) .equals("red")) super.render(ms, gx, gy, ticks); } }); this.addButton(new ImageButton(this.guiLeft + 4, this.guiTop + 4, 32, 32, 0, 32, 128, BUTTONS2, e -> { if (((entity.getCapability(HyrabwModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new HyrabwModVariables.PlayerVariables())).team) .equals("blue")) { HyrabwMod.PACKET_HANDLER.sendToServer(new ShopGui.ButtonPressedMessage(1, x, y, z)); ShopGui.handleButtonAction(entity, 1, x, y, z); } }) { @Override public void renderButton(MatrixStack ms, int gx, int gy, float ticks) { if (((entity.getCapability(HyrabwModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new HyrabwModVariables.PlayerVariables())).team) .equals("blue")) super.renderButton(ms, gx, gy, ticks); } }); } }
  4. I look more closely at Widget and Button classes, but don't understand how to use the "visible" field so I just tried adding it as ResourseLocation and set it to false, but it did nothing.
  5. I tried setting the value to false, but it had no effect so I think I'm doing something wrong. P.S. There's no AbstractWidget in 1.16.5, I only find Widget
  6. Can you explain how and where to use it please. Thank you in advance.
  7. @Override public void init(Minecraft minecraft, int width, int height) { super.init(minecraft, width, height); minecraft.keyboardListener.enableRepeatEvents(true); this.addButton(new ImageButton(this.guiLeft + 4, this.guiTop + 30, 32, 32, 192, 0, 128, BUTTONS2, e -> { if (((entity.getCapability(HyrabwModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new HyrabwModVariables.PlayerVariables())).team) .equals("blue")){ HyrabwMod.PACKET_HANDLER.sendToServer(new ShopGui.ButtonPressedMessage(0, x, y, z)); ShopGui.handleButtonAction(entity, 0, x, y, z); } }) { @Override public void render(MatrixStack ms, int gx, int gy, float ticks) { if (((entity.getCapability(HyrabwModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new HyrabwModVariables.PlayerVariables())).team) .equals("blue")) super.render(ms, gx, gy, ticks); } }); this.addButton(new ImageButton(this.guiLeft + 4, this.guiTop + 30, 32, 32, 192, 0, 128, BUTTONS2, e -> { if (((entity.getCapability(HyrabwModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new HyrabwModVariables.PlayerVariables())).team) .equals("red")){ HyrabwMod.PACKET_HANDLER.sendToServer(new ShopGui.ButtonPressedMessage(1, x, y, z)); ShopGui.handleButtonAction(entity, 1, x, y, z); } }) { @Override public void render(MatrixStack ms, int gx, int gy, float ticks) { if (((entity.getCapability(HyrabwModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new HyrabwModVariables.PlayerVariables())).team) .equals("red")) super.render(ms, gx, gy, ticks); } }); }}
  8. I want to make a gui with a few pages and buttons which are displayed on the different pages. But this undisplayed buttons overlap others buttons, so I can't interact with them. How to solve this?
  9. Hello! I'm beginner in minecraft modding. I want to create a GUI, that opens then key pressed, with buttons. I already create and register a key, but I faced with some troubles when try to make a interface. Firstly, if I want add items to the player inventory when the button is pressed, should I create container? And how to make the interface open when key pressed?
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.