Jump to content

lolgeny

Members
  • Posts

    12
  • Joined

  • Last visited

Everything posted by lolgeny

  1. Update: I've been looking at the Texture class and think I should use that - but I can't find a transformer for it
  2. Hi, I've got some arrows in an ImageButton made from a ResourceLocation. Is there a way to rotate them - either at creation or rendering (it doesn't matter)? I am using the constructor public ImageButton(int xIn, int yIn, int widthIn, int heightIn, int xTexStartIn, int yTexStartIn, int yDiffTextIn, ResourceLocation resourceLocationIn, Button.IPressable onPressIn) Is there a different constructor that I could use? Or some way of modifying the ResourceLocation? They are just rendered with super.render(...). Thanks in advance. If it came to it, I could rotate the arrows on the file but it would be useful if I could do it dynamically.
  3. Thanks, it works!
  4. public class MyGUI extends Screen { public MyGUI() { super(new StringTextComponent("My GUI")); } @Override public void init() { this.addButton(new Button(this.width/2-100, this.height/2-50,200, 100, "Click me!", (button) -> this.onClose())); } @Override public void render(int p_render_1_, int p_render_2_, float p_render_3_) { this.renderBackground(); super.render(p_render_1_, p_render_2_, p_render_3_); this.drawCenteredString(this.font, "Yes, click it!", this.width/2, this.height/2 + 70, 0xFFFFFF); } }
  5. Thank you! It now loads the GUI, but there's still a problem... Have I created the button wrongly?
  6. Thank you for your response! I've changed some things: on the GUI, I now use super(new StringTextComponent("My GUI")); and to launch it, I use @Override public ActionResultType onBlockActivated(BlockState state, World worldIn, BlockPos pos, PlayerEntity player, Hand handIn, BlockRayTraceResult p_225533_6_) { if (worldIn.isRemote()) { DistExecutor.runWhenOn(Dist.CLIENT, () -> () -> Minecraft.getInstance().displayGuiScreen(new MyGUI())); } return ActionResultType.SUCCESS; } Now it crashes with a NullPointerException, not freezing this time: it just goes to 'Saving World' and crashes on the renderBackground method java.lang.NullPointerException: Rendering screen at net.minecraft.client.gui.screen.Screen.renderBackground(Screen.java:367) ~[forge-1.15.2-31.1.46_mapped_snapshot_20200225-1.15.1-recomp.jar:?] {re:classloading,pl:runtimedistcleaner:A}
  7. On my block, I have @Override public ActionResultType onBlockActivated(BlockState state, World worldIn, BlockPos pos, PlayerEntity player, Hand handIn, BlockRayTraceResult p_225533_6_) { Minecraft.getInstance().displayGuiScreen(new MyGUI()); return ActionResultType.SUCCESS; } The log shows nothing abnormal, doesn't mention GUI/crashing and only has an error that I force close the game. How do you construct it normally? That was really the only method I could find to create one from a string, sorry if I'm overlooking something here
  8. I've also tried with Objects.requireNonNull(ITextComponent.Serializer.fromJson("{\"text\": \"MyGUI\"}")) same thing happened. I got the idea of null from https://forum.islandearth.net/d/10-forge-modding-tutorial-1-14-creating-custom-guis-1-3 but to be fair I haven't been completely following that.
  9. Hello, I'm trying to make a GUI using Screen. So far I've got public class MyGUI extends Screen { public MyGUI() { super(null); } @Override public void init(Minecraft p_init_1_, int p_init_2_, int p_init_3_) { this.addButton(new Button(this.width/2-100, this.height/2-50,200, 100, "Click me!", (button) -> this.onClose())); } @Override public void render(int p_render_1_, int p_render_2_, float p_render_3_) { this.renderBackground(); super.render(p_render_1_, p_render_2_, p_render_3_); this.drawCenteredString(this.font, "Click the button!", this.width/2, this.height/2 + 70, 0xFFFFFF); } } It opens the Screen when I right-click on my block. Right now it draws the background (i.e the screen darkens) but not the buttons/text, then proceeds to freeze the game after a few seconds / pressing Esc. Thanks in advance!
  10. Sorry if I'm missing something here, but I'm trying to create a gui with custom buttons. When looking at the function signature for the ImageButton constructor, I saw the parameters int xTexStartIn, int yTexStartIn, int yDiffTextIn What are they, and what should I set them to? Thanks in advance, and sorry again that I'm new to modding and don't know this sort of stuff yet.
×
×
  • Create New...

Important Information

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