-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a recipe for duplicating filled sample takers
- Loading branch information
1 parent
a453b05
commit f47058d
Showing
4 changed files
with
103 additions
and
0 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
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
70 changes: 70 additions & 0 deletions
70
src/main/java/top/offsetmonkey538/compactmobfarms/recipe/FilledSampleTakerCloningRecipe.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,70 @@ | ||
package top.offsetmonkey538.compactmobfarms.recipe; | ||
|
||
import net.minecraft.inventory.RecipeInputInventory; | ||
import net.minecraft.item.ItemStack; | ||
import net.minecraft.recipe.RecipeSerializer; | ||
import net.minecraft.recipe.SpecialCraftingRecipe; | ||
import net.minecraft.recipe.book.CraftingRecipeCategory; | ||
import net.minecraft.registry.DynamicRegistryManager; | ||
import net.minecraft.util.Identifier; | ||
import net.minecraft.world.World; | ||
import top.offsetmonkey538.compactmobfarms.item.ModItems; | ||
import top.offsetmonkey538.compactmobfarms.item.SampleTakerItem; | ||
|
||
public class FilledSampleTakerCloningRecipe extends SpecialCraftingRecipe { | ||
public FilledSampleTakerCloningRecipe(Identifier id, CraftingRecipeCategory category) { | ||
super(id, category); | ||
} | ||
|
||
@Override | ||
public boolean matches(RecipeInputInventory inventory, World world) { | ||
boolean foundFilledSampleTaker = false; | ||
boolean foundEmptySampleTaker = false; | ||
boolean foundSpiritBottle = false; | ||
|
||
for (int i = 0; i < inventory.getInputStacks().size(); i++) { | ||
final ItemStack stack = inventory.getInputStacks().get(i); | ||
if (stack.isEmpty()) continue; | ||
|
||
if (stack.isOf(ModItems.FILLED_SAMPLE_TAKER)) { | ||
if (foundFilledSampleTaker) return false; | ||
foundFilledSampleTaker = true; | ||
} | ||
|
||
if (stack.isOf(ModItems.SAMPLE_TAKER)) { | ||
if (SampleTakerItem.getSamplesCollected(stack).size() > 0) return false; | ||
|
||
if (foundEmptySampleTaker) return false; | ||
foundEmptySampleTaker = true; | ||
} | ||
|
||
if (stack.isOf(ModItems.SPIRIT_BOTTLE)) { | ||
if (foundSpiritBottle) return false; | ||
foundSpiritBottle = true; | ||
} | ||
} | ||
|
||
return foundFilledSampleTaker && | ||
foundEmptySampleTaker && | ||
foundSpiritBottle; | ||
} | ||
|
||
@Override | ||
public ItemStack craft(RecipeInputInventory inventory, DynamicRegistryManager registryManager) { | ||
final ItemStack filledSampleTaker = inventory.getInputStacks().stream() | ||
.filter(stack -> stack.isOf(ModItems.FILLED_SAMPLE_TAKER)) | ||
.toList().get(0); | ||
|
||
return filledSampleTaker.copyWithCount(2); | ||
} | ||
|
||
@Override | ||
public boolean fits(int width, int height) { | ||
return (width * height >= 3); | ||
} | ||
|
||
@Override | ||
public RecipeSerializer<?> getSerializer() { | ||
return ModRecipes.CLONE_FILLED_SAMPLE_TAKER; | ||
} | ||
} |
25 changes: 25 additions & 0 deletions
25
src/main/java/top/offsetmonkey538/compactmobfarms/recipe/ModRecipes.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,25 @@ | ||
package top.offsetmonkey538.compactmobfarms.recipe; | ||
|
||
import net.minecraft.recipe.RecipeSerializer; | ||
import net.minecraft.recipe.SpecialRecipeSerializer; | ||
import net.minecraft.registry.Registries; | ||
import net.minecraft.registry.Registry; | ||
|
||
import static top.offsetmonkey538.compactmobfarms.CompactMobFarms.*; | ||
|
||
public final class ModRecipes { | ||
private ModRecipes() { | ||
|
||
} | ||
|
||
public static final SpecialRecipeSerializer<FilledSampleTakerCloningRecipe> CLONE_FILLED_SAMPLE_TAKER = register("clone_filled_sample_taker", new SpecialRecipeSerializer<>(FilledSampleTakerCloningRecipe::new)); | ||
|
||
private static <T extends RecipeSerializer<?>> T register(String name, T item) { | ||
return Registry.register(Registries.RECIPE_SERIALIZER, id(name), item); | ||
} | ||
|
||
@SuppressWarnings("EmptyMethod") | ||
public static void register() { | ||
// Registers recipe serializers by loading the class. | ||
} | ||
} |