<commit_before>#region LICENCE
/*
Copyright 2016-2017 video_error

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
 */
#endregion

using System;
using ClassicalSharp.Entities;
using ClassicalSharp.Gui.Widgets;
using ClassicalSharp.Survival.UI;
using OpenTK;
using OpenTK.Input;

namespace ClassicalSharp.Survival {

	/// <summary>
	/// A mod for adding the features of Minecraft Classic Survival Test version 0.24_07(http://minecraft.gamepedia.com/Version_history/Classic#0.24_07).
	/// </summary>
	internal sealed class SurvivalTest {

		// Declares and assigns the mod name.
		public const string ModName = "SurvivalTest M0d";
		// Declares and assigns the mod version.
		public const string ModVersion = "PR0T0TYPE[1]";
		// Declares and assigns the mod author.
		public const string ModAuthor = "video_error";
		// Declares and assigns the mod name with ampersand color codes.
		public const string ModNameAmpersand = "&cSurvival&eTest &cM0d";
		// Declares and assigns the mod name with percent color codes.
		public const string ModNamePercent = "%cSurvival%eTest %cM0d";
		// Declares and assigns the mod version with ampersand color codes.
		public const string ModVersionAmpersand = "&5PR0T0TYPE&8[&d1&8]";
		// Declares and assigns the mod version with percent color codes.
		public const string ModVersionPercent = "%5PR0T0TYPE%8[%d1%8]";
		// Declares and assigns the mod author with ampersand color codes.
		public const string ModAuthorAmpersand = "&fv&ei&bd&ae&do&8_&cerror";
		// Declares and assigns the mod author with percent color codes.
		public const string ModAuthorPercent = "%fv%ei%bd%ae%do%8_%cerror";
		// Declares and assigns the mod name with version.
		public const string ModNameWithVersion = ModName + " - " + ModVersion;
		// Declares and assigns the mod name with version and ampersand color codes.
		public const string ModNameWithVersionAmpersand = ModNameAmpersand + " &8- " + ModVersionAmpersand;
		// Declares and assigns the mod name with version and percent color codes.
		public const string ModNameWithVersionPercent = ModNamePercent + " %8- " + ModVersionPercent;
		// Declares and assigns the full mode name including: mod name, mod version, and mod author.
		public const string FullModName = ModName + " - " + ModVersion + " By: " + ModAuthor;
		// Declares and assigns the full mode name including: mod name, mod version, and mod author with apersand color codes.
		public const string FullModNameAmpersand = ModNameAmpersand + " &8- " + ModVersionAmpersand + " &8By: " + ModAuthorAmpersand;
		// Declares and assigns the full mode name including: mod name, mod version, and mod author with percent color codes.
		public const string FullModNamePercent = ModNamePercent + " %8- " + ModVersionPercent + " %8By: " + ModAuthorPercent;

		// Declares the main game value responsible for all other game elements.
		private readonly Game game;

		// Declares the wrapper value used for grabbing all elements used by the survival test mod.
		private readonly Wrapper wrapper;

		/// <summary>
		/// Responsible for class instantiation and used for initialization.
		/// </summary>
		public SurvivalTest(Game game) {
			// Assigns the main game value to the inputed game paramter.
			this.game = game;

			// Assigns the wrapper value by creating a new instance and inputing the needed game element value.
			wrapper = new Wrapper(game);

			// Assigns the old inventory keybinding value to the current inventory keybinding.
			OldInventoryKeybind = wrapper.GetInputHandler.Keys[KeyBind.Inventory];

			// Attaches the method for loading the player's inventory to the on new map loaded event for initialization.
			wrapper.GetWorldEvents.OnNewMapLoaded += LoadInventory;
			wrapper.GetWorldEvents.OnNewMap += Respawn;

			// Attaches the method for rebinding the inventory keybind on game window closing.
			((INativeWindow)game.window).Closed += RebindInventoryKeybind;
		}

