<commit_before>package com.ferreusveritas.dynamictrees.client;

import java.util.Collection;
import java.util.List;
import java.util.function.Function;

import com.ferreusveritas.dynamictrees.util.MathHelper;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.Lists;

import net.minecraft.client.renderer.texture.TextureAtlasSprite;
import net.minecraft.client.renderer.texture.TextureUtil;
import net.minecraft.client.resources.IResourceManager;
import net.minecraft.crash.CrashReport;
import net.minecraft.crash.CrashReportCategory;
import net.minecraft.crash.ICrashReportDetail;
import net.minecraft.util.ReportedException;
import net.minecraft.util.ResourceLocation;

public class ThickRingTextureAtlasSprite extends TextureAtlasSprite {

	ResourceLocation baseRingLocation;
	
	public ThickRingTextureAtlasSprite(ResourceLocation spriteName, ResourceLocation baseRingLocation) {
		super(spriteName.toString());
		
		this.baseRingLocation = baseRingLocation;
	}
	
	@Override
	public boolean hasCustomLoader(net.minecraft.client.resources.IResourceManager manager, net.minecraft.util.ResourceLocation location) {
		return true;
	}

	@Override
	public boolean load(IResourceManager manager, ResourceLocation location, Function<ResourceLocation, TextureAtlasSprite> textureGetter) {
		TextureAtlasSprite baseTexture = textureGetter.apply(baseRingLocation);
		int[][] baseTextureData = baseTexture.getFrameTextureData(0);
		
		this.width = baseTexture.getIconWidth() * 3;
		this.height = baseTexture.getIconHeight() * 3;
		
		int[][] textureData = new int[baseTextureData.length][this.width * this.height];
		
		for (int mipmapLvl = 0; mipmapLvl < textureData.length; mipmapLvl++) {
			for (int pixelIndex = 0; pixelIndex < textureData[mipmapLvl].length; pixelIndex++) {
				int size = (int) Math.sqrt(textureData[mipmapLvl].length);
				int srcSize = (int) Math.sqrt(baseTextureData[mipmapLvl].length);
				
				int x = pixelIndex % size;
				int y = pixelIndex / size;
				
				int srcX = x % srcSize;//(int) (x * ((double) srcSize / size));
				int srcY = y % srcSize;//(int) (y * ((double) srcSize / size));
				int srcIndex = srcX + (srcY * srcSize);
				
				textureData[mipmapLvl][pixelIndex] = baseTextureData[mipmapLvl][srcIndex];
			}
		}
		
		this.setFramesTextureData(Lists.<int[][]>newArrayList(textureData));
		
		// TODO: copy animation data
		// TODO: generate texture
		
		return false;
	}
	
	@Override
	public Collection<ResourceLocation> getDependencies() {
		return ImmutableList.of(baseRingLocation);
	}

}
<commit_msg>Fixed mipmapping on generated textures<commit_after>package com.ferreusveritas.dynamictrees.client;

import java.util.Collection;
import java.util.List;
import java.util.function.Function;

import com.ferreusveritas.dynamictrees.util.MathHelper;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.Lists;

import net.minecraft.client.renderer.texture.TextureAtlasSprite;
import net.minecraft.client.renderer.texture.TextureUtil;
import net.minecraft.client.resources.IResourceManager;
import net.minecraft.crash.CrashReport;
import net.minecraft.crash.CrashReportCategory;
import net.minecraft.crash.ICrashReportDetail;
import net.minecraft.util.ReportedException;
import net.minecraft.util.ResourceLocation;

public class ThickRingTextureAtlasSprite extends TextureAtlasSprite {

	ResourceLocation baseRingLocation;
	
	public ThickRingTextureAtlasSprite(ResourceLocation spriteName, ResourceLocation baseRingLocation) {
		super(spriteName.toString());
		
		this.baseRingLocation = baseRingLocation;
	}
	
	@Override
	public boolean hasCustomLoader(net.minecraft.client.resources.IResourceManager manager, net.minecraft.util.ResourceLocation location) {
		return true;
	}

	@Override
	public boolean load(IResourceManager manager, ResourceLocation location, Function<ResourceLocation, TextureAtlasSprite> textureGetter) {
		TextureAtlasSprite baseTexture = textureGetter.apply(baseRingLocation);
		int[][] baseTextureData = baseTexture.getFrameTextureData(0);
		int srcWidth = baseTexture.getIconWidth();
		int srcHeight = baseTexture.getIconHeight();
		
		this.width = srcWidth * 3;
		this.height = srcHeight * 3;
		
		int[][] textureData = new int[baseTextureData.length][];
		// only generate texture data for the first mipmap level, let the Minecraft handle the rest
		textureData[0] = new int[width * height];
		for (int pixelIndex = 0; pixelIndex < textureData[0].length; pixelIndex++) {
			// TODO: generate texture
			int x = pixelIndex % width;
			int y = pixelIndex / width;
			
			int srcX = x % srcWidth;//(int) (x * ((double) srcSize / size));
			int srcY = y % srcHeight;//(int) (y * ((double) srcSize / size));
			int srcIndex = srcX + (srcY * srcWidth);
			
			textureData[0][pixelIndex] = baseTextureData[0][srcIndex];
		}
		this.setFramesTextureData(Lists.<int[][]>newArrayList(textureData));
		
		return false;
	}
	
	@Override
	public Collection<ResourceLocation> getDependencies() {
		return ImmutableList.of(baseRingLocation);
	}

}

{'fraction_non_alphanumeric': 0.10671154226885765, 'fraction_numerical': 0.0025737477727182734, 'mean_word_length': 5.307116104868914, 'pattern_counts': {'":': 0, '<': 12, '<?xml version=': 0, '>': 9, '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': '2565832', 'n_tokens_mistral': 1661, 'n_tokens_neox': 1525, 'n_words': 309}