-
Notifications
You must be signed in to change notification settings - Fork 18
/
TipArrowCauldronInteraction.java
32 lines (29 loc) · 1.44 KB
/
TipArrowCauldronInteraction.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
32
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.ItemStack;
import net.minecraft.world.item.Items;
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;
/** Tips a stack of 16 arrows in the cauldron */
public class TipArrowCauldronInteraction extends AbstractDecreaseLayerCauldronInteraction {
public static final TipArrowCauldronInteraction INSTANCE = new TipArrowCauldronInteraction();
private TipArrowCauldronInteraction() {
super(LayeredCauldronBlock.LEVEL, true, SoundEvents.GENERIC_SPLASH);
}
@Override
protected ItemStack getResult(BlockState state, Level level, BlockPos pos, ItemStack stack) {
PotionCauldronBlockEntity cauldron = InspirationsRecipes.potionCauldronEntity.getBlockEntity(level, pos);
if (cauldron != null) {
int resultCount = Math.min(stack.getCount(), 16);
stack.shrink(resultCount - 1);
return PotionUtils.setPotion(new ItemStack(Items.TIPPED_ARROW, resultCount), cauldron.getPotion());
}
return ItemStack.EMPTY;
}
}