		// Declares and assigns the under heart texture for the health bar.
		private TextureRec UnderHeartTexRect = new TextureRec(16/256F, 0/256F, 9/256F, 9/256F);
		// Declares and assigns the heart texture for the health bar.
		private TextureRec HeartTexRect = new TextureRec(52/256F, 0/256F, 9/256F, 9/256F);
		// Declares and assigns the half heart texture for the health bar.
		private TextureRec HalfHeartTexRect = new TextureRec(61/256F, 0/256F, 9/256F, 9/256F);

		/// <summary>
		/// Responsible for rendering the player's health bar ingame.
		/// </summary>
		public void RenderHealthBar(BlockHotbarWidget hotbar) {
			// Declares and assigns the evaluation of the selected block's size.
			int selectedBlockSize = (int)Math.Ceiling(22.5F * 2 * game.GuiHotbarScale);
			// Declares and assigns the evaluation of the hotbar's scale which is used for the scale of the heart textures.
			int scale = (int)(18 * game.GuiHotbarScale);

			// Declares and assigns the offset of the hotbar's scale.
			float offset = 16 * game.GuiHotbarScale;

			// Declares the X value used for the heart textures.
			int xValue = 0;
			// Declares and assigns the Y value's delta used for the heart textures, evaluated using the selected block's size and the scale.
			int yValue = game.Height - selectedBlockSize - scale - 2;
			// Declares and assigns the icon texture used for grabbing the heart textures.
			int iconTex = wrapper.GetIGuiInterface.IconsTex;
			// Using the graphics API, the texture is binded.
			wrapper.GetIGraphicsAPI.BindTexture(iconTex);

			// Responsible for rendering the under heart textures.
			for(int underHeart = 0; underHeart < MaxHealth / 2; underHeart++) {
				// Assigns the X value for the under heart texture using the hotbar's X value,
				// the for loop iteration value, and the offset.
				xValue = hotbar.X + (int)(underHeart * offset);

				// Declares and assigns the under heart texture using the binded icon texture,
				// X value, Y value, scale, and the under heart texture rectangle.
				Texture underHeartTex = new Texture(iconTex, xValue, yValue, scale, scale, UnderHeartTexRect);

				// Tells the graphics API to apply texturing when rasterizing primitives.
				wrapper.GetIGraphicsAPI.Texturing = true;
				// Renders the under heart texture using the graphics API.
				underHeartTex.Render(wrapper.GetIGraphicsAPI);
				// Tells the graphics API we no longer need to apply texturing when rasterizing primitives.
				wrapper.GetIGraphicsAPI.Texturing = false;
			}

			// Declares and assigns the half heart offset used for deciding whether to render an extra half heart or not.
			int halfHeartOffset = 1;

			// Detects whether the player's health is an even or odd number,
			// ensuring that an extra half heart isn't or is rendered.
			if(Health % 2 == 0) {
				// Assigns the half heart offset to one.
				halfHeartOffset = 1;
			} else {
				// Assigns the half heart offset to minus one.
				halfHeartOffset = -1;
			}

			// Responsible for rendering the half heart textures.
			for(int halfHeart = 0; halfHeart < Health / 2 - halfHeartOffset; halfHeart++) {
				// Assigns the X value for the half heart texture using the hotbar's X value,
				// the for loop iteration value, and the offset.
				xValue = hotbar.X + (int)(halfHeart * offset);

				// Declares and assigns the half heart texture using the binded icon texture,
				// X value, Y value, scale, and the half heart texture rectangle.
				Texture halfHeartTex = new Texture(iconTex, xValue, yValue, scale, scale, HalfHeartTexRect);

				// Tells the graphics API to apply texturing when rasterizing primitives.
				wrapper.GetIGraphicsAPI.Texturing = true;
				// Renders the half heart texture using the graphics API.
				halfHeartTex.Render(wrapper.GetIGraphicsAPI);
				// Tells the graphics API we no longer need to apply texturing when rasterizing primitives.
				wrapper.GetIGraphicsAPI.Texturing = false;
			}

			// Responsible for rendering the heart textures.
			for(int heart = 0; heart < Health / 2; heart++) {
				// Assigns the X value for the heart texture using the hotbar's X value,
				// the for loop iteration value, and the offset.
				xValue = hotbar.X + (int)(heart * offset);

				// Declares and assigns the heart texture using the binded icon texture,
				// X value, Y value, scale, and the half heart texture rectangle.
				Texture heartTex = new Texture(iconTex, xValue, yValue, scale, scale, HeartTexRect);

				// Tells the graphics API to apply texturing when rasterizing primitives.
				wrapper.GetIGraphicsAPI.Texturing = true;
				// Renders the heart texture using the graphics API.
				heartTex.Render(wrapper.GetIGraphicsAPI);
				// Tells the graphics API we no longer need to apply texturing when rasterizing primitives.
				wrapper.GetIGraphicsAPI.Texturing = false;
			}
		}

