<commit_before>package openccsensors.common.util;

import java.util.Collection;
import java.util.HashMap;
import java.util.List;

import net.minecraft.block.Block;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLiving;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.potion.PotionEffect;
import net.minecraft.util.EnumMovingObjectType;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.util.Vec3;
import net.minecraft.world.World;
import net.minecraft.world.chunk.Chunk;

public class EntityUtils {

	
	public static HashMap<String, Entity> getEntities(World world, Vec3 sensorPos, double radius, Class filter) {
		HashMap<String, Entity> map = new HashMap<String, Entity>();
		
		int dChunk = (int) Math.ceil(radius / 16.0F);
		
		int x = (int)sensorPos.xCoord;
		int y = (int)sensorPos.yCoord;
		int z = (int)sensorPos.zCoord;

		for (int dx = -dChunk; dx <= dChunk; dx++) {
			for (int dz = -dChunk; dz <= dChunk; dz++) {
				Chunk chunk = world.getChunkFromBlockCoords(x+16*dx, z+16*dz);
				for (List<Entity> subchunk : chunk.entityLists) {
					for (Entity entity : subchunk) {
						Vec3 livingPos = Vec3.createVectorHelper(
								entity.posX + 0.5,
								entity.posY + 0.5,
								entity.posZ + 0.5
						);
						if (sensorPos.distanceTo(livingPos) <= radius && filter.isAssignableFrom(entity.getClass())) {
							String targetName = (entity instanceof EntityPlayer) ? entity
									.getEntityName() : entity
									.getEntityName() + entity.entityId;
							targetName = targetName.replaceAll("\\s", "");
							map.put(targetName, entity);
						}
					}
				}
			}
		}

		return map;
	}

	
	public static HashMap livingToMap(EntityLiving living, Vec3 sensorPos, boolean additional) {
		HashMap map = new HashMap();
		
		HashMap position = new HashMap();
		position.put("X", living.posX - sensorPos.xCoord);
		position.put("Y", living.posY - sensorPos.yCoord);
		position.put("Z", living.posZ - sensorPos.zCoord);
		map.put("Position", position);

		map.put("Name", (living instanceof EntityPlayer) ? "Player" : living.getEntityName());
		map.put("RawName", living.getClass().getName());
		map.put("IsPlayer", living instanceof EntityPlayer);
		
		if (additional) {

			map.put("HeldItem", InventoryUtils.itemstackToMap(living.getHeldItem()));
	
			HashMap armour = new HashMap();
			armour.put("Boots", InventoryUtils.itemstackToMap(living.getCurrentItemOrArmor(1)));
			armour.put("Leggings", InventoryUtils.itemstackToMap(living.getCurrentItemOrArmor(2)));
			armour.put("Chestplate", InventoryUtils.itemstackToMap(living.getCurrentItemOrArmor(3)));
			armour.put("Helmet", InventoryUtils.itemstackToMap(living.getCurrentItemOrArmor(4)));
			
			map.put("Armour", armour);
			map.put("Health", living.getHealth());
			map.put("IsAirborne", living.isAirBorne);
			map.put("IsJumping", living.isJumping);
			map.put("IsBlocking", living.isBlocking());
			map.put("IsBurning", living.isBurning());
			map.put("IsAlive", living.isEntityAlive());
			map.put("IsInWater", living.isInWater());
			map.put("IsOnLadder", living.isOnLadder());
			map.put("IsSleeping", living.isPlayerSleeping());
			map.put("IsRiding", living.isRiding());
			map.put("IsSneaking", living.isSneaking());
			map.put("IsSprinting", living.isSprinting());
			map.put("IsWet", living.isWet());
			map.put("IsChild", living.isChild());
			map.put("IsHome", living.isWithinHomeDistanceCurrentPosition());
			map.put("Yaw", living.rotationYaw);
			map.put("Pitch", living.rotationPitch);
			map.put("YawHead", living.rotationYawHead);
	
			HashMap potionEffects = new HashMap();
			Collection<PotionEffect> effects = living.getActivePotionEffects();
			int count = 1;
			for (PotionEffect effect : effects) {
				potionEffects.put(count, effect.getEffectName());
				count++;
			}
			map.put("PotionEffects", potionEffects);
		}
	
		if (living instanceof EntityPlayer) {
			EntityPlayer player = (EntityPlayer) living;
			map.put("Username", player.username);
			map.put("ExperienceTotal", player.experienceTotal);
			map.put("ExperienceLevel", player.experienceLevel);
			map.put("Experience", player.experience);
			if (additional) {
				map.put("FoodLevel", player.getFoodStats().getFoodLevel());
				map.put("Gamemode", player.capabilities.isCreativeMode);
				map.put("Inventory", InventoryUtils.invToMap(player.inventory));

		        Vec3 posVec = player.worldObj.getWorldVec3Pool().getVecFromPool(player.posX, player.posY + 1.62F, player.posZ);
		        Vec3 lookVec = player.getLook(1.0f);
		        Vec3 targetVec = posVec.addVector(lookVec.xCoord * 10f, lookVec.yCoord * 10f, lookVec.zCoord * 10f);
		        MovingObjectPosition mop = player.worldObj.rayTraceBlocks(posVec, targetVec);
		        map.put("IsLookingAtBlock", mop.typeOfHit == EnumMovingObjectType.TILE);
		        if (mop.typeOfHit == EnumMovingObjectType.TILE) {
		        	int blockId = player.worldObj.getBlockId(mop.blockX, mop.blockY, mop.blockZ);
		        	HashMap lookingAt = new HashMap();
		        	lookingAt.put("X", mop.blockX - sensorPos.xCoord);
		        	lookingAt.put("Y", mop.blockY - sensorPos.yCoord);
		        	lookingAt.put("Z", mop.blockZ - sensorPos.zCoord);
		        	map.put("LookingAt", lookingAt);
		        }
			}
		
			map.put("Experience", player.experience);
		}

		return map;
	}
}<commit_msg>additional tameable/wolf data<commit_after>package openccsensors.common.util;

