Clean up predicates a bit

This commit is contained in:
Eclipse 2024-12-06 11:34:46 +00:00
parent c38bf26298
commit 79bf4afb87
No known key found for this signature in database
GPG key ID: 95E6998F82EC938A
3 changed files with 5 additions and 6 deletions

View file

@ -23,7 +23,7 @@
* @link https://github.com/GeyserMC/Geyser * @link https://github.com/GeyserMC/Geyser
*/ */
package org.geysermc.geyser.api.item.custom.v2.predicate; package org.geysermc.geyser.api.item.custom.v2.predicate.match;
public record CustomModelDataProperty<T>(T data, int index) { public record CustomModelDataString(String value, int index) {
} }

View file

@ -26,7 +26,6 @@
package org.geysermc.geyser.api.item.custom.v2.predicate.match; package org.geysermc.geyser.api.item.custom.v2.predicate.match;
import net.kyori.adventure.key.Key; import net.kyori.adventure.key.Key;
import org.geysermc.geyser.api.item.custom.v2.predicate.CustomModelDataProperty;
// TODO can we do more? // TODO can we do more?
public class MatchPredicateProperty<T> { public class MatchPredicateProperty<T> {
@ -34,7 +33,7 @@ public class MatchPredicateProperty<T> {
public static final MatchPredicateProperty<ChargeType> CHARGE_TYPE = create(); public static final MatchPredicateProperty<ChargeType> CHARGE_TYPE = create();
public static final MatchPredicateProperty<Key> TRIM_MATERIAL = create(); public static final MatchPredicateProperty<Key> TRIM_MATERIAL = create();
public static final MatchPredicateProperty<Key> CONTEXT_DIMENSION = create(); public static final MatchPredicateProperty<Key> CONTEXT_DIMENSION = create();
public static final MatchPredicateProperty<CustomModelDataProperty<String>> CUSTOM_MODEL_DATA = create(); public static final MatchPredicateProperty<CustomModelDataString> CUSTOM_MODEL_DATA = create();
private MatchPredicateProperty() {} private MatchPredicateProperty() {}

View file

@ -36,7 +36,7 @@ import org.geysermc.geyser.api.item.custom.v2.BedrockCreativeTab;
import org.geysermc.geyser.api.item.custom.v2.CustomItemBedrockOptions; import org.geysermc.geyser.api.item.custom.v2.CustomItemBedrockOptions;
import org.geysermc.geyser.api.item.custom.v2.CustomItemDefinition; import org.geysermc.geyser.api.item.custom.v2.CustomItemDefinition;
import org.geysermc.geyser.api.item.custom.v2.predicate.ConditionPredicate; import org.geysermc.geyser.api.item.custom.v2.predicate.ConditionPredicate;
import org.geysermc.geyser.api.item.custom.v2.predicate.CustomModelDataProperty; import org.geysermc.geyser.api.item.custom.v2.predicate.match.CustomModelDataString;
import org.geysermc.geyser.api.item.custom.v2.predicate.RangeDispatchPredicate; import org.geysermc.geyser.api.item.custom.v2.predicate.RangeDispatchPredicate;
import org.geysermc.geyser.api.item.custom.v2.predicate.match.ChargeType; import org.geysermc.geyser.api.item.custom.v2.predicate.match.ChargeType;
import org.geysermc.geyser.api.item.custom.v2.predicate.MatchPredicate; import org.geysermc.geyser.api.item.custom.v2.predicate.MatchPredicate;
@ -278,7 +278,7 @@ public class MappingsReader_v2 extends MappingsReader {
if (indexNode != null && indexNode.isIntegralNumber()) { if (indexNode != null && indexNode.isIntegralNumber()) {
index = indexNode.asInt(); index = indexNode.asInt();
} }
builder.predicate(new MatchPredicate<>(MatchPredicateProperty.CUSTOM_MODEL_DATA, new CustomModelDataProperty<>(value, index))); builder.predicate(new MatchPredicate<>(MatchPredicateProperty.CUSTOM_MODEL_DATA, new CustomModelDataString(value, index)));
} }
default -> throw new InvalidCustomMappingsFileException("Unknown property " + property); default -> throw new InvalidCustomMappingsFileException("Unknown property " + property);
} }