use of pl.asie.charset.lib.utils.ThreeState in project Charset by CharsetMC.
the class CharsetTweakDoubleDoors method onDoubleDoorChange.
public void onDoubleDoorChange(CharsetIMC imc) {
changeCalled = true;
Set<BlockDoor> oldAllowedDoors = Sets.newHashSet(allowedDoors);
allowedDoors.clear();
for (Block block : ForgeRegistries.BLOCKS) {
try {
if (block != null && block instanceof BlockDoor) {
ThreeState state = imc.allows("doubleDoor", block.getRegistryName());
boolean allowed = false;
if (state == ThreeState.MAYBE && !(block.getRegistryName().getResourceDomain().equals("malisisdoors"))) {
Class c = block.getClass();
Method m = MethodHandleHelper.reflectMethodRecurse(c, "onBlockActivated", "func_180639_a", World.class, BlockPos.class, IBlockState.class, EntityPlayer.class, EnumHand.class, EnumFacing.class, float.class, float.class, float.class);
if (m.getDeclaringClass() == BlockDoor.class) {
allowed = true;
}
} else if (state == ThreeState.YES) {
allowed = true;
}
if (allowed) {
Collection<IProperty<?>> properties = block.getBlockState().getProperties();
if (properties.contains(BlockDoor.FACING) && properties.contains(BlockDoor.OPEN) && properties.contains(BlockDoor.HINGE)) {
allowedDoors.add((BlockDoor) block);
if (!oldAllowedDoors.contains(block)) {
ModCharset.logger.info("[tweak.doubledoors] Allowing " + block.getRegistryName().toString());
} else {
oldAllowedDoors.remove(block);
}
}
}
}
} catch (ReflectionHelper.UnableToFindMethodException e) {
// This is fine.
}
}
for (BlockDoor block : oldAllowedDoors) {
ModCharset.logger.info("[tweak.doubledoors] Removing " + block.getRegistryName().toString());
}
}
Aggregations