import java.util.Collection;
import java.util.HashMap;
import java.util.List;

import net.minecraft.block.Block;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLiving;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.potion.PotionEffect;
import net.minecraft.util.EnumMovingObjectType;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.util.Vec3;
import net.minecraft.world.World;
import net.minecraft.world.chunk.Chunk;

public class EntityUtils {

	
	public static HashMap<String, Entity> getEntities(World world, Vec3 sensorPos, double radius, Class filter) {
		HashMap<String, Entity> map = new HashMap<String, Entity>();
		
		int dChunk = (int) Math.ceil(radius / 16.0F);
		
		int x = (int)sensorPos.xCoord;
		int y = (int)sensorPos.yCoord;
		int z = (int)sensorPos.zCoord;

		for (int dx = -dChunk; dx <= dChunk; dx++) {
			for (int dz = -dChunk; dz <= dChunk; dz++) {
				Chunk chunk = world.getChunkFromBlockCoords(x+16*dx, z+16*dz);
				for (List<Entity> subchunk : chunk.entityLists) {
					for (Entity entity : subchunk) {
						Vec3 livingPos = Vec3.createVectorHelper(
								entity.posX + 0.5,
								entity.posY + 0.5,
								entity.posZ + 0.5
						);
						if (sensorPos.distanceTo(livingPos) <= radius && filter.isAssignableFrom(entity.getClass())) {
							String targetName = (entity instanceof EntityPlayer) ? entity
									.getEntityName() : entity
									.getEntityName() + entity.entityId;
							targetName = targetName.replaceAll("\\s", "");
							map.put(targetName, entity);
						}
					}
				}
			}
		}

		return map;
	}

	
	public static HashMap livingToMap(EntityLiving living, Vec3 sensorPos, boolean additional) {
		HashMap map = new HashMap();
		
		HashMap position = new HashMap();
		position.put("X", living.posX - sensorPos.xCoord);
		position.put("Y", living.posY - sensorPos.yCoord);
		position.put("Z", living.posZ - sensorPos.zCoord);
		map.put("Position", position);

		map.put("Name", (living instanceof EntityPlayer) ? "Player" : living.getEntityName());
		map.put("RawName", living.getClass().getName());
		map.put("IsPlayer", living instanceof EntityPlayer);
		
		if (additional) {

			map.put("HeldItem", InventoryUtils.itemstackToMap(living.getHeldItem()));
	
			HashMap armour = new HashMap();
			armour.put("Boots", InventoryUtils.itemstackToMap(living.getCurrentItemOrArmor(1)));
			armour.put("Leggings", InventoryUtils.itemstackToMap(living.getCurrentItemOrArmor(2)));
			armour.put("Chestplate", InventoryUtils.itemstackToMap(living.getCurrentItemOrArmor(3)));
			armour.put("Helmet", InventoryUtils.itemstackToMap(living.getCurrentItemOrArmor(4)));
			
			map.put("Armour", armour);
			map.put("Health", living.getHealth());
			map.put("IsAirborne", living.isAirBorne);
			map.put("IsJumping", living.isJumping);
			map.put("IsBlocking", living.isBlocking());
			map.put("IsBurning", living.isBurning());
			map.put("IsAlive", living.isEntityAlive());
			map.put("IsInWater", living.isInWater());
			map.put("IsOnLadder", living.isOnLadder());
			map.put("IsSleeping", living.isPlayerSleeping());
			map.put("IsRiding", living.isRiding());
			map.put("IsSneaking", living.isSneaking());
			map.put("IsSprinting", living.isSprinting());
			map.put("IsWet", living.isWet());
			map.put("IsChild", living.isChild());
			map.put("IsHome", living.isWithinHomeDistanceCurrentPosition());
			map.put("Yaw", living.rotationYaw);
			map.put("Pitch", living.rotationPitch);
			map.put("YawHead", living.rotationYawHead);
	
			HashMap potionEffects = new HashMap();
			Collection<PotionEffect> effects = living.getActivePotionEffects();
			int count = 1;
			for (PotionEffect effect : effects) {
				potionEffects.put(count, effect.getEffectName());
				count++;
			}
			map.put("PotionEffects", potionEffects);
		}
	
		if (living instanceof EntityPlayer) {
			EntityPlayer player = (EntityPlayer) living;
			map.put("Username", player.username);
			map.put("ExperienceTotal", player.experienceTotal);
			map.put("ExperienceLevel", player.experienceLevel);
			map.put("Experience", player.experience);
			if (additional) {
				map.put("FoodLevel", player.getFoodStats().getFoodLevel());
				map.put("Gamemode", player.capabilities.isCreativeMode);
				map.put("Inventory", InventoryUtils.invToMap(player.inventory));

		        Vec3 posVec = player.worldObj.getWorldVec3Pool().getVecFromPool(player.posX, player.posY + 1.62F, player.posZ);
		        Vec3 lookVec = player.getLook(1.0f);
		        Vec3 targetVec = posVec.addVector(lookVec.xCoord * 10f, lookVec.yCoord * 10f, lookVec.zCoord * 10f);
		        MovingObjectPosition mop = player.worldObj.rayTraceBlocks(posVec, targetVec);
		        map.put("IsLookingAtBlock", mop.typeOfHit == EnumMovingObjectType.TILE);
		        if (mop.typeOfHit == EnumMovingObjectType.TILE) {
		        	int blockId = player.worldObj.getBlockId(mop.blockX, mop.blockY, mop.blockZ);
		        	HashMap lookingAt = new HashMap();
		        	lookingAt.put("X", mop.blockX - sensorPos.xCoord);
		        	lookingAt.put("Y", mop.blockY - sensorPos.yCoord);
		        	lookingAt.put("Z", mop.blockZ - sensorPos.zCoord);
		        	map.put("LookingAt", lookingAt);
		        }
			}
		
			map.put("Experience", player.experience);
		}
		
		if (living instanceof EntityTameable) {
			EntityTameable tameable = (EntityTameable) living;
			map.put("IsSitting", tameable.isSitting());
			map.put("IsTamed", tameable.isTamed());
			if (tameable.isTamed()) {
				map.put("OwnerName", tameable.getOwnerName());
			}
		}
		
		if (living instanceof EntityWolf) {
			EntityWolf wolf = (EntityTameable) living;
			map.put("IsAngry", wolf.isAngry());
			if (((EntityTameable)wolf).isTamed()) {
				map.put("CollarColor", wolf.getCollarColor());
			}
		}

		return map;
	}
}
{'fraction_non_alphanumeric': 0.1475322365495776, 'fraction_numerical': 0.006758559359715429, 'mean_word_length': 4.05438202247191, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 13, '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': '2971639', 'n_tokens_mistral': 4299, 'n_tokens_neox': 3643, 'n_words': 644}