Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class AmberProtectionOverlay {
- private static final ResourceLocation AMBER_PROTECTION_TEXTURE = new ResourceLocation(UnusualPrehistory.MODID, "textures/amber_protection/amber_protection.png");
- private static final ResourceLocation AMBER_PROTECTION_HALF_TEXTURE = new ResourceLocation(UnusualPrehistory.MODID, "textures/amber_protection/amber_protection_half.png");
- //Should be equal to max health
- private static final int MAX_PROTECTION_LEVELS_PER_ROW = 20;
- private static final int BLIT_SIZE = 9;
- private static final int BLIT_SPACING = 8;
- private static final int ROW_HEIGHT_OFFSET = 10;
- private static final int HEART_WIDTH_OFFSET = 80;
- public static final IGuiOverlay HUD_AMBER_PROTECTION = (gui, poseStack, partialTick, width, height) -> {
- int centerX = width / 2;
- int bottomY = height;
- int numProtectionLevels = ClientAmberProtectionData.getAmberProtection();
- boolean shouldBlit = numProtectionLevels > 0;
- boolean isCreative = Minecraft.getInstance().player.isCreative();
- int blitX = centerX - 91;
- int blitY = bottomY - 39;
- int xOffset = 0;
- for (int level = 0; level <= numProtectionLevels && shouldBlit && !isCreative; level++) {
- int rowMultpl = Mth.absFloor(level / MAX_PROTECTION_LEVELS_PER_ROW);
- blitY = blitY - (rowMultpl * ROW_HEIGHT_OFFSET);
- xOffset = (HEART_WIDTH_OFFSET * rowMultpl);
- if (level % 2 == 0) {
- blitX = centerX - 91 + ((level / 2) * BLIT_SPACING) - xOffset;
- }
- if (level < numProtectionLevels) {
- if (level % 2 == 0) {
- RenderSystem.setShaderTexture(0, AMBER_PROTECTION_HALF_TEXTURE);
- } else {
- RenderSystem.setShaderTexture(0, AMBER_PROTECTION_TEXTURE);
- }
- gui.blit(poseStack, blitX, blitY, 0, 0, BLIT_SIZE, BLIT_SIZE, BLIT_SIZE, BLIT_SIZE);
- } else {
- break;
- }
- }
- };
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement