Skip to content

Commit b5a192a

Browse files
committed
Add SlotSingleIngredient
1 parent dfd5ec2 commit b5a192a

1 file changed

Lines changed: 38 additions & 0 deletions

File tree

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
package org.cyclops.cyclopscore.inventory.slot;
2+
3+
import net.minecraft.world.Container;
4+
import net.minecraft.world.item.ItemStack;
5+
import net.minecraft.world.item.crafting.Ingredient;
6+
7+
/**
8+
* Slot that is used for only accepting an item matching the given ingredient.
9+
*
10+
* @author rubensworks
11+
*/
12+
public class SlotSingleIngredient extends SlotExtended {
13+
14+
private Ingredient ingredient;
15+
16+
/**
17+
* Make a new instance.
18+
*
19+
* @param inventory The inventory this slot will be in.
20+
* @param index The index of this slot.
21+
* @param x X coordinate.
22+
* @param y Y coordinate.
23+
* @param ingredient The ingredient to accept.
24+
*/
25+
public SlotSingleIngredient(Container inventory, int index, int x, int y, Ingredient ingredient) {
26+
super(inventory, index, x, y);
27+
this.ingredient = ingredient;
28+
}
29+
30+
@Override
31+
public boolean mayPlace(ItemStack itemStack) {
32+
return super.mayPlace(itemStack) && ingredient.test(itemStack);
33+
}
34+
35+
public Ingredient getIngredientAllowed() {
36+
return ingredient;
37+
}
38+
}

0 commit comments

Comments
 (0)