Skip to content

Commit

Permalink
Make it compile
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexProgrammerDE committed Nov 5, 2024
1 parent 8bce409 commit 7eae4e6
Showing 1 changed file with 12 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import com.soulfiremc.server.data.BlockItems;
import com.soulfiremc.server.data.EffectType;
import com.soulfiremc.server.protocol.bot.container.SFItemStack;
import org.geysermc.mcprotocollib.protocol.data.game.item.component.ConsumeEffect;
import org.geysermc.mcprotocollib.protocol.data.game.item.component.DataComponentType;

public class ItemTypeHelper {
Expand All @@ -36,11 +37,17 @@ public static boolean isTool(SFItemStack itemStack) {

public static boolean isGoodEdibleFood(SFItemStack itemStack) {
var components = itemStack.components();
return components.getOptional(DataComponentType.FOOD).map(f -> {
for (var effect : f.getEffects()) {
if (EffectType.REGISTRY.getById(effect.getEffect().getEffect().ordinal()).category()
== EffectType.EffectCategory.HARMFUL) {
return false;
return components.getOptional(DataComponentType.CONSUMABLE).map(f -> {
for (var consumeEffects : f.onConsumeEffects()) {
if (!(consumeEffects instanceof ConsumeEffect.ApplyEffects applyEffects)) {
continue;
}

for (var mobEffect : applyEffects.effects()) {
if (EffectType.REGISTRY.getById(mobEffect.getEffect().ordinal()).category()
== EffectType.EffectCategory.HARMFUL) {
return false;
}
}
}

Expand Down

0 comments on commit 7eae4e6

Please sign in to comment.