Number Variable as Overlay Component Position

Started by GamesOfLife on

Topic category: Help with Minecraft modding (Java Edition)

Joined Feb 2024
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Number Variable as Overlay Component Position

I am attempting to create a fishing minigame similar to that in Stardew Valley. I have an overlay with two components: a "fishbackground", which is stationary, and a "fish" which I want the X position of to be set to a PLAYER_PERSISTENT number variable(in this case, "fishpos"). You can't do this in the overlay UI(I think), so I'm trying to do it in the Java editor.
My Java is rusty and my knowledge on the innerworkings of Minecraft and MCreator is limited, so I'm not sure how to do this.


Below is my attempt. I copy-pasted a line referencing the variable from a procedure and threw it into one of parameters of the getGuiGraphics().blit method, but I just got an error. Help would be appreciated :P

FishingOverlay.java snippet :

if (true) {
	event.getGuiGraphics().blit(ResourceLocation.parse("gone_fishin:textures/screens/fishbackground.png"), w / 2 + -90, h / 2 + 80, 0, 0, 182, 16, 182, 16);

	//THIS GUY RIGHT HERE GRRRRR
	event.getGuiGraphics().blit(ResourceLocation.parse("gone_fishin:textures/screens/fish.png"), w / 2 - 7, h / 2 + entity.getData(GoneFishinModVariables.PLAYER_VARIABLES).fishpos, 0, 0, 16, 16, 16, 16);
}