// Path: src/main/java/cn/jiongjionger/neverlag/module/pandawire/IPandaWireInjector.java
// public interface IPandaWireInjector {
// 
// 	public static void inject() {
// 	}
// 
// 	public static void uninject() {
// 	}
// 
// }
// 
// Path: src/main/java/cn/jiongjionger/neverlag/module/pandawire/PandaWireReflectUtil.java
// public class PandaWireReflectUtil {
// 
// 	/*
// 	 * @author md_5
// 	 */
// 
// 	public static <T> T get(final Object obj, final Field field, final Class<T> type) {
// 		try {
// 			return type.cast(setAccessible(field).get(obj));
// 		} catch (ReflectiveOperationException ex) {
// 			ex.printStackTrace();
// 			return null;
// 		}
// 	}
// 
// 	public static <T> T getOfT(final Object obj, final Class<T> type) {
// 		for (final Field field : obj.getClass().getDeclaredFields()) {
// 			if (type.equals(field.getType())) {
// 				return get(obj, field, type);
// 			}
// 		}
// 		return null;
// 	}
// 
// 	public static <T extends AccessibleObject> T setAccessible(T object) {
// 		object.setAccessible(true);
// 		return object;
// 	}
// 
// 	public static void setStatic(final String name, final Class<?> clazz, final Object val) {
// 		try {
// 			final Field field = clazz.getDeclaredField(name);
// 			setAccessible(Field.class.getDeclaredField("modifiers")).setInt(field, field.getModifiers() & ~Modifier.FINAL);
// 			setAccessible(Field.class.getDeclaredField("root")).set(field, null);
// 			setAccessible(Field.class.getDeclaredField("overrideFieldAccessor")).set(field, null);
// 			setAccessible(field).set(null, val);
// 		} catch (ReflectiveOperationException ex) {
// 			ex.printStackTrace();
// 		}
// 	}
// }


import org.bukkit.Bukkit;
import com.google.common.collect.UnmodifiableIterator;
import cn.jiongjionger.neverlag.module.pandawire.IPandaWireInjector;
import cn.jiongjionger.neverlag.module.pandawire.PandaWireReflectUtil;
import net.minecraft.server.v1_11_R1.Block;
import net.minecraft.server.v1_11_R1.BlockRedstoneWire;
import net.minecraft.server.v1_11_R1.Blocks;
import net.minecraft.server.v1_11_R1.IBlockData;
import net.minecraft.server.v1_11_R1.MinecraftKey;
package cn.jiongjionger.neverlag.module.pandawire.v1_11_R1;




public class PandaWireInjector implements IPandaWireInjector{

	private static Block get(final String s) {
		return Block.REGISTRY.get(new MinecraftKey(s));
	}

	public static void inject() {
		try {
			register(55, "redstone_wire", new PandaRedstoneWire());
			PandaWireReflectUtil.setStatic("REDSTONE_WIRE", Blocks.class, get("redstone_wire"));
		} catch (Exception e) {
			Bukkit.getLogger().info("[NeverLag]PandaWireInjector inject failed!");
		}
	}

	private static void register(int typeid, String minecraftKey, final Block block) {
		Block.REGISTRY.a(typeid, new MinecraftKey(minecraftKey), block);
		UnmodifiableIterator<IBlockData> iterable = block.s().a().iterator();
		while (iterable.hasNext()) {
			IBlockData iblockdata = iterable.next();
			int k = Block.REGISTRY.a(block) << 4 | block.toLegacyData(iblockdata);
			Block.REGISTRY_ID.a(iblockdata, k);

		}
	}

