<commit_before>package sx.lambda.voxel.client.gui.screens

import com.badlogic.gdx.Gdx
import com.badlogic.gdx.graphics.Texture
import com.badlogic.gdx.graphics.g2d.SpriteBatch
import groovy.transform.CompileStatic
import sx.lambda.voxel.VoxelGameClient
import sx.lambda.voxel.api.BuiltInBlockIds
import sx.lambda.voxel.api.VoxelGameAPI
import sx.lambda.voxel.client.gui.GuiScreen

import static com.badlogic.gdx.graphics.GL20.*

@CompileStatic
class IngameHUD  implements GuiScreen {

    private Texture icons

    private final float TEXTURE_PERCENT = 0.05f

    public IngameHUD() {
        super()
    }

    @Override
    public void render(boolean inGame, SpriteBatch guiBatch) {
        Gdx.gl.glEnable(GL_BLEND)

        int blockInHead = VoxelGameClient.instance.player.getBlockInHead(VoxelGameClient.instance.world)
        if(blockInHead != null) {
            switch(blockInHead) {
                case BuiltInBlockIds.WATER_ID:
                    VoxelGameAPI.instance.getBlockByID(blockInHead).getRenderer().render2d(guiBatch, 0, 0, Math.max(Gdx.graphics.getWidth(), Gdx.graphics.getHeight()))
                    // TODO add ability to set transparency with a spritebatcher so that we can render transparent overlay for the water
                    break;
            }
        }

        VoxelGameAPI.instance.getBlockByID(VoxelGameClient.instance.player.itemInHand).renderer.render2d(guiBatch, 0, 0, 50);

        // Draw crosshair (after guiBatcher render because it needs to render with its own blending mode
        float centerX = Gdx.graphics.getWidth()/2f as float
        float centerY = Gdx.graphics.getHeight()/2f as float
        float crosshairSize = 32
        float halfCrosshairSize = crosshairSize/2f as float
        this.drawTexture(guiBatch, 0, (int)Math.round(centerX-halfCrosshairSize), (int)Math.round(centerY-halfCrosshairSize), (int)Math.round(centerX+halfCrosshairSize), (int)Math.round(centerY+halfCrosshairSize))
    }

    @Override
    void finish() {
        icons.dispose()
    }

    @Override
    void onMouseClick(int clickType) {}

    @Override
    public void init() {
        this.icons = new Texture(Gdx.files.internal("textures/gui/icons.png"))
    }

    private void drawTexture(SpriteBatch batch, int number, int x, int y, int x2, int y2) {
        float u = ((number%9)*TEXTURE_PERCENT);
        float v = ((number/9)*TEXTURE_PERCENT);
        float u2 = u+TEXTURE_PERCENT-0.001f
        float v2 = v+TEXTURE_PERCENT-0.001f

        batch.draw(icons, x, y, x2, y2, u, v, u2, v2)
    }

    public Texture getIcons() { icons }

}<commit_msg>Fix crosshair sizing issue<commit_after>package sx.lambda.voxel.client.gui.screens

import com.badlogic.gdx.Gdx
import com.badlogic.gdx.graphics.Texture
import com.badlogic.gdx.graphics.g2d.SpriteBatch
import groovy.transform.CompileStatic
import sx.lambda.voxel.VoxelGameClient
import sx.lambda.voxel.api.BuiltInBlockIds
import sx.lambda.voxel.api.VoxelGameAPI
import sx.lambda.voxel.client.gui.GuiScreen

import static com.badlogic.gdx.graphics.GL20.*

@CompileStatic
class IngameHUD  implements GuiScreen {

    private Texture icons

    private final float TEXTURE_PERCENT = 0.05f

    public IngameHUD() {
        super()
    }

    @Override
    public void render(boolean inGame, SpriteBatch guiBatch) {
        Gdx.gl.glEnable(GL_BLEND)

        int blockInHead = VoxelGameClient.instance.player.getBlockInHead(VoxelGameClient.instance.world)
        if(blockInHead != null) {
            switch(blockInHead) {
                case BuiltInBlockIds.WATER_ID:
                    VoxelGameAPI.instance.getBlockByID(blockInHead).getRenderer().render2d(guiBatch, 0, 0, Math.max(Gdx.graphics.getWidth(), Gdx.graphics.getHeight()))
                    // TODO add ability to set transparency with a spritebatcher so that we can render transparent overlay for the water
                    break;
            }
        }

        VoxelGameAPI.instance.getBlockByID(VoxelGameClient.instance.player.itemInHand).renderer.render2d(guiBatch, 0, 0, 50);

        // Draw crosshair (after guiBatcher render because it needs to render with its own blending mode
        float centerX = Gdx.graphics.getWidth()/2f as float
        float centerY = Gdx.graphics.getHeight()/2f as float
        int crosshairSize = 32
        float halfCrosshairSize = crosshairSize/2f as float
        this.drawTexture(guiBatch, 0, (int)Math.round(centerX-halfCrosshairSize), (int)Math.round(centerY+halfCrosshairSize), crosshairSize, crosshairSize)
    }

    @Override
    void finish() {
        icons.dispose()
    }

    @Override
    void onMouseClick(int clickType) {}

    @Override
    public void init() {
        this.icons = new Texture(Gdx.files.internal("textures/gui/icons.png"))
    }

    private void drawTexture(SpriteBatch batch, int number, int x, int y, int width, int height) {
        float u = ((number%9)*TEXTURE_PERCENT);
        float v = ((number/9)*TEXTURE_PERCENT);
        float u2 = u+TEXTURE_PERCENT-0.001f
        float v2 = v+TEXTURE_PERCENT-0.001f

        batch.draw(icons, x, y, width, height, u, v, u2, v2)
    }

    public Texture getIcons() { icons }

}
{'fraction_non_alphanumeric': 0.09704233520201044, 'fraction_numerical': 0.013918422578774405, 'mean_word_length': 3.0077459333849728, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6645504', 'n_tokens_mistral': 1774, 'n_tokens_neox': 1644, 'n_words': 353}