Use unbreakable predicate when converting v1 to v2 mappings

This commit is contained in:
Eclipse 2024-12-12 10:58:02 +00:00
parent bca98c7d22
commit 6e0e3c03dd
No known key found for this signature in database
GPG key ID: 95E6998F82EC938A

View file

@ -32,8 +32,11 @@ import org.geysermc.geyser.api.GeyserApi;
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.CustomItemDefinition;
import org.geysermc.geyser.api.item.custom.v2.predicate.ConditionPredicate;
import org.geysermc.geyser.api.item.custom.v2.predicate.RangeDispatchPredicate;
import org.geysermc.geyser.api.util.TriState;
import java.util.Objects;
import java.util.OptionalInt;
import java.util.Set;
@ -149,6 +152,9 @@ public interface CustomItemData {
if (options.damagePredicate().isPresent()) {
definition.predicate(new RangeDispatchPredicate(RangeDispatchPredicate.RangeDispatchProperty.DAMAGE, options.damagePredicate().getAsInt()));
}
if (options.unbreakable() != TriState.NOT_SET) {
definition.predicate(new ConditionPredicate(ConditionPredicate.ConditionProperty.UNBREAKABLE, Objects.requireNonNull(options.unbreakable().toBoolean())));
}
return definition;
}