use of com.teamresourceful.resourcefulbees.api.beedata.CoreData in project ResourcefulBees by Resourceful-Bees.
the class HoneyDipper method useOn.
@Override
@NotNull
public InteractionResult useOn(@NotNull UseOnContext useContext) {
if (!useContext.getLevel().isClientSide()) {
Block clickedBlock = useContext.getLevel().getBlockState(useContext.getClickedPos()).getBlock();
if (selectedBee instanceof CustomBeeEntity) {
CoreData beeData = ((CustomBeeEntity) selectedBee).getCoreData();
if (!beeData.getBlockFlowers().isEmpty() && beeData.getBlockFlowers().contains(clickedBlock)) {
setFlowerPosition(useContext);
return InteractionResult.SUCCESS;
}
} else if (selectedBee != null && clickedBlock.is(BlockTags.FLOWERS)) {
setFlowerPosition(useContext);
return InteractionResult.SUCCESS;
}
BlockEntity clickedTile = useContext.getLevel().getBlockEntity(useContext.getClickedPos());
if (selectedBee != null && (clickedTile instanceof BeehiveBlockEntity || clickedTile instanceof ApiaryTileEntity)) {
selectedBee.hivePos = useContext.getClickedPos();
sendMessageToPlayer(useContext.getPlayer(), MessageTypes.HIVE, useContext.getClickedPos());
selectedBee = null;
return InteractionResult.SUCCESS;
}
}
return super.useOn(useContext);
}
Aggregations