Palladium 🐿️

Palladium 🐿️

290k Downloads

An additional function for "guiUtil"

Spyeedy opened this issue · 0 comments

commented

The existing blit function in GuiUtilJS only draws textures in 256x256 resolution. So smaller textures, say 16x16 would be scaled to fit into 256x256 size.

It would be nice to have a function overload for guiUtil to specify the resolution size of the texture. I believe Minecraft has a static blit function for that.

Minecraft's code in GuiComponent (1.19.2)
public static void blit(PoseStack pPoseStack, int pX, int pY, int pBlitOffset, float pUOffset, float pVOffset, int pUWidth, int pVHeight, int pTextureHeight, int pTextureWidth) {
    innerBlit(pPoseStack, pX, pX + pUWidth, pY, pY + pVHeight, pBlitOffset, pUWidth, pVHeight, pUOffset, pVOffset, pTextureHeight, pTextureWidth);
}

public static void blit(PoseStack pPoseStack, int pX, int pY, int pWidth, int pHeight, float pUOffset, float pVOffset, int pUWidth, int pVHeight, int pTextureWidth, int pTextureHeight) {
    innerBlit(pPoseStack, pX, pX + pWidth, pY, pY + pHeight, 0, pUWidth, pVHeight, pUOffset, pVOffset, pTextureWidth, pTextureHeight);
}

And perhaps a way to scale a texture regardless of their resolution.
I attempted to use poseStack and the scale function within the PoseStack class, worked like a charm in my script

PoseStack scale snippet
PalladiumEvents.registerGuiOverlays(event => {
	event.register('spy_pack/omnitrix_select_overlay', (minecraft, gui, poseStack, partialTick, screenWidth, screenHeight) => {
		const selectedAlien = palladium.getProperty(minecraft.player, CURRENT_ALIEN);

		let ability = palladium.getAbilityEntry(minecraft.player, "spy_pack:omni_god", "open_omni");

		let scaleVal = 34.0/256.0;

		if (ability && ability.isEnabled()) {
			poseStack.pushPose();
			poseStack.scale(scaleVal, scaleVal, 1.0);
			guiUtil.blit(alien_texture_path + "omnitrix.png", gui, poseStack, 10, 10, 0, 0, 256, 256)
			poseStack.popPose();
		}
	});
});