-
Notifications
You must be signed in to change notification settings - Fork 18
/
DyedBottleIntoEmptyCauldronInteraction.java
34 lines (30 loc) · 1.46 KB
/
DyedBottleIntoEmptyCauldronInteraction.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
33
34
package knightminer.inspirations.recipes.cauldron.dye;
import knightminer.inspirations.library.MiscUtil;
import knightminer.inspirations.recipes.InspirationsRecipes;
import knightminer.inspirations.recipes.block.entity.DyeCauldronBlockEntity;
import knightminer.inspirations.recipes.cauldron.FillCauldronInteraction;
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.level.Level;
import net.minecraft.world.level.block.LayeredCauldronBlock;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.block.state.BlockState;
import javax.annotation.Nullable;
/** Pours a dyed bottle into an empty cauldron */
public class DyedBottleIntoEmptyCauldronInteraction extends FillCauldronInteraction {
@Nullable
private final Integer color;
public DyedBottleIntoEmptyCauldronInteraction(@Nullable Integer color) {
super(InspirationsRecipes.dyeCauldron.defaultBlockState().setValue(LayeredCauldronBlock.LEVEL, 1), Items.GLASS_BOTTLE, SoundEvents.BOTTLE_EMPTY);
this.color = color;
}
@Override
protected void afterSetBlock(BlockState oldState, Level level, BlockPos pos, ItemStack stack) {
BlockEntity be = level.getBlockEntity(pos);
if (be != null && be.getType() == InspirationsRecipes.dyeCauldronEntity) {
((DyeCauldronBlockEntity) be).setColor(this.color != null ? this.color : MiscUtil.getColor(stack));
}
}
}