diff --git a/build.gradle b/build.gradle index b0cead1a..9f747bfd 100644 --- a/build.gradle +++ b/build.gradle @@ -38,27 +38,30 @@ dependencies { def useOptional(String dep) { dependencies.modRuntime (dep) { - exclude group: "net.fabricmc.fabric-api" - exclude group: "net.fabricmc" + exclude group: 'net.fabricmc.fabric-api' + exclude group: 'net.fabricmc' if (!dep.contains("me.shedaniel")) { - exclude group: "me.shedaniel" + exclude group: 'me.shedaniel.cloth' + exclude group: 'me.shedaniel' } } dependencies.modCompileOnly (dep) { - exclude group: "net.fabricmc.fabric-api" - exclude group: "net.fabricmc" + exclude group: 'net.fabricmc.fabric-api' + exclude group: 'net.fabricmc' if (!dep.contains("me.shedaniel")) { - exclude group: "me.shedaniel" + exclude group: 'me.shedaniel.cloth' + exclude group: 'me.shedaniel' } } } def useApi(String dep) { dependencies.modApi (dep) { - exclude group: "net.fabricmc.fabric-api" - exclude group: "net.fabricmc" + exclude group: 'net.fabricmc.fabric-api' + exclude group: 'net.fabricmc' if (!dep.contains("me.shedaniel")) { - exclude group: "me.shedaniel" + exclude group: 'me.shedaniel.cloth' + exclude group: 'me.shedaniel' } } } diff --git a/src/main/java/ru/bclib/blocks/properties/StringProperty.java b/src/main/java/ru/bclib/blocks/properties/StringProperty.java new file mode 100644 index 00000000..1b86316e --- /dev/null +++ b/src/main/java/ru/bclib/blocks/properties/StringProperty.java @@ -0,0 +1,52 @@ +package ru.bclib.blocks.properties; + +import com.google.common.collect.Sets; +import net.minecraft.world.level.block.state.properties.Property; + +import java.util.*; + +public class StringProperty extends Property { + + private final Set values; + + public static StringProperty create(String name, String... values) { + return new StringProperty(name, values); + } + + protected StringProperty(String string, String... values) { + super(string, String.class); + this.values = Sets.newHashSet(values); + } + + @Override + public Collection getPossibleValues() { + return Collections.unmodifiableSet(values); + } + + @Override + public String getName(String comparable) { + return comparable; + } + + @Override + public Optional getValue(String string) { + if (values.contains(string)) { + return Optional.of(string); + } else { + return Optional.empty(); + } + } + + @Override + public int generateHashCode() { + return super.generateHashCode() + Objects.hashCode(values); + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (!(o instanceof StringProperty that)) return false; + if (!super.equals(o)) return false; + return values.equals(that.values); + } +}