<commit_before>package com.cazsius.solcarrot.client.gui;

import com.cazsius.solcarrot.capability.FoodCapability;
import com.cazsius.solcarrot.capability.FoodInstance;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;

import java.util.List;
import java.util.Optional;

import static com.cazsius.solcarrot.lib.Localization.localized;

@SideOnly(Side.CLIENT)
public final class GuiFoodBook extends GuiScreen {
	private static final ResourceLocation backgroundTexture = new ResourceLocation("textures/gui/book.png");
	private static final int textureWidth = 192;
	private static final int textureHeight = 192;
	
	private static final int foodsPerRow = 5;
	private static final int rowsPerPage = 5;
	private static final int foodsPerPage = foodsPerRow * rowsPerPage;
	
	private int leftEdge;
	private int topEdge;
	private int centerX;
	private int centerY;
	
	private NextPageButton nextPageButton;
	private NextPageButton prevPageButton;
	private GuiButton doneButton;
	
	private final FoodCapability foodCapability;
	private final List<FoodInstance> foodLog;
	
	private int pageCount;
	private int currentPage = 0;
	
	public GuiFoodBook(EntityPlayer player) {
		super();
		
		foodCapability = FoodCapability.get(player);
		foodLog = foodCapability.getHistory();
		pageCount = (foodLog.size() + foodsPerPage - 1) / foodsPerPage;
		System.out.println("page count: " + pageCount + ", foods per page:" + foodsPerPage);
	}
	
	@Override
	public void initGui() {
		super.initGui();
		
		centerX = width / 2;
		centerY = height / 2;
		leftEdge = centerX - (textureWidth) / 2;
		topEdge = centerY - (textureHeight) / 2;
		
		buttonList.clear();
		
		int pageFlipButtonSpacing = 50;
		prevPageButton = addButton(new NextPageButton(1, centerX - pageFlipButtonSpacing / 2 - NextPageButton.width, topEdge + 150, false));
		nextPageButton = addButton(new NextPageButton(2, centerX + pageFlipButtonSpacing / 2, topEdge + 150, true));
		
		updateButtonVisibility();
	}
	
	private void updateButtonVisibility() {
		this.nextPageButton.visible = currentPage < pageCount - 1;
		this.prevPageButton.visible = currentPage > 0;
	}
	
	public void drawScreen(int mouseX, int mouseY, float partialTicks) {
		drawDefaultBackground();
		
		GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
		mc.getTextureManager().bindTexture(backgroundTexture);
		drawTexturedModalRect(leftEdge, topEdge, 0, 0, textureWidth, textureHeight);<commit_msg>removed debug message<commit_after>package com.cazsius.solcarrot.client.gui;

import com.cazsius.solcarrot.capability.FoodCapability;
import com.cazsius.solcarrot.capability.FoodInstance;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;

import java.util.List;
import java.util.Optional;

import static com.cazsius.solcarrot.lib.Localization.localized;

@SideOnly(Side.CLIENT)
public final class GuiFoodBook extends GuiScreen {
	private static final ResourceLocation backgroundTexture = new ResourceLocation("textures/gui/book.png");
	private static final int textureWidth = 192;
	private static final int textureHeight = 192;
	
	private static final int foodsPerRow = 5;
	private static final int rowsPerPage = 5;
	private static final int foodsPerPage = foodsPerRow * rowsPerPage;
	
	private int leftEdge;
	private int topEdge;
	private int centerX;
	private int centerY;
	
	private NextPageButton nextPageButton;
	private NextPageButton prevPageButton;
	private GuiButton doneButton;
	
	private final FoodCapability foodCapability;
	private final List<FoodInstance> foodLog;
	
	private int pageCount;
	private int currentPage = 0;
	
	public GuiFoodBook(EntityPlayer player) {
		super();
		
		foodCapability = FoodCapability.get(player);
		foodLog = foodCapability.getHistory();
		pageCount = (foodLog.size() + foodsPerPage - 1) / foodsPerPage;
	}
	
	@Override
	public void initGui() {
		super.initGui();
		
		centerX = width / 2;
		centerY = height / 2;
		leftEdge = centerX - (textureWidth) / 2;
		topEdge = centerY - (textureHeight) / 2;
		
		buttonList.clear();
		
		int pageFlipButtonSpacing = 50;
		prevPageButton = addButton(new NextPageButton(1, centerX - pageFlipButtonSpacing / 2 - NextPageButton.width, topEdge + 150, false));
		nextPageButton = addButton(new NextPageButton(2, centerX + pageFlipButtonSpacing / 2, topEdge + 150, true));
		
		updateButtonVisibility();
	}
	
	private void updateButtonVisibility() {
		this.nextPageButton.visible = currentPage < pageCount - 1;
		this.prevPageButton.visible = currentPage > 0;
	}
	
	public void drawScreen(int mouseX, int mouseY, float partialTicks) {
		drawDefaultBackground();
		
		GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
		mc.getTextureManager().bindTexture(backgroundTexture);
		drawTexturedModalRect(leftEdge, topEdge, 0, 0, textureWidth, textureHeight);
{'fraction_non_alphanumeric': 0.09421487603305785, 'fraction_numerical': 0.013957759412304867, 'mean_word_length': 5.098544232922732, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, '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': '4043570', 'n_tokens_mistral': 1838, 'n_tokens_neox': 1667, 'n_words': 404}