-
Notifications
You must be signed in to change notification settings - Fork 18
/
FillPotionCauldronInteraction.java
31 lines (28 loc) · 1.32 KB
/
FillPotionCauldronInteraction.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
package knightminer.inspirations.recipes.cauldron.potion;
import knightminer.inspirations.recipes.InspirationsRecipes;
import knightminer.inspirations.recipes.block.entity.PotionCauldronBlockEntity;
import knightminer.inspirations.recipes.cauldron.AbstractDecreaseLayerCauldronInteraction;
import net.minecraft.core.BlockPos;
import net.minecraft.sounds.SoundEvents;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.alchemy.PotionUtils;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.LayeredCauldronBlock;
import net.minecraft.world.level.block.state.BlockState;
/** Fills a potion from the potion cauldron */
public class FillPotionCauldronInteraction extends AbstractDecreaseLayerCauldronInteraction {
private final Item potionItem;
public FillPotionCauldronInteraction(Item potionItem) {
super(LayeredCauldronBlock.LEVEL, true, SoundEvents.BOTTLE_FILL);
this.potionItem = potionItem;
}
@Override
protected ItemStack getResult(BlockState state, Level level, BlockPos pos, ItemStack stack) {
PotionCauldronBlockEntity cauldron = InspirationsRecipes.potionCauldronEntity.getBlockEntity(level, pos);
if (cauldron != null) {
return PotionUtils.setPotion(new ItemStack(potionItem), cauldron.getPotion());
}
return ItemStack.EMPTY;
}
}