// 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 java.util.Iterator;
import java.util.List;
import java.util.Set;
import org.apache.commons.lang3.ArrayUtils;
import org.bukkit.event.block.BlockRedstoneEvent;
import com.google.common.collect.Lists;
import com.google.common.collect.Sets;
import cn.jiongjionger.neverlag.module.pandawire.PandaWireReflectUtil;
import net.minecraft.server.v1_9_R1.BaseBlockPosition;
import net.minecraft.server.v1_9_R1.Block;
import net.minecraft.server.v1_9_R1.BlockDiodeAbstract;
import net.minecraft.server.v1_9_R1.BlockPiston;
import net.minecraft.server.v1_9_R1.BlockPosition;
import net.minecraft.server.v1_9_R1.BlockRedstoneComparator;
import net.minecraft.server.v1_9_R1.BlockRedstoneTorch;
import net.minecraft.server.v1_9_R1.BlockRedstoneWire;
import net.minecraft.server.v1_9_R1.EnumDirection;
import net.minecraft.server.v1_9_R1.IBlockAccess;
import net.minecraft.server.v1_9_R1.IBlockData;
import net.minecraft.server.v1_9_R1.SoundEffectType;
import net.minecraft.server.v1_9_R1.World;
package cn.jiongjionger.neverlag.module.pandawire.v1_9_R1;





/*
 * @author Panda4994
 */

public class PandaRedstoneWire extends BlockRedstoneWire {

	/*
	 * 作者说用LinkedHashSet替代arraylist没有明显的性能提示，红石设备不多的时候的确如此
	 * 但是实测在红石设备数量很大的时候，有2~5%的性能提升（基于PaperSpigot1.10.2测试），所以还是改用LinkedHashSet来实现
	 */
	// 需要被断路的红石位置
	private Set<BlockPosition> turnOff = Sets.newLinkedHashSet();
	// 需要被激活的红石位置
	private Set<BlockPosition> turnOn = Sets.newLinkedHashSet();
	private final Set<BlockPosition> updatedRedstoneWire = Sets.newLinkedHashSet();
	private static final EnumDirection[] facingsHorizontal = { EnumDirection.WEST, EnumDirection.EAST, EnumDirection.NORTH, EnumDirection.SOUTH };
	private static final EnumDirection[] facingsVertical = { EnumDirection.DOWN, EnumDirection.UP };
	private static final EnumDirection[] facings = (EnumDirection[]) ArrayUtils.addAll(facingsVertical, facingsHorizontal);
	private static final BaseBlockPosition[] surroundingBlocksOffset;

	static {
		Set<BaseBlockPosition> set = Sets.newLinkedHashSet();
		for (EnumDirection facing : facings) {
			set.add(PandaWireReflectUtil.getOfT(facing, BaseBlockPosition.class));
		}
		for (EnumDirection facing1 : facings) {
			BaseBlockPosition v1 = (BaseBlockPosition) PandaWireReflectUtil.getOfT(facing1, BaseBlockPosition.class);
			for (EnumDirection facing2 : facings) {
// 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_9_R1/PandaRedstoneWire.java
import java.util.Iterator;
import java.util.List;
import java.util.Set;
import org.apache.commons.lang3.ArrayUtils;
import org.bukkit.event.block.BlockRedstoneEvent;
import com.google.common.collect.Lists;
import com.google.common.collect.Sets;
import cn.jiongjionger.neverlag.module.pandawire.PandaWireReflectUtil;
import net.minecraft.server.v1_9_R1.BaseBlockPosition;
import net.minecraft.server.v1_9_R1.Block;
import net.minecraft.server.v1_9_R1.BlockDiodeAbstract;
import net.minecraft.server.v1_9_R1.BlockPiston;
import net.minecraft.server.v1_9_R1.BlockPosition;
import net.minecraft.server.v1_9_R1.BlockRedstoneComparator;
import net.minecraft.server.v1_9_R1.BlockRedstoneTorch;
import net.minecraft.server.v1_9_R1.BlockRedstoneWire;
import net.minecraft.server.v1_9_R1.EnumDirection;
import net.minecraft.server.v1_9_R1.IBlockAccess;
import net.minecraft.server.v1_9_R1.IBlockData;
import net.minecraft.server.v1_9_R1.SoundEffectType;
import net.minecraft.server.v1_9_R1.World;

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





/*
 * @author Panda4994
 */

public class PandaRedstoneWire extends BlockRedstoneWire {

	/*
	 * 作者说用LinkedHashSet替代arraylist没有明显的性能提示，红石设备不多的时候的确如此
	 * 但是实测在红石设备数量很大的时候，有2~5%的性能提升（基于PaperSpigot1.10.2测试），所以还是改用LinkedHashSet来实现
	 */
	// 需要被断路的红石位置
	private Set<BlockPosition> turnOff = Sets.newLinkedHashSet();
	// 需要被激活的红石位置
	private Set<BlockPosition> turnOn = Sets.newLinkedHashSet();
	private final Set<BlockPosition> updatedRedstoneWire = Sets.newLinkedHashSet();
	private static final EnumDirection[] facingsHorizontal = { EnumDirection.WEST, EnumDirection.EAST, EnumDirection.NORTH, EnumDirection.SOUTH };
	private static final EnumDirection[] facingsVertical = { EnumDirection.DOWN, EnumDirection.UP };
	private static final EnumDirection[] facings = (EnumDirection[]) ArrayUtils.addAll(facingsVertical, facingsHorizontal);
	private static final BaseBlockPosition[] surroundingBlocksOffset;

	static {
		Set<BaseBlockPosition> set = Sets.newLinkedHashSet();
		for (EnumDirection facing : facings) {
			set.add(PandaWireReflectUtil.getOfT(facing, BaseBlockPosition.class));
		}
		for (EnumDirection facing1 : facings) {
			BaseBlockPosition v1 = (BaseBlockPosition) PandaWireReflectUtil.getOfT(facing1, BaseBlockPosition.class);
			for (EnumDirection facing2 : facings) {
				BaseBlockPosition v2 = (BaseBlockPosition) PandaWireReflectUtil.getOfT(facing2, BaseBlockPosition.class);