/*
 * This file is part of Sponge, licensed under the MIT License (MIT).
 *
 * Copyright (c) SpongePowered <https://www.spongepowered.org>
 * Copyright (c) contributors
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 * THE SOFTWARE.
 */
package org.spongepowered.common.mixin.core.block.properties;

import net.minecraft.block.properties.PropertyHelper;
import org.spongepowered.api.block.trait.BlockTrait;
import org.spongepowered.api.util.Functional;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.common.interfaces.block.IMixinPropertyHolder;

import java.util.function.Predicate;

@Mixin(value = PropertyHelper.class)
public abstract class MixinPropertyHelper<T extends Comparable<T>> implements BlockTrait<T>, IMixinPropertyHolder {

    protected String propertyName;
    protected String idString;

    @Shadow private String name;
    @SuppressWarnings("rawtypes")
    @Shadow private Class valueClass;

    @Override
    public String getId() {
        return this.idString;
    }

    @Override
    public String getName() {
        return this.name;
    }

    @SuppressWarnings("unchecked")
    public Class<T> getTraitValueClass() {
        return this.valueClass;
    }

    @Override
    public Predicate<T> getPredicate() {
        return Functional.predicateIn(getPossibleValues());
    }

    @Override
    public void setId(String id) {
        this.idString = id;
    }
}

@@ -1457,16 +1457,155 @@
 tional;%0A
+import org.spongepowered.asm.mixin.Implements;%0Aimport org.spongepowered.asm.mixin.Interface;%0Aimport org.spongepowered.asm.mixin.Intrinsic;%0A
 import o
@@ -1638,16 +1638,16 @@
 .Mixin;%0A
-
 import o
@@ -1828,16 +1828,85 @@
 .class)%0A
+@Implements(@Interface(iface = BlockTrait.class, prefix = %22trait$%22))%0A
 public a
@@ -2124,63 +2124,74 @@
   @S
-uppressWarnings(%22rawtypes%22)%0A    @Shadow private Class v
+hadow(prefix = %22shadow$%22)%0A    public abstract Class%3CT%3E shadow$getV
 alue
@@ -2195,16 +2195,18 @@
 lueClass
+()
 ;%0A%0A    @
@@ -2365,37 +2365,17 @@
    @
-SuppressWarnings(%22unchecked%22)
+Intrinsic
 %0A   
@@ -2395,15 +2395,16 @@
 %3CT%3E 
-getTrai
+trait$ge
 tVal
@@ -2435,17 +2435,27 @@
 rn this.
-v
+shadow$getV
 alueClas
@@ -2455,16 +2455,18 @@
 lueClass
+()
 ;%0A    %7D%0A

Fix BlockTrait.getValueClass() not working in obf environment