<commit_before>package net.earthcomputer.easyeditors.api;

import net.minecraft.block.Block;
import net.minecraft.block.BlockLiquid;
import net.minecraft.block.material.Material;
import net.minecraft.block.state.IBlockState;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.BlockRendererDispatcher;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.client.renderer.WorldRenderer;
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
import net.minecraft.client.renderer.texture.TextureMap;
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
import net.minecraft.client.resources.model.IBakedModel;
import net.minecraft.init.Blocks;
import net.minecraft.util.BlockPos;
import net.minecraft.world.IBlockAccess;

public class AnimatedBlockRenderer {

	private static final int HORIZONTAL_CYCLE_TIME = 8000;
	private static final int VERTICAL_CYCLE_TIME = 4000;

	private IBlockState block;

	public AnimatedBlockRenderer(IBlockState block) {
		this.block = block;
	}

	public void render(int x, int y) {
		Minecraft mc = Minecraft.getMinecraft();
		mc.getTextureManager().bindTexture(TextureMap.locationBlocksTexture);
		Block block = this.block.getBlock();
		IBlockAccess world;

		Tessellator tessellator = Tessellator.getInstance();
		WorldRenderer worldRenderer = tessellator.getWorldRenderer();

		if (block.getRenderType() != -1) {
			switch (block.getRenderType()) {
			case 1:
				String fluid = block.getMaterial() == Material.lava ? "lava" : "water";
				String state;
				if (block == BlockLiquid.getStaticBlock(block.getMaterial()))
					state = "still";
				else if (block == BlockLiquid.getFlowingBlock(block.getMaterial()))
					state = "flowing";
				else {
					System.err.println(
							"Invalid block with render type 1: " + Block.blockRegistry.getNameForObject(block));
					break;
				}
				TextureAtlasSprite sprite = Minecraft.getMinecraft().getTextureMapBlocks()
						.getAtlasSprite(String.format("minecraft:blocks/%s_%s", fluid, state));

				worldRenderer.startDrawingQuads();
				worldRenderer.addVertexWithUV(x, y + 16, 50, sprite.getMinU(), sprite.getMaxV());
				worldRenderer.addVertexWithUV(x + 16, y + 16, 50 , sprite.getMaxU(), sprite.getMaxV());
				worldRenderer.addVertexWithUV(x + 16, y, 50, sprite.getMaxU(), sprite.getMinV());
				worldRenderer.addVertexWithUV(x, y, 50, sprite.getMinU(), sprite.getMinV());
				tessellator.draw();<commit_msg>Added rendering code for render type 2 for AnimatedBlockRenderer. Only works if the blocks has a corresponding item<commit_after>package net.earthcomputer.easyeditors.api;

import net.minecraft.block.Block;
import net.minecraft.block.BlockLiquid;
import net.minecraft.block.material.Material;
import net.minecraft.block.state.IBlockState;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.BlockRendererDispatcher;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.client.renderer.RenderHelper;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.client.renderer.WorldRenderer;
import net.minecraft.client.renderer.entity.RenderItem;
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
import net.minecraft.client.renderer.texture.TextureMap;
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
import net.minecraft.client.resources.model.IBakedModel;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.BlockPos;
import net.minecraft.world.IBlockAccess;

public class AnimatedBlockRenderer {

	private static final int HORIZONTAL_CYCLE_TIME = 8000;
	private static final int VERTICAL_CYCLE_TIME = 4000;

	private IBlockState block;

	public AnimatedBlockRenderer(IBlockState block) {
		this.block = block;
	}

	public void render(int x, int y) {
		Minecraft mc = Minecraft.getMinecraft();
		mc.getTextureManager().bindTexture(TextureMap.locationBlocksTexture);
		Block block = this.block.getBlock();
		IBlockAccess world;

		Tessellator tessellator = Tessellator.getInstance();
		WorldRenderer worldRenderer = tessellator.getWorldRenderer();

		if (block.getRenderType() != -1) {
			switch (block.getRenderType()) {
			case 1:
				String fluid = block.getMaterial() == Material.lava ? "lava" : "water";
				String state;
				if (block == BlockLiquid.getStaticBlock(block.getMaterial()))
					state = "still";
				else if (block == BlockLiquid.getFlowingBlock(block.getMaterial()))
					state = "flowing";
				else {
					System.err.println(
							"Invalid block with render type 1: " + Block.blockRegistry.getNameForObject(block));
					break;
				}
				TextureAtlasSprite sprite = Minecraft.getMinecraft().getTextureMapBlocks()
						.getAtlasSprite(String.format("minecraft:blocks/%s_%s", fluid, state));

				worldRenderer.startDrawingQuads();
				worldRenderer.addVertexWithUV(x, y + 16, 50, sprite.getMinU(), sprite.getMaxV());
				worldRenderer.addVertexWithUV(x + 16, y + 16, 50, sprite.getMaxU(), sprite.getMaxV());
				worldRenderer.addVertexWithUV(x + 16, y, 50, sprite.getMaxU(), sprite.getMinV());
				worldRenderer.addVertexWithUV(x, y, 50, sprite.getMinU(), sprite.getMinV());
				tessellator.draw();
				break;
			case 2:
				Item item = Item.getItemFromBlock(block);
				if (item != null) {
					ItemStack stack = new ItemStack(item);
					RenderHelper.disableStandardItemLighting();
					RenderHelper.enableGUIStandardItemLighting();
					RenderItem renderItem = Minecraft.getMinecraft().getRenderItem();
					renderItem.zLevel = 50;
					renderItem.renderItemAndEffectIntoGUI(stack, x, y);
					renderItem.zLevel = 0;
					RenderHelper.enableStandardItemLighting();
					GlStateManager.color(0, 0, 0, 0);
				}
{'fraction_non_alphanumeric': 0.11524485205052777, 'fraction_numerical': 0.010901540058833708, 'mean_word_length': 5.033402922755741, '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': '1091115', 'n_tokens_mistral': 2038, 'n_tokens_neox': 1787, 'n_words': 344}