<commit_before>package Tamaized.TamModized.registry;

import java.lang.reflect.InvocationTargetException;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;

import Tamaized.TamModized.capabilities.CapabilityList;
import Tamaized.TamModized.capabilities.dimTracker.IDimensionCapability;
import net.minecraft.block.Block;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.network.play.server.SPacketEntityEffect;
import net.minecraft.network.play.server.SPacketPlayerAbilities;
import net.minecraft.network.play.server.SPacketRespawn;
import net.minecraft.potion.PotionEffect;
import net.minecraft.server.MinecraftServer;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.MathHelper;
import net.minecraft.world.Teleporter;
import net.minecraft.world.WorldProvider;
import net.minecraft.world.WorldServer;
import net.minecraftforge.fml.common.FMLCommonHandler;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.fml.common.gameevent.TickEvent.Phase;
import net.minecraftforge.fml.common.gameevent.TickEvent.PlayerTickEvent;

public class PortalHandlerRegistry {

	private static Map<Block, TeleporterWrapper> map = new HashMap<Block, TeleporterWrapper>();

	private static class TeleporterWrapper {

		private final int dim;
		private final Class<? extends Teleporter> teleporter;

		public TeleporterWrapper(int dimension, Class<? extends Teleporter> t) {
			dim = dimension;
			teleporter = t;
		}

		public int getDimension() {
			return dim;
		}

		public Class<? extends Teleporter> getTeleporter() {
			return teleporter;
		}

	}

	public static void register(IBlockState state, int dimension, Class<? extends Teleporter> teleporter) {
		register(state.getBlock(), dimension, teleporter);
	}

	public static void register(Block block, int dimension, Class<? extends Teleporter> teleporter) {
		map.put(block, new TeleporterWrapper(dimension, teleporter));
	}

	public static TeleporterWrapper getTeleporter(IBlockState state) {
		return getTeleporter(state.getBlock());
	}

	public static TeleporterWrapper getTeleporter(Block block) {
		return map.get(block);
	}

	public static boolean contains(IBlockState state) {
		return contains(state.getBlock());
	}

	public static boolean contains(Block block) {
		return map.containsKey(block);
	}

	public static void doTeleport(IDimensionCapability cap, EntityPlayerMP player, TeleporterWrapper teleporter) throws InstantiationException, IllegalAccessException, IllegalArgumentException, InvocationTargetException, NoSuchMethodException, SecurityException {
		if (player.world == null || !(player.world instanceof WorldServer)) return;
		if (player.dimension != teleporter.getDimension() && player.dimension != 1) {
			cap.setLastDimension(player.dimension);
			TeleportLoc port = new TeleportLoc(teleporter.getTeleporter().getConstructor(WorldServer.class).newInstance(player.mcServer.worldServerForDimension(teleporter.getDimension())));
			transferPlayerToDimension(player.mcServer, player, teleporter.getDimension(), port);
		} else if (player.dimension == 1) { // From end<commit_msg>cherry-pick: closes #23<commit_after>package Tamaized.TamModized.registry;

import java.lang.reflect.InvocationTargetException;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;

import Tamaized.TamModized.capabilities.CapabilityList;
import Tamaized.TamModized.capabilities.dimTracker.IDimensionCapability;
import net.minecraft.block.Block;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.network.play.server.SPacketEntityEffect;
import net.minecraft.network.play.server.SPacketPlayerAbilities;
import net.minecraft.network.play.server.SPacketRespawn;
import net.minecraft.potion.PotionEffect;
import net.minecraft.server.MinecraftServer;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.MathHelper;
import net.minecraft.world.Teleporter;
import net.minecraft.world.WorldProvider;
import net.minecraft.world.WorldServer;
import net.minecraftforge.fml.common.FMLCommonHandler;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.fml.common.gameevent.TickEvent.Phase;
import net.minecraftforge.fml.common.gameevent.TickEvent.PlayerTickEvent;

public class PortalHandlerRegistry {

	private static Map<Block, TeleporterWrapper> map = new HashMap<Block, TeleporterWrapper>();

	private static class TeleporterWrapper {

		private final int dim;
		private final Class<? extends Teleporter> teleporter;

		public TeleporterWrapper(int dimension, Class<? extends Teleporter> t) {
			dim = dimension;
			teleporter = t;
		}

		public int getDimension() {
			return dim;
		}

		public Class<? extends Teleporter> getTeleporter() {
			return teleporter;
		}

	}

	public static void register(IBlockState state, int dimension, Class<? extends Teleporter> teleporter) {
		register(state.getBlock(), dimension, teleporter);
	}

	public static void register(Block block, int dimension, Class<? extends Teleporter> teleporter) {
		map.put(block, new TeleporterWrapper(dimension, teleporter));
	}

	public static TeleporterWrapper getTeleporter(IBlockState state) {
		return getTeleporter(state.getBlock());
	}

	public static TeleporterWrapper getTeleporter(Block block) {
		return map.get(block);
	}

	public static boolean contains(IBlockState state) {
		return contains(state.getBlock());
	}

	public static boolean contains(Block block) {
		return map.containsKey(block);
	}

	public static void doTeleport(IDimensionCapability cap, EntityPlayerMP player, TeleporterWrapper teleporter) throws InstantiationException, IllegalAccessException, IllegalArgumentException, InvocationTargetException, NoSuchMethodException, SecurityException {
		if (player.dimension != teleporter.getDimension() && player.dimension != 1) {
			cap.setLastDimension(player.dimension);
			TeleportLoc port = new TeleportLoc(teleporter.getTeleporter().getConstructor(WorldServer.class).newInstance(player.mcServer.worldServerForDimension(teleporter.getDimension())));
			transferPlayerToDimension(player.mcServer, player, teleporter.getDimension(), port);
		} else if (player.dimension == 1) { // From end
{'fraction_non_alphanumeric': 0.09652690863579474, 'fraction_numerical': 0.0009386733416770963, 'mean_word_length': 6.390751445086705, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 17, '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': '5045109', 'n_tokens_mistral': 1875, 'n_tokens_neox': 1808, 'n_words': 390}