-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor potion brewing. Add filter for removing.
- Loading branch information
Showing
4 changed files
with
75 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
src/main/java/com/almostreliable/morejs/features/potion/CustomBrewingFilter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package com.almostreliable.morejs.features.potion; | ||
|
||
import com.almostreliable.morejs.util.Utils; | ||
import net.minecraft.world.item.crafting.Ingredient; | ||
import net.neoforged.neoforge.common.brewing.BrewingRecipe; | ||
|
||
import java.util.Optional; | ||
import java.util.function.Predicate; | ||
|
||
public record CustomBrewingFilter(Optional<Ingredient> ingredient, Optional<Ingredient> input, | ||
Optional<Ingredient> output) implements Predicate<BrewingRecipe> { | ||
|
||
@Override | ||
public boolean test(BrewingRecipe brewingRecipe) { | ||
if (input.filter(input -> Utils.matchesIngredient(input, brewingRecipe.getInput())).isEmpty()) { | ||
return false; | ||
} | ||
|
||
if (output.filter(output -> output.test(brewingRecipe.getOutput())).isEmpty()) { | ||
return false; | ||
} | ||
|
||
return ingredient | ||
.filter(ingredient -> Utils.matchesIngredient(ingredient, brewingRecipe.getIngredient())) | ||
.isPresent(); | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
src/main/java/com/almostreliable/morejs/features/potion/PotionBrewingFilter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package com.almostreliable.morejs.features.potion; | ||
|
||
import com.almostreliable.morejs.util.Utils; | ||
import net.minecraft.core.HolderSet; | ||
import net.minecraft.world.item.alchemy.Potion; | ||
import net.minecraft.world.item.alchemy.PotionBrewing; | ||
import net.minecraft.world.item.crafting.Ingredient; | ||
|
||
import java.util.Optional; | ||
import java.util.function.Predicate; | ||
|
||
public record PotionBrewingFilter(Optional<Ingredient> ingredient, Optional<HolderSet<Potion>> input, | ||
Optional<HolderSet<Potion>> output) implements Predicate<PotionBrewing.Mix<Potion>> { | ||
|
||
@Override | ||
public boolean test(PotionBrewing.Mix<Potion> potionMix) { | ||
if (input.filter(input -> input.contains(potionMix.from())).isEmpty()) { | ||
return false; | ||
} | ||
|
||
if (output.filter(output -> output.contains(potionMix.to())).isEmpty()) { | ||
return false; | ||
} | ||
return ingredient | ||
.filter(ingredient -> Utils.matchesIngredient(ingredient, potionMix.ingredient())) | ||
.isPresent(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters