<commit_before>package protocolsupport.protocol.typeremapper.nbt.tileupdate;

import java.util.EnumMap;

import gnu.trove.map.hash.TIntObjectHashMap;
import net.minecraft.server.v1_9_R1.NBTTagCompound;
import protocolsupport.api.ProtocolVersion;
import protocolsupport.protocol.PacketDataSerializer;
import protocolsupport.utils.ProtocolVersionsHelper;

public class TileNBTTransformer {

	private static final TIntObjectHashMap<EnumMap<ProtocolVersion, SpecificTransformer>> registry = new TIntObjectHashMap<>();

	private static void register(int type, SpecificTransformer transformer, ProtocolVersion... versions) {
		registry.putIfAbsent(type, new EnumMap<ProtocolVersion, SpecificTransformer>(ProtocolVersion.class));
		EnumMap<ProtocolVersion, SpecificTransformer> map = registry.get(type);
		for (ProtocolVersion version : versions) {
			map.put(version, transformer);
		}
	}

	static {
		register(
			1,
			new SpecificTransformer() {
				@Override
				public NBTTagCompound transform(NBTTagCompound input) {
					input.remove("SpawnPotentials");
					input.remove("SpawnData");
					return input;
				}
			},
			ProtocolVersionsHelper.BEFORE_1_7
		);
		register(
			4,
			new SpecificTransformer() {
				@Override
				public NBTTagCompound transform(NBTTagCompound input) {
					PacketDataSerializer.transformSkull(input);
					return input;
				}
			},
			ProtocolVersion.getAllBefore(ProtocolVersion.MINECRAFT_1_7_5)
		);
	}

	public static NBTTagCompound transform(int type, ProtocolVersion version, NBTTagCompound compound) {
		EnumMap<ProtocolVersion, SpecificTransformer> map = registry.get(type);
		if (map != null) {
			SpecificTransformer transformer = map.get(version);
			if (transformer != null) {
				return transformer.transform(compound);
			}
		}
		return compound;
	}

}<commit_msg>Transform mob spawner data so it doesn't crash<commit_after>package protocolsupport.protocol.typeremapper.nbt.tileupdate;

import java.util.EnumMap;

import gnu.trove.map.hash.TIntObjectHashMap;
import net.minecraft.server.v1_9_R1.NBTTagCompound;
import protocolsupport.api.ProtocolVersion;
import protocolsupport.protocol.PacketDataSerializer;
import protocolsupport.utils.ProtocolVersionsHelper;

public class TileNBTTransformer {

	private static final TIntObjectHashMap<EnumMap<ProtocolVersion, SpecificTransformer>> registry = new TIntObjectHashMap<>();

	private static void register(int type, SpecificTransformer transformer, ProtocolVersion... versions) {
		registry.putIfAbsent(type, new EnumMap<ProtocolVersion, SpecificTransformer>(ProtocolVersion.class));
		EnumMap<ProtocolVersion, SpecificTransformer> map = registry.get(type);
		for (ProtocolVersion version : versions) {
			map.put(version, transformer);
		}
	}

	static {
		register(
			1,
			new SpecificTransformer() {
				@Override
				public NBTTagCompound transform(NBTTagCompound input) {
					NBTTagCompound spawndata = input.getCompound("SpawnData");
					input.remove("SpawnPotentials");
					input.remove("SpawnData");
					if (spawndata != null) {
						String mobname = spawndata.getString("Id");
						if (!mobname.isEmpty()) {
							input.setString("EntityId", mobname);
						}
					}
					return input;
				}
			},
			ProtocolVersionsHelper.BEFORE_1_9
		);
		register(
			4,
			new SpecificTransformer() {
				@Override
				public NBTTagCompound transform(NBTTagCompound input) {
					PacketDataSerializer.transformSkull(input);
					return input;
				}
			},
			ProtocolVersion.getAllBefore(ProtocolVersion.MINECRAFT_1_7_5)
		);
	}

	public static NBTTagCompound transform(int type, ProtocolVersion version, NBTTagCompound compound) {
		EnumMap<ProtocolVersion, SpecificTransformer> map = registry.get(type);
		if (map != null) {
			SpecificTransformer transformer = map.get(version);
			if (transformer != null) {
				return transformer.transform(compound);
			}
		}
		return compound;
	}

}
{'fraction_non_alphanumeric': 0.09678249678249679, 'fraction_numerical': 0.005148005148005148, 'mean_word_length': 4.852409638554217, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 15, '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': '1796565', 'n_tokens_mistral': 1356, 'n_tokens_neox': 1156, 'n_words': 224}