Search in sources :

Example 6 with Property

use of net.minecraft.world.level.block.state.properties.Property in project SpongeCommon by SpongePowered.

the class AbstractSpongeStateMatcher method isValid.

protected final boolean isValid(final StateHolder<?, ?> stateHolder) {
    for (final Map.Entry<StateProperty<@NonNull ?>, Object> entry : this.properties.entrySet()) {
        final Property<?> property = (Property<?>) entry.getKey();
        final Object value = stateHolder.getValues().get(property);
        if (value == null || !value.equals(entry.getValue())) {
            return false;
        }
    }
    for (final StateProperty<@NonNull ?> entry : this.requiredProperties) {
        final Property<?> property = (Property<?>) entry;
        if (stateHolder.getValues().get(property) == null) {
            return false;
        }
    }
    final DataHolder dataHolder = (DataHolder) stateHolder;
    for (final KeyValueMatcher<?> valueMatcher : this.keyValueMatchers) {
        if (!this.matches(dataHolder, valueMatcher)) {
            return false;
        }
    }
    return true;
}
Also used : DataHolder(org.spongepowered.api.data.DataHolder) StateProperty(org.spongepowered.api.state.StateProperty) NonNull(org.checkerframework.checker.nullness.qual.NonNull) MonotonicNonNull(org.checkerframework.checker.nullness.qual.MonotonicNonNull) HashMap(java.util.HashMap) Map(java.util.Map) Property(net.minecraft.world.level.block.state.properties.Property) StateProperty(org.spongepowered.api.state.StateProperty)

Aggregations

Property (net.minecraft.world.level.block.state.properties.Property)6 HashMap (java.util.HashMap)2 HashSet (java.util.HashSet)2 Map (java.util.Map)2 Direction (net.minecraft.core.Direction)2 BlockState (net.minecraft.world.level.block.state.BlockState)2 TypeDeclaration (com.github.javaparser.ast.body.TypeDeclaration)1 JsonArray (com.google.gson.JsonArray)1 JsonElement (com.google.gson.JsonElement)1 JsonObject (com.google.gson.JsonObject)1 CommandSyntaxException (com.mojang.brigadier.exceptions.CommandSyntaxException)1 ClassName (com.squareup.javapoet.ClassName)1 FieldSpec (com.squareup.javapoet.FieldSpec)1 MethodSpec (com.squareup.javapoet.MethodSpec)1 ParameterizedTypeName (com.squareup.javapoet.ParameterizedTypeName)1 TypeName (com.squareup.javapoet.TypeName)1 FullDyeColor (com.wuest.prefab.blocks.FullDyeColor)1 IOException (java.io.IOException)1 Collection (java.util.Collection)1 Comparator (java.util.Comparator)1