	public static void uninject() {
		try {
			register(55, "redstone_wire", new BlockRedstoneWire());
			PandaWireReflectUtil.setStatic("REDSTONE_WIRE", Blocks.class, get("redstone_wire"));
		} catch (Exception e) {
// Path: src/main/java/cn/jiongjionger/neverlag/module/pandawire/IPandaWireInjector.java
// public interface IPandaWireInjector {
// 
// 	public static void inject() {
// 	}
// 
// 	public static void uninject() {
// 	}
// 
// }
// 
// Path: src/main/java/cn/jiongjionger/neverlag/module/pandawire/PandaWireReflectUtil.java
// public class PandaWireReflectUtil {
// 
// 	/*
// 	 * @author md_5
// 	 */
// 
// 	public static <T> T get(final Object obj, final Field field, final Class<T> type) {
// 		try {
// 			return type.cast(setAccessible(field).get(obj));
// 		} catch (ReflectiveOperationException ex) {
// 			ex.printStackTrace();
// 			return null;
// 		}
// 	}
// 
// 	public static <T> T getOfT(final Object obj, final Class<T> type) {
// 		for (final Field field : obj.getClass().getDeclaredFields()) {
// 			if (type.equals(field.getType())) {
// 				return get(obj, field, type);
// 			}
// 		}
// 		return null;
// 	}
// 
// 	public static <T extends AccessibleObject> T setAccessible(T object) {
// 		object.setAccessible(true);
// 		return object;
// 	}
// 
// 	public static void setStatic(final String name, final Class<?> clazz, final Object val) {
// 		try {
// 			final Field field = clazz.getDeclaredField(name);
// 			setAccessible(Field.class.getDeclaredField("modifiers")).setInt(field, field.getModifiers() & ~Modifier.FINAL);
// 			setAccessible(Field.class.getDeclaredField("root")).set(field, null);
// 			setAccessible(Field.class.getDeclaredField("overrideFieldAccessor")).set(field, null);
// 			setAccessible(field).set(null, val);
// 		} catch (ReflectiveOperationException ex) {
// 			ex.printStackTrace();
// 		}
// 	}
// }


// Path: src/main/java/cn/jiongjionger/neverlag/module/pandawire/v1_11_R1/PandaWireInjector.java
import org.bukkit.Bukkit;
import com.google.common.collect.UnmodifiableIterator;
import cn.jiongjionger.neverlag.module.pandawire.IPandaWireInjector;
import cn.jiongjionger.neverlag.module.pandawire.PandaWireReflectUtil;
import net.minecraft.server.v1_11_R1.Block;
import net.minecraft.server.v1_11_R1.BlockRedstoneWire;
import net.minecraft.server.v1_11_R1.Blocks;
import net.minecraft.server.v1_11_R1.IBlockData;
import net.minecraft.server.v1_11_R1.MinecraftKey;

package cn.jiongjionger.neverlag.module.pandawire.v1_11_R1;




public class PandaWireInjector implements IPandaWireInjector{

	private static Block get(final String s) {
		return Block.REGISTRY.get(new MinecraftKey(s));
	}

	public static void inject() {
		try {
			register(55, "redstone_wire", new PandaRedstoneWire());
			PandaWireReflectUtil.setStatic("REDSTONE_WIRE", Blocks.class, get("redstone_wire"));
		} catch (Exception e) {
			Bukkit.getLogger().info("[NeverLag]PandaWireInjector inject failed!");
		}
	}

	private static void register(int typeid, String minecraftKey, final Block block) {
		Block.REGISTRY.a(typeid, new MinecraftKey(minecraftKey), block);
		UnmodifiableIterator<IBlockData> iterable = block.s().a().iterator();
		while (iterable.hasNext()) {
			IBlockData iblockdata = iterable.next();
			int k = Block.REGISTRY.a(block) << 4 | block.toLegacyData(iblockdata);
			Block.REGISTRY_ID.a(iblockdata, k);

		}
	}

	public static void uninject() {
		try {
			register(55, "redstone_wire", new BlockRedstoneWire());
			PandaWireReflectUtil.setStatic("REDSTONE_WIRE", Blocks.class, get("redstone_wire"));
		} catch (Exception e) {
			Bukkit.getLogger().info("[NeverLag]PandaWireInjector uninject failed!");