package org.cyclops.integrateddynamics.core.evaluate.variable;

import net.minecraft.util.text.TextFormatting;
import org.cyclops.cyclopscore.helper.Helpers;
import org.cyclops.integrateddynamics.api.evaluate.EvaluationException;
import org.cyclops.integrateddynamics.api.evaluate.variable.IValue;
import org.cyclops.integrateddynamics.api.evaluate.variable.IValueType;
import org.cyclops.integrateddynamics.api.evaluate.variable.IValueTypeNullable;
import org.cyclops.integrateddynamics.api.evaluate.variable.IVariable;

/**
 * Value type category with values that can be null.
 * @author rubensworks
 */
public class ValueTypeCategoryNullable extends ValueTypeCategoryBase<IValue> {

    public ValueTypeCategoryNullable() {
        super("nullable", Helpers.RGBToInt(100, 100, 100), TextFormatting.DARK_GRAY.toString());
    }

    public boolean isNull(IVariable a) throws EvaluationException {
        return ((IValueTypeNullable) a.getType()).isNull(a.getValue());
    }

    @Override
    public boolean correspondsTo(IValueType<?> valueType) {
        return super.correspondsTo(valueType) && valueType instanceof IValueTypeNullable;
    }
}

@@ -892,16 +892,34 @@
 ption %7B%0A
+        try %7B%0A    
         
@@ -978,24 +978,150 @@
 etValue());%0A
+        %7D catch (ClassCastException e) %7B%0A            // This can happen with 'any' types.%0A            return false;%0A        %7D%0A
     %7D%0A%0A    @

Fix crash when applying isNull on ANY value types, Closes #625