		bool CanRenderBubbleBar;

		private TextureRec BubbleTexRec = new TextureRec(16/256F, 18/256F, 9/256F, 9/256F);

		public void RenderBubbleBar(BlockHotbarWidget hotbar) {
			if(CanRenderBubbleBar) {
				int selectedBlockSize = (int)Math.Ceiling(22.5F * 2 * game.GuiHotbarScale);
				int scale = (int)(18 * game.GuiHotbarScale);

				float offset = 16 * game.GuiHotbarScale;

				int xValue = 0;
				int yValue = game.Height - selectedBlockSize - scale * 2 - 2;
				int iconTex = wrapper.GetIGuiInterface.IconsTex;

				wrapper.GetIGraphicsAPI.BindTexture(iconTex);

				for(int bubble = 0; bubble < LungCapacity; bubble++) {
					xValue = hotbar.X + (int)(bubble * offset);

					Texture bubbleTex = new Texture(iconTex, xValue, yValue, scale, scale, BubbleTexRec);

					wrapper.GetIGraphicsAPI.Texturing = true;

					bubbleTex.Render(wrapper.GetIGraphicsAPI);
<commit_msg>Centralized rendering methods under one method.<commit_after>#region LICENCE
/*
Copyright 2016-2017 video_error

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
 */
#endregion

using System;
using ClassicalSharp.Entities;
using ClassicalSharp.Gui.Widgets;
using ClassicalSharp.Survival.UI;
using OpenTK;
using OpenTK.Input;

namespace ClassicalSharp.Survival {

	/// <summary>
	/// A mod for adding the features of Minecraft Classic Survival Test version 0.24_07(http://minecraft.gamepedia.com/Version_history/Classic#0.24_07).
	/// </summary>
	internal sealed class SurvivalTest {

		// Declares and assigns the mod name.
		public const string ModName = "SurvivalTest M0d";
		// Declares and assigns the mod version.
		public const string ModVersion = "PR0T0TYPE[1]";
		// Declares and assigns the mod author.
		public const string ModAuthor = "video_error";
		// Declares and assigns the mod name with ampersand color codes.
		public const string ModNameAmpersand = "&cSurvival&eTest &cM0d";
		// Declares and assigns the mod name with percent color codes.
		public const string ModNamePercent = "%cSurvival%eTest %cM0d";
		// Declares and assigns the mod version with ampersand color codes.
		public const string ModVersionAmpersand = "&5PR0T0TYPE&8[&d1&8]";
		// Declares and assigns the mod version with percent color codes.
		public const string ModVersionPercent = "%5PR0T0TYPE%8[%d1%8]";
		// Declares and assigns the mod author with ampersand color codes.
		public const string ModAuthorAmpersand = "&fv&ei&bd&ae&do&8_&cerror";
		// Declares and assigns the mod author with percent color codes.
		public const string ModAuthorPercent = "%fv%ei%bd%ae%do%8_%cerror";
		// Declares and assigns the mod name with version.
		public const string ModNameWithVersion = ModName + " - " + ModVersion;
		// Declares and assigns the mod name with version and ampersand color codes.
		public const string ModNameWithVersionAmpersand = ModNameAmpersand + " &8- " + ModVersionAmpersand;
		// Declares and assigns the mod name with version and percent color codes.
		public const string ModNameWithVersionPercent = ModNamePercent + " %8- " + ModVersionPercent;
		// Declares and assigns the full mode name including: mod name, mod version, and mod author.
		public const string FullModName = ModName + " - " + ModVersion + " By: " + ModAuthor;
		// Declares and assigns the full mode name including: mod name, mod version, and mod author with apersand color codes.
		public const string FullModNameAmpersand = ModNameAmpersand + " &8- " + ModVersionAmpersand + " &8By: " + ModAuthorAmpersand;
		// Declares and assigns the full mode name including: mod name, mod version, and mod author with percent color codes.
		public const string FullModNamePercent = ModNamePercent + " %8- " + ModVersionPercent + " %8By: " + ModAuthorPercent;

		// Declares the main game value responsible for all other game elements.
		private readonly Game game;

		// Declares the wrapper value used for grabbing all elements used by the survival test mod.
		private readonly Wrapper wrapper;

		/// <summary>
		/// Responsible for class instantiation and used for initialization.
		/// </summary>
		public SurvivalTest(Game game) {
			// Assigns the main game value to the inputed game paramter.
			this.game = game;

			// Assigns the wrapper value by creating a new instance and inputing the needed game element value.
			wrapper = new Wrapper(game);

			// Assigns the old inventory keybinding value to the current inventory keybinding.
			OldInventoryKeybind = wrapper.GetInputHandler.Keys[KeyBind.Inventory];

			// Attaches the method for loading the player's inventory to the on new map loaded event for initialization.
			wrapper.GetWorldEvents.OnNewMapLoaded += LoadInventory;
			wrapper.GetWorldEvents.OnNewMap += Respawn;

			// Attaches the method for rebinding the inventory keybind on game window closing.
			((INativeWindow)game.window).Closed += RebindInventoryKeybind;
		}

		public void Render(BlockHotbarWidget hotbar) {
			RenderHealthBar(hotbar);
			RenderBubbleBar(hotbar);
		}

		// Declares and assigns the under heart texture for the health bar.
		private TextureRec UnderHeartTexRect = new TextureRec(16/256F, 0/256F, 9/256F, 9/256F);
		// Declares and assigns the heart texture for the health bar.
		private TextureRec HeartTexRect = new TextureRec(52/256F, 0/256F, 9/256F, 9/256F);
		// Declares and assigns the half heart texture for the health bar.
		private TextureRec HalfHeartTexRect = new TextureRec(61/256F, 0/256F, 9/256F, 9/256F);

		/// <summary>
		/// Responsible for rendering the player's health bar ingame.
		/// </summary>
		private void RenderHealthBar(BlockHotbarWidget hotbar) {
			// Declares and assigns the evaluation of the selected block's size.
			int selectedBlockSize = (int)Math.Ceiling(22.5F * 2 * game.GuiHotbarScale);
			// Declares and assigns the evaluation of the hotbar's scale which is used for the scale of the heart textures.
			int scale = (int)(18 * game.GuiHotbarScale);

			// Declares and assigns the offset of the hotbar's scale.
			float offset = 16 * game.GuiHotbarScale;

			// Declares the X value used for the heart textures.
			int xValue = 0;
			// Declares and assigns the Y value's delta used for the heart textures, evaluated using the selected block's size and the scale.
			int yValue = game.Height - selectedBlockSize - scale - 2;
			// Declares and assigns the icon texture used for grabbing the heart textures.
			int iconTex = wrapper.GetIGuiInterface.IconsTex;
			// Using the graphics API, the texture is binded.
			wrapper.GetIGraphicsAPI.BindTexture(iconTex);

			// Responsible for rendering the under heart textures.
			for(int underHeart = 0; underHeart < MaxHealth / 2; underHeart++) {
				// Assigns the X value for the under heart texture using the hotbar's X value,
				// the for loop iteration value, and the offset.
				xValue = hotbar.X + (int)(underHeart * offset);

				// Declares and assigns the under heart texture using the binded icon texture,
				// X value, Y value, scale, and the under heart texture rectangle.
				Texture underHeartTex = new Texture(iconTex, xValue, yValue, scale, scale, UnderHeartTexRect);

				// Tells the graphics API to apply texturing when rasterizing primitives.
				wrapper.GetIGraphicsAPI.Texturing = true;
				// Renders the under heart texture using the graphics API.
				underHeartTex.Render(wrapper.GetIGraphicsAPI);
				// Tells the graphics API we no longer need to apply texturing when rasterizing primitives.
				wrapper.GetIGraphicsAPI.Texturing = false;
			}

			// Declares and assigns the half heart offset used for deciding whether to render an extra half heart or not.
			int halfHeartOffset = 1;

			// Detects whether the player's health is an even or odd number,
			// ensuring that an extra half heart isn't or is rendered.
			if(Health % 2 == 0) {
				// Assigns the half heart offset to one.
				halfHeartOffset = 1;
			} else {
				// Assigns the half heart offset to minus one.
				halfHeartOffset = -1;
			}

			// Responsible for rendering the half heart textures.
			for(int halfHeart = 0; halfHeart < Health / 2 - halfHeartOffset; halfHeart++) {
				// Assigns the X value for the half heart texture using the hotbar's X value,
				// the for loop iteration value, and the offset.
				xValue = hotbar.X + (int)(halfHeart * offset);

				// Declares and assigns the half heart texture using the binded icon texture,
				// X value, Y value, scale, and the half heart texture rectangle.
				Texture halfHeartTex = new Texture(iconTex, xValue, yValue, scale, scale, HalfHeartTexRect);

				// Tells the graphics API to apply texturing when rasterizing primitives.
				wrapper.GetIGraphicsAPI.Texturing = true;
				// Renders the half heart texture using the graphics API.
				halfHeartTex.Render(wrapper.GetIGraphicsAPI);
				// Tells the graphics API we no longer need to apply texturing when rasterizing primitives.
				wrapper.GetIGraphicsAPI.Texturing = false;
			}

			// Responsible for rendering the heart textures.
			for(int heart = 0; heart < Health / 2; heart++) {
				// Assigns the X value for the heart texture using the hotbar's X value,
				// the for loop iteration value, and the offset.
				xValue = hotbar.X + (int)(heart * offset);

				// Declares and assigns the heart texture using the binded icon texture,
				// X value, Y value, scale, and the half heart texture rectangle.
				Texture heartTex = new Texture(iconTex, xValue, yValue, scale, scale, HeartTexRect);

				// Tells the graphics API to apply texturing when rasterizing primitives.
				wrapper.GetIGraphicsAPI.Texturing = true;
				// Renders the heart texture using the graphics API.
				heartTex.Render(wrapper.GetIGraphicsAPI);
				// Tells the graphics API we no longer need to apply texturing when rasterizing primitives.
				wrapper.GetIGraphicsAPI.Texturing = false;
			}
		}

		bool CanRenderBubbleBar;

		private TextureRec BubbleTexRec = new TextureRec(16/256F, 18/256F, 9/256F, 9/256F);

		private void RenderBubbleBar(BlockHotbarWidget hotbar) {
			if(CanRenderBubbleBar) {
				int selectedBlockSize = (int)Math.Ceiling(22.5F * 2 * game.GuiHotbarScale);
				int scale = (int)(18 * game.GuiHotbarScale);

				float offset = 16 * game.GuiHotbarScale;

				int xValue = 0;
				int yValue = game.Height - selectedBlockSize - scale * 2 - 2;
				int iconTex = wrapper.GetIGuiInterface.IconsTex;

				wrapper.GetIGraphicsAPI.BindTexture(iconTex);

				for(int bubble = 0; bubble < LungCapacity; bubble++) {
					xValue = hotbar.X + (int)(bubble * offset);

					Texture bubbleTex = new Texture(iconTex, xValue, yValue, scale, scale, BubbleTexRec);

					wrapper.GetIGraphicsAPI.Texturing = true;

					bubbleTex.Render(wrapper.GetIGraphicsAPI);

{'fraction_non_alphanumeric': 0.08024570024570024, 'fraction_numerical': 0.014742014742014743, 'mean_word_length': 3.6357630979498863, 'pattern_counts': {'":': 0, '<': 23, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '7115172', 'n_tokens_mistral': 6779, 'n_tokens_neox': 5721, 'n_words': 2293}